浏览代码

add configs for user to disable some features in their app

usecase: in Editor app, the RasterCache may should be disabled to avoid Engine errors when the RenderTexture is too big
/main
xingwei.zhu 5 年前
当前提交
8c3bfde6
共有 5 个文件被更改,包括 44 次插入5 次删除
  1. 5
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_initializer.cs
  2. 10
      Runtime/ui/renderer/compositeCanvas/flow/raster_cache.cs
  3. 4
      Runtime/ui/window.cs
  4. 1
      Samples/UIWidgetsGallery/GalleryMain.cs
  5. 29
      Runtime/editor/window_config.cs

5
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader_initializer.cs


using Unity.UIWidgets.editor;
const bool enableComputeBuffer = false;
const bool enableDebugLog = false;
public static bool supportComputeBuffer;

}
static void InitShaders() {
supportComputeBuffer = enableComputeBuffer && SystemInfo.supportsComputeShaders && IsShaderSupported();
supportComputeBuffer = !WindowConfig.disableComputeBuffer && SystemInfo.supportsComputeShaders && IsShaderSupported();
if (!supportComputeBuffer) {
DebugAssert(false, "init default shaders");

10
Runtime/ui/renderer/compositeCanvas/flow/raster_cache.cs


return false;
}
if (Window.instance.windowConfig.disableRasterCache) {
return false;
}
var bounds = picture.paintBounds;
if (bounds.isEmpty) {
return false;

}
if (picture.isDynamic) {
return false;
}
//https://forum.unity.com/threads/rendertexture-create-failed-rendertexture-too-big.58667/
if (picture.paintBounds.size.width > 4096 ||
picture.paintBounds.size.height > 4096) {
return false;
}

4
Runtime/ui/window.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using UnityEngine;

protected int _antiAliasing = defaultAntiAliasing;
public WindowConfig windowConfig = WindowConfig.defaultConfig;
protected Size _physicalSize = Size.zero;

1
Samples/UIWidgetsGallery/GalleryMain.cs


using UIWidgetsGallery.gallery;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

29
Runtime/editor/window_config.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.editor {
public class WindowConfig {
public readonly bool disableRasterCache;
static bool? _disableComputeBuffer = null;
public static bool disableComputeBuffer {
//disable compute buffer by default for now
get { return _disableComputeBuffer ?? true; }
set {
D.assert(_disableComputeBuffer == null
|| _disableComputeBuffer == value
, () => "The global settings of [disableComputeBuffer] cannot be initiated for multiple times!");
_disableComputeBuffer = value;
}
}
public WindowConfig(bool disableRasterCache) {
this.disableRasterCache = disableRasterCache;
}
public static readonly WindowConfig defaultConfig = new WindowConfig(
disableRasterCache: false
);
}
}
正在加载...
取消
保存