@simulatte/webgpu-doe 0.1.2 → 0.3.2
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 +19 -0
- package/LICENSE +191 -0
- package/README.md +121 -126
- package/assets/fawn-icon-main.svg +222 -0
- package/examples/with-webgpu-compute.js +25 -0
- package/package.json +31 -26
- package/src/index.d.ts +125 -0
- package/src/index.js +644 -408
- 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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@simulatte/webgpu-doe` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.3.2] - 2026-03-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Reintroduced `@simulatte/webgpu-doe` as a standalone helper-only package.
|
|
10
|
+
- Exported `createDoeNamespace(...)`, `doe`, and the default Doe namespace.
|
|
11
|
+
- Added standalone TypeScript types for the Doe helper contract.
|
|
12
|
+
- Added a package-local smoke test and example showing how to bind Doe to
|
|
13
|
+
`@simulatte/webgpu` or `@simulatte/webgpu/compute`.
|
|
14
|
+
|
|
15
|
+
### Notes
|
|
16
|
+
|
|
17
|
+
- This package intentionally does not ship a runtime, addon, or Bun FFI layer.
|
|
18
|
+
- The Doe helper surface remains compatible with the helper contract currently
|
|
19
|
+
shipped inside `@simulatte/webgpu`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Fawn Contributors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,173 +1,168 @@
|
|
|
1
1
|
# @simulatte/webgpu-doe
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<td valign="middle">
|
|
6
|
+
<strong>Run the Doe helper layer over real WebGPU devices from Fawn or any compatible raw runtime.</strong>
|
|
7
|
+
</td>
|
|
8
|
+
<td valign="middle">
|
|
9
|
+
<img src="assets/fawn-icon-main.svg" alt="Fawn logo" width="88" />
|
|
10
|
+
</td>
|
|
11
|
+
</tr>
|
|
12
|
+
</table>
|
|
4
13
|
|
|
5
|
-
|
|
14
|
+
`@simulatte/webgpu-doe` is the standalone Doe helper layer extracted from
|
|
15
|
+
Fawn's headless WebGPU package surface.
|
|
6
16
|
|
|
7
|
-
|
|
17
|
+
This package does **not** ship a runtime, native addon, Bun FFI layer, or raw
|
|
18
|
+
WebGPU implementation. It ships the Doe helper namespace only:
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
- `createDoeNamespace(...)`
|
|
21
|
+
- `doe`
|
|
22
|
+
- `default`
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
required (`xcode-select --install` on macOS).
|
|
24
|
+
Use it when you want the same helper surface that exists inside
|
|
25
|
+
`@simulatte/webgpu`, but as a separate package boundary.
|
|
16
26
|
|
|
17
|
-
##
|
|
27
|
+
## What this package includes
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
- Doe buffer helpers: `gpu.buffer.create(...)`, `gpu.buffer.read(...)`
|
|
30
|
+
- Doe compute helpers: `gpu.kernel.run(...)`, `gpu.kernel.create(...)`,
|
|
31
|
+
`gpu.compute(...)`
|
|
32
|
+
- Generic TypeScript types for the bound Doe namespace and helper options
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
const adapter = await gpu.requestAdapter();
|
|
24
|
-
const device = await adapter.requestDevice();
|
|
34
|
+
## What this package does not include
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
- no runtime or device discovery on its own
|
|
37
|
+
- no Node addon or Bun FFI transport
|
|
38
|
+
- no raw WebGPU wrapper classes
|
|
39
|
+
- no feature publication, limits, or globals
|
|
28
40
|
|
|
29
|
-
|
|
30
|
-
const buffer = device.createBuffer({
|
|
31
|
-
size: 64,
|
|
32
|
-
usage: globals.GPUBufferUsage.STORAGE | globals.GPUBufferUsage.COPY_SRC,
|
|
33
|
-
});
|
|
41
|
+
You either:
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@group(0) @binding(0) var<storage, read_write> data: array<f32>;
|
|
38
|
-
@compute @workgroup_size(64)
|
|
39
|
-
fn main(@builtin(global_invocation_id) id: vec3u) {
|
|
40
|
-
data[id.x] = data[id.x] * 2.0;
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
});
|
|
43
|
+
1. inject a `requestDevice(...)` function from another package, or
|
|
44
|
+
2. bind Doe to an already-created compatible device with `doe.bind(device)`
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
```
|
|
46
|
+
## Install
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
headless compute and basic render work. See [more examples](#more-examples)
|
|
50
|
-
below for `navigator.gpu` setup and provider inspection.
|
|
48
|
+
Pair it with a compatible runtime package, usually `@simulatte/webgpu`:
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
```bash
|
|
51
|
+
npm install @simulatte/webgpu-doe @simulatte/webgpu
|
|
52
|
+
```
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
`libdoe_webgpu` and submits work through Doe's Metal backend.
|
|
56
|
-
- Runtime ownership: WGSL is compiled to MSL inside Doe's AST-based compiler
|
|
57
|
-
instead of going through Dawn.
|
|
58
|
-
- Small package payload: the shared library is about 2 MB on `darwin-arm64`.
|
|
59
|
-
- WebGPU-shaped surface: `requestAdapter`, `requestDevice`, buffer mapping,
|
|
60
|
-
bind groups, compute pipelines, command encoders, and basic render passes are
|
|
61
|
-
exposed directly from the package.
|
|
54
|
+
## How the packages fit together
|
|
62
55
|
|
|
63
|
-
|
|
56
|
+
- `@simulatte/webgpu`
|
|
57
|
+
- full headless WebGPU package
|
|
58
|
+
- includes the native runtime, raw WebGPU surface, and the same Doe helper contract
|
|
59
|
+
- `@simulatte/webgpu/compute`
|
|
60
|
+
- narrower compute-first facade over the same underlying runtime
|
|
61
|
+
- `@simulatte/webgpu-doe`
|
|
62
|
+
- helper-only package
|
|
63
|
+
- no runtime transport
|
|
64
|
+
- meant for reuse, custom binding, and independent versioning of the Doe helper contract
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
-
|
|
66
|
+
Normal users can keep using `@simulatte/webgpu` or `@simulatte/webgpu/compute`
|
|
67
|
+
directly. `@simulatte/webgpu-doe` is the explicit extraction for advanced
|
|
68
|
+
composition and for making the Doe helper layer independently publishable.
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
## Start here
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
| **Metal** (macOS) | Production | Basic (no vertex/index) | WGSL -> MSL (AST-based) | Ready for package use |
|
|
73
|
-
| **Vulkan** (Linux) | WIP | Not started | WGSL -> SPIR-V needed | Experimental |
|
|
74
|
-
| **D3D12** (Windows) | WIP | Not started | WGSL -> HLSL/DXIL needed | Experimental |
|
|
72
|
+
The same simple compute pass, shown first as the helper-only package mounted on
|
|
73
|
+
the compute runtime and then as a direct bind over an already-created device.
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
map/unmap, indirect dispatch, `shader-f16`, subgroups, override constants,
|
|
78
|
-
workgroup shared memory, multiple entry points, textures, samplers, and basic
|
|
79
|
-
render-pass execution.
|
|
75
|
+
### 1. Bind Doe to `@simulatte/webgpu/compute`
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
```js
|
|
78
|
+
import { requestDevice } from "@simulatte/webgpu/compute";
|
|
79
|
+
import { createDoeNamespace } from "@simulatte/webgpu-doe";
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const doe = createDoeNamespace({ requestDevice });
|
|
82
|
+
const gpu = await doe.requestDevice();
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Atomics: workgroup atomic and non-atomic both claimable
|
|
91
|
-
- Matrix-vector multiply: 3 variants claimable
|
|
92
|
-
- Concurrent execution: claimable
|
|
93
|
-
- Zero-init workgroup memory: claimable
|
|
94
|
-
- Draw throughput: 200k draws claimable
|
|
95
|
-
- Binary size: about 2 MB vs Dawn's about 11 MB
|
|
84
|
+
const src = gpu.buffer.create({ data: Float32Array.of(1, 2, 3, 4) });
|
|
85
|
+
const dst = gpu.buffer.create({ size: src.size, usage: "storageReadWrite" });
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
await gpu.kernel.run({
|
|
88
|
+
code: `
|
|
89
|
+
@group(0) @binding(0) var<storage, read> src: array<f32>;
|
|
90
|
+
@group(0) @binding(1) var<storage, read_write> dst: array<f32>;
|
|
101
91
|
|
|
102
|
-
|
|
92
|
+
@compute @workgroup_size(4)
|
|
93
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
94
|
+
let i = gid.x;
|
|
95
|
+
dst[i] = src[i] * 2.0;
|
|
96
|
+
}
|
|
97
|
+
`,
|
|
98
|
+
bindings: [src, dst],
|
|
99
|
+
workgroups: 1,
|
|
100
|
+
});
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
console.log(await gpu.buffer.read({ buffer: dst, type: Float32Array }));
|
|
103
|
+
```
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
- `device.createBuffer()` / `device.createShaderModule()` (WGSL)
|
|
108
|
-
- `device.createComputePipeline()` / `device.createComputePipelineAsync()`
|
|
109
|
-
- `device.createBindGroupLayout()` / `device.createBindGroup()`
|
|
110
|
-
- `device.createPipelineLayout()` / `pipeline.getBindGroupLayout()`
|
|
111
|
-
- `device.createCommandEncoder()` / `encoder.beginComputePass()`
|
|
112
|
-
- `pass.setPipeline()` / `pass.setBindGroup()` / `pass.dispatchWorkgroups()`
|
|
113
|
-
- `pass.dispatchWorkgroupsIndirect()`
|
|
114
|
-
- `encoder.copyBufferToBuffer()` / `queue.submit()` / `queue.writeBuffer()`
|
|
115
|
-
- `buffer.mapAsync()` / `buffer.getMappedRange()` / `buffer.unmap()`
|
|
116
|
-
- `queue.onSubmittedWorkDone()`
|
|
105
|
+
### 2. Bind Doe to an existing device
|
|
117
106
|
|
|
118
|
-
|
|
107
|
+
```js
|
|
108
|
+
import { requestDevice } from "@simulatte/webgpu";
|
|
109
|
+
import doe from "@simulatte/webgpu-doe";
|
|
119
110
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
const device = await requestDevice();
|
|
112
|
+
const gpu = doe.bind(device);
|
|
113
|
+
```
|
|
123
114
|
|
|
124
|
-
|
|
115
|
+
### 3. Inject your own request path
|
|
125
116
|
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
```js
|
|
118
|
+
import { createDoeNamespace } from "@simulatte/webgpu-doe";
|
|
128
119
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
const doe = createDoeNamespace({
|
|
121
|
+
async requestDevice(options) {
|
|
122
|
+
return createMyCompatibleDevice(options);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
133
125
|
|
|
134
|
-
|
|
126
|
+
const gpu = await doe.requestDevice();
|
|
127
|
+
```
|
|
135
128
|
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
The only requirement is that the bound device exposes the WebGPU methods Doe
|
|
130
|
+
uses internally:
|
|
138
131
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
- `createBuffer`
|
|
133
|
+
- `createShaderModule`
|
|
134
|
+
- `createBindGroupLayout`
|
|
135
|
+
- `createPipelineLayout`
|
|
136
|
+
- `createComputePipeline`
|
|
137
|
+
- `createBindGroup`
|
|
138
|
+
- `createCommandEncoder`
|
|
139
|
+
- `queue.writeBuffer`
|
|
140
|
+
- `queue.submit`
|
|
141
|
+
- optionally `queue.onSubmittedWorkDone`
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
## API surface
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
import { providerInfo } from '@simulatte/webgpu-doe';
|
|
147
|
-
console.log(providerInfo());
|
|
148
|
-
// { module: '@simulatte/webgpu-doe', loaded: true, doeNative: true, ... }
|
|
149
|
-
```
|
|
145
|
+
### `createDoeNamespace({ requestDevice } = {})`
|
|
150
146
|
|
|
151
|
-
|
|
147
|
+
Creates a Doe namespace object with:
|
|
152
148
|
|
|
153
|
-
|
|
149
|
+
- `requestDevice(options?)`
|
|
150
|
+
- `bind(device)`
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
3. `<workspace>/zig/zig-out/lib/libdoe_webgpu.{ext}` (monorepo layout)
|
|
158
|
-
4. `<cwd>/zig/zig-out/lib/libdoe_webgpu.{ext}`
|
|
152
|
+
If `requestDevice` is omitted, `doe.requestDevice()` throws an explicit error
|
|
153
|
+
and `doe.bind(device)` remains available.
|
|
159
154
|
|
|
160
|
-
|
|
155
|
+
### `doe`
|
|
161
156
|
|
|
162
|
-
|
|
157
|
+
Default namespace created with no injected `requestDevice(...)`. This is
|
|
158
|
+
useful when you want only `doe.bind(device)`.
|
|
163
159
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
```
|
|
160
|
+
## Release contract
|
|
161
|
+
|
|
162
|
+
This package intentionally owns only the helper contract. It should stay
|
|
163
|
+
transport-free. Runtime loading and raw WebGPU surfaces belong in
|
|
164
|
+
`@simulatte/webgpu`.
|
|
170
165
|
|
|
171
166
|
## License
|
|
172
167
|
|
|
173
|
-
|
|
168
|
+
Apache-2.0
|