Expand description
wgpu-backed Dispatcher impl for engawa render graphs.
engawa owns the typed IR; this crate owns the wgpu wiring.
Operators construct a WgpuDispatcher once per graph (or
once per consumer lifetime), pass it the device + queue + a
target format, and call dispatch_graph from their render
loop.
Scope (v0.1): fullscreen-effect graphs. Every node with
a Material is dispatched as a render-pass that draws a
single fullscreen triangle through a built-in vertex shader,
with the operator’s WGSL providing the fragment. Compute and
blit passes are pending — same trait, follow-on work.
Per-call dispatch is canonical: WgpuDispatcher::new
clones the (internally reference-counted) device/queue
handles — no lifetime borrow — and dispatch_with takes the
graph + bindings + live handles + per-frame FrameUniforms
every call. Offscreen ping-pong textures come from the
TexturePool lease API.
Scope (NOT v0.1): swapchain management, bind-group
authoring. Engawa’s ResourceBindings is the operator-facing
handoff for those — the consumer binds wgpu handles to engawa
ResourceIds. This crate dispatches; the consumer feeds it.
Modules§
- catalog
- Typed effect catalog — the built-in post-process effects every engawa consumer composes from (engawa roadmap v0.4, realised here in the wgpu backend crate so the WGSL lives next to the dispatcher that runs it).
Structs§
- Bound
Resources - Per-frame map of engawa
ResourceId→ live wgpu handle. The consumer (mado, future ayatsuri) populates this before callingdispatch_with. Engawa already validated at compile time that every node references a resource that’s either an input or another node’s output; the dispatcher validates that every referenced resource has aBoundResourceentry at dispatch time. - Frame
Uniforms - Per-frame uniform payloads — a typed map of engawa
ResourceId→bytemuck-encoded bytes thatWgpuDispatcher::dispatch_withwrites into the correspondingBoundResource::Uniformbuffers before any pass of that dispatch is encoded, so every node in the graph walk sees the same frame data. - Texture
Key - Allocation key: textures are interchangeable iff size, format, and usage all match.
- Texture
Lease - A leased pooled texture. Move-only — holding the lease IS
the right to use the texture (see the module doc for the
honest tier statement). Dropping a lease without
TexturePool::releasesimply lets wgpu free the texture; safe, just forfeits reuse. - Texture
Pool - Free-list pool of offscreen textures. One per consumer render loop; lease at frame start, release at frame end.
- Wgpu
Dispatcher - Dispatcher that compiles engawa render graphs to wgpu
commands. Construct once; call
dispatch_withper frame.
Enums§
- Bound
Resource - Live wgpu handle wrapped in a tagged enum so the dispatcher can match the bind type the Material declared. Operators build this from their own wgpu resources at dispatch time.
- Wgpu
Dispatcher Error - Typed dispatch-failure surface. Every variant here is
CONSTRUCTED by the dispatch path — the M3 review (2026-06-12)
found five declared-but-never-built variants advertising a typed
API the error paths didn’t deliver;
MissingMaterial(materialless nodes are clear nodes by design, so the state was unreachable) is deleted and the rest now flow throughDispatcher::dispatch_nodevia Display at the trait seam (the engawa trait returnsDispatchError, so typed variants stringify exactly once there).
Constants§
- FULLSCREEN_
VERTEX_ WGSL - The canonical fullscreen triangle: three vertices in clip
space (no buffers needed).
vertex_index0/1/2 maps to (-1,-1) / (3,-1) / (-1,3), which fully covers [-1, 1]² with no overdraw beyond the viewport.
Functions§
- combined_
shader_ source - Concatenate the built-in fullscreen vertex shader with the
operator’s WGSL (which provides
fs_main). Returns the combined source ready to hand towgpu::Device::create_shader_module.