Idiomatic Zig bindings for https://github.com/gfx-rs/wgpu-native
- Zig 99.8%
- C 0.2%
| examples/sort | v27.0.4.0 -> v29.0.1.1 | |
| src | v27.0.4.0 -> v29.0.1.1 | |
| .gitignore | move from building locally to fetching compiled distributions | |
| build.zig | drop emsdk dependency for emscripten target | |
| build.zig.zon | v27.0.4.0 -> v29.0.1.1 | |
| README.md | Add README | |
wgpu
Idiomatic Zig bindings for wgpu-native, exposing WebGPU for native applications and the web.
The package translates the upstream C API at build time, wraps resource lifetime and descriptors in Zig types, and links wgpu-native on desktop or Dawn's Emscripten WebGPU package for the web.
Install
zig fetch --save git+https://codeberg.org/shahwali/wgpu-zig.git
Targets: macOS, Windows, Linux, and Emscripten (WebGPU). Requires Zig 0.16.0 or newer.
constwgpu=@import("wgpu");constinstance=trywgpu.Instance.init(null);deferinstance.deinit();constadapter=tryinstance.requestAdapterSync(.{});deferadapter.deinit();constdevice=tryadapter.requestDeviceSync(.{});deferdevice.deinit();constqueue=trydevice.getQueue();deferqueue.deinit();Examples
See examples/sort for a complete GPU compute example.
It is also used in knots as an alternative to the Vulkan backend.