Skip to main content

Module backdrop

Module backdrop 

Source
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:

  1. prepare_layer_backdrops (PrepareBindGroups, after prepare_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-3 capture_texture, so every filter shader works unchanged (the snapshot is opaque, which satisfies the premultiplied contract trivially). Backdrop chains are forced always_dirty at resolve, so this stages every frame.
  2. run_backdrop_passes (called from ui_layer_capture_pass, before stock ui_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.
  3. [stage_backdrop_composite] (called from prepare_layer_composites) stamps a [LayerCompositeBatch] onto the layer’s backdrop quad (injected by redistribute_ui_layers one 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§

BackdropBlit
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.
BackdropBlitPipeline
The snapshot-blit pipeline: main texture + clamp-to-edge sampler + one dynamically-offset BackdropBlitUniforms. Deliberately not the filter layout (that mandates the 160-byte FilterUniforms via min_binding_size), same reasoning as the mip blit.
BackdropBlitPipelineKey
BackdropBlitUniforms
The blit’s per-layer uniforms: the snapshot rect mapped into the main texture’s UV space. Mirrors BlitUniforms in backdrop_blit.wgsl.
BackdropMeta
Per-frame backdrop staging, index-aligned with ExtractedUiLayers::layers. Owns its own uniform buffers — the content filter’s LayerFilterMeta buffer is written by its own system, and a shared buffer across systems would order-couple the writes.
BackdropSlot
A layer’s persistent backdrop resources: the snapshot texture (blit target + chain source) and the chain’s ping-pong pair, with the same output_valid discipline as FilterSlot. Allocated at the capture’s size + format whenever the layer has a backdrop chain; dies with the LayerSlot on 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_COLOR is 0.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 (no ViewTarget on 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 stock ui_pass consumes the quads.