|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
Document-scoped cache of unique glyph outlines and their GPU residence. More...
#include "donner/svg/renderer/geode/GeodeGlyphResidency.h"
Public Member Functions | |
| GeodeGlyphCache (uint64_t deviceId, std::shared_ptr< GeodeDocumentGeometryBudget > budget=nullptr) | |
| Create an empty cache bound to deviceId. | |
| GeodeGlyphCache (const GeodeGlyphCache &)=delete | |
| GeodeGlyphCache & | operator= (const GeodeGlyphCache &)=delete |
| uint64_t | owningDeviceId () const |
| Device this cache's residence was built on. | |
| GeodeGlyphResidentEntry * | find (const GlyphGeometryKey &key) |
| Look up key, returning null on a miss. Does not mark the entry used; the caller does that once it commits to drawing. | |
| GeodeGlyphResidentEntry * | insert (const GlyphGeometryKey &key, Path &&outline, EncodedPath &&encoded) |
| Insert an entry for key, taking ownership of outline and its encode. The returned address is stable for the entry's lifetime. | |
| GeodeGlyphResidentEntry * | insertWithinBudget (const GlyphGeometryKey &key, Path &&outline, EncodedPath &&encoded, uint64_t oldestOpenFrame, size_t maxEntries, uint64_t maxRetainedBytes, size_t *evictedOut=nullptr) |
| Insert through the per-cache entry/byte envelope after evicting entries old enough to be safe. The family reservation in insert remains the aggregate cross-document admission gate. | |
| size_t | size () const |
| Number of live entries. | |
| uint64_t | encodedBytes () const |
| Summed GeodeGlyphResidentEntry::encodedBytes over live entries. | |
| uint64_t | retainedBytes () const |
| Total CPU bytes retained by cached outlines and encodes. | |
| size_t | beginFrame (uint64_t frameIndex, uint64_t oldestOpenFrame, size_t maxEntries, uint64_t maxRetainedBytes) |
| Trim to budget at most once per frame. The frame-index guard makes the call idempotent no matter how many times a frame touches the cache, so the caller can put it on the accessor and cover every draw entry point. Returns the number of entries dropped. | |
| size_t | evictToBudget (uint64_t oldestOpenFrame, size_t maxEntries, uint64_t maxRetainedBytes) |
| Drop entries until the cache fits the budget, oldest-unused first. | |
Document-scoped cache of unique glyph outlines and their GPU residence.
Bound to one device exactly like GeodeResidentSlab: a document rendered by a second device gets a fresh cache, so no entry can hand a stale device's buffer or bind group to another device's render pass.
Eviction is generation-based rather than strictly ordered: entries carry the frame index of their last use, and when the cache is over budget the oldest unused entries are dropped first. Dropping an entry destroys its GeodeResidentSlot, which returns the slab range through the slab's deferred free list, so the range only becomes reusable at the NEXT frame's merge - never inside the frame whose recorded draws still reference it. Entries used in the current frame are never candidates for the same reason.
Not thread-safe; the renderer serializes one frame per device at a time.
|
inline |
Drop entries until the cache fits the budget, oldest-unused first.
An entry last used at or after oldestOpenFrame is never dropped: some frame that touched it has not submitted, its recorded draws still read that geometry, and dropping the entry would return the slab range for a later allocation to overwrite. oldestOpenFrame is device-scoped, so an offscreen pass nested inside an outer frame cannot free the outer frame's geometry out from under it. Returns the number of entries dropped.