dawn-rs
Rust bindings and thin wrappers for Dawn WebGPU.
Status
Active development. Not approved for production use.
Requirements
- Dawn build or prebuilt release containing:
include/webgpu/webgpu.hlib/libwebgpu_dawn.a(or platform equivalent)
DAWN_ROOTpoints to the Dawn artifacts directory.
Generate Bindings
Inputs
DAWN_JSONpoints todawn.jsonfrom Dawn source.--api-headerpoints toinclude/webgpu/webgpu.hfrom the build/prebuilt artifacts.
Commands
- Windows
cargo run -p dawn-codegen --bin dawn_codegen -- --dawn-json <path_to_dawn_json> --api-header <path_to_webgpu.h> --out-dir src/generated
- macOS
cargo run -p dawn-codegen --bin dawn_codegen -- --dawn-json <path_to_dawn_json> --api-header <path_to_webgpu.h> --out-dir src/generated --clang-arg --sysroot=$(xcrun --show-sdk-path --sdk macosx)
Notes
- Generated
ffi.rsis split per OS/arch undersrc/generated/ffi/, withsrc/generated/ffi.rsselecting the active target. - Generated wrappers (
objects/structs/functions/extensions/constants/callbacks/enums) are emitted as single-file targets undersrc/generated/targets/, withsrc/generated/mod.rsselecting by OS/arch. build.rsonly emits link directives; codegen is run explicitly.
Examples
DAWN_ROOT=/path/to/dawn
Upstream References
- Dawn API schema: dawn.json
- Generator design notes: docs/codegen.md
- C++ wrapper template: generator/templates/api_cpp.h
License
BSD 3-Clause "New" or "Revised" License. See LICENSE.