Expand description
Shader compiler with naga validation
StructsΒ§
- Cache
Stats - Cache statistics
- Compiled
Shader - Compiled shader with validated module
- Shader
Compiler - Shader compiler with caching
ConstantsΒ§
- MD2_
MATH_ πCONSTANTS - MD2 math constants (mirrors projectMβs
milkdrop-shaders.h). - MD2_
NOISE_ πTEXSIZE_ CONSTANTS - Procedural noise pack
texsize_*vec4 constants. Module-scope (was previously emitted insidefs_main) so lifted user functions that referencetexsize_noise_lq.zwfor a per-texel offset compile cleanly. The values are fixed at engine init (seeonedrop-renderer::noise), so promoting them fromlettoconstis a free win. - MD2_
PRIVATE_ πSTATE_ DECLS - MD2 per-invocation private state hoisted to module scope.
- USER_
COMP_ πBINDINGS - USER_
COMP_ πFRAGMENT_ PREFIX - USER_
COMP_ πFRAGMENT_ SUFFIX - USER_
COMP_ πHELPERS - MD2 helper functions every comp shader expects to find at module scope.
- USER_
COMP_ πVERTEX - USER_
TEXTURE_ FIRST_ BINDING - First @binding index used by the user-texture array. The
14 bindings below this are claimed by built-ins (uniforms, main texture,
blur, noise, four sampler variants) β see
USER_COMP_BINDINGS. - USER_
TEXTURE_ SLOTS - Re-export so the renderer can spell the same constant in its bind group
builder. Single source of truth: the wrapper declares
MAX_USER_TEXTURE_SLOTSbindings; the comp pipeline allocates that many entries. - USER_
WARP_ πFRAGMENT_ PREFIX - Fragment-shader header for user-authored warp shaders. Same shape
as
USER_COMP_FRAGMENT_PREFIX(seed every MD2var<private>binding fromuniformsand per-invocation inputs), butuv/uv_origcome from the rasterised warp UV β not from a fullscreen-triangle screen UV β andretis seeded from the previous-frame texture at that warped UV. The renderer bindsprev_texturetosampler_main_texturesoGetPixel(uv)(defined in the shared helpers) does the right thing. - USER_
WARP_ πFRAGMENT_ SUFFIX - Fragment-shader trailer for the warp pass. Same convention as the
comp suffix (return
vec4(ret, 1.0)), minus thegamma_adjfactor β gamma is a display-side concern applied later in the comp pass. - USER_
WARP_ πVERTEX - Warp-pass vertex shader. Consumes the same
WarpVertexlayout the renderer uses for the default warp pipeline (pos_clip: vec2<f32>at@location(0)plusuv_warp: vec2<f32>at@location(1)) so switching between the default and user pipelines doesnβt change vertex buffer plumbing on the renderer side.
FunctionsΒ§
- append_
user_ πtexsize_ constants - Emit a
let texsize_<NAME>: vec4<f32> = vec4<f32>(w, h, 1/w, 1/h);line for each filled slot in the plan. Preset code reads these directly:tex2D(sampler_clouds, uv + texsize_clouds.zw * dt)is a common pattern for βstep one texel along the texture dimensionβ. - wrap_
user_ comp_ shader - Wrap a translated WGSL fragment body into a complete shader module (prelude + texture bindings + entry points).
- wrap_
user_ comp_ shader_ with_ plan - Same as
wrap_user_comp_shader, but emits per-presettexsize_<NAME>constants from the suppliedTextureBindingPlan. The user-texture bindings themselves are always declared (so the bind-group layout the comp pipeline owns stays stable); only the WGSL identifiers the user body can reference (texsize_clouds, β¦) change per preset. - wrap_
user_ warp_ shader_ with_ plan - Wrap a translated WGSL fragment body for the warp pass into a
complete shader module. Mirror of
wrap_user_comp_shader_with_planβ same uniforms, same texture bindings, same MD2 private-state declarations β but with a vertex shader that consumes the warp-meshWarpVertex(pos_clip+uv_warp) and a fragment that seedsuvfromuv_warpandretfrom the previous-frame texture at that UV.