Vixen
02b45cc4
csharp
public sealed class FoliageCellPages

The pool of foliage cells a frame keeps uploaded.

Read the guide page for this →

Remarks

The second half of [docs/plan/31 § D13], and it is the same shape as the first. TerrainTilePages makes a terrain's tiles pages; this makes a volume's cells pages. What differs is that a cell's contents are instances rather than texels, so the "load" is a count rather than a read — the bytes are in the volume already, because a volume is what the scene deserialised.

⚠ The saving is the upload and not the memory, and saying so matters. Upload writes every instance of every chunk into a device buffer; over a forest of two thousand cells that is fifty thousand records rewritten every time anything about the volume changes. Streaming makes it the few hundred cells a source can reach. Getting the instances themselves off the heap needs a cell-addressable file, which is the same thing terrain's file-backed tile source is waiting on.

Fields and properties (4)

  • public int PageSize
  • public int SlotCount

    How many slots the pool has.

  • public int Resident

    How many cells are uploaded.

  • public bool Changed

    Whether the resident set has moved since it was last read.

Methods (7)

  • public FoliageCellPages(int countX, int slots)

    Creates a pool over a window of cells.

  • public bool IsResident(int index)

    Whether a cell of the window is uploaded.

  • public ValueTask<int> LoadAsync(PageKey key, Memory<byte> destination, CancellationToken cancellation)
  • public bool Place(PageKey key, int slot, ReadOnlySpan<byte> bytes)

    Puts a loaded page's bytes into a slot.

  • public void Evict(PageKey key, int slot)

    Says a page is no longer resident, and its slot is about to be reused.

  • public void Accept()

    Says the resident set has been acted on.

  • public (int X, int Z) CellOf(int index)

    Which cell of the window an index is.

Used by (1)

  • FoliageStreamerVixen.Rendering.Terrain