bool StripUnused(StripVariantsInfo stripInfo /*not null*/, Shader shader, ShaderSnippetData snippetData, ShaderCompilerData compilerData) { foreach (string shadername in stripInfo.globalShaderNames) { if (StripGlobalShader(shadername, shader)) { return(true); } } foreach (string keyword in stripInfo.globalKeywords) { if (StripGlobalKeywords(keyword, compilerData)) { return(true); } } if (stripInfo.specifiedShaders != null) { foreach (SpecifiedShaderKeyword specifed in stripInfo.specifiedShaders) { if (StripSpecifiedKeyward(specifed, shader, compilerData)) { return(true); } } } return(false); }
public void OnProcessShader(Shader shader, ShaderSnippetData snippetData, IList <ShaderCompilerData> compilerDataList) { LightweightRenderPipelineAsset lwrpAsset = GraphicsSettings.renderPipelineAsset as LightweightRenderPipelineAsset; if (lwrpAsset == null || compilerDataList == null || compilerDataList.Count == 0) { return; } StripVariantsInfo stripInfo = lwrpAsset.stripVariantsInfo; int prevVariantCount = compilerDataList.Count; for (int i = 0; i < compilerDataList.Count; ++i) { if (stripInfo != null) { if (StripUnused(stripInfo, shader, snippetData, compilerDataList[i])) { compilerDataList.RemoveAt(i); --i; } } } if (lwrpAsset.shaderVariantLogLevel != ShaderVariantLogLevel.Disabled) { m_TotalVariantsInputCount += prevVariantCount; m_TotalVariantsOutputCount += compilerDataList.Count; if (compilerDataList.Count < prevVariantCount) { LogShaderVariants(shader, snippetData, lwrpAsset.shaderVariantLogLevel, prevVariantCount, compilerDataList.Count); } } }