Vixen
02b45cc4
csharp
public readonly struct EffectKey

A shader name, the permutation values that select one variant of it, and the implementations filling its compose slots.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The cache key for everything downstream: an in-memory dictionary, an on-disk bytecode cache, and the build-time enumeration that has to produce a superset of what a playthrough asks for. All three need the same value to mean the same variant, which is why this is a value type with a stated normal form rather than whatever a dictionary of objects happened to hash to.

Only keys the shader actually branched on belong here. Raven reports UsedPermutationKeys for exactly this reason: twenty declared flags where three affect the output is eight distinct shaders, not a million. Filtering is the caller's — From takes the keys to include — because only the effect system knows which shader is being keyed, and a key that quietly dropped values would be a cache that returns the wrong shader.

Sorted by name so that setting the same values in a different order gives the same key. Without it the cache would hold one entry per insertion order and hit almost never, which is the sort of miss that shows up as a frame-time cliff rather than as a wrong image.

The composition is part of the key, and it has to be. A permutation changes which branch of one shader survives; a ShaderComposition changes which shaders the compilation contains at all. Two materials with the same name and the same permutations but different features are different code, and a key blind to that returns the first one compiled for both.

Fields and properties (3)

  • public string ShaderName

    The shader this selects a variant of.

  • public ImmutableArray<KeyValuePair<string, string>> Values

    The permutation values, sorted by name.

  • public ShaderComposition Composition

    What fills the shader's compose slots.

Methods (10)

  • public static EffectKey Of(string shaderName)

    The key for a shader with no permutations set.

  • public EffectKey With(ShaderComposition composition)

    This key with filling the shader's slots.

  • public static EffectKey Of(string shaderName, IEnumerable<KeyValuePair<string, string>> values, ShaderComposition composition = default(ShaderComposition))

    The key for a shader from permutation values that are already text.

  • public static EffectKey From(string shaderName, ParameterCollection parameters, IEnumerable<ParameterKey> used, ShaderComposition composition = default(ShaderComposition))

    The key for a shader, taking from only the permutations named in .

  • public bool Equals(EffectKey other)

    Indicates whether the current object is equal to another object of the same type.

  • public override bool Equals(object? obj)

    Indicates whether this instance and a specified object are equal.

  • public override int GetHashCode()

    Returns the hash code for this instance.

  • public static bool operator ==(EffectKey left, EffectKey right)

    Whether two keys select the same variant of the same shader.

  • public static bool operator !=(EffectKey left, EffectKey right)

    Whether two keys select different variants, or different shaders.

  • public override string ToString()

    The key as one stable string — a cache filename, a log line.

Used by (129, showing 40)

  • DevelopmentEffectsThirdPersonShooter
  • LibraryEffectsVirtualGeometry
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.PostFx.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.PostFx.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.PostFx.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AlwaysCompilesVixen.Rendering.Tests
  • AutoExposureTestsVixen.Rendering.PostFx.Tests
  • BakedVixen.Graphics.Golden.Tests
  • BakedVixen.Graphics.Golden.Tests
  • BakedVixen.Graphics.Golden.Tests
  • BakedVixen.Rendering.Tests
  • BindlessFrameTestsVixen.Rendering.Tests
  • BindlessSamplingDeviceTestsVixen.Graphics.Golden.Tests
  • BloomTestsVixen.Rendering.PostFx.Tests
  • BufferTransferDeviceTestsVixen.Graphics.Golden.Tests
  • ChainVixen.Graphics.Golden.Tests
  • ClusterCullingDeviceTestsVixen.Graphics.Golden.Tests
  • ClusterResolveTestsVixen.Rendering.Tests
  • ClusteredLightingTestsVixen.Rendering.Tests
  • ClusteredShadingDeviceTestsVixen.Graphics.Golden.Tests
  • CompilerVixen.Graphics.Golden.Tests
  • CompilesVixen.Rendering.Tests
  • CompilesVixen.Rendering.Tests