Expand description
Render-world half of backdropFilter: the snapshot blit, the backdrop
filter run, and the backdrop composite quad.
Per frame, for each layer with an extracted backdrop chain:
prepare_layer_backdrops(PrepareBindGroups, afterprepare_layer_textures) stages a snapshot blit (crop-sample the camera main texture over the layer’s capture rect —backdrop_blit.wgsl) and a filter run over the snapshot, reusing the content-filter pipeline wholesale: the snapshot is bound as the pass-0 source AND as the binding-3capture_texture, so every filter shader works unchanged (the snapshot is opaque, which satisfies the premultiplied contract trivially). Backdrop chains are forcedalways_dirtyat resolve, so this stages every frame.run_backdrop_passes(called fromui_layer_capture_pass, before stockui_pass) executes blit → chain. The blit bind group is created HERE, in the pass system:ViewTarget’s a/b main texture flips during PostProcess, so a prepare-time binding would race (Bevy’s tonemapping node is the precedent). At this point in the camera schedule the main texture holds the tonemapped 3D frame with no UI — exactly the v1 backdrop.- [
stage_backdrop_composite] (called fromprepare_layer_composites) stamps a [LayerCompositeBatch] onto the layer’s backdrop quad (injected byredistribute_ui_layersone epsilon below the content quad): the un-inflated border box (frost never paints in the outset ring) sampling the chain’s output, multiplied by the group alpha. Gating is graceful by construction — a withheld backdrop quad draws nothing and the region shows the real (unfiltered) frame already in the target, never an invisible subtree.
Structs§
- Backdrop
Blit - One staged snapshot blit: pipeline + this layer’s uniform entry. The bind
group is created in the pass (
run_backdrop_passes) — the main-texture view is not stable at prepare time. - Backdrop
Blit Pipeline - The snapshot-blit pipeline: main texture + clamp-to-edge sampler + one
dynamically-offset
BackdropBlitUniforms. Deliberately not the filter layout (that mandates the 160-byteFilterUniformsviamin_binding_size), same reasoning as the mip blit. - Backdrop
Blit Pipeline Key - Backdrop
Blit Uniforms - The blit’s per-layer uniforms: the snapshot rect mapped into the main
texture’s UV space. Mirrors
BlitUniformsinbackdrop_blit.wgsl. - Backdrop
Meta - Per-frame backdrop staging, index-aligned with
ExtractedUiLayers::layers. Owns its own uniform buffers — the content filter’sLayerFilterMetabuffer is written by its own system, and a shared buffer across systems would order-couple the writes. - Backdrop
Slot - A layer’s persistent backdrop resources: the snapshot texture (blit
target + chain source) and the chain’s ping-pong pair, with the same
output_validdiscipline asFilterSlot. Allocated at the capture’s size + format whenever the layer has a backdrop chain; dies with theLayerSloton realloc. No mip state: the backdrop quad is never 3D-transformed in v1.
Constants§
- BACKDROP_
UNDERLAY_ EPSILON - The backdrop quad’s stacking offset below its layer’s first stolen item.
stack_z_offsets::BACKGROUND_COLORis0.0, so an explicit negative epsilon is required to sort strictly under the content composite quad (which sits AT the first stolen key). Per-node z offsets span −0.1..0.08 and adjacent stack indices differ by 1.0, so 0.005 can never sink the quad under a preceding sibling.
Functions§
- alloc_
backdrop_ slot - Allocate a layer’s backdrop slot at the capture’s size and format.
- backdrop_
gate - Whether this layer’s backdrop composite may draw this frame, maintaining
the gate-warn bookkeeping. Returns the bind group to sample when ready.
Mirrors the content-filter gate in
prepare_layer_composites, with a milder warning: a withheld BACKDROP quad shows the unfiltered frame (the pixels are already in the target), never an invisible subtree. - backdrop_
quad - The backdrop quad’s clipped geometry: the UN-inflated border box
(
min + outset .. min + size − outset) with UVs relative to the INFLATED snapshot — frost never paints in the outset ring, but its blur was computed with real neighborhood.None= fully clipped away (or a degenerate box), draw nothing. - camera_
main_ texture - Fetch the camera’s current main-texture view for
run_backdrop_passes.None(noViewTargeton the camera) skips every backdrop this frame. - init_
backdrop_ blit_ pipeline - prepare_
layer_ backdrops - Stage every backdrop’s blit + filter run for this frame. Mirrors
prepare_layer_filters’ three phases (stage → write buffers + bind groups → predict validity), with two deliberate differences: staging is unconditional per frame (the source frame is live), and the validity prediction requires the BLIT pipeline compiled too — the chain would otherwise filter a garbage snapshot. - run_
backdrop_ passes - Execute one layer’s staged backdrop work inside the capture-pass
encoder: blit the frame region into the snapshot, then replay the chain
snapshot → ping-pong. Called per layer from
ui_layer_capture_pass, before stockui_passconsumes the quads.