Module user_warp_pipeline

Module user_warp_pipeline 

Source
Expand description

User-shader path for the warp pass.

Sibling of crate::CompPipeline’s user-shader path. When a preset ships a warp_shader=… block, [onedrop-codegen::ShaderCompiler] translates it through the same HLSL→WGSL chain the comp pass uses and emits a complete WGSL module against the ShaderUniforms bind- group layout. The default crate::WarpPipeline runs the engine’s hand-written warp.wgsl with a minimal 3-binding layout; this parallel pipeline runs the user’s translated module against the full 25-binding layout the codegen wrapper assumes.

§Wiring

  • Vertex format: same WarpVertex the default warp pipeline consumes (pos_clip: vec2<f32> + uv_warp: vec2<f32>), so the warp mesh vertex buffer is shared verbatim.
  • Binding 1 (sampler_main_texture): the renderer binds prev_texture here. GetPixel(uv) in the user shader therefore samples the previous frame at the per-pixel warped UV — exactly the MD2 warp convention.
  • Bindings 3..5 (sampler_blur1/2/3_texture): the warp pass runs before the blur pipeline, so this frame’s blurred copies don’t exist yet. We bind the previous frame’s blur pyramid (prev_blur1/2/3_texture in crate::ChainTextures), mirroring how prev_texture carries the previous warp output. Authored GetBlur1(uv) calls inside a translated warp shader therefore sample a true Gaussian-blurred copy — one frame stale — instead of un-blurred prev_texture.
  • Bindings 6..10 (sampler_noise_*_texture): real noise pack views from crate::GpuContext’s NoisePack — identical to what the comp pipeline sees.
  • Bindings 15..22 (sampler_user_<n>_texture): per-preset disk-loaded user textures, threaded through from the same TextureBindingPlan the comp side uses.
  • Binding 23 (sampler_prev_main_texture): aliased to prev_texture.

Structs§

UserWarpPipeline
Pipeline + bind group + uniforms buffer for the user-authored warp fragment shader. Instantiated lazily by crate::WarpPipeline’s set_user_shader_with_plan; lives alongside the default warp path and replaces it at draw time when present.
WarpAuxViews
View pack for the user warp pass.

Functions§

build_warp_pipeline_from_wgsl 🔒
Build the wgpu render pipeline. Vertex layout matches WarpVertex (pos_clip at @location(0), uv_warp at @location(1)); fragment targets target_format with BlendState::REPLACE (the warp pass owns the entire render target).
create_user_warp_bind_group 🔒
Build the 25-entry bind group for the user warp pass.