Native WebGPU implementation for Bun runtime
npm install bun-webgpuWebGPU (Dawn) FFI bindings for Bun.
``ts
import { setupGlobals } from 'bun-webgpu';
setupGlobals();
const adapter = navigator.gpu.requestAdapter();
const device = await adapter?.requestDevice();
// ... use WebGPU ...
`
Find out more about WebGPU types here.
_Note:_ There are prebuilt binaries in the pipeline artifacts.
* Bun: Ensure you have BunJS installed. (https://bun.sh)
* Zig: The native components of this library are written in Zig. Ensure Zig is installed and available in your PATH. (https://ziglang.org/learn/getting-started/)
* Pre-built Dawn Libraries: This project relies on pre-built Dawn libraries.
* See packages/bun-webgpu/dawn/README.md for details on how to download the required Dawn shared libraries.
* Basically just run bun run ./dawn/download_artifacts.ts
The package.json includes scripts to build the native library components.
* build:devbuild:prod
*
To run the CTS, build the library first, then run the tests:
`bash`
./run-cts.sh 'webgpu:api,operation,adapter,requestDevice:always_returns_device:*'
Run all webgpu tests for example with ./run-cts.sh 'webgpu:*'
Current results for webgpu:api,* are:``
Summary
Passed w/o warnings = 39994 / 51160 = 78.17%
Passed with warnings = 0 / 51160 = 0.00%
Skipped = 8290 / 51160 = 16.20%
Failed = 2876 / 51160 = 5.62%
To run tests, build the library first, then run the tests:
`bash``
bun test