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

Persistent per-occurrence instance records for one text element. More...

#include "donner/svg/renderer/geode/GeodeGlyphResidency.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

 GeodeTextInstanceRecordComponent (const GeodeTextInstanceRecordComponent &)=delete
GeodeTextInstanceRecordComponent & operator= (const GeodeTextInstanceRecordComponent &)=delete
 GeodeTextInstanceRecordComponent (GeodeTextInstanceRecordComponent &&other) noexcept
 Transfer occurrence slots and CPU reservations without freeing live slab records.
GeodeTextInstanceRecordComponent & operator= (GeodeTextInstanceRecordComponent &&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.
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 within the element's draw, 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 an untouched component is.
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.

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 one text element.

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

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

No explicit invalidation is needed when the text changes: a re-laid-out element simply produces different record bytes for the affected slots, the compare misses, and those slots are rewritten. A shorter run leaves trailing slots unused (and free for the element to grow back into); a longer one appends.

lastFrame guards the one case the compare cannot: the same element written twice while an earlier writer's draws are still unsubmitted - the same 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 glyph 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.


Class Documentation

◆ donner::geode::GeodeTextInstanceRecordComponent::Occurrence

struct donner::geode::GeodeTextInstanceRecordComponent::Occurrence

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

Class Members
vector< uint8_t > lastRecord
Slot slot

Constructor & Destructor Documentation

◆ GeodeTextInstanceRecordComponent()

donner::geode::GeodeTextInstanceRecordComponent::GeodeTextInstanceRecordComponent ( GeodeTextInstanceRecordComponent && 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::GeodeTextInstanceRecordComponent::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=()

GeodeTextInstanceRecordComponent & donner::geode::GeodeTextInstanceRecordComponent::operator= ( GeodeTextInstanceRecordComponent && 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.

◆ reserveOccurrence()

bool donner::geode::GeodeTextInstanceRecordComponent::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::GeodeTextInstanceRecordComponent::kProjectedBytesPerOccurrence
staticconstexpr
Initial value:
=
static constexpr uint64_t kOccurrencePayloadBytes
Estimated retained bytes in one occurrence and its instance record.
Definition GeodeGlyphResidency.h:460
std::unique_ptr< Occurrence > OccurrenceOwner
Stable owner for a separately allocated occurrence record.
Definition GeodeGlyphResidency.h:458

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


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