|
| 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 | chunkBytesForId (uint64_t bufferId) const |
| | Byte size of the chunk carrying bufferId, or 0 when this slab does not own it.
|
| | GeodeResidentSlab (uint64_t deviceId, std::weak_ptr< GeodeHandleRetirement > owner, std::shared_ptr< GeodeDocumentGeometryBudget > budget=nullptr) |
| | Create an empty slab bound to deviceId (usually the current renderer's device). Chunks are allocated lazily on first use.
|
|
| GeodeResidentSlab (const GeodeResidentSlab &)=delete |
|
GeodeResidentSlab & | operator= (const GeodeResidentSlab &)=delete |
|
uint64_t | owningDeviceId () const |
| | Device this slab's chunks were created on.
|
|
const std::shared_ptr< GeodeDocumentGeometryBudget > & | documentBudget () const |
| | Document budget charged for resident geometry, if one was supplied.
|
| void | beginFrame (uint64_t frameIndex) |
| | Merge the previous frame's freed ranges into the reusable free list. Gated on frameIndex (the renderer's frame counter) so the merge runs at most once per frame no matter how many times the renderer touches the slab: the accessor calls this on every slot lookup, which covers every draw entry point (full-document draws and multi-document tile/thumbnail frames alike) without trusting any single call site.
|
|
bool | allocate (GeodeDevice &device, uint64_t size, uint64_t alignment, Allocation &out) |
| | Bump- or free-list-allocate size bytes aligned to alignment. Creates a new chunk (and counts it) when nothing fits. Returns false when the device cannot create a buffer.
|
|
void | free (const Allocation &alloc) |
| | Return an allocation for reuse at the NEXT frame boundary. The range is not reusable within the current frame: see beginFrame().
|
| void | retireBindGroup (gpu::BindGroup bindGroup) |
| | Park a bind group a slot is dropping until the next frame boundary.
|
Document-scoped suballocation slab for GPU residence.
Per-slot residence previously gave every cached path its own combined GPU buffer, so a first frame allocated one buffer per resident slot (Lion: 133). The slab replaces those with sub-ranges of a small number of growable chunk buffers owned by the document's registry context, cutting first-frame bufferCreates to one chunk per growth step (1 to 2 for typical documents).
Allocations are bump-placed and returned through a first-fit free list, so a geometry edit that re-uploads a slot reuses the freed range. Each chunk's bytes are accounted in the device's live-resident-bytes gauge on creation and released when the slab is destroyed with its registry. Note the gauge therefore reports slab CAPACITY, not live payload bytes: it grows when a chunk is created and never shrinks on slot reset, which is the right shape for leak detection but over-reads against the previous per-slot accounting.
The slab is bound to one device (GeodeDevice::deviceId()): a document rendered by several devices keeps one slab per device, so no device reuses or replaces another's.
Not thread-safe: allocate/free/beginFrame mutate the free list and bump cursors without locking. Every caller holds the document, which serializes them. A renderer is one of them: the slots it borrows for a frame go back when that frame ends, while the document is still held, and it keeps none past the frame. Destroying it releases nothing on the calling thread: its buffers and bind groups go to the owning context's retirement (see the constructor), because the device's own thread may be using its tables.