Vixen
02b45cc4
csharp
public sealed class GpuClusterVisibility

The device side of the cluster traversal: the DAG in buffers, the dispatch, and the page requests coming back.

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

Remarks

GpuVisibilityGroup's sibling, and the same three-part arrangement. That one owns the object cull's buffers and dispatch, MeshRenderFeature extracts what it culls, and GpuCullingRenderer puts the dispatch in the frame. This one owns the traversal's buffers and dispatch, VirtualGeometryRenderFeature extracts what it traverses, and ClusterCullingRenderer puts it in the frame. Deliberately the same shape, because it is the same decision at a different depth of the same hierarchy — which is improvement 3 of docs/plan/22-virtualized-geometry.md, and is why the shader is one shader.

Two kinds of buffer, and the difference is what changes. The cluster records, the child runs and the roots are the meshes — they change when a mesh is registered or forgotten, which is a load, not a frame. The instances are the scene — they change when something moves. So the first three are uploaded on a dirty flag and the last through a PersistentUploadBuffer`1, which is phase 0's answer to the same question about objects.

The answer never comes back to the host, and that is the point. What the dispatch writes is a visible-cluster list an indirect draw reads and a request list the residency service reads. Only the second is read back, it is small, and it is read a frame late on purpose — see ServiceRequests.

Fields and properties (40)

  • public const int VisiblePerInstance

    How many bytes of visible-cluster list are allocated per instance per view.

  • public const int VisibleBase

    How many counter words the visible list carries before its first entry.

  • public const uint PageAbsent

    What the slot table holds for a page whose bytes are not in the pool.

  • public const int RequestCapacity

    How many page requests one frame's dispatch may record.

  • public EffectSystem? Effects

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

  • public ComputePipelineCache? Pipelines

    Where the compute pipeline comes from. Null does nothing.

  • public HiZPyramid? Occluders

    Last frame's depth, min-reduced, or null to test the frustum and the cone alone.

  • public PageResidency? Residency

    Which pages are in the pool. Null traverses as though none are.

  • public int MeshCount

    How many meshes are registered.

  • public int ClusterCount

    How many clusters they have between them.

  • public int PageCount

    How many pages, which is what the slot table has to cover.

  • public int PageSize

    How many bytes one page occupies in the pool.

  • public int MaximumTriangles

    The most triangles any registered cluster holds.

  • public int InstanceCount

    How many instances the last Prepare uploaded.

  • public long InstanceBytesUploaded

    How many bytes of instance records it handed to the device.

  • public int InstanceUploadRegions

    How many separate writes those bytes took.

  • public bool TraversedOnDevice

    Whether the last frame's traversal ran on the device.

  • public int VisibleClusters

    How many clusters the last serviced frame's traversal wanted to draw.

  • public int SoftwareClusters

    How many of them the software raster was asked to draw.

  • public bool VisibleOverflowed

    Whether that count exceeded what the list can hold.

  • public int RequestedPages

    How many page requests came back from it.

  • public BufferHandle Visible

    The buffer the accepted clusters are appended to: element zero is the count.

  • public BufferHandle Requests

    The pages the traversal wanted and did not have. Element zero is the count.

  • public BufferHandle Geometry

    Where each cluster's bytes are, for the raster.

  • public BufferHandle Grids

    One quantization grid per registered mesh.

  • public BufferHandle Materials

    Which material each cluster uses, for the resolve's binning.

  • public int MaterialCount

    The highest material index any registered cluster names, plus one.

  • public BufferHandle Slots

    Where each page sits in the pool, or PageAbsent.

  • public long SlotsOffset

    Where this frame's slot table starts in that buffer.

  • public int SlotBase

    Where it starts in entries rather than bytes.

  • public BufferHandle Instances

    Where this frame's instance records start.

  • public long InstancesOffset
  • public int InstanceBase

    Where this frame's instance records start, in records rather than bytes.

  • public BufferHandle Bones

    Every skinned instance's matrices, for the raster and the resolve to read.

  • public int BoneBase

    Where this frame's palettes start, in matrices rather than bytes.

  • public int BoneCount

    How many matrices this frame's palettes hold, including the leading identity.

  • public ReadOnlySpan<CullCluster> Records

    The merged cluster records, as the device will read them.

  • public ReadOnlySpan<RasterCluster> GeometryRecords

    The merged geometry records, as the raster will read them.

  • public ReadOnlySpan<RasterMesh> MeshRecords

    One grid per registered mesh, as the raster and the resolve read them.

  • public ReadOnlySpan<CullInstance> InstanceRecords

    This frame's instance records, before they reach the device.

Methods (12)

  • public GpuClusterVisibility(IGraphicsDevice device)

    Creates a traversal that runs on a device.

  • public ClusterMesh Register(MeshletMesh mesh, MeshletPageSet pages, int source)

    Registers a mesh's DAG, and pins its root page.

  • public ClusterMesh MeshAt(int index)

    What a registered mesh's records are, by registration order.

  • public void Begin(int count)

    Begins a frame's instance records, keeping what did not change.

  • public void BeginBones()

    Begins a frame's bone palettes, discarding the last frame's.

  • public int AddBones(ReadOnlySpan<Matrix4x4> palette)

    Adds one instance's palette to this frame's.

  • public void Set(int index, in CullInstance instance)

    Sets one instance's record, uploading it only if it differs.

  • public void UploadInstances()

    Hands whatever changed to the device.

  • public bool Prepare(IReadOnlyList<RenderView> frameViews, ReadOnlySpan<float> errorScale, ReadOnlySpan<float> errorThreshold, ReadOnlySpan<float> softwareThreshold = default(ReadOnlySpan<float>))

    Resolves the variant, uploads what changed, and leaves a dispatch for the frame to record.

  • public bool Record(ICommandList list)

    Records the traversal into the frame's own list.

  • public int ServiceRequests(int maxLoads = 8)

    Feeds the previous frame's requests to the residency service and lets it work.

  • public void Dispose()

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

Used by (23)

  • VirtualGeometryGameVirtualGeometry
  • AssetVirtualGeometrySourceVixen.Engine.Renderer
  • BinVixen.Rendering
  • ClusterCullingRendererVixen.Rendering
  • ClusterRasterTestsVixen.Rendering.Tests
  • ClusterResolveTestsVixen.Rendering.Tests
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • GpuClusterRasterVixen.Rendering
  • GpuClusterResolveVixen.Rendering
  • GpuClusterSoftwareRasterVixen.Rendering
  • GpuVisibilityTilesVixen.Rendering
  • SceneRenderHostTestsVixen.Engine.Renderer.Tests
  • SkinnedClusterTestsVixen.Rendering.Tests
  • VirtualGeometryContentTestsVixen.Rendering.Tests
  • VirtualGeometryDeviceTestsVixen.Graphics.Golden.Tests
  • VirtualGeometryFrameTestsVixen.Rendering.Tests
  • VirtualGeometryGoldenTestsVixen.Graphics.Golden.Tests
  • VirtualGeometryRenderFeatureVixen.Rendering
  • VirtualGeometrySystemVixen.Rendering
  • VisibilityBufferRendererVixen.Rendering
  • VisibilityResolveTestsVixen.Rendering.Tests
  • ImportedGeometryLoadsTestsVixen.Editor.Assets.Tests