Vixen
02b45cc4
csharp
public sealed class EffectConstants

One effect's uniform block, filled from a ParameterCollection.

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

Remarks

The other half of the effect system, and the first thing in the engine to use it. An Effect carries ConstantBufferSize and a EffectParameter per value it declares — a key, an offset and a size — which is exactly a layout for the block a shader reads. This is what turns that table plus a collection of values into bytes on the GPU.

Every parameter is written, not only the ones somebody set. A shader declaring var exposure: float = 1f and a host that never mentions exposure must get one, not zero — and zero exposure is a black frame with no error anywhere. The default comes off the key, which is where the generator put what the shader declared.

It re-uploads when the values change, not every frame. Version exists for this, and the effect is part of the comparison as well: resolving a different variant changes the layout, so the same version against a different effect is a different block.

Fields and properties (7)

  • public BufferHandle Buffer

    The buffer the block lives in, invalid until something has been uploaded.

  • public long Offset

    Where this frame's block starts, in bytes. Bind the buffer here rather than at zero.

  • public long Stride

    How many bytes one frame's block occupies, including its alignment padding.

  • public int Alignment

    What a uniform binding's offset must be a multiple of.

  • public int Size

    How many bytes the current block is.

  • public ReadOnlySpan<byte> Bytes

    The block as it was last filled.

  • public int UploadCount

    How many times the bytes have actually gone to the GPU.

Methods (4)

  • public EffectConstants(IGraphicsDevice device, string name = "Constants")

    One effect's uniform block, filled from a ParameterCollection.

  • public bool Update(Effect effect, ParameterCollection parameters)

    Fills and uploads the block if anything changed, and returns whether there is one.

  • public bool Update(object layout, int size, ReadOnlySpan<EffectParameter> members, ParameterCollection parameters)

    Fills and uploads a block whose layout does not come from an effect.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (24)

  • BinVixen.Rendering
  • BindlessFrameTestsVixen.Rendering.Tests
  • BlockVixen.Rendering
  • ComputeRendererVixen.Rendering
  • EffectSetWriterVixen.Rendering
  • FullScreenRendererVixen.Rendering
  • GpuClusterRasterVixen.Rendering
  • GpuClusterSoftwareRasterVixen.Rendering
  • GpuVisibilityTilesVixen.Rendering
  • IrradianceFieldFillVixen.Rendering
  • IrradianceFieldRepairVixen.Rendering
  • MaterialCompilerTestsVixen.Rendering.Tests
  • MaterialRenderFeatureVixen.Rendering
  • PostProcessTestsVixen.Rendering.Tests
  • ReflectionTraceFillVixen.Rendering
  • SceneConstantsVixen.Rendering
  • SceneLightingTestsVixen.Rendering.Tests
  • ScreenProbeAccumulateFillVixen.Rendering
  • ScreenProbeFilterFillVixen.Rendering
  • ScreenProbeTraceFillVixen.Rendering
  • SurfaceCacheGatherFillVixen.Rendering
  • SurfaceCacheLightFillVixen.Rendering
  • ViewConstantsVixen.Rendering
  • VirtualShadowAtlasVixen.Rendering