/** * Structural-hash → composition cache with the "swap when ready" pattern. * * The cache is keyed by a STRUCTURAL HASH of the composition — the exact recompile-trigger * set (component/id/blend/mask/order/visible/opacity-bucket/transform/ * bbox/requiresRTT/compileTime props/colorSpace/toneMapping), made explicit instead of * comparing node identity. `collectStructuralHashInputs` (composer.ts) produces the * inputs; `structuralHash` digests them here. Same inputs → same key → the built composition * (pipelines + bind groups + RTT textures + IR) is reused; any trigger change → a new key → * a fresh build. * * Swap-when-ready: when the composition changes the cache builds the new value but * keeps the previous one as the render target until the new one has drawn its first frame * successfully (`markReady`), so an in-progress recompile never flashes. LRU keeps ~4 built * compositions alive (users toggle back and forth while editing); eviction beyond that * disposes the evicted composition's exclusive resources (RTT textures). The current render * target and the in-flight pending build are never evicted. * * Generic over the built value `V` (the pass-manager composition bundle) so this module has * no GPU coupling and is unit-testable with a plain object + a spy disposer. */ /** FNV-1a 32-bit — a fast, stable, order-sensitive digest of the structural inputs. */ export declare function structuralHash(inputs: readonly string[]): string; export interface PipelineCacheOptions { /** LRU capacity. Default 4 (swap-during-editing without thrash). */ maxSize?: number; /** Called when an entry is evicted / released — destroy its exclusive RTT textures etc. */ dispose?: (value: V, hash: string) => void; } export interface PipelineCache { /** * Return the built value for `hash`, building + caching it (via `buildFn`) on a miss. * A freshly-built value becomes the PENDING composition (not the render target) unless * there is no active composition yet (first build → active immediately). LRU-evicts the * least-recently-used entry when over capacity (never the active or pending one). */ getOrBuild(hash: string, buildFn: () => V): V; /** * Promote the pending composition to active once it has drawn its first successful frame. * The previous active stays in the LRU (reusable on a quick swap-back); it is disposed * only when evicted. No-op unless `hash` is the current pending build. */ markReady(hash: string): void; /** The composition to RENDER this frame — active until the pending build is confirmed. */ readonly renderValue: V | null; /** The active (rendered) composition's hash. */ readonly activeHash: string | null; /** The pending (built, not-yet-confirmed) composition's hash, or null. */ readonly pendingHash: string | null; /** Explicitly release a hash (dispose + drop). Clears active/pending if it was one. */ release(hash: string): void; has(hash: string): boolean; /** Number of cached compositions. */ readonly size: number; /** Dispose every cached composition and reset. */ clear(): void; } export declare function createPipelineCache(options?: PipelineCacheOptions): PipelineCache; //# sourceMappingURL=pipelineCache.d.ts.map