Skip to main content

Crate engawa_wgpu

Crate engawa_wgpu 

Source
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§

BoundResources
Per-frame map of engawa ResourceId → live wgpu handle. The consumer (mado, future ayatsuri) populates this before calling dispatch_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 a BoundResource entry at dispatch time.
FrameUniforms
Per-frame uniform payloads — a typed map of engawa ResourceIdbytemuck-encoded bytes that WgpuDispatcher::dispatch_with writes into the corresponding BoundResource::Uniform buffers before any pass of that dispatch is encoded, so every node in the graph walk sees the same frame data.
TextureKey
Allocation key: textures are interchangeable iff size, format, and usage all match.
TextureLease
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::release simply lets wgpu free the texture; safe, just forfeits reuse.
TexturePool
Free-list pool of offscreen textures. One per consumer render loop; lease at frame start, release at frame end.
WgpuDispatcher
Dispatcher that compiles engawa render graphs to wgpu commands. Construct once; call dispatch_with per frame.

Enums§

BoundResource
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.
WgpuDispatcherError
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 through Dispatcher::dispatch_node via Display at the trait seam (the engawa trait returns DispatchError, so typed variants stringify exactly once there).

Constants§

FULLSCREEN_VERTEX_WGSL
The canonical fullscreen triangle: three vertices in clip space (no buffers needed). vertex_index 0/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 to wgpu::Device::create_shader_module.