How gfx-rs/wgpu-native works
wgpu-native is a Rust implementation of the native WebGPU C API, built on wgpu-core. A C application calls the exported API to create an instance, obtain an adapter and device, create resources and encode rendering or compute work, then submit it through a queue. The Rust layer translates C descriptors and values before delegating to wgpu-core. The README establishes the core dependency and header-based bindings; sampled excerpts show API dispatch and conversion helpers, but do not expose the full backend or resource flow.
Main entry points: lib.rs WebGPU entry points · wgpu.h Native API header · conv.rs C/Rust conversion · utils.rs FFI utilities
Components 12
C API
- Native API header
ffi/wgpu.h - WebGPU entry points
src/lib.rs
Rust Runtime
- Instance and device
src/lib.rs - GPU resources
src/lib.rs - Render and compute
src/lib.rs - Queue operations
src/lib.rs - wgpu-core
Runtime Support
- C/Rust conversion
src/conv.rs - FFI utilities
src/utils.rs - Logging callbacks
src/logging.rs - Unimplemented API
src/unimplemented.rs
Other components
- C application
Connections 11
- C application → Native API header: uses contract
README.md - C application → WebGPU entry points: calls
README.md - Native API header → WebGPU entry points: defines bindings
README.md - WebGPU entry points → C/Rust conversion: maps values
src/lib.rs - C/Rust conversion → FFI utilities: uses helpers
src/conv.rs - WebGPU entry points → Instance and device: handles requests
src/lib.rs - WebGPU entry points → GPU resources: handles requests
src/lib.rs - WebGPU entry points → Render and compute: handles requests
src/lib.rs - WebGPU entry points → Queue operations: handles requests
src/lib.rs - WebGPU entry points → wgpu-core: delegates to
- Logging callbacks → FFI utilities: formats callbacks
src/logging.rs