dawn-rs 0.1.3-dev

Rust wrapper for the Dawn API
Documentation

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.h
    • lib/libwebgpu_dawn.a (or platform equivalent)
  • DAWN_ROOT points to the Dawn artifacts directory.

Generate Bindings

Inputs

  • DAWN_JSON points to dawn.json from Dawn source.
  • --api-header points to include/webgpu/webgpu.h from 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.rs is split per OS/arch under src/generated/ffi/, with src/generated/ffi.rs selecting the active target.
  • Generated wrappers (objects/structs/functions/extensions/constants/callbacks/enums) are emitted as single-file targets under src/generated/targets/, with src/generated/mod.rs selecting by OS/arch.
  • build.rs only emits link directives; codegen is run explicitly.

Examples

DAWN_ROOT=/path/to/dawn cargo run --example adapter_info

Upstream References

License

BSD 3-Clause "New" or "Revised" License. See LICENSE.