Vixen
02b45cc4
csharp
public sealed class GeometryResidency

What is resident in the shared geometry buffer, and how many entities want it.

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

Remarks

One slice per mesh, however many entities draw it. A courtyard of forty identical crates is one upload and one slice; without this it would be forty, and the vertex buffer would run out on a scene a level designer would call small. That sharing is the whole reason the cache exists — GeometryBuffer already handles suballocation, and it has no notion of two callers wanting the same bytes.

Reference counted, because an entity being destroyed is not a mesh being unloaded. Freeing on the first release would drop the crate the other thirty-nine are still drawing; never freeing would make a level transition leak everything the old level held. The count is entities, not loads.

⚠ The host flushes, and it must be outside a render pass. Acquire stages an upload into the buffer's staging area; Flush is what records the transfer, and Vulkan forbids a transfer inside a render pass — the same constraint DebugDrawRenderer.Upload and UiRenderer's atlas both have.

⚠ A mesh too large for the remaining space is refused rather than growing the buffer. Growing means recreating a buffer the GPU may still be reading from, and the alternative to a refusal here is a stall of unbounded length in the middle of a frame. What the caller does about it — evict, or draw nothing — is above this.

Fields and properties (3)

  • public GeometryBuffer Buffer

    The buffer everything here lives in.

  • public int Count

    How many distinct meshes are resident.

  • public int Claims

    How many entities are holding the meshes that are resident, in total.

Methods (6)

  • public GeometryResidency(GeometryBuffer buffer)

    What is resident in the shared geometry buffer, and how many entities want it.

  • public bool Acquire(GeometryKey key, Func<MeshData> build, out GeometrySlice slice, out BoundingSphere bounds)

    Takes a claim on a mesh, uploading it if this is the first.

  • public bool Release(GeometryKey key)

    Gives up a claim, freeing the mesh when it was the last.

  • public bool TryGet(GeometryKey key, out GeometrySlice slice)

    Where a resident mesh lives, without taking a claim on it.

  • public int ClaimsOn(GeometryKey key)

    How many entities are holding one mesh.

  • public int Flush(ICommandList list)

    Records the staged uploads into a command list.

Used by (5)

  • MeshExtractionSystemVixen.Rendering
  • MeshExtractionTestsVixen.Rendering.Tests
  • VirtualGeometryExtractionTestsVixen.Rendering.Tests
  • WorldRendererVixen.Engine.Renderer
  • WorldRendererTestsVixen.Engine.Renderer.Tests