Vixen
02b45cc4
csharp
public sealed class GpuVisibilityTiles

Binning the visibility buffer by material, so a resolve dispatches over the tiles a material is actually in.

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

Remarks

This is where improvement 2 of docs/plan/22-virtualized-geometry.md is paid for. Nanite resolves its visibility buffer into a GBuffer, which is a large part of why Unreal is deferred-first. Binning by material and dispatching the existing clustered forward shading over each material's tiles keeps one shading path, one material tree and mobile bandwidth — and a material covering one per cent of the screen dispatches over one per cent of the tiles rather than rasterizing a depth-tested full-screen quad.

The counters are the dispatch arguments, so there is no compaction pass. Each material gets three words: the tile count, and two ones. The atomic that appends a tile to a material's list is the same write that tells DispatchIndirect how many workgroups to launch, so the host never learns how much of the screen a material covers — the same trade the visible-cluster list makes with the raster's instance count.

The worst case is real and is stated rather than hidden. A screen where every tile holds every material degenerates to the same work UE does, with the bookkeeping on top. Materials are spatially coherent in practice; that is the assumption, and Overflowed is how a frame that broke it says so.

Fields and properties (16)

  • public const int TileSize

    How many pixels a tile is on a side.

  • public const int DefaultTileCapacity

    How many tiles one material's list holds to begin with.

  • public const int MaxMaterials

    How many materials the binning covers.

  • public const int ArgumentWords

    How many words one material's dispatch arguments occupy.

  • public EffectSystem? Effects

    Where the binning variant is resolved from. Null does nothing.

  • public ComputePipelineCache? Pipelines

    Where the compute pipeline comes from. Null does nothing.

  • public GpuClusterVisibility? Visibility

    The traversal whose answer is being binned. Null does nothing.

  • public Int2 TileCount

    How many tiles covered the screen the last time this ran.

  • public int MaterialCount

    How many materials the last run binned.

  • public ReadOnlySpan<uint> Counts

    How many tiles each material's list held, as of the last ReadCounts.

  • public bool Overflowed

    Whether any material wanted more tiles than its list held.

  • public int TileCapacity

    How many tiles one material's list holds, which grows when one of them wanted more.

  • public int Growths

    How many times the lists have been grown.

  • public BufferHandle Tiles

    Each material's tile list, TileCapacity words apart.

  • public BufferHandle Arguments

    Each material's dispatch arguments, ArgumentWords words apart.

  • public static EffectKey Key

    The effect key selecting the binning pass.

Methods (8)

  • public GpuVisibilityTiles(IGraphicsDevice device)

    Creates a binner that runs on a device.

  • public static Int2 TilesFor(Int2 size)

    How many tiles cover a screen of this many pixels.

  • public static long ArgumentOffset(int material)

    Where a material's dispatch arguments start, in bytes.

  • public static int NextCapacity(int current, int wanted, Int2 tileCount)

    What the capacity becomes after a frame where a material wanted more than it had.

  • public long TileBase(int material)

    Where a material's tile list starts, as a word index.

  • public bool Record(ICommandList list, TextureViewHandle identities, Int2 size)

    Records the binning pass, and clears the counters it is about to fill.

  • public int ReadCounts()

    Reads back what the previous frame's binning counted.

  • public void Dispose()

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

Used by (10)

  • BinVixen.Rendering
  • ClusterResolveTestsVixen.Rendering.Tests
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • GpuClusterResolveVixen.Rendering
  • SceneRenderHostTestsVixen.Engine.Renderer.Tests
  • VirtualGeometryContentTestsVixen.Rendering.Tests
  • VirtualGeometrySystemVixen.Rendering
  • VisibilityBufferRendererVixen.Rendering
  • VisibilityResolveTestsVixen.Rendering.Tests