浏览代码

compile the necessary shaders only

/main
xingwei.zhu 5 年前
当前提交
3c52e8e3
共有 2 个文件被更改,包括 52 次插入49 次删除
  1. 4
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs
  2. 97
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs

4
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs


static int _instanceNum;
public static bool enableComputeBuffer = true;
public static bool enableComputeBuffer = false;
static bool supportComputeBuffer {
public static bool supportComputeBuffer {
get { return SystemInfo.supportsComputeShaders && CanvasShader.supportComputeBuffer && enableComputeBuffer; }
}

97
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_shader.cs


public static readonly bool supportComputeBuffer;
static CanvasShader() {
var convexFillShader = GetShader("UIWidgets/canvas_convexFill");
var fill0Shader = GetShader("UIWidgets/canvas_fill0");
var fill1Shader = GetShader("UIWidgets/canvas_fill1");
var stroke0Shader = GetShader("UIWidgets/canvas_stroke0");
var stroke1Shader = GetShader("UIWidgets/canvas_stroke1");
var texShader = GetShader("UIWidgets/canvas_tex");
var stencilShader = GetShader("UIWidgets/canvas_stencil");
var filterShader = GetShader("UIWidgets/canvas_filter");
var shadowBoxShader = GetShader("UIWidgets/ShadowBox");
var shadowRBoxShader = GetShader("UIWidgets/ShadowRBox");
var strokeAlphaShader = GetShader("UIWidgets/canvas_strokeAlpha");
var convexFillShaderCompute = GetShader("UIWidgets/canvas_convexFill_cb");
supportComputeBuffer = convexFillShaderCompute.isSupported;
var convexFillShaderCompute = GetShader("UIWidgets/canvas_convexFill_cb");
var fill0ShaderCompute = GetShader("UIWidgets/canvas_fill0_cb");
var fill1ShaderCompute = GetShader("UIWidgets/canvas_fill1_cb");
var stroke0ShaderCompute = GetShader("UIWidgets/canvas_stroke0_cb");
var stroke1ShaderCompute = GetShader("UIWidgets/canvas_stroke1_cb");
var texShaderCompute = GetShader("UIWidgets/canvas_tex_cb");
var stencilShaderCompute = GetShader("UIWidgets/canvas_stencil_cb");
var filterShaderCompute = GetShader("UIWidgets/canvas_filter_cb");
var shadowBoxShaderCompute = GetShader("UIWidgets/ShadowBox_cb");
var shadowRBoxShaderCompute = GetShader("UIWidgets/ShadowRBox_cb");
var strokeAlphaShaderCompute = GetShader("UIWidgets/canvas_strokeAlpha_cb");
_convexFillMat = new MaterialByBlendModeStencilComp(convexFillShader);
_fill0Mat = new MaterialByStencilComp(fill0Shader);
_fill1Mat = new MaterialByBlendMode(fill1Shader);
_stroke0Mat = new MaterialByBlendModeStencilComp(stroke0Shader);
_stroke1Mat = new Material(stroke1Shader) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat = new MaterialByBlendModeStencilComp(strokeAlphaShader);
_texMat = new MaterialByBlendModeStencilComp(texShader);
_stencilMat = new Material(stencilShader) {hideFlags = HideFlags.HideAndDontSave};
_filterMat = new Material(filterShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox = new Material(shadowBoxShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox = new Material(shadowRBoxShader) {hideFlags = HideFlags.HideAndDontSave};
//if compute buffer is not supported, load normal shaders
if (!PictureFlusher.supportComputeBuffer) {
var convexFillShader = GetShader("UIWidgets/canvas_convexFill");
var fill0Shader = GetShader("UIWidgets/canvas_fill0");
var fill1Shader = GetShader("UIWidgets/canvas_fill1");
var stroke0Shader = GetShader("UIWidgets/canvas_stroke0");
var stroke1Shader = GetShader("UIWidgets/canvas_stroke1");
var texShader = GetShader("UIWidgets/canvas_tex");
var stencilShader = GetShader("UIWidgets/canvas_stencil");
var filterShader = GetShader("UIWidgets/canvas_filter");
var shadowBoxShader = GetShader("UIWidgets/ShadowBox");
var shadowRBoxShader = GetShader("UIWidgets/ShadowRBox");
var strokeAlphaShader = GetShader("UIWidgets/canvas_strokeAlpha");
_convexFillMat_cb = new MaterialByBlendModeStencilComp(convexFillShaderCompute);
_fill0Mat_cb = new MaterialByStencilComp(fill0ShaderCompute);
_fill1Mat_cb = new MaterialByBlendMode(fill1ShaderCompute);
_stroke0Mat_cb = new MaterialByBlendModeStencilComp(stroke0ShaderCompute);
_stroke1Mat_cb = new Material(stroke1ShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat_cb = new MaterialByBlendModeStencilComp(strokeAlphaShaderCompute);
_texMat_cb = new MaterialByBlendModeStencilComp(texShaderCompute);
_stencilMat_cb = new Material(stencilShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_filterMat_cb = new Material(filterShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox_cb = new Material(shadowBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox_cb = new Material(shadowRBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_convexFillMat = new MaterialByBlendModeStencilComp(convexFillShader);
_fill0Mat = new MaterialByStencilComp(fill0Shader);
_fill1Mat = new MaterialByBlendMode(fill1Shader);
_stroke0Mat = new MaterialByBlendModeStencilComp(stroke0Shader);
_stroke1Mat = new Material(stroke1Shader) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat = new MaterialByBlendModeStencilComp(strokeAlphaShader);
_texMat = new MaterialByBlendModeStencilComp(texShader);
_stencilMat = new Material(stencilShader) {hideFlags = HideFlags.HideAndDontSave};
_filterMat = new Material(filterShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox = new Material(shadowBoxShader) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox = new Material(shadowRBoxShader) {hideFlags = HideFlags.HideAndDontSave};
}
else {
var fill0ShaderCompute = GetShader("UIWidgets/canvas_fill0_cb");
var fill1ShaderCompute = GetShader("UIWidgets/canvas_fill1_cb");
var stroke0ShaderCompute = GetShader("UIWidgets/canvas_stroke0_cb");
var stroke1ShaderCompute = GetShader("UIWidgets/canvas_stroke1_cb");
var texShaderCompute = GetShader("UIWidgets/canvas_tex_cb");
var stencilShaderCompute = GetShader("UIWidgets/canvas_stencil_cb");
var filterShaderCompute = GetShader("UIWidgets/canvas_filter_cb");
var shadowBoxShaderCompute = GetShader("UIWidgets/ShadowBox_cb");
var shadowRBoxShaderCompute = GetShader("UIWidgets/ShadowRBox_cb");
var strokeAlphaShaderCompute = GetShader("UIWidgets/canvas_strokeAlpha_cb");
//check compute buffer support
supportComputeBuffer = convexFillShaderCompute.isSupported;
_convexFillMat_cb = new MaterialByBlendModeStencilComp(convexFillShaderCompute);
_fill0Mat_cb = new MaterialByStencilComp(fill0ShaderCompute);
_fill1Mat_cb = new MaterialByBlendMode(fill1ShaderCompute);
_stroke0Mat_cb = new MaterialByBlendModeStencilComp(stroke0ShaderCompute);
_stroke1Mat_cb = new Material(stroke1ShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_strokeAlphaMat_cb = new MaterialByBlendModeStencilComp(strokeAlphaShaderCompute);
_texMat_cb = new MaterialByBlendModeStencilComp(texShaderCompute);
_stencilMat_cb = new Material(stencilShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_filterMat_cb = new Material(filterShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowBox_cb = new Material(shadowBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
_shadowRBox_cb = new Material(shadowRBoxShaderCompute) {hideFlags = HideFlags.HideAndDontSave};
}
}
static readonly int _viewportId = Shader.PropertyToID("_viewport");

正在加载...
取消
保存