Vixen
02b45cc4
csharp
public sealed class GpuClusterRaster

One draw for every cluster the traversal chose: phase 4's hardware-raster visibility buffer.

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

Remarks

One command, and the host never learns how many clusters it covers. The draw is a single instanced DrawIndexedIndirect whose instance count is copied out of the visible list's own count word — so a frame that drew a million clusters and a frame that drew none are the same command with the same arguments, differing in four bytes the device wrote.

Indirect, and not DrawIndexedIndirectCount. That entry point exists for a list of argument structures whose length the device decides, which is what a compacted per-object draw needs. Here there is one structure and the device decides its instanceCount — so a four-byte copy into the argument buffer does the whole job, and the pass needs neither HasDrawIndirectCount nor HasMultiDrawIndirect. That is worth having: it makes the visibility buffer reachable on every target the RHI supports rather than on the ones with the newer feature.

The index buffer is a straight run and holds no mesh's indices. Every cluster is drawn with the same index count — three times the most triangles any registered cluster holds — and the indices are 0, 1, 2, …, so SV_VertexID reaches the vertex stage unchanged. The real corners are bytes inside a page, which the vertex stage fetches once it knows which cluster it is drawing. A cluster with fewer triangles has corners left over and they collapse to a degenerate triangle; the alternative is one argument structure per cluster and a multi-draw, which is the thing this arrangement exists to avoid.

The output is one uint per pixel, not two. docs/plan/22-virtualized-geometry.md phase 4 says RG32_UINT — a cluster index and a triangle index in separate channels — and this packs both into R32UInt: twenty-five bits of visible-list slot and seven of triangle. Half the bandwidth of a full-screen target that every resolve pass reads, and the bit budget is not tight: a cluster holds a hundred and twenty-eight triangles by construction, and thirty-three million drawn clusters is far beyond what a frame reaches. It also means no new pixel format in three backends. MaximumSlots is the bound, and it is checked rather than assumed.

Fields and properties (12)

  • public const int TriangleBits

    How many bits of the identity word name the triangle within its cluster.

  • public const uint MaximumTriangles

    The most triangles a cluster may hold and still be addressable by a pixel.

  • public const int MaximumSlots

    The most entries the visible list may hold and still be addressable by a pixel.

  • public const uint Nothing

    What a pixel nothing covered holds.

  • public const PixelFormat Format

    The format the visibility buffer is.

  • public EffectSystem? Effects

    Where the raster variant is resolved from. Null draws nothing.

  • public EffectPipelineDescriber? Modules

    Where the shader modules come from. Null draws nothing.

  • public GpuClusterVisibility? Visibility

    The traversal whose answer to draw. Null draws nothing.

  • public MeshletPagePool? Pages

    The pool the geometry is read out of. Null draws nothing.

  • public bool Drawn

    Whether the last Record issued the draw.

  • public int IndexCount

    How many indices one cluster's draw covers.

  • public static EffectKey Key

    The effect key selecting the raster.

Methods (8)

  • public static uint Pack(uint slot, uint triangle)

    One pixel's identity, as the shader packs it.

  • public static bool Covered(uint identity)

    Whether anything drew to a pixel at all.

  • public static uint Slot(uint identity)

    Which visible-list slot a pixel names. Meaningless unless Covered.

  • public static uint Triangle(uint identity)

    Which triangle of that cluster it names.

  • public GpuClusterRaster(IGraphicsDevice device)

    Creates a raster that draws on a device.

  • public bool Record(ICommandList list, in Matrix4x4 viewProjection, PixelFormat colour, PixelFormat depth)

    Records the one draw that covers every cluster the traversal accepted.

  • public bool Prepare(ICommandList list)

    Makes the buffers, and copies this frame's cluster count into the draw's arguments.

  • public void Dispose()

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

Used by (13)

  • VirtualGeometryGameVirtualGeometry
  • ClusterCullingRendererVixen.Rendering
  • ClusterRasterTestsVixen.Rendering.Tests
  • ClusterResolveTestsVixen.Rendering.Tests
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • GpuClusterVisibilityVixen.Rendering
  • SceneRenderHostTestsVixen.Engine.Renderer.Tests
  • SoftwareRasterTestsVixen.Rendering.Tests
  • VirtualGeometryContentTestsVixen.Rendering.Tests
  • VirtualGeometryGoldenTestsVixen.Graphics.Golden.Tests
  • VirtualGeometrySystemVixen.Rendering
  • VisibilityBufferRendererVixen.Rendering