Vixen
02b45cc4
csharp
public static class ShaderConstants

Writes values into a constant buffer at offsets Raven computed.

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

Remarks

Every method takes the offset rather than deriving one: the generated code carries the numbers out of the shader's reflection, so the layout a host writes is by construction the layout the backends emitted. Computing offsets here would be computing them a second way, which is the arrangement that lets a host and a shader disagree about float3 padding — and disagree silently, because every byte still lands inside the buffer.

What these have to know that a memcpy does not. std140 is not the CLR's layout, and three cases differ: a bool occupies four bytes, a float3 is twelve bytes on a sixteen-byte boundary, and a matrix is stored by column with each column padded to its stride. A Matrix4x4 happens to be a straight blit, and that is not luck — see Write.

Methods (13)

  • public static void Write(Span<byte> buffer, int offset, float value)

    Writes a float.

  • public static void Write(Span<byte> buffer, int offset, int value)

    Writes an int.

  • public static void Write(Span<byte> buffer, int offset, uint value)

    Writes a uint.

  • public static void Write(Span<byte> buffer, int offset, bool value)

    Writes a bool as the four bytes a shader reads it as.

  • public static void Write(Span<byte> buffer, int offset, in Vector2 value)

    Writes a float2.

  • public static void Write(Span<byte> buffer, int offset, in Vector3 value)

    Writes a float3 — twelve bytes, with the fourth left as it was.

  • public static void Write(Span<byte> buffer, int offset, in Vector4 value)

    Writes a float4.

  • public static void Write(Span<byte> buffer, int offset, in Int2 value)

    Writes an int2.

  • public static void Write(Span<byte> buffer, int offset, in Int3 value)

    Writes an int3 — twelve bytes, as Write.

  • public static void Write(Span<byte> buffer, int offset, in Int4 value)

    Writes an int4.

  • public static void Write(Span<byte> buffer, int offset, in Matrix4x4 value)

    Writes a mat4 — the host's sixty-four bytes, unchanged.

  • public static void Write(Span<byte> buffer, int offset, in Matrix3x3 value, int columnStride)

    Writes a mat3, padding each column to .

  • public static void WriteArray<T>(Span<byte> buffer, int offset, int stride, int length, ReadOnlySpan<T> values) where T : unmanaged

    Writes each element of at .

Used by (69, showing 40)

  • AmbientCombineConstantsVixen.Rendering.PostFx
  • AutoExposureConstantsVixen.Rendering
  • BloomConstantsVixen.Rendering
  • ClusterRasterConstantsVixen.Rendering
  • ClusterSoftwareRasterConstantsVixen.Rendering
  • DepthOfFieldConstantsVixen.Rendering
  • DistanceFieldAoGlobalDistanceFieldDistanceFieldVolumesElementVixen.Rendering.PostFx
  • DistanceFieldAoPerMaterialConstantsVixen.Rendering.PostFx
  • FogConstantsVixen.Rendering.PostFx
  • ForwardPlusCascadesElementVixen.Rendering
  • ForwardPlusGlobalDistanceFieldDistanceFieldVolumesElementVixen.Rendering
  • ForwardPlusLightsElementVixen.Rendering
  • ForwardPlusPerDrawConstantsVixen.Rendering
  • ForwardPlusPerFrameConstantsVixen.Rendering
  • ForwardPlusPerMaterialConstantsVixen.Rendering
  • ForwardPlusPerViewConstantsVixen.Rendering
  • ForwardPlusProbeVolumesElementVixen.Rendering
  • FxaaConstantsVixen.Rendering.PostFx
  • GrassConstantsVixen.Rendering.Terrain
  • GrassScatterConstantsVixen.Rendering.Terrain
  • ImpostorCaptureConstantsVixen.Rendering
  • ImpostorConstantsVixen.Rendering.Terrain
  • ImpostorFinishConstantsVixen.Rendering
  • IndirectDiffusePerFrameConstantsVixen.Rendering.PostFx
  • IndirectDiffusePerMaterialConstantsVixen.Rendering.PostFx
  • IrradianceFillGlobalDistanceFieldDistanceFieldVolumesElementVixen.Rendering
  • IrradianceFillPerMaterialConstantsVixen.Rendering
  • IrradianceRepairConstantsVixen.Rendering
  • LensFlareConstantsVixen.Rendering
  • LightingConstantsVixen.Shaders.Tests
  • LightingLightsElementVixen.Shaders.Tests
  • LocalExposureConstantsVixen.Rendering
  • MotionBlurConstantsVixen.Rendering
  • MotionVectorsPerMaterialConstantsVixen.Rendering
  • MotionVectorsPerViewConstantsVixen.Rendering
  • OutlineConstantsVixen.Rendering.PostFx
  • ParticleSpritePerMaterialConstantsVixen.Rendering
  • ParticleSpritePerViewConstantsVixen.Rendering
  • PlaceholderConstantsVixen.Rendering
  • ReflectionTraceGlobalDistanceFieldDistanceFieldVolumesElementVixen.Rendering