@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/full.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BoundDoeNamespace,
|
|
3
|
+
DoeKernelDispatchOptions,
|
|
4
|
+
DoeNamespace,
|
|
5
|
+
DoeRunComputeOptions,
|
|
6
|
+
} from "./doe.js";
|
|
7
|
+
|
|
8
|
+
export interface ProviderInfo {
|
|
9
|
+
module: string;
|
|
10
|
+
loaded: boolean;
|
|
11
|
+
loadError: string;
|
|
12
|
+
defaultCreateArgs: string[];
|
|
13
|
+
doeNative: boolean;
|
|
14
|
+
libraryFlavor: string;
|
|
15
|
+
doeLibraryPath: string;
|
|
16
|
+
buildMetadataSource: string;
|
|
17
|
+
buildMetadataPath: string;
|
|
18
|
+
leanVerifiedBuild: boolean | null;
|
|
19
|
+
proofArtifactSha256: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DoeRuntimeRunResult {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
exitCode: number;
|
|
25
|
+
stdout: string;
|
|
26
|
+
stderr: string;
|
|
27
|
+
signal: string | null;
|
|
28
|
+
command: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DoeRuntimeBenchResult extends DoeRuntimeRunResult {
|
|
32
|
+
traceJsonlPath: string | null;
|
|
33
|
+
traceMetaPath: string | null;
|
|
34
|
+
traceMeta: Record<string, unknown> | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DoeRuntimeBenchOptions {
|
|
38
|
+
commandsPath: string;
|
|
39
|
+
quirksPath?: string;
|
|
40
|
+
vendor?: string;
|
|
41
|
+
api?: string;
|
|
42
|
+
family?: string;
|
|
43
|
+
driver?: string;
|
|
44
|
+
traceJsonlPath?: string;
|
|
45
|
+
traceMetaPath?: string;
|
|
46
|
+
uploadBufferUsage?: string;
|
|
47
|
+
uploadSubmitEvery?: number;
|
|
48
|
+
queueWaitMode?: string;
|
|
49
|
+
queueSyncMode?: string;
|
|
50
|
+
extraArgs?: string[];
|
|
51
|
+
cwd?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface DoeRuntime {
|
|
55
|
+
binPath: string;
|
|
56
|
+
libPath: string | null;
|
|
57
|
+
runRaw(args: string[], spawnOptions?: Record<string, unknown>): DoeRuntimeRunResult;
|
|
58
|
+
runBench(options: DoeRuntimeBenchOptions): DoeRuntimeBenchResult;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RequestDeviceOptions {
|
|
62
|
+
adapterOptions?: GPURequestAdapterOptions;
|
|
63
|
+
deviceDescriptor?: GPUDeviceDescriptor;
|
|
64
|
+
createArgs?: string[] | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface FullDoeRunComputeOptions extends DoeRunComputeOptions<GPUBuffer> {}
|
|
68
|
+
|
|
69
|
+
export interface FullDoeKernelDispatchOptions extends DoeKernelDispatchOptions<GPUBuffer> {}
|
|
70
|
+
|
|
71
|
+
export interface FullDoeKernel {
|
|
72
|
+
readonly device: GPUDevice;
|
|
73
|
+
readonly entryPoint: string;
|
|
74
|
+
dispatch(options: FullDoeKernelDispatchOptions): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface FullBoundDoeNamespace
|
|
78
|
+
extends BoundDoeNamespace<GPUDevice, GPUBuffer, FullDoeKernel, FullDoeRunComputeOptions> {}
|
|
79
|
+
|
|
80
|
+
export interface FullDoeNamespace
|
|
81
|
+
extends DoeNamespace<
|
|
82
|
+
GPUDevice,
|
|
83
|
+
GPUBuffer,
|
|
84
|
+
FullDoeKernel,
|
|
85
|
+
FullBoundDoeNamespace,
|
|
86
|
+
FullDoeRunComputeOptions,
|
|
87
|
+
RequestDeviceOptions
|
|
88
|
+
> {}
|
|
89
|
+
|
|
90
|
+
export const globals: Record<string, unknown>;
|
|
91
|
+
export function create(createArgs?: string[] | null): GPU;
|
|
92
|
+
export function setupGlobals(target?: object, createArgs?: string[] | null): GPU;
|
|
93
|
+
export function requestAdapter(
|
|
94
|
+
adapterOptions?: GPURequestAdapterOptions,
|
|
95
|
+
createArgs?: string[] | null
|
|
96
|
+
): Promise<GPUAdapter | null>;
|
|
97
|
+
export function requestDevice(options?: RequestDeviceOptions): Promise<GPUDevice>;
|
|
98
|
+
export function providerInfo(): ProviderInfo;
|
|
99
|
+
export function createDoeRuntime(options?: {
|
|
100
|
+
binPath?: string;
|
|
101
|
+
libPath?: string;
|
|
102
|
+
}): DoeRuntime;
|
|
103
|
+
export function runDawnVsDoeCompare(options: Record<string, unknown>): DoeRuntimeRunResult;
|
|
104
|
+
|
|
105
|
+
export const doe: FullDoeNamespace;
|
|
106
|
+
|
|
107
|
+
declare const _default: {
|
|
108
|
+
create: typeof create;
|
|
109
|
+
globals: typeof globals;
|
|
110
|
+
setupGlobals: typeof setupGlobals;
|
|
111
|
+
requestAdapter: typeof requestAdapter;
|
|
112
|
+
requestDevice: typeof requestDevice;
|
|
113
|
+
providerInfo: typeof providerInfo;
|
|
114
|
+
createDoeRuntime: typeof createDoeRuntime;
|
|
115
|
+
runDawnVsDoeCompare: typeof runDawnVsDoeCompare;
|
|
116
|
+
doe: FullDoeNamespace;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default _default;
|
package/src/full.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
});
|
|
29
|
+
|
|
30
|
+
export * from './index.js';
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
...full,
|
|
34
|
+
doe,
|
|
35
|
+
};
|