@simulatte/webgpu 0.2.3 → 0.3.0
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/CHANGELOG.md +47 -4
- package/README.md +273 -235
- package/api-contract.md +163 -0
- package/assets/fawn-icon-main-256.png +0 -0
- package/assets/package-layers.svg +63 -0
- package/assets/package-surface-cube-snapshot.svg +7 -7
- package/{COMPAT_SCOPE.md → compat-scope.md} +1 -1
- package/examples/direct-webgpu/compute-dispatch.js +66 -0
- package/examples/direct-webgpu/explicit-bind-group.js +85 -0
- package/examples/direct-webgpu/request-device.js +10 -0
- package/examples/doe-api/buffers-readback.js +9 -0
- package/examples/doe-api/compile-and-dispatch.js +30 -0
- package/examples/doe-api/compute-dispatch.js +25 -0
- package/examples/doe-routines/compute-once-like-input.js +36 -0
- package/examples/doe-routines/compute-once-matmul.js +53 -0
- package/examples/doe-routines/compute-once-multiple-inputs.js +27 -0
- package/examples/doe-routines/compute-once.js +23 -0
- package/headless-webgpu-comparison.md +2 -2
- package/{LAYERING_PLAN.md → layering-plan.md} +10 -8
- package/native/doe_napi.c +102 -12
- package/package.json +26 -9
- package/prebuilds/darwin-arm64/doe_napi.node +0 -0
- package/prebuilds/darwin-arm64/libwebgpu_doe.dylib +0 -0
- package/prebuilds/darwin-arm64/metadata.json +6 -6
- package/prebuilds/linux-x64/doe_napi.node +0 -0
- package/prebuilds/linux-x64/libwebgpu_doe.so +0 -0
- package/prebuilds/linux-x64/metadata.json +5 -5
- package/scripts/generate-readme-assets.js +81 -8
- package/scripts/prebuild.js +23 -19
- package/src/auto_bind_group_layout.js +32 -0
- package/src/bun-ffi.js +93 -12
- package/src/bun.js +23 -2
- package/src/compute.d.ts +162 -0
- package/src/compute.js +915 -0
- package/src/doe.d.ts +184 -0
- package/src/doe.js +641 -0
- package/src/full.d.ts +119 -0
- package/src/full.js +35 -0
- package/src/index.js +1013 -38
- package/src/node-runtime.js +2 -2
- package/src/node.js +2 -2
- package/{SUPPORT_CONTRACTS.md → support-contracts.md} +27 -41
- package/{ZIG_SOURCE_INVENTORY.md → zig-source-inventory.md} +2 -2
- package/API_CONTRACT.md +0 -182
package/src/node-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
1
|
+
export * from "./full.js";
|
|
2
|
+
export { default } from "./full.js";
|
package/src/node.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
1
|
+
export * from "./full.js";
|
|
2
|
+
export { default } from "./full.js";
|
|
@@ -12,8 +12,8 @@ Scope:
|
|
|
12
12
|
|
|
13
13
|
This document defines three explicit layers:
|
|
14
14
|
|
|
15
|
-
1. `core`
|
|
16
|
-
- compute-first headless WebGPU
|
|
15
|
+
1. `compute` (`core` runtime boundary)
|
|
16
|
+
- compute-first headless WebGPU for AI workloads and other buffer/dispatch-heavy tasks
|
|
17
17
|
- minimal releaseable package/runtime surface
|
|
18
18
|
- explicit unsupported for sampled/render/browser gaps
|
|
19
19
|
2. `full`
|
|
@@ -30,7 +30,7 @@ depends on the full runtime artifact plus browser-specific gates; it must not
|
|
|
30
30
|
depend on npm packaging shape.
|
|
31
31
|
|
|
32
32
|
Boundary-enforcement and refactor-order details are defined in
|
|
33
|
-
`
|
|
33
|
+
[`./layering-plan.md`](./layering-plan.md).
|
|
34
34
|
|
|
35
35
|
## Dependency contract
|
|
36
36
|
|
|
@@ -62,7 +62,7 @@ Implementation intent:
|
|
|
62
62
|
|
|
63
63
|
Three surfaces are implied by this split:
|
|
64
64
|
|
|
65
|
-
1. `
|
|
65
|
+
1. `compute`
|
|
66
66
|
- headless compute-first package/runtime
|
|
67
67
|
2. `full`
|
|
68
68
|
- headless full WebGPU package/runtime
|
|
@@ -100,11 +100,11 @@ Browser-owned semantics remain outside both `core` and `full`.
|
|
|
100
100
|
| Fallback policy / denylist / kill switch | `out_of_scope` | `out_of_scope` | `required` |
|
|
101
101
|
| Chromium process behavior | `out_of_scope` | `out_of_scope` | `required` |
|
|
102
102
|
|
|
103
|
-
##
|
|
103
|
+
## Compute support contract (`core` runtime, `@simulatte/webgpu/compute` export)
|
|
104
104
|
|
|
105
105
|
### Target user
|
|
106
106
|
|
|
107
|
-
-
|
|
107
|
+
- AI workloads
|
|
108
108
|
- simulation
|
|
109
109
|
- data processing
|
|
110
110
|
- CI and benchmark orchestration
|
|
@@ -112,59 +112,44 @@ Browser-owned semantics remain outside both `core` and `full`.
|
|
|
112
112
|
|
|
113
113
|
### Promise
|
|
114
114
|
|
|
115
|
-
`
|
|
115
|
+
`compute` promises a stable compute-first headless WebGPU surface sized for AI
|
|
116
|
+
workloads and other buffer/dispatch-heavy headless execution, with explicit
|
|
116
117
|
unsupported behavior for sampled-texture, render, and browser-owned semantics.
|
|
117
118
|
|
|
118
119
|
### Included object model
|
|
119
120
|
|
|
120
|
-
`
|
|
121
|
+
`compute` includes:
|
|
121
122
|
|
|
122
123
|
- `GPU`, `GPUAdapter`, `GPUDevice`, `GPUQueue`
|
|
123
124
|
- `GPUBuffer`
|
|
124
125
|
- `GPUShaderModule` for compute WGSL
|
|
125
126
|
- `GPUBindGroupLayout`, `GPUBindGroup`, `GPUPipelineLayout`
|
|
126
127
|
- `GPUComputePipeline`
|
|
128
|
+
- `createComputePipelineAsync`
|
|
127
129
|
- `GPUCommandEncoder` for copy, upload, clear, barrier, and compute encoding
|
|
128
130
|
- `GPUComputePassEncoder`
|
|
129
131
|
- `dispatchWorkgroups`
|
|
130
132
|
- `dispatchWorkgroupsIndirect`
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
`
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- `
|
|
139
|
-
- `COPY_DST`
|
|
140
|
-
- `TEXTURE_BINDING`
|
|
141
|
-
- `STORAGE_BINDING`
|
|
142
|
-
|
|
143
|
-
Excluded from `core`:
|
|
144
|
-
|
|
145
|
-
- `GPUSampler`
|
|
146
|
-
- sampled-texture semantics
|
|
147
|
-
- render-attachment semantics
|
|
148
|
-
- browser presentation semantics
|
|
149
|
-
|
|
150
|
-
Best rule:
|
|
151
|
-
|
|
152
|
-
- `core` gets samplerless compute textures only
|
|
153
|
-
- `full` gets sampled textures and render semantics
|
|
133
|
+
- queue `writeBuffer`
|
|
134
|
+
- buffer readback via `MAP_READ` + `copyBufferToBuffer`
|
|
135
|
+
- Node/Bun bootstrap globals required for headless execution:
|
|
136
|
+
- `navigator.gpu`
|
|
137
|
+
- `GPUBufferUsage`
|
|
138
|
+
- `GPUShaderStage`
|
|
139
|
+
- `GPUMapMode`
|
|
140
|
+
- `GPUTextureUsage`
|
|
154
141
|
|
|
155
142
|
### WGSL contract
|
|
156
143
|
|
|
157
|
-
WGSL required in `
|
|
144
|
+
WGSL required in `compute`:
|
|
158
145
|
|
|
159
146
|
- storage buffers
|
|
160
147
|
- uniform buffers
|
|
161
148
|
- workgroup buffers
|
|
162
149
|
- atomics
|
|
163
150
|
- barriers
|
|
164
|
-
- `textureLoad`
|
|
165
|
-
- `textureStore`
|
|
166
151
|
|
|
167
|
-
WGSL out of scope for `
|
|
152
|
+
WGSL out of scope for `compute`:
|
|
168
153
|
|
|
169
154
|
- sampler declarations and binding semantics
|
|
170
155
|
- `textureSample*`
|
|
@@ -174,9 +159,10 @@ WGSL out of scope for `core`:
|
|
|
174
159
|
|
|
175
160
|
### Explicit exclusions
|
|
176
161
|
|
|
177
|
-
`
|
|
162
|
+
`compute` does not own:
|
|
178
163
|
|
|
179
164
|
- `GPUSampler`
|
|
165
|
+
- sampled textures
|
|
180
166
|
- `GPURenderPipeline`
|
|
181
167
|
- `GPURenderPassEncoder`
|
|
182
168
|
- `GPURenderBundleEncoder`
|
|
@@ -191,7 +177,7 @@ WGSL out of scope for `core`:
|
|
|
191
177
|
|
|
192
178
|
### Release gates for `core`
|
|
193
179
|
|
|
194
|
-
`
|
|
180
|
+
`compute` acceptance requires:
|
|
195
181
|
|
|
196
182
|
1. schema, correctness, and trace gates green
|
|
197
183
|
2. package contract tests green for Node and declared Bun surface
|
|
@@ -199,9 +185,9 @@ WGSL out of scope for `core`:
|
|
|
199
185
|
- adapter/device acquisition
|
|
200
186
|
- buffers
|
|
201
187
|
- copy/upload
|
|
188
|
+
- readback
|
|
202
189
|
- compute pipeline
|
|
203
190
|
- compute dispatch
|
|
204
|
-
- compute-visible texture load/store paths
|
|
205
191
|
4. benchmark cube evidence limited to:
|
|
206
192
|
- upload
|
|
207
193
|
- compute e2e
|
|
@@ -209,7 +195,7 @@ WGSL out of scope for `core`:
|
|
|
209
195
|
5. explicit unsupported taxonomy for any sampler, sampled-texture, render,
|
|
210
196
|
surface, or browser API request outside the `core` contract
|
|
211
197
|
|
|
212
|
-
### Non-goals for `
|
|
198
|
+
### Non-goals for `compute`
|
|
213
199
|
|
|
214
200
|
1. full WebGPU JS object-model parity
|
|
215
201
|
2. sampled-texture semantics
|
|
@@ -229,8 +215,8 @@ WGSL out of scope for `core`:
|
|
|
229
215
|
### Promise
|
|
230
216
|
|
|
231
217
|
`full` promises a full headless WebGPU surface. It is a strict superset of
|
|
232
|
-
`
|
|
233
|
-
or Chromium wire/drop-in readiness by itself.
|
|
218
|
+
`compute`, but it still does not claim browser-process ownership, DOM
|
|
219
|
+
integration, or Chromium wire/drop-in readiness by itself.
|
|
234
220
|
|
|
235
221
|
### Added object model
|
|
236
222
|
|
package/API_CONTRACT.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# @simulatte/webgpu API Contract
|
|
2
|
-
|
|
3
|
-
Contract version: `v1`
|
|
4
|
-
|
|
5
|
-
Scope: current single-surface headless WebGPU package contract for Node.js and
|
|
6
|
-
Bun, plus Doe runtime helpers used by benchmarking, CI, and artifact-backed
|
|
7
|
-
comparison workflows.
|
|
8
|
-
|
|
9
|
-
This is the current single-surface package contract.
|
|
10
|
-
For the proposed future layered `core` vs `full` support split, see
|
|
11
|
-
`SUPPORT_CONTRACTS.md`.
|
|
12
|
-
|
|
13
|
-
This contract covers package-surface GPU access, provider metadata, and helper
|
|
14
|
-
entrypoints. It does not promise DOM/canvas ownership or browser-process
|
|
15
|
-
parity.
|
|
16
|
-
|
|
17
|
-
## Node runtime API
|
|
18
|
-
|
|
19
|
-
Module: `@simulatte/webgpu` (Node default export target)
|
|
20
|
-
|
|
21
|
-
### `create(createArgs?)`
|
|
22
|
-
|
|
23
|
-
Input:
|
|
24
|
-
|
|
25
|
-
- `createArgs?: string[]` (currently ignored by the default Doe-native provider)
|
|
26
|
-
|
|
27
|
-
Behavior:
|
|
28
|
-
|
|
29
|
-
- loads the Doe-native N-API addon and `libwebgpu_doe`
|
|
30
|
-
- returns a GPU object backed by the in-tree Doe provider
|
|
31
|
-
|
|
32
|
-
Output:
|
|
33
|
-
|
|
34
|
-
- `GPU` object with `requestAdapter(...)`
|
|
35
|
-
|
|
36
|
-
### `globals`
|
|
37
|
-
|
|
38
|
-
Output:
|
|
39
|
-
|
|
40
|
-
- provider globals object suitable for `Object.assign(globalThis, globals)`
|
|
41
|
-
|
|
42
|
-
### `setupGlobals(target?, createArgs?)`
|
|
43
|
-
|
|
44
|
-
Input:
|
|
45
|
-
|
|
46
|
-
- `target?: object` (default: `globalThis`)
|
|
47
|
-
- `createArgs?: string[]`
|
|
48
|
-
|
|
49
|
-
Behavior:
|
|
50
|
-
|
|
51
|
-
- installs provider globals if missing
|
|
52
|
-
- installs `navigator.gpu` if missing
|
|
53
|
-
|
|
54
|
-
Output:
|
|
55
|
-
|
|
56
|
-
- `GPU` object
|
|
57
|
-
|
|
58
|
-
### `requestAdapter(adapterOptions?, createArgs?)`
|
|
59
|
-
|
|
60
|
-
Output:
|
|
61
|
-
|
|
62
|
-
- `Promise<GPUAdapter | null>`
|
|
63
|
-
|
|
64
|
-
### `requestDevice(options?)`
|
|
65
|
-
|
|
66
|
-
Input:
|
|
67
|
-
|
|
68
|
-
- `options.adapterOptions?: object`
|
|
69
|
-
- `options.deviceDescriptor?: object`
|
|
70
|
-
- `options.createArgs?: string[]`
|
|
71
|
-
|
|
72
|
-
Output:
|
|
73
|
-
|
|
74
|
-
- `Promise<GPUDevice>`
|
|
75
|
-
|
|
76
|
-
### `providerInfo()`
|
|
77
|
-
|
|
78
|
-
Output object:
|
|
79
|
-
|
|
80
|
-
- `module: string`
|
|
81
|
-
- `loaded: boolean`
|
|
82
|
-
- `loadError: string`
|
|
83
|
-
- `defaultCreateArgs: string[]`
|
|
84
|
-
- `doeNative: boolean`
|
|
85
|
-
- `libraryFlavor: string`
|
|
86
|
-
- `doeLibraryPath: string`
|
|
87
|
-
- `buildMetadataSource: string`
|
|
88
|
-
- `buildMetadataPath: string`
|
|
89
|
-
- `leanVerifiedBuild: boolean | null`
|
|
90
|
-
- `proofArtifactSha256: string | null`
|
|
91
|
-
|
|
92
|
-
Behavior:
|
|
93
|
-
|
|
94
|
-
- reports package-surface library provenance when prebuild metadata or Zig build
|
|
95
|
-
metadata is available
|
|
96
|
-
- does not guess: if metadata is unavailable, `leanVerifiedBuild` is `null`
|
|
97
|
-
|
|
98
|
-
### `createDoeRuntime(options?)`
|
|
99
|
-
|
|
100
|
-
Input:
|
|
101
|
-
|
|
102
|
-
- `options.binPath?: string`
|
|
103
|
-
- `options.libPath?: string`
|
|
104
|
-
|
|
105
|
-
Output object:
|
|
106
|
-
|
|
107
|
-
- `binPath: string`
|
|
108
|
-
- `libPath: string | null`
|
|
109
|
-
- `runRaw(args: string[], spawnOptions?): RunResult`
|
|
110
|
-
- `runBench(options: BenchOptions): BenchResult`
|
|
111
|
-
|
|
112
|
-
`BenchOptions`:
|
|
113
|
-
|
|
114
|
-
- `commandsPath: string` (required)
|
|
115
|
-
- `quirksPath?: string`
|
|
116
|
-
- `vendor?: string`
|
|
117
|
-
- `api?: string`
|
|
118
|
-
- `family?: string`
|
|
119
|
-
- `driver?: string`
|
|
120
|
-
- `traceJsonlPath?: string`
|
|
121
|
-
- `traceMetaPath?: string`
|
|
122
|
-
- `uploadBufferUsage?: string`
|
|
123
|
-
- `uploadSubmitEvery?: number`
|
|
124
|
-
- `queueWaitMode?: string`
|
|
125
|
-
- `queueSyncMode?: string`
|
|
126
|
-
- `extraArgs?: string[]`
|
|
127
|
-
|
|
128
|
-
`RunResult`:
|
|
129
|
-
|
|
130
|
-
- `ok: boolean`
|
|
131
|
-
- `exitCode: number`
|
|
132
|
-
- `stdout: string`
|
|
133
|
-
- `stderr: string`
|
|
134
|
-
- `signal: string | null`
|
|
135
|
-
- `command: string[]`
|
|
136
|
-
|
|
137
|
-
`BenchResult` extends `RunResult` with:
|
|
138
|
-
|
|
139
|
-
- `traceJsonlPath: string | null`
|
|
140
|
-
- `traceMetaPath: string | null`
|
|
141
|
-
- `traceMeta: object | null`
|
|
142
|
-
|
|
143
|
-
### `runDawnVsDoeCompare(options)`
|
|
144
|
-
|
|
145
|
-
Input:
|
|
146
|
-
|
|
147
|
-
- `repoRoot?: string`
|
|
148
|
-
- `compareScriptPath?: string`
|
|
149
|
-
- `pythonBin?: string`
|
|
150
|
-
- `configPath?: string`
|
|
151
|
-
- `outPath?: string`
|
|
152
|
-
- `extraArgs?: string[]`
|
|
153
|
-
- `env?: Record<string, string>`
|
|
154
|
-
|
|
155
|
-
Behavior:
|
|
156
|
-
|
|
157
|
-
- wraps `bench/compare_dawn_vs_doe.py`
|
|
158
|
-
- requires either `configPath` or `--config` in `extraArgs`
|
|
159
|
-
|
|
160
|
-
Output:
|
|
161
|
-
|
|
162
|
-
- `RunResult`
|
|
163
|
-
|
|
164
|
-
## CLI contract
|
|
165
|
-
|
|
166
|
-
### `fawn-webgpu-bench`
|
|
167
|
-
|
|
168
|
-
Purpose:
|
|
169
|
-
|
|
170
|
-
- execute Doe command-stream benchmark runs and emit trace artifacts.
|
|
171
|
-
|
|
172
|
-
### `fawn-webgpu-compare`
|
|
173
|
-
|
|
174
|
-
Purpose:
|
|
175
|
-
|
|
176
|
-
- one-command Dawn-vs-Doe compare wrapper from Node tooling.
|
|
177
|
-
|
|
178
|
-
## Non-goals in v1
|
|
179
|
-
|
|
180
|
-
1. Full browser-parity WebGPU JS object model emulation.
|
|
181
|
-
2. Browser presentation parity.
|
|
182
|
-
3. npm `webgpu` drop-in compatibility guarantee.
|