Expand description
The persistent capture-texture store — the resource that makes layer
capture caching possible. Split from render.rs (which stays the pass /
composite half): slot structs, allocation, and the per-frame
prepare_layer_textures maintenance. Everything is re-exported through
super so consumers keep their render::… paths.
Structs§
- Filter
Slot - A layer’s persistent filter-pass resources: two same-size ping-pong
textures (pass 0 samples the capture and writes
textures[0], pass 1 samplestextures[0]and writestextures[1], and so on) plus the bookkeeping that lets a clean chain skip re-running its passes. Allocated at the capture’s size + format; dies with theLayerSloton realloc. - Layer
Atlases - The per-layer offscreen capture textures (spike: one texture per layer;
the planned per-depth shared atlas swaps in behind the same indices).
Index-aligned with
ExtractedUiLayers::layers; entries are clones of the persistentLayerTextureStoreslots. - Layer
Slot - One layer’s persistent capture texture. Unlike Bevy’s
TextureCache(descriptor-keyed pool — same-size layers can swap textures between frames, and nothing pins content), a slot is keyed by the layer root’sMainEntity, so a clean layer’s texture reliably still holds last frame’s capture. - Layer
Texture Store - Persistent (cross-frame) capture textures, keyed by layer root — the
resource that makes capture caching possible. Slots are allocated /
reallocated by
prepare_layer_texturesand evicted a few frames after their layer disappears (demote, despawn).
Functions§
- prepare_
layer_ textures - Maintains the persistent per-layer capture textures (camera target format —
stolen pipelines were specialized against it; sample count 1 —
ui_passrenders unsampled): get-or-(re)allocate each live layer’sLayerTextureStoreslot, mirror it into the index-alignedLayerAtlases, and evict slots whose layer is gone. Also owns theFilterSlotlifecycle: ping-pong textures allocated while the layer has a chain, cleared (with their version bookkeeping — load-bearing, see the in-body comment) when it doesn’t. Deliberately not Bevy’sTextureCache— capture caching needs each layer to keep its own texture (and its pixels) across frames.