dawn-rs
Rust bindings and thin wrappers for Dawn WebGPU.
Status
Active development. Not approved for production use.
Prerequisites
- Rust toolchain (
cargo+ stable toolchain). - A built Dawn tree.
DAWN_ROOTpointing to either:- the Dawn source root with build output directory that contains static libs (for example
dawn/out/Release).
- the Dawn source root with build output directory that contains static libs (for example
Build Dawn first by following the official guide:
Windows note:
- Rust defaults to static CRT in many setups. If needed, build Dawn with
/MT:cmake -GNinja -B out/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DABSL_MSVC_STATIC_RUNTIME=ON
- If you build Dawn with GN instead of CMake, use a static non-component build as well:
gn gen out/Release --args="is_debug=false is_component_build=false is_clang=true target_cpu=\"x64\""ninja -C out/Release
Quick Start
Run the native adapter example:
DAWN_ROOT=/path/to/dawn
Run the native triangle example:
DAWN_ROOT=/path/to/dawn
Run wire triangle example (dawn-rs):
DAWN_ROOT=/path/to/dawn
Run wire nya-cat example (dawn-wgpu):
DAWN_ROOT=/path/to/dawn
Code Generation
Inputs:
--dawn-json: path tosrc/dawn/dawn.jsonfrom Dawn source.--api-header: path toinclude/webgpu/webgpu.hfrom Dawn build/prebuilt artifacts.
Windows:
macOS:
Notes:
- Generated bindings are selected per OS/arch in
src/generated/mod.rs. build.rshandles link directives and builds the C++ wire shim.- Codegen is explicit; it does not run automatically during normal
cargo build.
Update Dawn API Snapshot
Use the helper script to fetch the latest Dawn release and regenerate bindings:
Optional:
--forceto regenerate even ifDAWN_VERSIONis already latest.DAWN_TAGSenv var to override generator tags (default:dawn,native).
Upstream References
- Dawn API schema: dawn.json
- Generator notes: docs/dawn/codegen.md
- C++ wrapper template: generator/templates/api_cpp.h
License
BSD 3-Clause "New" or "Revised" License. See LICENSE.