Vixen
02b45cc4

AccelerationStructureInstance

struct Core/Vixen.Graphics/AccelerationStructures.cs:109
csharp
public struct AccelerationStructureInstance

One placed reference to a bottom-level structure, in the layout every API shares.

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

Remarks

Sixty-four bytes, bit for bit VkAccelerationStructureInstanceKHR (and D3D12's D3D12_RAYTRACING_INSTANCE_DESC, which is the same layout — the vendors agreed for once): a 3×4 row-major world transform, a 24-bit custom index with an 8-bit visibility mask, a 24-bit hit-group offset with 8 flag bits, and the bottom-level structure's GPU address from GetAccelerationStructureAddress.

The transform's rows are the upper three rows of a column-vector matrix — each row is (basis.X, basis.Y, basis.Z, translation) for one world axis. Row-vector Matrix4x4 users transpose on the way in; FromRows spells the layout so the transposition happens in exactly one place.

Fields and properties (15)

  • public float R0X

    Row zero of the transform: world X from object space, then X translation.

  • public float R0Y

    Row zero of the transform: world X from object space, then X translation.

  • public float R0Z

    Row zero of the transform: world X from object space, then X translation.

  • public float R0W

    Row zero of the transform: world X from object space, then X translation.

  • public float R1X

    Row one: world Y.

  • public float R1Y

    Row one: world Y.

  • public float R1Z

    Row one: world Y.

  • public float R1W

    Row one: world Y.

  • public float R2X

    Row two: world Z.

  • public float R2Y

    Row two: world Z.

  • public float R2Z

    Row two: world Z.

  • public float R2W

    Row two: world Z.

  • public uint IndexAndMask

    Low 24 bits: the custom index a shader reads back. High 8: the visibility mask — zero is invisible to every ray.

  • public uint OffsetAndFlags

    Low 24 bits: the hit-group offset (zero for ray queries). High 8: instance flags — zero is the default, and the queries here disable culling per query anyway.

  • public ulong BottomLevel

    The bottom-level structure's GPU address.

Methods (2)

  • public static AccelerationStructureInstance Identity(ulong bottomLevel, int index = 0)

    An identity-placed, fully visible instance of one bottom-level structure.

  • public static AccelerationStructureInstance FromRows(ulong bottomLevel, ReadOnlySpan<float> rows, int index = 0)

    The transform from three explicit rows, each (basis, translation) for one world axis.

Used by (1)

  • AccelerationStructureDeviceTestsVixen.Graphics.Golden.Tests