Vixen
02b45cc4
csharp
public sealed class ParameterCollection

The values set against a set of parameter keys: a material's parameters, a view's, a draw's.

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

Remarks

One byte buffer with an offset per key, rather than a dictionary of boxed values. The thing this is asked to do thousands of times a frame is "give me the bytes for these parameters so I can fill a constant buffer", and a Dictionary<key, object> answers that with a boxing allocation and a pointer chase per parameter.

Values and permutations are kept apart, because they are consumed at different times. A value is written into a buffer every frame it changes; a permutation decides which shader exists and changing one is a recompile. Stride keeps them in one collection and distinguishes by key type at every use; keeping them in two makes "what is this frame's effect key" a field rather than a filter over everything set.

Not thread-safe, deliberately. A collection belongs to one material or one view, and the frame phases that read it — preparation, recording — do so after the phase that writes it has finished. Guarding it would put a lock on the hottest path in the renderer to protect against a pattern the frame structure already rules out.

Fields and properties (5)

  • public int Version

    Bumped whenever a value changes, so a consumer can skip work it already did.

  • public int PermutationVersion

    Bumped whenever a permutation changes, which is when the effect must be re-resolved.

  • public int Count

    How many value keys have been set.

  • public IEnumerable<ParameterKey> Keys

    The keys that have a value, in no particular order.

  • public IEnumerable<KeyValuePair<ParameterKey, object>> Permutations

    Every permutation set here, for building an effect key.

Methods (8)

  • public void Set<T>(ParameterKey<T> key, T value) where T : unmanaged

    Sets a value.

  • public T Get<T>(ParameterKey<T> key) where T : unmanaged

    The value set for a key, or the key's own default when nothing set one.

  • public bool Has(ParameterKey key)

    Whether a key has a value of its own.

  • public ReadOnlySpan<byte> Bytes(ParameterKey key)

    The raw bytes set for a key, empty when nothing set one.

  • public void Set<T>(PermutationKey<T> key, T value) where T : notnull

    Sets a permutation, which changes which shader this collection selects.

  • public T Get<T>(PermutationKey<T> key) where T : notnull

    The permutation set for a key, or the shader's declared default.

  • public void Apply(ParameterCollection source)

    Copies everything from another collection over this one.

  • public void Clear()

    Forgets everything, keeping the buffer for the next fill.

Used by (108, showing 40)

  • ArenaThirdPersonShooter
  • ArenaFrameThirdPersonShooter
  • ArenaIlluminationThirdPersonShooter
  • AccelerationStructureDeviceTestsVixen.Graphics.Golden.Tests
  • AmbientCombineRendererVixen.Rendering.PostFx
  • AmbientOcclusionRendererVixen.Rendering.PostFx
  • AssetMaterialSourceVixen.Engine.Renderer
  • AssetMaterialSourceTestsVixen.Engine.Renderer.Tests
  • AssetTextureSourceTestsVixen.Engine.Renderer.Tests
  • AutoExposureRendererVixen.Rendering.PostFx
  • AutoExposureTestsVixen.Rendering.PostFx.Tests
  • BinVixen.Rendering
  • BindlessFrameTestsVixen.Rendering.Tests
  • BlockVixen.Rendering
  • BloomRendererVixen.Rendering.PostFx
  • BloomTestsVixen.Rendering.PostFx.Tests
  • BufferTransferDeviceTestsVixen.Graphics.Golden.Tests
  • ClusterCullingDeviceTestsVixen.Graphics.Golden.Tests
  • ClusterGridVixen.Rendering
  • ClusteredLightingTestsVixen.Rendering.Tests
  • ClusteredShadingDeviceTestsVixen.Graphics.Golden.Tests
  • CompositorImageTestsVixen.Graphics.Golden.Tests
  • ComputeRendererVixen.Rendering
  • DepthOfFieldRendererVixen.Rendering.PostFx
  • DistanceFieldAoRendererVixen.Rendering.PostFx
  • EffectCacheTestsVixen.Shaders.Tests
  • EffectConstantsVixen.Rendering
  • EffectKeyVixen.Shaders
  • EffectSetWriterVixen.Rendering
  • EffectSystemTestsVixen.Shaders.Tests
  • EnvironmentLightVixen.Rendering
  • EnvironmentLightingTestsVixen.Rendering.Tests
  • FogRendererVixen.Rendering.PostFx
  • ForwardFrameTestsVixen.Rendering.Tests
  • ForwardLightingRenderFeatureVixen.Rendering
  • FullScreenRendererVixen.Rendering
  • FxaaRendererVixen.Rendering.PostFx
  • GeneratedBindingsTestsVixen.Shaders.Tests
  • GlobalDistanceFieldRendererTestsVixen.Rendering.Tests
  • GlobalDistanceFieldTextureVixen.Rendering