Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodeOccurrenceRecords Struct Reference

Persistent per-occurrence instance records for content drawn more than once over shared resident geometry: the glyph occurrences of one text element, or the second and later draws of one resident slot within a frame (each marker placement of a marker's content, a non-adjacent repeat of a <use> source). More...

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

Classes

struct  Occurrence
 One occurrence's record slot plus the bytes last written to it. More...

Public Types

using OccurrenceOwner = std::unique_ptr<Occurrence>
 Stable owner for a separately allocated occurrence record.

Public Member Functions

 GeodeOccurrenceRecords (const GeodeOccurrenceRecords &)=delete
GeodeOccurrenceRecords & operator= (const GeodeOccurrenceRecords &)=delete
 GeodeOccurrenceRecords (GeodeOccurrenceRecords &&other) noexcept
 Transfer occurrence slots and CPU reservations without freeing live slab records.
GeodeOccurrenceRecords & operator= (GeodeOccurrenceRecords &&other) noexcept
 Release current slots and take ownership of another component's records.
bool reserveOccurrence (std::shared_ptr< GeodeDocumentGeometryBudget > budget)
 Reserve CPU bytes and vector capacity before appending one occurrence.
bool appendReservedOccurrence (const GeodeRecordSlab::Slot &slot)
 Append a slab slot after reserveOccurrence has admitted its CPU payload.
void rollbackOccurrence ()
 Restore the CPU reservation after an occurrence append fails.
uint64_t cpuRetainedBytesForTesting () const
 CPU bytes currently charged for this component, exposed to tests.
GeodeClipUniform * reserveClipUniform (Occurrence &occurrence, size_t bytes)
 The clip uniform of occurrence, created and charged with the occurrence's other CPU bytes on first use: the record of its range and a copy of bytes bytes of uniform.
void releaseClipUniforms ()
 Return every occurrence's clip uniform range to clipUniformSlab (deferred to its next frame boundary, like every other slab free) and drop the uniforms and their charge.
void freeRecordSlots ()
 Return every slot to the slab (deferred to the next frame's merge, like every other record free) and drop them.

Public Attributes

std::vector< OccurrenceOwner > occurrences
 Occurrence slots in paint order. Index is the occurrence's ordinal among its owner's draws in one frame, so it is stable across unchanged frames. Owners may move when the vector grows, but each separately allocated occurrence stays put while a pending batch holds pointers into it.
std::shared_ptr< GeodeRecordSlab > recordSlab
 Slab the slots were allocated from, this device's record slab for the document; also keeps that slab alive for as long as the slots are.
uint64_t lastFrame = 0
 Device-scoped frame generation of the last draw that wrote these slots. Zero means "never written": generations start at 1, and the guard reads this as "older than every open frame", which is what untouched records are.
std::shared_ptr< GeodeDocumentGeometryBudget > cpuBudget
 Document budget for CPU records.
GeodeGeometryCacheReservation cpuReservation
 Owned CPU-byte reservation.
uint64_t cpuRetainedBytes = 0
 Charged owner and record bytes. Geometry slab every occurrence's clipUniform range comes from: the slab of the slot whose draws the occurrences repeat, on the same device. Null until an occurrence first draws under a clip polygon.
std::shared_ptr< GeodeResidentSlab > clipUniformSlab

Static Public Attributes

static constexpr uint64_t kOccurrencePayloadBytes = sizeof(Occurrence) + sizeof(InstanceRecord)
 Estimated retained bytes in one occurrence and its instance record.
static constexpr uint64_t kProjectedBytesPerOccurrence
 Per-occurrence charge including the owner's vector entry.

Detailed Description

Persistent per-occurrence instance records for content drawn more than once over shared resident geometry: the glyph occurrences of one text element, or the second and later draws of one resident slot within a frame (each marker placement of a marker's content, a non-adjacent repeat of a <use> source).

The geometry is shared, so the thing that has to exist once per OCCURRENCE is the record: transform, colour, clip rectangle, and the shared geometry's chunk-relative bases. Handing every occurrence a fresh record slot each frame would work, but it would also write 256 bytes per occurrence per frame forever, which keeps a static frame off the zero-bytes steady state the rest of the renderer reaches.

So the slots live on their owner (a text element, one set per device that draws it, see GeodeTextInstanceResidencyComponent; or a resident slot, see GeodeResidentSlot::repeatRecords) and persist. Occurrence i of the owner always writes slot i, the bytes are compared before writing, and an unchanged frame writes nothing. Slots are allocated together on first use, in draw order, which keeps their indices consecutive - exactly the property a batch needs to cover them with one draw.

No explicit invalidation is needed when the content changes: a changed occurrence simply produces different record bytes for the affected slots, the compare misses, and those slots are rewritten. A frame with fewer occurrences leaves trailing slots unused (and free for the owner to grow back into); a frame with more appends.

lastFrame guards the one case the compare cannot: the same owner written twice while an earlier writer's draws are still unsubmitted - a text element drawn twice in one frame (a <use> of the text), or an offscreen pass rendering the same document inside an outer frame that has already recorded its batch. The second writer must not rewrite those records, because every buffer write in a frame executes before every draw in that frame's submit. lastFrame holds a DEVICE-scoped generation (GeodeDevice::beginFrameGeneration) so the comparison covers renderers sharing a device, and the renderer diverts the second writer to per-frame temporary slots instead.

An occurrence drawn under a clip polygon also keeps a uniform of its own (GeodeClipUniform): the polygon reaches the shader only through the draw-level uniform, which an ordered batch otherwise shares.


Class Documentation

◆ donner::geode::GeodeOccurrenceRecords::Occurrence

struct donner::geode::GeodeOccurrenceRecords::Occurrence

One occurrence's record slot plus the bytes last written to it.

Class Members
unique_ptr< GeodeClipUniform > clipUniform The batch-level uniform this occurrence's draw binds while a clip polygon is active; created the first time it draws under one and kept until its owner releases it.
vector< uint8_t > lastRecord
Slot slot

Constructor & Destructor Documentation

◆ GeodeOccurrenceRecords()

donner::geode::GeodeOccurrenceRecords::GeodeOccurrenceRecords ( GeodeOccurrenceRecords && other)
inlinenoexcept

Transfer occurrence slots and CPU reservations without freeing live slab records.

Parameters
otherComponent whose records are moved into this object.

Member Function Documentation

◆ appendReservedOccurrence()

bool donner::geode::GeodeOccurrenceRecords::appendReservedOccurrence ( const GeodeRecordSlab::Slot & slot)
inline

Append a slab slot after reserveOccurrence has admitted its CPU payload.

Parameters
slotGPU record slab slot assigned to the new occurrence.
Returns
False if the pending reservation cannot be completed.

◆ operator=()

GeodeOccurrenceRecords & donner::geode::GeodeOccurrenceRecords::operator= ( GeodeOccurrenceRecords && other)
inlinenoexcept

Release current slots and take ownership of another component's records.

Parameters
otherComponent whose records are moved into this object.
Returns
This component after the transfer.

◆ reserveClipUniform()

GeodeClipUniform * donner::geode::GeodeOccurrenceRecords::reserveClipUniform ( Occurrence & occurrence,
size_t bytes )
inline

The clip uniform of occurrence, created and charged with the occurrence's other CPU bytes on first use: the record of its range and a copy of bytes bytes of uniform.

Parameters
occurrenceAn occurrence of this component.
bytesSize of the uniform it will hold.
Returns
The occurrence's clip uniform, or null, leaving none, when the budget refuses it.

◆ reserveOccurrence()

bool donner::geode::GeodeOccurrenceRecords::reserveOccurrence ( std::shared_ptr< GeodeDocumentGeometryBudget > budget)
inline

Reserve CPU bytes and vector capacity before appending one occurrence.

Parameters
budgetDocument budget that will own the new reservation.
Returns
False if capacity growth or byte admission fails.

Member Data Documentation

◆ kProjectedBytesPerOccurrence

uint64_t donner::geode::GeodeOccurrenceRecords::kProjectedBytesPerOccurrence
staticconstexpr
Initial value:
=
std::unique_ptr< Occurrence > OccurrenceOwner
Stable owner for a separately allocated occurrence record.
Definition GeodeResidentPathComponent.h:520
static constexpr uint64_t kOccurrencePayloadBytes
Estimated retained bytes in one occurrence and its instance record.
Definition GeodeResidentPathComponent.h:522

Per-occurrence charge including the owner's vector entry.


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