diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 7498c715e9d..f0a8fe31f81 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed GLES shaders compilation failing on Windows platform (not a mobile platform) due to uniform count limit. - Fixed an issue where preset button could still be used, when it is not supposed to. [case 1246261](https://issuetracker.unity3d.com/issues/urp-reset-functionality-does-not-work-for-renderobject-preset-asset) - Fixed an issue with URP switching such that every avaiable URP makes a total set of supported features such that all URPs are taken into consideration. [case 1157420](https://issuetracker.unity3d.com/issues/lwrp-srp-switching-doesnt-work-even-with-manually-adding-shadervariants-per-scene) +- Fixed a performance problem with ShaderPreprocessor with large amount of active shader variants in the project. ## [7.3.0] - 2020-03-11 diff --git a/com.unity.render-pipelines.universal/Editor/ShaderPreprocessor.cs b/com.unity.render-pipelines.universal/Editor/ShaderPreprocessor.cs index 8b52444f9f4..511c0f4ea8c 100644 --- a/com.unity.render-pipelines.universal/Editor/ShaderPreprocessor.cs +++ b/com.unity.render-pipelines.universal/Editor/ShaderPreprocessor.cs @@ -212,14 +212,23 @@ public void OnProcessShader(Shader shader, ShaderSnippetData snippetData, IList< int prevVariantCount = compilerDataList.Count; - - for (int i = 0; i < compilerDataList.Count; ++i) + + var inputShaderVariantCount = compilerDataList.Count; + for (int i = 0; i < inputShaderVariantCount;) { - if (StripUnused(ShaderBuildPreprocessor.supportedFeatures, shader, snippetData, compilerDataList[i])) - { + bool removeInput = StripUnused(ShaderBuildPreprocessor.supportedFeatures, shader, snippetData, compilerDataList[i]); + if (removeInput) + compilerDataList[i] = compilerDataList[--inputShaderVariantCount]; + else + ++i; + } + + if(compilerDataList is List inputDataList) + inputDataList.RemoveRange(inputShaderVariantCount, inputDataList.Count - inputShaderVariantCount); + else + { + for(int i = compilerDataList.Count -1; i >= inputShaderVariantCount; --i) compilerDataList.RemoveAt(i); - --i; - } } if (urpAsset.shaderVariantLogLevel != ShaderVariantLogLevel.Disabled)