Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodeRecordSlab Class Reference

Document-scoped, painter-ordered record slab for ordered draw batching (ordered batching). More...

#include "donner/svg/renderer/geode/GeodeResidentPathComponent.h"

Classes

struct  Slot
 One record slot: its index in the contiguous array and its absolute byte offset in the owning buffer. More...
struct  BatchUniformHandle
 A batch-uniform buffer plus its stable identity; buffer is null when the slab declined (uniform cache full, or buffer creation failed). More...

Public Member Functions

 GeodeRecordSlab (uint64_t deviceId, std::weak_ptr< GeodeHandleRetirement > owner, std::shared_ptr< GeodeDocumentGeometryBudget > budget=nullptr)
 GeodeRecordSlab (const GeodeRecordSlab &)=delete
GeodeRecordSlab & operator= (const GeodeRecordSlab &)=delete
uint64_t owningDeviceId () const
 Device on which this record slab's buffers were created.
const std::shared_ptr< GeodeDocumentGeometryBudget > & documentBudget () const
 Document budget charged for resident records, if one was supplied.
void beginFrame (uint64_t frameIndex)
 Merge the previous frame's freed slots into the reusable free list. The frame-index guard makes the merge idempotent per device-scoped generation. Callers defer this merge while an older frame remains open on the device, because its unsubmitted commands may still reference freed slots and retired bind groups.
void retireBindGroup (gpu::BindGroup bindGroup)
 Park a bind group a slot is dropping until the next frame boundary.
bool allocateSlot (GeodeDevice &device, Slot &out)
 Allocate the next record slot (free-list first, then bump in the newest buffer). Returns false when the device cannot create a buffer.
void freeSlot (const Slot &slot)
 Defer freeing a slot until the next frame: a slot reused within the frame that freed it would overwrite a record the frame's already recorded batch draws still read.
BatchUniformHandle acquireBatchUniform (GeodeDevice &device, const void *bytes, uint64_t size)
 Persistent buffer holding one distinct scene-batch uniform value.
const gpu::Buffer & bufferForId (uint64_t bufferId) const
 The chunk buffer carrying bufferId, or a null handle when this slab does not own it. Uploads need the owning handle; Slot and Allocation only carry an identity view.
uint64_t liveBytes () const
 Total live bytes across all buffers (resident-bytes accounting).
uint64_t batchUniformMetadataBytesForTesting () const
 Capacity bytes held by batch-uniform metadata, exposed to tests.
uint64_t batchUniformPayloadBytesForTesting () const
 Capacity bytes held by CPU uniform payloads, exposed to tests.

Static Public Member Functions

static std::optional< uint64_t > batchUniformRetainedBytes (uint64_t uniformBytes)
 Include fixed uniform metadata when estimating a slab's retained bytes.

Detailed Description

Document-scoped, painter-ordered record slab for ordered draw batching (ordered batching).

Cross-entity batches issue ONE draw whose instances read instances[firstInstance + i] from a contiguous record array. Records therefore live in a document-scoped slab instead of inside each entity's geometry chunk: slot indices are allocated in draw order, freed ranges defer to the next frame (the same discipline as GeodeResidentSlab::beginFrame), and a batch covers only consecutive slots of one buffer, splitting at free-list reuse or buffer-growth boundaries.

Buffer growth keeps old slots in place: a grown slab allocates a bigger buffer and future slots land there, so no record ever moves. Batches that would straddle the buffer boundary split instead.

Bound to one device like GeodeResidentSlab; not thread-safe.


Class Documentation

◆ donner::geode::GeodeRecordSlab::Slot

struct donner::geode::GeodeRecordSlab::Slot

One record slot: its index in the contiguous array and its absolute byte offset in the owning buffer.

Class Members
BufferRef buffer
uint64_t bufferId = 0 Stable identity of buffer (see GeodeDevice::AllocateBufferId). Anything that caches keyed on this slot must compare the id: the handle address is recycled once the owning slab is destroyed.
uint32_t index = 0
uint64_t offset = 0

◆ donner::geode::GeodeRecordSlab::BatchUniformHandle

struct donner::geode::GeodeRecordSlab::BatchUniformHandle

A batch-uniform buffer plus its stable identity; buffer is null when the slab declined (uniform cache full, or buffer creation failed).

Class Members
BufferRef buffer
uint64_t bufferId = 0

Constructor & Destructor Documentation

◆ GeodeRecordSlab()

donner::geode::GeodeRecordSlab::GeodeRecordSlab ( uint64_t deviceId,
std::weak_ptr< GeodeHandleRetirement > owner,
std::shared_ptr< GeodeDocumentGeometryBudget > budget = nullptr )
inline
Parameters
deviceIdDevice the slab's buffers are created on.
ownerRetirement of the context that owns the device (see GeodeDevice::handleRetirement); must be live. The slab's buffers and bind groups are handed there when it is destroyed, so they are released on that context's thread whichever thread destroys the slab.
budgetDocument budget its bytes are charged to, if any.

Member Function Documentation

◆ acquireBatchUniform()

BatchUniformHandle donner::geode::GeodeRecordSlab::acquireBatchUniform ( GeodeDevice & device,
const void * bytes,
uint64_t size )
inline

Persistent buffer holding one distinct scene-batch uniform value.

A batch uniform is frame-constant (identity mvp plus the frame's viewport / clip / antialias state), so a steady frame finds its entry and writes nothing at all - the per-frame arena would rewrite it every frame because the arena's bytes do not survive.

Entries are keyed by their exact bytes and are never rewritten, so a differing value (a second render-target size within one frame) takes a new entry and a batch already recorded this frame keeps reading its own bytes at submit time. Returns a null handle once kMaxBatchUniforms distinct values are live, and the caller falls back to its per-frame arena.

◆ batchUniformRetainedBytes()

std::optional< uint64_t > donner::geode::GeodeRecordSlab::batchUniformRetainedBytes ( uint64_t uniformBytes)
inlinestatic

Include fixed uniform metadata when estimating a slab's retained bytes.

Parameters
uniformBytesBytes of uniform buffer payload.
Returns
Aggregate charge, or no value if addition overflows.

◆ bufferForId()

const gpu::Buffer & donner::geode::GeodeRecordSlab::bufferForId ( uint64_t bufferId) const
inline

The chunk buffer carrying bufferId, or a null handle when this slab does not own it. Uploads need the owning handle; Slot and Allocation only carry an identity view.

Parameters
bufferIdStable buffer id stamped on the slot or allocation.

◆ retireBindGroup()

void donner::geode::GeodeRecordSlab::retireBindGroup ( gpu::BindGroup bindGroup)
inline

Park a bind group a slot is dropping until the next frame boundary.

A slot's cached bind group can be dropped mid-frame (geometry re-upload, component removal, encode change) while draws recorded earlier in the frame still name it and have not reached the backend yet. Destroying it there fails those draws closed, so it is held here and released at the next beginFrame, by which point the frame that recorded them has been submitted.

Parameters
bindGroupBind group to release at the next frame boundary.

The documentation for this class was generated from the following file: