Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
GeodeResidentPathComponent.h File Reference

Per-entity GPU residence for Geode's cached encoded-path geometry. More...

#include <atomic>
#include <cstdint>
#include <cstring>
#include <limits>
#include <memory>
#include <optional>
#include <span>
#include <utility>
#include <vector>
#include "donner/gpu/Descriptors.h"
#include "donner/gpu/Handles.h"
#include "donner/svg/renderer/geode/GeodeDevice.h"
#include "donner/svg/renderer/geode/GeodeResourceBudget.h"
#include "donner/svg/renderer/geode/GeodeWgpuAdapterDevice.h"
#include "donner/svg/renderer/geode/GeodeWgpuUtil.h"
Include dependency graph for GeodeResidentPathComponent.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::geode::InstanceRecord
 Layout of the per-instance record at binding 7 of the Slug fill pipeline. Must match InstanceRecord in shaders/slug_fill.wgsl. The vertex stage composes uniforms.mvp * transform; the fragment stage reads the remaining fields through a flat instance-id varying, so overlapping batched instances still blend in painter (instance) order. All geometry bases are element offsets relative to the bound buffer range's start (chunk-relative for resident geometry). More...
class  donner::geode::GeodeRecordSlab
 Document-scoped, painter-ordered record slab for ordered draw batching (ordered batching). More...
struct  donner::geode::GeodeRecordSlab::Slot
 One record slot: its index in the contiguous array and its absolute byte offset in the owning buffer. More...
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). More...
class  donner::geode::GeodeResidentSlab
 Document-scoped suballocation slab for GPU residence. More...
struct  donner::geode::GeodeResidentSlab::Allocation
 One sub-range of a slab chunk. More...
struct  donner::geode::GeodeResidentSlot
 GPU-resident geometry for one cached EncodedPath (a fill slot or a stroke slot). Owns a single combined-usage GPU buffer that holds the path's eight analytic dual-ray SSBO regions and per-draw uniform block, plus the cached fill bind group. Bounding vertices live in that uniform and are expanded from vertex_index, so the resident geometry needs no vertex buffer. The buffer and bind group are built once by GeoEncoder on first residence and reused every subsequent unchanged frame. More...
struct  donner::geode::GeodeResidentSlot::Region
 A byte sub-range of buffer. size == 0 is never bound directly - empty SSBO regions reserve a zero-filled dummy slot wide enough for one element of the WGSL array they feed, so the shader's band-count gate keeps them un-dereferenced and the binding still passes WebGPU's minimum-size validation (matching the per-frame arena allocStorageOrDummy dummy). More...
struct  donner::geode::GeodeResidentGradientSlot
 GPU-resident geometry for one gradient-painted fill. Mirrors GeodeResidentSlot: a combined-usage buffer holds the same eight analytic dual-ray SSBO regions, but the uniform region holds the 672-byte gradient uniform block (stops inline, shaders/slug_gradient.wgsl) and the cached bind group uses the 11-binding gradient pipeline layout with the device-owned dummy clip-mask texture/sampler in bindings 3 and 4. Residence is only taken when no clip mask, clip polygon, or mask pass is active (the gradient shader's clip flags must stay zero for the cached bind group to remain stable), exactly like the solid-fill residence gate. More...
struct  donner::geode::GeodeResidentGradientSlot::Region
 A byte sub-range of buffer (same semantics as GeodeResidentSlot::Region). More...
struct  donner::geode::GeodeResidentPathComponent
 Sibling of GeodePathCacheComponent: holds the GPU residence for an entity's fill and stroke encodes. Installed lazily by RendererGeode at the solid-fill draw sites; removed by the same entt listener that clears GeodePathCacheComponent when geometry changes. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Detailed Description

Per-entity GPU residence for Geode's cached encoded-path geometry.

GeodePathCacheComponent keeps the CPU-side EncodedPath across frames, but the renderer still re-uploaded that geometry to a fresh per-frame bump arena on every draw - the measured headline cost was a static Ghostscript Tiger writing ~1.44 MB per frame across 2,432 writeBuffer calls even though the CPU encode cache hit, plus one createBindGroup per draw (304/frame).

This component gives each cached path a persistent GPU buffer that survives frames, so an unchanged document's steady-state frame writes ~zero geometry bytes and re-uses a cached bind group. It lives BESIDE GeodePathCacheComponent on the same entity and is removed by the same ComputedPathComponent on_update / on_destroy listener (RendererGeode::Impl::onComputedPathChanged), so the GPU residence invalidates exactly when the geometry changes. Registry teardown (document close) destroys the component and RAII-frees the buffer - the eviction story for "many distinct documents".

Lives in donner::geode (not donner::svg::geode) to match the other Geode types referenced unqualified via geode:: inside donner::svg.


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

◆ donner::geode::GeodeResidentSlab::Allocation

struct donner::geode::GeodeResidentSlab::Allocation

One sub-range of a slab chunk.

Class Members
BufferRef buffer
uint64_t bufferId = 0 Stable identity of buffer (see GeodeDevice::AllocateBufferId). Only allocation results carry it; free matches on the handle, which is unambiguous while the slab that owns the chunk is alive.
uint64_t offset = 0
uint64_t size = 0

◆ donner::geode::GeodeResidentSlot::Region

struct donner::geode::GeodeResidentSlot::Region

A byte sub-range of buffer. size == 0 is never bound directly - empty SSBO regions reserve a zero-filled dummy slot wide enough for one element of the WGSL array they feed, so the shader's band-count gate keeps them un-dereferenced and the binding still passes WebGPU's minimum-size validation (matching the per-frame arena allocStorageOrDummy dummy).

Class Members
uint64_t offset = 0
uint64_t size = 0

◆ donner::geode::GeodeResidentGradientSlot::Region

struct donner::geode::GeodeResidentGradientSlot::Region

A byte sub-range of buffer (same semantics as GeodeResidentSlot::Region).

Class Members
uint64_t offset = 0
uint64_t size = 0