Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- 2D shaders now use half-precision floats whenever precise results are not necessary.

### Fixed
- Fixed a performance problem with ShaderPreprocessor with large amount of active shader variants in the project
- Fixed an issue where linear to sRGB conversion occurred twice on certain Android devices.
- Fixed an issue where there were 2 widgets showing the outer angle of a spot light.
- Fixed an issue where Unity rendered fullscreen quads with the pink error shader when you enabled the Stop NaN post-processing pass.
Expand Down
21 changes: 15 additions & 6 deletions com.unity.render-pipelines.universal/Editor/ShaderPreprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,23 @@ public void OnProcessShader(Shader shader, ShaderSnippetData snippetData, IList<
return;

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<ShaderCompilerData> 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)
Expand Down