wasdk-wgpu
A wgpu backend over the engine's wasi:webgpu, through wgpu's own extension point for another WebGPU implementation (custom), so code written against wgpu (valo, and Waft through it) draws in a component unchanged (the design's decision 14), and draws on a view through wgpu's own surface, as a browser's canvas is drawn on, so a framework's renderer runs as it does on any system (decision 52). What wgpu has and WebGPU lacks, such as a surface on a window that is not a view, ray tracing, or shaders other than WGSL, panics with a message naming the gap; the crate's docs list all of it. Ported from the experiment.
- Takes:
wasi:webgpu, aswasdk::webgpugenerates it, andwasdk:platform's views andgpu-interop;wgpu. - Provides:
instance(), awgpu::Instanceon wgpu's custom backend;SharedView, a program's view shared with the surfaces made on it, the windowInstance::create_surfacetakes, its handle aWebCanvasWindowHandlepointing at it, whose surface hands out the view's canvas texture each frame and whose frameQueue::presentpresents on the view, with the layers the view holds, the one way the crate draws on a view;import_texture, a hardware buffer the program holds, one it allocated, a decoded image's or a video frame's, imported as awgpu::Textureover its memory throughwasdk:platform/gpu-interop, for what the buffer's usage names; andconvert, the conversions between wgpu's vocabulary and WebGPU's. - Used by: programs that draw with wgpu, such as
examples/triangle;waft-embedder-wasdk, which draws an Waft app's views with valo over it.
let instance = instance;
let adapter = instance.request_adapter.await?;
let = adapter.request_device.await?;
let view = new;
let surface = instance.create_surface?;
let metrics = view.metrics;
surface.configure;
// Each frame:
let Success = surface.get_current_texture else ;
// ...draw into `frame.texture` and submit...
view.set_layers; // a program with composition layers
queue.present;
configure sets the view's canvas to the size configured (view.set-canvas-size), so a frame's texture is always that size, whatever the view's own; a program configures again as its view's size changes, as it would a window's surface anywhere.
The crate compiles natively too, so cargo clippy --workspace reaches it, but only a component's imports mean anything.