Module comp_pipeline

Module comp_pipeline 

Source
Expand description

Comp pass GPU pipeline.

Reads render_texture (warp output) and writes a display-ready frame to final_texture. Filters here are display-only; they must not feed back into the next frame’s warp. See shaders/comp.wgsl for the geometry/UV conventions.

§Uniform layout

The bind group binds the standard ShaderUniforms layout (defined in onedrop-codegen::prelude) at @group(0) @binding(0). This is the same layout user comp shaders translated from MD2 HLSL expect, so a future shader-swap path (sprint B2 follow-up) only needs to recreate the render pipeline — bind group layout and buffer remain valid.

Structs§

CompAuxViews
Texture views the comp pass binds beyond the main warp output and blur pyramid. Bundled into a struct so the pipeline constructor + the resize rebind path don’t take a 10-argument list.
CompPipeline
OwnedCompAuxViews 🔒
CompAuxViews with owned (cloned) views — wgpu::TextureView is a refcounted handle so cloning is cheap. Used inside CompPipeline to remember the latest aux bindings across user-shader swaps.

Constants§

PREV_MAIN_BINDING
WGSL binding index for the previous-frame display texture used by the echo effect. Sits immediately after the user-texture slots (binding 22 is the last user texture, 23 is prev_main).

Functions§

build_pipeline_from_wgsl 🔒
Build a comp-pass RenderPipeline from a fully-formed WGSL source string.
build_user_shader_bind_group_layout 🔒
Build one of the four MD2 sampler variants used by sampler_{fw,fc,pw,pc}. MD2 encodes the choice into the sampler name: f/p = filter mode (filtered=linear vs point=nearest), w/c = address mode (wrap vs clamp-to-edge). Real preset authoring intent is matched per call site (sampler_pw_main = high-frequency point sample wrapped to texture boundary; sampler_fc_main = smooth bilinear sample clamped at edges). Build the bind-group layout user-translated shaders bind against.
make_fallback_user_texture_view 🔒
1×1 opaque white texture for unfilled user-texture slots. Returns just the view — the underlying texture is created on the spot and kept alive by the view’s refcounted handle. Sampling it produces vec4(1, 1, 1, 1) so any tex2D(sampler_user_N_texture, uv) * X degrades to X.
make_md2_sampler 🔒