Expand description
Mip-chain generation for 3D-transformed layers’ capture textures.
A transformed composite quad minifies its capture (tilt compresses many
texels per pixel); bilinear-only sampling shimmers. Layers with the
TRANSFORM3D promotion reason therefore allocate their sampled texture
with a full mip chain ([super::alloc_layer_slot] /
[super::alloc_filter_slot], keyed on the reason so identity↔non-identity
value changes never realloc), and this module rebuilds the chain exactly
when level 0 is rewritten — a cached capture keeps its mips for free.
The lifecycle mirrors the filter machinery: prepare_layer_mips stages
one MipRun per dirty chain (pipeline + per-level bind groups/targets —
the capture pass can create no GPU resources), ui_layer_capture_pass
replays it right after the layer’s capture/filter passes, and the
composite samples through the trilinear/anisotropic sampler only while the
slot’s mips_valid holds (the fallback is plain bilinear over level 0 —
never a gate, never a stale mip). For filtered layers the chain builds on
the filter output ping-pong (what the quad actually samples), not the
raw capture.
Each downsample level is one fullscreen-triangle pass (mip_blit.wgsl)
sampling level i into level i + 1: linear filtering into a half-size
target is a standard 2×2 box downsample, correct on premultiplied content.
Structs§
- Layer
Blit Pipeline - The downsample-blit pipeline: one texture + sampler bind group, no
uniforms (deliberately not the filter layout — that mandates the 160-byte
FilterUniformsviamin_binding_size). - Layer
Blit Pipeline Key - Layer
MipMeta - Per-frame mip staging, index-aligned with
ExtractedUiLayers::layers.runs[idx] = None= no downsample work (unmipped layer, cache hit, source not ready, or pipeline still compiling — the composite then falls back to bilinear over level 0 via the slot’smips_valid). - MipChain
- The per-texture mip-chain views a mipped slot carries. Built at alloc time (the capture pass creates no views); the blit source bind groups are filled lazily at first staging (they need the pipeline’s layout) and die with the slot on realloc.
- MipLevel
- One staged downsample pass: bind
bind_group(source level), render 3 vertices intotarget(the next level). - MipRun
- A layer’s staged downsample chain this frame.
Functions§
- build_
mip_ chain - Build the per-level + full views for a texture allocated with
mip_level_countlevels. - init_
layer_ blit_ pipeline - mip_
level_ count - Mip levels for a texture of
size— the full chain down to 1×1. - prepare_
layer_ mips - Stage the downsample chain for every
wants_mipslayer whose sampled texture’s mips are stale. Predictive like the filter staging:mips_validflips true only when the staged run is certain to execute this frame (source complete + blit pipeline compiled); until then the composite’s bilinear fallback covers.