public sealed class PermutationKeyDictionaryWhich permutation keys each shader's variants are selected by, and which of them nothing may drop.
Remarks
A dictionary with one rule, and the rule is the reason this is not a Dictionary. A host says which keys a pass's effect key is built from by assigning the generated …Keys.UsedPermutationKeys under the shader's name — one line, written once per host, and every shipping host writes it. An engine that needs a key that list does not carry — one contributed by a composed shader, which no pass's reflection can know about — registers it separately. ⚠ Assignment then discarded the registration, and nothing said so.
⚠ What that cost, measured. WorldRenderer's constructor registered MaterialKeys.LayerCount for ForwardPlus and both shipping samples assigned ForwardPlusKeys.UsedPermutationKeys over it afterwards — as did five golden device suites — so a three-layer material resolved the variant compiled for the shader's declared two in every host that actually drew. The unregistered-permutation trap, arrived at from the far side: the key was registered, and then unregistered by a line whose author had no way to know.
So Register is not merely additive: what it registers survives a later assignment. That is what makes the defect unfixable by forgetting rather than fixable by remembering — the next host somebody writes assigns the same generated array on the same line, and the key is still there afterwards, because there is no API on this type that can take it away.
Nothing here is a claim that a key should be in the effect key at all. A key nothing branches on splits the variant cache for nothing, which is why the assigned list is the shader's own reported set and this holds only what an engine explicitly registered on top.
Fields and properties (4)
public IEnumerable<string> KeysThe shader names something has been said about.
public IEnumerable<IReadOnlyList<ParameterKey>> ValuesEach shader's key list.
public int CountHow many shaders have an entry.
public IReadOnlyList<ParameterKey> this[string shaderName]The keys one shader's variants are selected by.
Methods (4)
public bool ContainsKey(string shaderName)Whether anything has been said about a shader.
public bool TryGetValue(string shaderName, out IReadOnlyList<ParameterKey> value)The keys one shader's variants are selected by, if any were stated.
public IEnumerator<KeyValuePair<string, IReadOnlyList<ParameterKey>>> GetEnumerator()Returns an enumerator that iterates through the collection.
public void Register(string shaderName, ParameterKey key)Adds a key to a shader's list and states that no later assignment may remove it.
Used by (4)
- CompositorBuilderVixen.Rendering
- MaterialRenderFeatureVixen.Rendering
- PermutationKeyDictionaryTestsVixen.Rendering.Tests
- WorldRendererVixen.Engine.Renderer