@simulatte/webgpu-doe 0.1.3 → 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 +159 -8
- package/assets/fawn-icon-main.svg +222 -0
- package/examples/with-webgpu-compute.js +25 -0
- package/package.json +46 -4
- package/src/index.d.ts +125 -0
- package/src/index.js +731 -0
package/package.json
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simulatte/webgpu-doe",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Standalone Doe helper namespace for WebGPU-compatible runtimes",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.d.ts",
|
|
12
|
+
"default": "./src/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"assets/",
|
|
20
|
+
"examples/",
|
|
21
|
+
"src/",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.md",
|
|
24
|
+
"CHANGELOG.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "node ./test-node.js",
|
|
28
|
+
"smoke": "node ./test-node.js"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"webgpu",
|
|
32
|
+
"doe",
|
|
33
|
+
"helpers",
|
|
34
|
+
"compute",
|
|
35
|
+
"wgsl"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/clocksmith/fawn.git",
|
|
40
|
+
"directory": "nursery/webgpu-doe"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/clocksmith/fawn/tree/main/nursery/webgpu-doe",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/clocksmith/fawn/issues"
|
|
45
|
+
},
|
|
6
46
|
"publishConfig": {
|
|
7
47
|
"access": "public"
|
|
8
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"author": "Fawn",
|
|
50
|
+
"license": "Apache-2.0"
|
|
9
51
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export type DoeBufferUsage =
|
|
2
|
+
| "upload"
|
|
3
|
+
| "readback"
|
|
4
|
+
| "uniform"
|
|
5
|
+
| "storageRead"
|
|
6
|
+
| "storageReadWrite";
|
|
7
|
+
|
|
8
|
+
export type DoeWorkgroups = number | [number, number] | [number, number, number];
|
|
9
|
+
|
|
10
|
+
export type DoeBindingAccess = "uniform" | "storageRead" | "storageReadWrite";
|
|
11
|
+
|
|
12
|
+
export interface DoeCreateBufferOptions {
|
|
13
|
+
size?: number;
|
|
14
|
+
usage?: DoeBufferUsage | DoeBufferUsage[] | number;
|
|
15
|
+
data?: ArrayBufferView | ArrayBuffer;
|
|
16
|
+
label?: string;
|
|
17
|
+
mappedAtCreation?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DoeReadBufferSubrangeOptions {
|
|
21
|
+
size?: number;
|
|
22
|
+
offset?: number;
|
|
23
|
+
label?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DoeReadBufferOptions<T extends ArrayBufferView = ArrayBufferView>
|
|
27
|
+
extends DoeReadBufferSubrangeOptions {
|
|
28
|
+
buffer: unknown;
|
|
29
|
+
type: { new (buffer: ArrayBuffer): T };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DoeBindingBuffer<TBuffer> {
|
|
33
|
+
buffer: TBuffer;
|
|
34
|
+
access?: DoeBindingAccess;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DoeComputeInputDataOptions {
|
|
38
|
+
data: ArrayBufferView | ArrayBuffer;
|
|
39
|
+
usage?: DoeBufferUsage | DoeBufferUsage[];
|
|
40
|
+
access?: DoeBindingAccess;
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type DoeComputeInput<TBuffer> =
|
|
45
|
+
| ArrayBufferView
|
|
46
|
+
| ArrayBuffer
|
|
47
|
+
| TBuffer
|
|
48
|
+
| DoeBindingBuffer<TBuffer>
|
|
49
|
+
| DoeComputeInputDataOptions;
|
|
50
|
+
|
|
51
|
+
export interface DoeComputeOnceOutputOptions<T extends ArrayBufferView> {
|
|
52
|
+
type: { new (buffer: ArrayBuffer): T };
|
|
53
|
+
size?: number;
|
|
54
|
+
likeInput?: number;
|
|
55
|
+
usage?: DoeBufferUsage | DoeBufferUsage[];
|
|
56
|
+
access?: DoeBindingAccess;
|
|
57
|
+
label?: string;
|
|
58
|
+
read?: DoeReadBufferSubrangeOptions;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DoeComputeOnceOptions<TBuffer, T extends ArrayBufferView> {
|
|
62
|
+
code: string;
|
|
63
|
+
entryPoint?: string;
|
|
64
|
+
inputs?: Array<DoeComputeInput<TBuffer>>;
|
|
65
|
+
output: DoeComputeOnceOutputOptions<T>;
|
|
66
|
+
workgroups: DoeWorkgroups;
|
|
67
|
+
label?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface DoeKernelCreateOptions<TBuffer> {
|
|
71
|
+
code: string;
|
|
72
|
+
entryPoint?: string;
|
|
73
|
+
bindings?: Array<TBuffer | DoeBindingBuffer<TBuffer>>;
|
|
74
|
+
workgroups: DoeWorkgroups;
|
|
75
|
+
label?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface DoeKernelDispatchOptions<TBuffer> {
|
|
79
|
+
bindings?: Array<TBuffer | DoeBindingBuffer<TBuffer>>;
|
|
80
|
+
workgroups: DoeWorkgroups;
|
|
81
|
+
label?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface BoundDoeBufferNamespace<TBuffer> {
|
|
85
|
+
create(options: DoeCreateBufferOptions): TBuffer;
|
|
86
|
+
read<T extends ArrayBufferView>(
|
|
87
|
+
options: DoeReadBufferOptions<T>,
|
|
88
|
+
): Promise<T>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface BoundDoeKernelNamespace<
|
|
92
|
+
TBuffer,
|
|
93
|
+
TKernel,
|
|
94
|
+
TKernelOptions,
|
|
95
|
+
> {
|
|
96
|
+
run(options: TKernelOptions): Promise<void>;
|
|
97
|
+
create(options: TKernelOptions): TKernel;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface BoundDoeNamespace<
|
|
101
|
+
TDevice,
|
|
102
|
+
TBuffer,
|
|
103
|
+
TKernel,
|
|
104
|
+
TKernelOptions,
|
|
105
|
+
> {
|
|
106
|
+
readonly device: TDevice;
|
|
107
|
+
readonly buffer: BoundDoeBufferNamespace<TBuffer>;
|
|
108
|
+
readonly kernel: BoundDoeKernelNamespace<
|
|
109
|
+
TBuffer,
|
|
110
|
+
TKernel,
|
|
111
|
+
TKernelOptions
|
|
112
|
+
>;
|
|
113
|
+
compute<T extends ArrayBufferView>(
|
|
114
|
+
options: DoeComputeOnceOptions<TBuffer, T>,
|
|
115
|
+
): Promise<T>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface DoeNamespace<
|
|
119
|
+
TDevice,
|
|
120
|
+
TBoundDoe,
|
|
121
|
+
TRequestDeviceOptions = unknown,
|
|
122
|
+
> {
|
|
123
|
+
requestDevice(options?: TRequestDeviceOptions): Promise<TBoundDoe>;
|
|
124
|
+
bind(device: TDevice): TBoundDoe;
|
|
125
|
+
}
|