@simulatte/webgpu-doe 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -178
- package/package.json +6 -43
- package/binding.gyp +0 -20
- package/native/doe_napi.c +0 -1677
- package/prebuilds/darwin-arm64/doe_napi.node +0 -0
- package/prebuilds/darwin-arm64/libdoe_webgpu.dylib +0 -0
- package/src/index.js +0 -495
package/README.md
CHANGED
|
@@ -1,186 +1,17 @@
|
|
|
1
1
|
# @simulatte/webgpu-doe
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[Doe](https://github.com/clocksmith/fawn) runtime.
|
|
3
|
+
This package is deprecated.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Use [`@simulatte/webgpu`](https://www.npmjs.com/package/@simulatte/webgpu) instead.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
shader compiler and dispatches directly to Metal via a Zig + ObjC bridge.
|
|
7
|
+
- Replacement package: [`@simulatte/webgpu`](https://www.npmjs.com/package/@simulatte/webgpu)
|
|
8
|
+
- Package page: [`@simulatte/webgpu` on npm](https://www.npmjs.com/package/@simulatte/webgpu)
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
## Migration
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Architecture
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
JavaScript (DoeGPUDevice, DoeGPUBuffer, ...)
|
|
22
|
-
|
|
|
23
|
-
N-API addon (doe_napi.c)
|
|
24
|
-
|
|
|
25
|
-
libdoe_webgpu.dylib ← Doe native Metal backend, ~2 MB
|
|
26
|
-
|
|
|
27
|
-
Metal.framework ← GPU execution (Apple Silicon)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
No Dawn dependency. All GPU calls go directly from Zig to Metal.
|
|
31
|
-
|
|
32
|
-
## Performance claims (Metal, Apple Silicon)
|
|
33
|
-
|
|
34
|
-
Apples-to-apples vs Dawn (Chromium's WebGPU), matched workloads and timing:
|
|
35
|
-
|
|
36
|
-
- **Compute e2e** — 1.5x faster (0.23ms vs 0.35ms, 4096 threads)
|
|
37
|
-
- **Buffer upload** — faster across 1 KB to 4 GB (8 sizes claimable)
|
|
38
|
-
- **Atomics** — workgroup atomic and non-atomic both claimable
|
|
39
|
-
- **Matrix-vector multiply** — 3 variants claimable (naive, swizzle, workgroup-shared)
|
|
40
|
-
- **Concurrent execution** — claimable
|
|
41
|
-
- **Zero-init workgroup memory** — claimable
|
|
42
|
-
- **Draw throughput** — 200k draws claimable
|
|
43
|
-
- **Binary size** — ~2 MB vs Dawn's ~11 MB
|
|
44
|
-
|
|
45
|
-
19 of 30 workloads are claimable. The remaining 11 are bottlenecked by
|
|
46
|
-
per-command Metal command buffer creation overhead (~350us vs Dawn's ~30us).
|
|
47
|
-
See `fawn/bench/` for methodology and raw data.
|
|
48
|
-
|
|
49
|
-
## API surface
|
|
50
|
-
|
|
51
|
-
Compute:
|
|
52
|
-
|
|
53
|
-
- `create()` / `setupGlobals()` / `requestAdapter()` / `requestDevice()`
|
|
54
|
-
- `device.createBuffer()` / `device.createShaderModule()` (WGSL)
|
|
55
|
-
- `device.createComputePipeline()` / `device.createBindGroupLayout()`
|
|
56
|
-
- `device.createBindGroup()` / `device.createPipelineLayout()`
|
|
57
|
-
- `device.createCommandEncoder()` / `encoder.beginComputePass()`
|
|
58
|
-
- `pass.setPipeline()` / `pass.setBindGroup()` / `pass.dispatchWorkgroups()`
|
|
59
|
-
- `pass.dispatchWorkgroupsIndirect()`
|
|
60
|
-
- `pipeline.getBindGroupLayout()`
|
|
61
|
-
- `device.createComputePipelineAsync()`
|
|
62
|
-
- `encoder.copyBufferToBuffer()` / `queue.submit()` / `queue.writeBuffer()`
|
|
63
|
-
- `buffer.mapAsync()` / `buffer.getMappedRange()` / `buffer.unmap()`
|
|
64
|
-
- `queue.onSubmittedWorkDone()`
|
|
65
|
-
|
|
66
|
-
Render:
|
|
67
|
-
|
|
68
|
-
- `device.createTexture()` / `texture.createView()` / `device.createSampler()`
|
|
69
|
-
- `device.createRenderPipeline()` / `encoder.beginRenderPass()`
|
|
70
|
-
- `renderPass.setPipeline()` / `renderPass.draw()` / `renderPass.end()`
|
|
71
|
-
|
|
72
|
-
Device capabilities:
|
|
73
|
-
|
|
74
|
-
- `device.limits` / `adapter.limits` — full Metal device limits
|
|
75
|
-
- `device.features` / `adapter.features` — reports `shader-f16`
|
|
76
|
-
|
|
77
|
-
Not yet supported: canvas/surface presentation, vertex/index buffer binding
|
|
78
|
-
in render passes, full render pipeline descriptor parsing.
|
|
79
|
-
|
|
80
|
-
## Backend readiness
|
|
81
|
-
|
|
82
|
-
| Backend | Compute | Render | WGSL compiler | Status |
|
|
83
|
-
|---------|---------|--------|---------------|--------|
|
|
84
|
-
| **Metal** (macOS) | Production | Basic (no vertex/index) | WGSL -> MSL (AST-based) | Ready |
|
|
85
|
-
| **Vulkan** (Linux) | WIP | Not started | WGSL -> SPIR-V needed | Experimental |
|
|
86
|
-
| **D3D12** (Windows) | WIP | Not started | WGSL -> HLSL/DXIL needed | Experimental |
|
|
87
|
-
|
|
88
|
-
**Metal** is the primary backend. All Doppler compute workloads run on Metal today:
|
|
89
|
-
bind groups 0-3, buffer map/unmap, indirect dispatch, shader-f16, subgroups,
|
|
90
|
-
override constants, workgroup shared memory, multiple entry points.
|
|
91
|
-
|
|
92
|
-
**Vulkan** and **D3D12** have real native runtime paths (not stubs) with instance
|
|
93
|
-
creation, compute dispatch, and buffer upload — but lack shader translation,
|
|
94
|
-
bind group management, buffer map/unmap, textures, and render pipelines.
|
|
95
|
-
|
|
96
|
-
See [`fawn/status.md`](../../status.md) for the full backend implementation matrix.
|
|
97
|
-
|
|
98
|
-
## Platform support
|
|
99
|
-
|
|
100
|
-
| Platform | Architecture | Status |
|
|
101
|
-
|----------|-------------|--------|
|
|
102
|
-
| macOS | arm64 | Prebuilt, tested |
|
|
103
|
-
| macOS | x64 | Not yet built |
|
|
104
|
-
| Linux | x64 | Not yet built (Vulkan backend experimental) |
|
|
105
|
-
| Windows | x64 | Not yet built (D3D12 backend experimental) |
|
|
106
|
-
|
|
107
|
-
## Install
|
|
108
|
-
|
|
109
|
-
```sh
|
|
110
|
-
npm install @simulatte/webgpu-doe
|
|
12
|
+
```bash
|
|
13
|
+
npm uninstall @simulatte/webgpu-doe
|
|
14
|
+
npm install @simulatte/webgpu
|
|
111
15
|
```
|
|
112
16
|
|
|
113
|
-
|
|
114
|
-
a C compiler (`xcode-select --install` on macOS).
|
|
115
|
-
|
|
116
|
-
## Usage
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
import { create, globals } from '@simulatte/webgpu-doe';
|
|
120
|
-
|
|
121
|
-
const gpu = create();
|
|
122
|
-
const adapter = await gpu.requestAdapter();
|
|
123
|
-
const device = await adapter.requestDevice();
|
|
124
|
-
|
|
125
|
-
console.log(device.limits.maxComputeWorkgroupSizeX); // 1024
|
|
126
|
-
console.log(device.features.has('shader-f16')); // true
|
|
127
|
-
|
|
128
|
-
// Standard WebGPU compute workflow
|
|
129
|
-
const buffer = device.createBuffer({
|
|
130
|
-
size: 64,
|
|
131
|
-
usage: globals.GPUBufferUsage.STORAGE | globals.GPUBufferUsage.COPY_SRC,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const shader = device.createShaderModule({
|
|
135
|
-
code: `
|
|
136
|
-
@group(0) @binding(0) var<storage, read_write> data: array<f32>;
|
|
137
|
-
@compute @workgroup_size(64)
|
|
138
|
-
fn main(@builtin(global_invocation_id) id: vec3u) {
|
|
139
|
-
data[id.x] = data[id.x] * 2.0;
|
|
140
|
-
}
|
|
141
|
-
`,
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// ... create pipeline, bind group, encode, dispatch, readback
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Setup globals (navigator.gpu)
|
|
148
|
-
|
|
149
|
-
```js
|
|
150
|
-
import { setupGlobals } from '@simulatte/webgpu-doe';
|
|
151
|
-
|
|
152
|
-
setupGlobals(globalThis);
|
|
153
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Provider info
|
|
157
|
-
|
|
158
|
-
```js
|
|
159
|
-
import { providerInfo } from '@simulatte/webgpu-doe';
|
|
160
|
-
console.log(providerInfo());
|
|
161
|
-
// { module: '@simulatte/webgpu-doe', loaded: true, doeNative: true, ... }
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Configuration
|
|
165
|
-
|
|
166
|
-
The library search order:
|
|
167
|
-
|
|
168
|
-
1. `DOE_WEBGPU_LIB` environment variable (full path)
|
|
169
|
-
2. `<package>/prebuilds/<platform>-<arch>/libdoe_webgpu.{ext}`
|
|
170
|
-
3. `<workspace>/zig/zig-out/lib/libdoe_webgpu.{ext}` (monorepo layout)
|
|
171
|
-
4. `<cwd>/zig/zig-out/lib/libdoe_webgpu.{ext}`
|
|
172
|
-
|
|
173
|
-
## Building from source
|
|
174
|
-
|
|
175
|
-
Requires [Zig](https://ziglang.org/download/) (0.15+).
|
|
176
|
-
|
|
177
|
-
```sh
|
|
178
|
-
git clone https://github.com/clocksmith/fawn
|
|
179
|
-
cd fawn/zig
|
|
180
|
-
zig build dropin
|
|
181
|
-
# Output: zig-out/lib/libdoe_webgpu.{dylib,so}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## License
|
|
185
|
-
|
|
186
|
-
ISC
|
|
17
|
+
`@simulatte/webgpu` is the maintained package name going forward.
|
package/package.json
CHANGED
|
@@ -1,46 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simulatte/webgpu-doe",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"./node": "./src/index.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"src/index.js",
|
|
13
|
-
"native/",
|
|
14
|
-
"binding.gyp",
|
|
15
|
-
"prebuilds/",
|
|
16
|
-
"README.md"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build:addon": "node-gyp rebuild"
|
|
20
|
-
},
|
|
21
|
-
"os": [
|
|
22
|
-
"darwin"
|
|
23
|
-
],
|
|
24
|
-
"cpu": [
|
|
25
|
-
"arm64"
|
|
26
|
-
],
|
|
27
|
-
"keywords": [
|
|
28
|
-
"webgpu",
|
|
29
|
-
"doe",
|
|
30
|
-
"gpu",
|
|
31
|
-
"compute",
|
|
32
|
-
"headless",
|
|
33
|
-
"node",
|
|
34
|
-
"native",
|
|
35
|
-
"napi",
|
|
36
|
-
"metal",
|
|
37
|
-
"vulkan",
|
|
38
|
-
"zig"
|
|
39
|
-
],
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "https://github.com/clocksmith/fawn",
|
|
43
|
-
"directory": "nursery/webgpu-doe"
|
|
44
|
-
},
|
|
45
|
-
"license": "ISC"
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Deprecated redirect package. Use @simulatte/webgpu instead.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
}
|
|
46
9
|
}
|
package/binding.gyp
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": [
|
|
3
|
-
{
|
|
4
|
-
"target_name": "doe_napi",
|
|
5
|
-
"sources": ["native/doe_napi.c"],
|
|
6
|
-
"include_dirs": [],
|
|
7
|
-
"conditions": [
|
|
8
|
-
["OS=='mac'", {
|
|
9
|
-
"xcode_settings": {
|
|
10
|
-
"OTHER_CFLAGS": ["-std=c11"],
|
|
11
|
-
"MACOSX_DEPLOYMENT_TARGET": "13.0"
|
|
12
|
-
}
|
|
13
|
-
}],
|
|
14
|
-
["OS=='linux'", {
|
|
15
|
-
"cflags": ["-std=c11"]
|
|
16
|
-
}]
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|