[2021.2][ShaderGraph] Add BuiltIn Target variant stripping #5204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
This PR addresses https://fogbugz.unity3d.com/f/cases/1345580/
Currently, the BuiltIn Target does no variant stripping (apart from what the ShaderLab compiler does for us). For users testing assets against, say, both BuiltIn and URP, this can yield a huge set of variants for compilation. This code is heavily based on the stripping done by URP, primarily because the BuiltIn Target and some of its shader library are also derived from the URP implementation (though most of the BuiltIn shader library are the same cginc files used by hand-written shaders for the built-in render pipeline). Some things to note (this should all be documented in comments in the code, but feel free to comment if it isn't clear:
Additional caveat on the logging of variant stripping in general: There are a large number of shader variants that are not logged by the existing URP and HDRP processors (the same will be true for the BuiltIn processor), even though they are seen/processed. Many of these occur after the ones logged by these processors, which means the final numbers (totals/percentages) in the console log are not the real final numbers. For example (using the URP Lit Shader Graph mentioned below), filtering so that only the BuiltIn passes are logged makes it appear as though we have included 12.5K out of 295K variants, when the real number is the 13K out of 410K variants mentioned below in the testing status. This is due to the large number of hidden/legacy/other shaders that are actually included in the project, but don't pass the logging filter.
Testing status
Manual testing according to the repro shadergraph from the bug (result after stripping is a similar number of total variants passed to the compiler as for URP - roughly 7K out of 280K variants, or about 2%).
Manual testing similar to above, but with the proposed new URP Lit Shader Graph (roughly 13K out of 410K variants, or about 3%).
Working on automated tests using the URP Lit Shader Graph.
Yamato jobs:
Comments to reviewers
Notes for the reviewers you have assigned.