@simulatte/webgpu 0.2.4 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +263 -71
  3. package/api-contract.md +70 -139
  4. package/assets/package-layers.svg +63 -0
  5. package/examples/direct-webgpu/compute-dispatch.js +66 -0
  6. package/examples/direct-webgpu/explicit-bind-group.js +85 -0
  7. package/examples/direct-webgpu/request-device.js +10 -0
  8. package/examples/doe-api/buffers-readback.js +9 -0
  9. package/examples/doe-api/compile-and-dispatch.js +30 -0
  10. package/examples/doe-api/compute-dispatch.js +25 -0
  11. package/examples/doe-routines/compute-once-like-input.js +36 -0
  12. package/examples/doe-routines/compute-once-matmul.js +53 -0
  13. package/examples/doe-routines/compute-once-multiple-inputs.js +27 -0
  14. package/examples/doe-routines/compute-once.js +23 -0
  15. package/headless-webgpu-comparison.md +2 -2
  16. package/layering-plan.md +1 -1
  17. package/native/doe_napi.c +102 -12
  18. package/package.json +2 -1
  19. package/prebuilds/darwin-arm64/doe_napi.node +0 -0
  20. package/prebuilds/darwin-arm64/libwebgpu_doe.dylib +0 -0
  21. package/prebuilds/darwin-arm64/metadata.json +6 -6
  22. package/prebuilds/linux-x64/doe_napi.node +0 -0
  23. package/prebuilds/linux-x64/libwebgpu_doe.so +0 -0
  24. package/prebuilds/linux-x64/metadata.json +5 -5
  25. package/scripts/generate-readme-assets.js +79 -6
  26. package/scripts/prebuild.js +23 -19
  27. package/src/auto_bind_group_layout.js +32 -0
  28. package/src/bun-ffi.js +93 -12
  29. package/src/bun.js +23 -2
  30. package/src/compute.d.ts +2 -1
  31. package/src/compute.js +671 -33
  32. package/src/doe.d.ts +127 -27
  33. package/src/doe.js +480 -114
  34. package/src/full.d.ts +8 -1
  35. package/src/full.js +28 -3
  36. package/src/index.js +1013 -38
package/src/full.d.ts CHANGED
@@ -78,7 +78,14 @@ export interface FullBoundDoeNamespace
78
78
  extends BoundDoeNamespace<GPUDevice, GPUBuffer, FullDoeKernel, FullDoeRunComputeOptions> {}
79
79
 
80
80
  export interface FullDoeNamespace
81
- extends DoeNamespace<GPUDevice, GPUBuffer, FullDoeKernel, FullBoundDoeNamespace, FullDoeRunComputeOptions> {}
81
+ extends DoeNamespace<
82
+ GPUDevice,
83
+ GPUBuffer,
84
+ FullDoeKernel,
85
+ FullBoundDoeNamespace,
86
+ FullDoeRunComputeOptions,
87
+ RequestDeviceOptions
88
+ > {}
82
89
 
83
90
  export const globals: Record<string, unknown>;
84
91
  export function create(createArgs?: string[] | null): GPU;
package/src/full.js CHANGED
@@ -1,8 +1,33 @@
1
- import full from './index.js';
2
- import { doe } from './doe.js';
1
+ import * as full from './index.js';
2
+ import { createDoeNamespace } from './doe.js';
3
+
4
+ /**
5
+ * Shared Doe API / Doe routines namespace for the full package surface.
6
+ *
7
+ * This exposes `await doe.requestDevice()` for the one-line Doe API entry,
8
+ * `doe.bind(device)` when you already have a full device, `doe.buffers.*` and
9
+ * `doe.compute.run(...)` / `doe.compute.compile(...)` for the `Doe API`
10
+ * surface, and `doe.compute.once(...)` for `Doe routines`.
11
+ *
12
+ * The exported `doe` object here is the JS convenience surface over the Doe
13
+ * runtime, not a separate runtime.
14
+ *
15
+ * This example shows the API in its basic form.
16
+ *
17
+ * ```js
18
+ * import { doe } from "@simulatte/webgpu";
19
+ *
20
+ * const gpu = await doe.requestDevice();
21
+ * ```
22
+ *
23
+ * - The Doe API and Doe routines shape is the same as `@simulatte/webgpu/compute`; the difference is that the underlying device here stays full-surface rather than compute-only.
24
+ * - If you need explicit render, sampler, or surface APIs, keep the raw device from `requestDevice()` or access `gpu.device` after `doe.requestDevice()`.
25
+ */
26
+ export const doe = createDoeNamespace({
27
+ requestDevice: full.requestDevice,
28
+ });
3
29
 
4
30
  export * from './index.js';
5
- export { doe };
6
31
 
7
32
  export default {
8
33
  ...full,