gfx-rs/wgpu
deno_webgpu
deno_webgpu (deno_webgpu/) is the WebGPU bindings for the Deno JavaScript runtime. It's vendored into the wgpu repository so changes to wgpu-core and to Deno's WebGPU surface stay in lockstep.
Purpose
- Implement the WebGPU JavaScript API (
navigator.gpu,GPUDevice,GPUBuffer, ...) on top ofwgpu-core. - Provide the runtime surface that Deno's CTS pipeline drives.
- Stay close enough to the WebGPU IDL that browsers and Deno agree on what each method does.
Directory layout
deno_webgpu/
├── Cargo.toml
├── LICENSE.md
├── README.md
├── 00_init.js Deno bootstrap glue
├── 01_webgpu.js ~23 KB — WebGPU JS surface
├── 02_surface.js ~1 KB — surface-related glue
├── adapter.rs ~15 KB
├── bind_group.rs / bind_group_layout.rs
├── buffer.rs
├── byow.rs "bring your own window" surface support (~10 KB)
├── command_buffer.rs / command_encoder.rs
├── compute_pass.rs / compute_pipeline.rs
├── device.rs ~30 KB
├── error.rs
├── lib.rs
├── pipeline_layout.rs
├── query_set.rs
├── queue.rs
├── render_bundle.rs / render_pass.rs / render_pipeline.rs
├── sampler.rs
├── shader.rs
├── surface.rs
├── texture.rs ~21 KB
└── webidl.rs WebIDL conversionsThe split mirrors wgpu-core's layout: every WebGPU object gets its own .rs file plus the IDL/*.js glue.
How it works
graph LR
UserJS[Deno user JS] -->|navigator.gpu| WGJS[01_webgpu.js]
WGJS -->|deno_core ops| Bridge[deno_webgpu Rust]
Bridge -->|Id-based calls| Core[wgpu-core::Global]
Core --> Hal[wgpu-hal]
Hal --> Driver[Vulkan/Metal/DX12/GL]The JS glue translates ECMAScript objects to op calls; the Rust glue calls into wgpu-core::Global using its FFI-shaped API. Errors flow back through Deno's JsError machinery.
Notable bits
byow.rs— "bring your own window" lets a user pass a window handle from outside Deno (for example, when embedding Deno in a Rust application that owns the window). Surface this through02_surface.js.webidl.rs— WebIDL-style coercions: numeric clamping, dictionary defaulting, sequence handling. Mirrors the WebGPU IDL.error.rs— central place where wgpu-core errors map to JS errors. Important for getting CTS error-paths right.
Integration points
- Above:
cts_runner(in this repo) and the standalone Deno binary downstream. - Below:
wgpu-core, plusdeno_core,deno_features,deno_console,deno_url,deno_web,deno_webidl. Versions are pinned in the rootCargo.toml.
When to edit
- A WebGPU IDL change — usually requires updates here, in
wgpu-core, and in01_webgpu.js. - A bug fix that only manifests through Deno (Deno-only path) — keep in mind
AGENTS.md's rule: only fix Deno bindings if the issue is Deno-specific. If it would also apply to Firefox or thewgpuRust API, fix it inwgpu-coreinstead.
Tests
Deno bindings are exercised primarily through the WebGPU CTS via cts_runner (see cts_runner).
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.