GPU programs.
No shaders to write.
Every demo here is a Miri program. You never hand-write GLSL, WGSL or
CUDA — the kernels are the same statically-typed Miri you'd write for the CPU, turned
device-resident by one keyword: gpu. Miri infers the uploads, transpiles the
kernels to WGSL, and runs them on WebGPU (and Metal, Vulkan, DX12). The code beside each
demo is the whole program — nothing is hidden.
The animation you see is the program beside it: the same source, compiled to WGSL by Miri and running on WebGPU in this tab. Nothing here is a hand-written stand-in — open any demo below to read its full source and build it yourself in four steps.
Three things show up in every program below. Learn to read them once:
gpu var
A buffer that lives in device memory. You declare it. Miri infers the upload and readback. No marshalling code, no binding boilerplate.
forall i in 0..n
A kernel — one GPU thread per index. A bare forall runs on the GPU when it
touches device data. The ordered passes inside a frame are written gpu forall.
gpu frame
The per-frame pass graph. Passes run in order over disjoint buffers and read live input —
frame.time, frame.dt, frame.mouse_x,
frame.drag_dx — supplied each frame by the runtime.
Open any demo above for its full source, its live counterpart running at full size, and the four steps to build and run it on your own GPU.