Pass classes are framework-neutral and exported from root, core, and adapter entrypoints.
Shared render-pass options
ShaderPass, BlitPass, and CopyPass share:
needsSwap: true is valid only for source → target. canvas is output-only. Named slots must exist and be written before use.
ShaderPass
Requires fragment containing:
Public methods:
setFragment validates the next source before replacing the active program and invalidating its pipeline cache.
shade and any helper it calls can read the current pass coordinates from motiongpuFragment.uv. The existing uv parameter remains required.
BlitPass and CopyPass
BlitPass samples its input with the configured filter. CopyPass attempts a direct GPU copy and otherwise uses an internal blit. Direct copy requires no clear, preserved output, distinct non-canvas textures, and equal dimensions and formats.
Both expose setSize, render, and dispose through the render-pass lifecycle.
ComputePass
The source requires @compute, numeric @workgroup_size(...), a compute function, and @builtin(global_invocation_id) in its signature.
isCompute is the readonly true discriminant.
PingPongComputePass
Adds required target, optional positive-integer iterations (default 1), and the isPingPong discriminant. Its target must be a declared storage texture with explicit dimensions.
The renderer calls advanceFrame() after the current iteration batch. Output A/B parity therefore remains correct when iteration count changes between frames.
PingPongShaderPass
Runs a pre-scene fragment shader with fn frag(uv: vec2f) -> vec4f. target must be a declared, fragment-visible, non-storage material texture.
Dimensions and scale must be finite and positive, iterations a positive integer, and format float-sampled.
isPingPongShader is the readonly true discriminant. setDimensions, setScale, and reset request A/B reinitialization; consumeResetColor is renderer-facing and clears that pending request.
frag and its helper functions can read the ping-pong target coordinates from motiongpuFragment.uv. They use the pass target dimensions and the same public Y-up orientation as the uv parameter.
See Render Passes, Compute Shaders, and the Ping-pong Fluid demo.