@simulatte/webgpu 0.2.1 → 0.2.4
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 +104 -0
- package/README.md +135 -108
- package/{API_CONTRACT.md → api-contract.md} +63 -3
- package/assets/fawn-icon-main-256.png +0 -0
- package/assets/package-surface-cube-snapshot.svg +14 -14
- package/compat-scope.md +46 -0
- package/headless-webgpu-comparison.md +3 -3
- package/layering-plan.md +259 -0
- package/native/doe_napi.c +110 -17
- package/package.json +28 -8
- package/prebuilds/darwin-arm64/doe_napi.node +0 -0
- package/prebuilds/darwin-arm64/libwebgpu_doe.dylib +0 -0
- package/prebuilds/darwin-arm64/metadata.json +5 -5
- package/prebuilds/linux-x64/doe_napi.node +0 -0
- package/prebuilds/linux-x64/libwebgpu_dawn.so +0 -0
- package/prebuilds/linux-x64/libwebgpu_doe.so +0 -0
- package/prebuilds/linux-x64/metadata.json +26 -0
- package/scripts/generate-readme-assets.js +2 -2
- package/src/bun-ffi.js +3 -2
- package/src/bun.js +2 -2
- package/src/compute.d.ts +161 -0
- package/src/compute.js +277 -0
- package/src/doe.d.ts +84 -0
- package/src/doe.js +275 -0
- package/src/full.d.ts +112 -0
- package/src/full.js +10 -0
- package/src/index.js +114 -15
- package/src/node-runtime.js +2 -2
- package/src/node.js +2 -2
- package/src/runtime_cli.js +3 -1
- package/support-contracts.md +339 -0
- package/zig-source-inventory.md +468 -0
- package/COMPAT_SCOPE.md +0 -32
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Proposed support contracts for core, full, and browser boundary
|
|
2
|
+
|
|
3
|
+
Contract status: `draft`
|
|
4
|
+
|
|
5
|
+
Scope:
|
|
6
|
+
|
|
7
|
+
- proposed future layering for Doe's JS-facing package surfaces
|
|
8
|
+
- headless WebGPU package/runtime contracts only
|
|
9
|
+
- browser-owned Chromium semantics are called out explicitly as outside package
|
|
10
|
+
ownership
|
|
11
|
+
- no runtime behavior changes are enabled by this document
|
|
12
|
+
|
|
13
|
+
This document defines three explicit layers:
|
|
14
|
+
|
|
15
|
+
1. `compute` (`core` runtime boundary)
|
|
16
|
+
- compute-first headless WebGPU for AI workloads and other buffer/dispatch-heavy tasks
|
|
17
|
+
- minimal releaseable package/runtime surface
|
|
18
|
+
- explicit unsupported for sampled/render/browser gaps
|
|
19
|
+
2. `full`
|
|
20
|
+
- full headless WebGPU
|
|
21
|
+
- strict superset of `core`
|
|
22
|
+
- still not a browser-process integration contract
|
|
23
|
+
3. browser / Track A
|
|
24
|
+
- Chromium-only integration seam
|
|
25
|
+
- not package-owned
|
|
26
|
+
- owns DOM/canvas/process/fallback/proc-surface concerns
|
|
27
|
+
|
|
28
|
+
This split is intentionally separate from Chromium Track A. Chromium integration
|
|
29
|
+
depends on the full runtime artifact plus browser-specific gates; it must not
|
|
30
|
+
depend on npm packaging shape.
|
|
31
|
+
|
|
32
|
+
Boundary-enforcement and refactor-order details are defined in
|
|
33
|
+
[`./layering-plan.md`](./layering-plan.md).
|
|
34
|
+
|
|
35
|
+
## Dependency contract
|
|
36
|
+
|
|
37
|
+
The layering rule is one-way:
|
|
38
|
+
|
|
39
|
+
1. `full` may import and extend `core`.
|
|
40
|
+
2. `core` must not import `full`.
|
|
41
|
+
3. browser / Track A may depend on the full runtime artifact and browser-owned
|
|
42
|
+
contracts.
|
|
43
|
+
4. `core` and `full` must not own Track A browser behavior.
|
|
44
|
+
5. `core` must remain releaseable and testable without `full`.
|
|
45
|
+
|
|
46
|
+
Implementation intent:
|
|
47
|
+
|
|
48
|
+
1. Zig:
|
|
49
|
+
- `zig/src/core/**` contains shared runtime, compute, copy/upload, limited
|
|
50
|
+
compute-visible texture handling, trace/replay, and backend-common code
|
|
51
|
+
- `zig/src/full/**` contains sampled textures, render, surface, and broader
|
|
52
|
+
lifecycle/parity layers built on `core`
|
|
53
|
+
2. Lean:
|
|
54
|
+
- `lean/Fawn/Core/**` contains shared invariants
|
|
55
|
+
- `lean/Fawn/Full/**` may import `Core` and add render/lifecycle proofs
|
|
56
|
+
3. Build outputs:
|
|
57
|
+
- `core` and `full` can be emitted as separate artifacts
|
|
58
|
+
- if separate binaries are used, `full` is built from `core` sources; `core`
|
|
59
|
+
must not dynamically depend on a `full` artifact
|
|
60
|
+
|
|
61
|
+
## Product boundary
|
|
62
|
+
|
|
63
|
+
Three surfaces are implied by this split:
|
|
64
|
+
|
|
65
|
+
1. `compute`
|
|
66
|
+
- headless compute-first package/runtime
|
|
67
|
+
2. `full`
|
|
68
|
+
- headless full WebGPU package/runtime
|
|
69
|
+
3. browser / Track A
|
|
70
|
+
- browser integration seam, wire/proc/drop-in parity, fallback policy,
|
|
71
|
+
process topology, and browser-specific gates
|
|
72
|
+
|
|
73
|
+
`full` is the top of the headless stack, not the browser stack.
|
|
74
|
+
Browser-owned semantics remain outside both `core` and `full`.
|
|
75
|
+
|
|
76
|
+
## Ownership matrix
|
|
77
|
+
|
|
78
|
+
| Capability area | `core` | `full` | browser / Track A |
|
|
79
|
+
| --- | --- | --- | --- |
|
|
80
|
+
| `GPU`, `GPUAdapter`, `GPUDevice`, `GPUQueue` | `required` | inherits `core` | not package-owned |
|
|
81
|
+
| `GPUBuffer` | `required` | inherits `core` | not package-owned |
|
|
82
|
+
| `GPUShaderModule` for compute WGSL | `required` | inherits `core` | not package-owned |
|
|
83
|
+
| `GPUBindGroupLayout`, `GPUBindGroup`, `GPUPipelineLayout` | `required` | inherits `core` | not package-owned |
|
|
84
|
+
| `GPUComputePipeline` | `required` | inherits `core` | not package-owned |
|
|
85
|
+
| `GPUCommandEncoder` for copy/upload/clear/barrier/compute | `required` | inherits `core` | not package-owned |
|
|
86
|
+
| `GPUComputePassEncoder` | `required` | inherits `core` | not package-owned |
|
|
87
|
+
| `dispatchWorkgroups`, `dispatchWorkgroupsIndirect` | `required` | inherits `core` | not package-owned |
|
|
88
|
+
| `GPUTexture` / `GPUTextureView` for compute-visible usages only | `required` | inherits and extends | not package-owned |
|
|
89
|
+
| `GPUSampler` | `out_of_scope` | `required` | not package-owned |
|
|
90
|
+
| `GPURenderPipeline` | `out_of_scope` | `required` | not package-owned |
|
|
91
|
+
| `GPURenderPassEncoder` | `out_of_scope` | `required` | not package-owned |
|
|
92
|
+
| `GPURenderBundleEncoder` | `out_of_scope` | `required` | not package-owned |
|
|
93
|
+
| Vertex / index buffers and draw variants | `out_of_scope` | `required` | not package-owned |
|
|
94
|
+
| Blend / depth-stencil / multisample | `out_of_scope` | `required` | not package-owned |
|
|
95
|
+
| Render-attachment textures | `out_of_scope` | `required` | not package-owned |
|
|
96
|
+
| Broader texture / view / format coverage | `limited` | `required` | not package-owned |
|
|
97
|
+
| `GPUCanvasContext` | `out_of_scope` | `out_of_scope` | `required` |
|
|
98
|
+
| DOM / canvas ownership | `out_of_scope` | `out_of_scope` | `required` |
|
|
99
|
+
| Proc-surface parity | `out_of_scope` | `out_of_scope` | `required` |
|
|
100
|
+
| Fallback policy / denylist / kill switch | `out_of_scope` | `out_of_scope` | `required` |
|
|
101
|
+
| Chromium process behavior | `out_of_scope` | `out_of_scope` | `required` |
|
|
102
|
+
|
|
103
|
+
## Compute support contract (`core` runtime, `@simulatte/webgpu/compute` export)
|
|
104
|
+
|
|
105
|
+
### Target user
|
|
106
|
+
|
|
107
|
+
- AI workloads
|
|
108
|
+
- simulation
|
|
109
|
+
- data processing
|
|
110
|
+
- CI and benchmark orchestration
|
|
111
|
+
- deterministic headless command execution
|
|
112
|
+
|
|
113
|
+
### Promise
|
|
114
|
+
|
|
115
|
+
`compute` promises a stable compute-first headless WebGPU surface sized for AI
|
|
116
|
+
workloads and other buffer/dispatch-heavy headless execution, with explicit
|
|
117
|
+
unsupported behavior for sampled-texture, render, and browser-owned semantics.
|
|
118
|
+
|
|
119
|
+
### Included object model
|
|
120
|
+
|
|
121
|
+
`compute` includes:
|
|
122
|
+
|
|
123
|
+
- `GPU`, `GPUAdapter`, `GPUDevice`, `GPUQueue`
|
|
124
|
+
- `GPUBuffer`
|
|
125
|
+
- `GPUShaderModule` for compute WGSL
|
|
126
|
+
- `GPUBindGroupLayout`, `GPUBindGroup`, `GPUPipelineLayout`
|
|
127
|
+
- `GPUComputePipeline`
|
|
128
|
+
- `createComputePipelineAsync`
|
|
129
|
+
- `GPUCommandEncoder` for copy, upload, clear, barrier, and compute encoding
|
|
130
|
+
- `GPUComputePassEncoder`
|
|
131
|
+
- `dispatchWorkgroups`
|
|
132
|
+
- `dispatchWorkgroupsIndirect`
|
|
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`
|
|
141
|
+
|
|
142
|
+
### WGSL contract
|
|
143
|
+
|
|
144
|
+
WGSL required in `compute`:
|
|
145
|
+
|
|
146
|
+
- storage buffers
|
|
147
|
+
- uniform buffers
|
|
148
|
+
- workgroup buffers
|
|
149
|
+
- atomics
|
|
150
|
+
- barriers
|
|
151
|
+
|
|
152
|
+
WGSL out of scope for `compute`:
|
|
153
|
+
|
|
154
|
+
- sampler declarations and binding semantics
|
|
155
|
+
- `textureSample*`
|
|
156
|
+
- vertex stage
|
|
157
|
+
- fragment stage
|
|
158
|
+
- render-attachment behavior
|
|
159
|
+
|
|
160
|
+
### Explicit exclusions
|
|
161
|
+
|
|
162
|
+
`compute` does not own:
|
|
163
|
+
|
|
164
|
+
- `GPUSampler`
|
|
165
|
+
- sampled textures
|
|
166
|
+
- `GPURenderPipeline`
|
|
167
|
+
- `GPURenderPassEncoder`
|
|
168
|
+
- `GPURenderBundleEncoder`
|
|
169
|
+
- vertex/index input state
|
|
170
|
+
- draw/drawIndexed/drawIndirect
|
|
171
|
+
- blend/depth-stencil/multisample
|
|
172
|
+
- render-attachment textures
|
|
173
|
+
- `GPUCanvasContext`
|
|
174
|
+
- DOM/canvas ownership
|
|
175
|
+
- proc-surface parity
|
|
176
|
+
- Chromium fallback/process policy
|
|
177
|
+
|
|
178
|
+
### Release gates for `core`
|
|
179
|
+
|
|
180
|
+
`compute` acceptance requires:
|
|
181
|
+
|
|
182
|
+
1. schema, correctness, and trace gates green
|
|
183
|
+
2. package contract tests green for Node and declared Bun surface
|
|
184
|
+
3. CTS subset coverage for:
|
|
185
|
+
- adapter/device acquisition
|
|
186
|
+
- buffers
|
|
187
|
+
- copy/upload
|
|
188
|
+
- readback
|
|
189
|
+
- compute pipeline
|
|
190
|
+
- compute dispatch
|
|
191
|
+
4. benchmark cube evidence limited to:
|
|
192
|
+
- upload
|
|
193
|
+
- compute e2e
|
|
194
|
+
- dispatch-only
|
|
195
|
+
5. explicit unsupported taxonomy for any sampler, sampled-texture, render,
|
|
196
|
+
surface, or browser API request outside the `core` contract
|
|
197
|
+
|
|
198
|
+
### Non-goals for `compute`
|
|
199
|
+
|
|
200
|
+
1. full WebGPU JS object-model parity
|
|
201
|
+
2. sampled-texture semantics
|
|
202
|
+
3. render pipeline completeness
|
|
203
|
+
4. browser presentation parity
|
|
204
|
+
5. Chromium drop-in readiness by itself
|
|
205
|
+
|
|
206
|
+
## Full support contract
|
|
207
|
+
|
|
208
|
+
### Target user
|
|
209
|
+
|
|
210
|
+
- headless rendering
|
|
211
|
+
- offscreen graphics testing
|
|
212
|
+
- broader WebGPU package compatibility
|
|
213
|
+
- future Chromium runtime-artifact dependency
|
|
214
|
+
|
|
215
|
+
### Promise
|
|
216
|
+
|
|
217
|
+
`full` promises a full headless WebGPU surface. It is a strict superset of
|
|
218
|
+
`compute`, but it still does not claim browser-process ownership, DOM
|
|
219
|
+
integration, or Chromium wire/drop-in readiness by itself.
|
|
220
|
+
|
|
221
|
+
### Added object model
|
|
222
|
+
|
|
223
|
+
`full` adds:
|
|
224
|
+
|
|
225
|
+
- `GPURenderPipeline`
|
|
226
|
+
- `GPURenderPassEncoder`
|
|
227
|
+
- `GPURenderBundleEncoder`
|
|
228
|
+
- vertex buffers
|
|
229
|
+
- index buffers
|
|
230
|
+
- `draw`
|
|
231
|
+
- `drawIndexed`
|
|
232
|
+
- `drawIndirect`
|
|
233
|
+
- render-state objects and behavior for blend, depth-stencil, and multisample
|
|
234
|
+
- `GPUSampler`
|
|
235
|
+
|
|
236
|
+
### Texture contract
|
|
237
|
+
|
|
238
|
+
`full` adds the texture/render surface that `core` deliberately excludes:
|
|
239
|
+
|
|
240
|
+
- sampled textures
|
|
241
|
+
- render-attachment textures
|
|
242
|
+
- broader texture/view/format coverage
|
|
243
|
+
- texture/view behavior needed by render pipelines and broader headless package
|
|
244
|
+
compatibility
|
|
245
|
+
|
|
246
|
+
### WGSL additions
|
|
247
|
+
|
|
248
|
+
WGSL added in `full`:
|
|
249
|
+
|
|
250
|
+
- sampler declarations and binding semantics
|
|
251
|
+
- `textureSample*`
|
|
252
|
+
- vertex stage
|
|
253
|
+
- fragment stage
|
|
254
|
+
|
|
255
|
+
`full` therefore owns the shader and object-model pieces needed for sampled
|
|
256
|
+
textures and render semantics. It still does not own DOM/canvas behavior.
|
|
257
|
+
|
|
258
|
+
### Still outside `full`
|
|
259
|
+
|
|
260
|
+
`full` still does not own:
|
|
261
|
+
|
|
262
|
+
- `GPUCanvasContext`
|
|
263
|
+
- DOM/canvas ownership
|
|
264
|
+
- proc-surface parity
|
|
265
|
+
- browser fallback policy
|
|
266
|
+
- Chromium process behavior
|
|
267
|
+
|
|
268
|
+
### Release gates for `full`
|
|
269
|
+
|
|
270
|
+
`full` acceptance requires:
|
|
271
|
+
|
|
272
|
+
1. every `core` gate remains green
|
|
273
|
+
2. full contract tests green for Node and declared Bun surface
|
|
274
|
+
3. broader CTS subset coverage for:
|
|
275
|
+
- render pipeline creation
|
|
276
|
+
- render pass execution
|
|
277
|
+
- render bundles where contract-required
|
|
278
|
+
- texture formats and sampling
|
|
279
|
+
- bind-group and pipeline-layout behavior
|
|
280
|
+
- query/lifecycle/error-scope paths
|
|
281
|
+
4. benchmark cube evidence may include:
|
|
282
|
+
- upload
|
|
283
|
+
- compute e2e
|
|
284
|
+
- render
|
|
285
|
+
- texture/raster
|
|
286
|
+
5. explicit unsupported taxonomy for any capability not yet in the full release
|
|
287
|
+
contract
|
|
288
|
+
6. no marketing or docs claim browser parity unless Track A browser gates also
|
|
289
|
+
pass
|
|
290
|
+
|
|
291
|
+
### Non-goals for `full`
|
|
292
|
+
|
|
293
|
+
1. replacing Chromium's process model
|
|
294
|
+
2. owning browser fallback policy
|
|
295
|
+
3. claiming `navigator.gpu` parity in the browser
|
|
296
|
+
4. bypassing Track A symbol/behavior/replay/drop-in gates
|
|
297
|
+
|
|
298
|
+
## Browser / Track A boundary contract
|
|
299
|
+
|
|
300
|
+
The following capabilities are not owned by `core` or `full` package contracts:
|
|
301
|
+
|
|
302
|
+
- `GPUCanvasContext`
|
|
303
|
+
- DOM/canvas ownership
|
|
304
|
+
- `navigator.gpu` behavior inside Chromium
|
|
305
|
+
- proc-surface completeness requirements
|
|
306
|
+
- browser fallback policy, denylist policy, and kill-switch policy
|
|
307
|
+
- renderer/GPU-process topology
|
|
308
|
+
- Chromium process behavior
|
|
309
|
+
|
|
310
|
+
These belong to Chromium Track A and must be governed by:
|
|
311
|
+
|
|
312
|
+
- `nursery/fawn-browser/README.md`
|
|
313
|
+
- `nursery/fawn-browser/plan.md`
|
|
314
|
+
- drop-in symbol/behavior/benchmark gates
|
|
315
|
+
- browser replay and claimability artifacts
|
|
316
|
+
|
|
317
|
+
## Current repo reality
|
|
318
|
+
|
|
319
|
+
This split is not yet how the repo is physically organized today.
|
|
320
|
+
|
|
321
|
+
Current state:
|
|
322
|
+
|
|
323
|
+
1. the canonical package is still a single `@simulatte/webgpu` surface
|
|
324
|
+
2. current package code already exposes some render objects and methods
|
|
325
|
+
3. current Zig/runtime docs track a single Doe runtime capability ledger
|
|
326
|
+
|
|
327
|
+
This document is therefore a target contract for future sharding, not a claim
|
|
328
|
+
that the split already exists.
|
|
329
|
+
|
|
330
|
+
## Adoption rules
|
|
331
|
+
|
|
332
|
+
Before naming or shipping separate `core` and `full` products:
|
|
333
|
+
|
|
334
|
+
1. create separate support ledgers and gates for each surface
|
|
335
|
+
2. enforce one-way import boundaries in Zig and Lean
|
|
336
|
+
3. move render, sampled-texture, and surface/lifecycle code out of the shared
|
|
337
|
+
core path
|
|
338
|
+
4. define separate package API contracts and compatibility scopes
|
|
339
|
+
5. keep Chromium depending on the full runtime artifact, not on npm packaging
|