@wasi-gfx/js-webgpu 0.2.0 → 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 (63) hide show
  1. package/README.md +3 -3
  2. package/dist/canvas.d.ts +3 -3
  3. package/dist/canvas.js +36 -23
  4. package/dist/webgpu.d.ts +39 -12
  5. package/dist/webgpu.js +248 -42
  6. package/package.json +12 -6
  7. package/types/interfaces/wasi-cli-run.d.ts +2 -2
  8. package/types/interfaces/wasi-cli-stdout.d.ts +14 -3
  9. package/types/interfaces/wasi-cli-types.d.ts +15 -0
  10. package/types/interfaces/wasi-gfx-frame-buffer-frame-buffer.d.ts +13 -0
  11. package/types/interfaces/wasi-gfx-surface-surface-frame-buffer.d.ts +12 -0
  12. package/types/interfaces/wasi-gfx-surface-surface-webgpu.d.ts +29 -0
  13. package/types/interfaces/{wasi-surface-surface.d.ts → wasi-gfx-surface-surface.d.ts} +8 -18
  14. package/types/interfaces/wasi-webgpu-webgpu.d.ts +809 -810
  15. package/types/wit.d.ts +9 -10
  16. package/wit/deps/wasi-cli-0.3.0/package.wit +256 -0
  17. package/wit/deps/wasi-clocks-0.3.0/package.wit +43 -0
  18. package/wit/deps/wasi-filesystem-0.3.0/package.wit +149 -0
  19. package/wit/deps/wasi-gfx-frame-buffer-0.2.0/package.wit +13 -0
  20. package/wit/deps/{surface/surface.wit → wasi-gfx-surface-0.2.0/package.wit} +69 -44
  21. package/wit/deps/wasi-random-0.3.0/package.wit +18 -0
  22. package/wit/deps/wasi-sockets-0.3.0/package.wit +116 -0
  23. package/wit/deps/{webgpu/webgpu.wit → wasi-webgpu-0.3.0-rc.2/package.wit} +1007 -836
  24. package/wit/world.wit +8 -7
  25. package/types/interfaces/wasi-frame-buffer-frame-buffer.d.ts +0 -21
  26. package/types/interfaces/wasi-graphics-context-graphics-context.d.ts +0 -17
  27. package/types/interfaces/wasi-io-error.d.ts +0 -18
  28. package/types/interfaces/wasi-io-poll.d.ts +0 -43
  29. package/types/interfaces/wasi-io-streams.d.ts +0 -240
  30. package/wit/deps/cli/command.wit +0 -7
  31. package/wit/deps/cli/environment.wit +0 -18
  32. package/wit/deps/cli/exit.wit +0 -4
  33. package/wit/deps/cli/imports.wit +0 -20
  34. package/wit/deps/cli/run.wit +0 -4
  35. package/wit/deps/cli/stdio.wit +0 -17
  36. package/wit/deps/cli/terminal.wit +0 -49
  37. package/wit/deps/clocks/monotonic-clock.wit +0 -45
  38. package/wit/deps/clocks/wall-clock.wit +0 -42
  39. package/wit/deps/clocks/world.wit +0 -6
  40. package/wit/deps/filesystem/preopens.wit +0 -8
  41. package/wit/deps/filesystem/types.wit +0 -634
  42. package/wit/deps/filesystem/world.wit +0 -6
  43. package/wit/deps/frame-buffer/frame-buffer.wit +0 -23
  44. package/wit/deps/graphics-context/graphics-context.wit +0 -18
  45. package/wit/deps/io/error.wit +0 -34
  46. package/wit/deps/io/poll.wit +0 -41
  47. package/wit/deps/io/streams.wit +0 -262
  48. package/wit/deps/io/world.wit +0 -6
  49. package/wit/deps/random/insecure-seed.wit +0 -25
  50. package/wit/deps/random/insecure.wit +0 -22
  51. package/wit/deps/random/random.wit +0 -26
  52. package/wit/deps/random/world.wit +0 -7
  53. package/wit/deps/sockets/instance-network.wit +0 -9
  54. package/wit/deps/sockets/ip-name-lookup.wit +0 -51
  55. package/wit/deps/sockets/network.wit +0 -145
  56. package/wit/deps/sockets/tcp-create-socket.wit +0 -27
  57. package/wit/deps/sockets/tcp.wit +0 -353
  58. package/wit/deps/sockets/udp-create-socket.wit +0 -27
  59. package/wit/deps/sockets/udp.wit +0 -266
  60. package/wit/deps/sockets/world.wit +0 -11
  61. package/wit/deps/webgpu/imports.wit +0 -5
  62. package/wit/deps.lock +0 -51
  63. package/wit/deps.toml +0 -18
@@ -1,139 +1,109 @@
1
- package wasi:webgpu@0.0.1;
1
+ package wasi:webgpu@0.3.0-rc.2;
2
2
 
3
3
  interface webgpu {
4
- use wasi:io/poll@0.2.0.{ pollable };
5
- use wasi:graphics-context/graphics-context@0.0.1.{ context, abstract-buffer };
6
- resource gpu-supported-limits {
7
- max-texture-dimension1-d: func() -> u32;
8
- max-texture-dimension2-d: func() -> u32;
9
- max-texture-dimension3-d: func() -> u32;
10
- max-texture-array-layers: func() -> u32;
11
- max-bind-groups: func() -> u32;
12
- max-bind-groups-plus-vertex-buffers: func() -> u32;
13
- max-bindings-per-bind-group: func() -> u32;
14
- max-dynamic-uniform-buffers-per-pipeline-layout: func() -> u32;
15
- max-dynamic-storage-buffers-per-pipeline-layout: func() -> u32;
16
- max-sampled-textures-per-shader-stage: func() -> u32;
17
- max-samplers-per-shader-stage: func() -> u32;
18
- max-storage-buffers-per-shader-stage: func() -> u32;
19
- max-storage-textures-per-shader-stage: func() -> u32;
20
- max-uniform-buffers-per-shader-stage: func() -> u32;
21
- max-uniform-buffer-binding-size: func() -> u64;
22
- max-storage-buffer-binding-size: func() -> u64;
23
- min-uniform-buffer-offset-alignment: func() -> u32;
24
- min-storage-buffer-offset-alignment: func() -> u32;
25
- max-vertex-buffers: func() -> u32;
26
- max-buffer-size: func() -> u64;
27
- max-vertex-attributes: func() -> u32;
28
- max-vertex-buffer-array-stride: func() -> u32;
29
- max-inter-stage-shader-variables: func() -> u32;
30
- max-color-attachments: func() -> u32;
31
- max-color-attachment-bytes-per-sample: func() -> u32;
32
- max-compute-workgroup-storage-size: func() -> u32;
33
- max-compute-invocations-per-workgroup: func() -> u32;
34
- max-compute-workgroup-size-x: func() -> u32;
35
- max-compute-workgroup-size-y: func() -> u32;
36
- max-compute-workgroup-size-z: func() -> u32;
37
- max-compute-workgroups-per-dimension: func() -> u32;
4
+ variant create-query-set-error-kind {
5
+ type-error,
38
6
  }
39
- resource gpu-supported-features {
40
- has: func(value: string) -> bool;
7
+
8
+ record create-query-set-error {
9
+ kind: create-query-set-error-kind,
10
+ message: string,
41
11
  }
42
- resource wgsl-language-features {
43
- has: func(value: string) -> bool;
12
+
13
+ variant get-mapped-range-error-kind {
14
+ operation-error,
15
+ range-error,
16
+ type-error,
44
17
  }
45
- resource gpu-adapter-info {
46
- vendor: func() -> string;
47
- architecture: func() -> string;
48
- device: func() -> string;
49
- description: func() -> string;
50
- subgroup-min-size: func() -> u32;
51
- subgroup-max-size: func() -> u32;
18
+
19
+ record get-mapped-range-error {
20
+ kind: get-mapped-range-error-kind,
21
+ message: string,
52
22
  }
23
+
53
24
  resource gpu {
54
- request-adapter: func(options: option<gpu-request-adapter-options>) -> option<gpu-adapter>;
25
+ request-adapter: async func(options: option<gpu-request-adapter-options>) -> option<gpu-adapter>;
55
26
  get-preferred-canvas-format: func() -> gpu-texture-format;
56
27
  wgsl-language-features: func() -> wgsl-language-features;
57
28
  }
58
- enum gpu-power-preference {
59
- low-power,
60
- high-performance,
61
- }
62
- record gpu-request-adapter-options {
63
- feature-level: option<string>,
64
- power-preference: option<gpu-power-preference>,
65
- force-fallback-adapter: option<bool>,
66
- xr-compatible: option<bool>,
67
- }
29
+
68
30
  resource gpu-adapter {
69
31
  features: func() -> gpu-supported-features;
70
32
  limits: func() -> gpu-supported-limits;
71
33
  info: func() -> gpu-adapter-info;
34
+ request-device: async func(descriptor: option<gpu-device-descriptor>) -> result<gpu-device, request-device-error>;
35
+ }
36
+
37
+ resource gpu-adapter-info {
38
+ vendor: func() -> string;
39
+ architecture: func() -> string;
40
+ device: func() -> string;
41
+ description: func() -> string;
42
+ subgroup-min-size: func() -> u32;
43
+ subgroup-max-size: func() -> u32;
72
44
  is-fallback-adapter: func() -> bool;
73
- request-device: func(descriptor: option<gpu-device-descriptor>) -> result<gpu-device, request-device-error>;
74
45
  }
75
- resource record-option-gpu-size64 {
76
- constructor();
77
- add: func(key: string, value: option<gpu-size64>);
78
- get: func(key: string) -> option<option<gpu-size64>>;
79
- has: func(key: string) -> bool;
80
- remove: func(key: string);
81
- keys: func() -> list<string>;
82
- values: func() -> list<option<gpu-size64>>;
83
- entries: func() -> list<tuple<string, option<gpu-size64>>>;
46
+
47
+ enum gpu-address-mode {
48
+ clamp-to-edge,
49
+ repeat,
50
+ mirror-repeat,
84
51
  }
85
- enum gpu-feature-name {
86
- depth-clip-control,
87
- depth32float-stencil8,
88
- texture-compression-bc,
89
- texture-compression-bc-sliced3d,
90
- texture-compression-etc2,
91
- texture-compression-astc,
92
- texture-compression-astc-sliced3d,
93
- timestamp-query,
94
- indirect-first-instance,
95
- shader-f16,
96
- rg11b10ufloat-renderable,
97
- bgra8unorm-storage,
98
- float32-filterable,
99
- float32-blendable,
100
- clip-distances,
101
- dual-source-blending,
102
- subgroups,
52
+
53
+ resource gpu-bind-group {
54
+ label: func() -> string;
55
+ set-label: func(label: string);
103
56
  }
104
- resource gpu-device {
105
- features: func() -> gpu-supported-features;
106
- limits: func() -> gpu-supported-limits;
107
- adapter-info: func() -> gpu-adapter-info;
108
- queue: func() -> gpu-queue;
109
- destroy: func();
110
- create-buffer: func(descriptor: gpu-buffer-descriptor) -> gpu-buffer;
111
- create-texture: func(descriptor: gpu-texture-descriptor) -> gpu-texture;
112
- create-sampler: func(descriptor: option<gpu-sampler-descriptor>) -> gpu-sampler;
113
- create-bind-group-layout: func(descriptor: gpu-bind-group-layout-descriptor) -> gpu-bind-group-layout;
114
- create-pipeline-layout: func(descriptor: gpu-pipeline-layout-descriptor) -> gpu-pipeline-layout;
115
- create-bind-group: func(descriptor: gpu-bind-group-descriptor) -> gpu-bind-group;
116
- create-shader-module: func(descriptor: gpu-shader-module-descriptor) -> gpu-shader-module;
117
- create-compute-pipeline: func(descriptor: gpu-compute-pipeline-descriptor) -> gpu-compute-pipeline;
118
- create-render-pipeline: func(descriptor: gpu-render-pipeline-descriptor) -> gpu-render-pipeline;
119
- create-compute-pipeline-async: func(descriptor: gpu-compute-pipeline-descriptor) -> result<gpu-compute-pipeline, create-pipeline-error>;
120
- create-render-pipeline-async: func(descriptor: gpu-render-pipeline-descriptor) -> result<gpu-render-pipeline, create-pipeline-error>;
121
- create-command-encoder: func(descriptor: option<gpu-command-encoder-descriptor>) -> gpu-command-encoder;
122
- create-render-bundle-encoder: func(descriptor: gpu-render-bundle-encoder-descriptor) -> gpu-render-bundle-encoder;
123
- create-query-set: func(descriptor: gpu-query-set-descriptor) -> result<gpu-query-set, create-query-set-error>;
57
+
58
+ resource gpu-bind-group-layout {
124
59
  label: func() -> string;
125
60
  set-label: func(label: string);
126
- lost: func() -> gpu-device-lost-info;
127
- push-error-scope: func(filter: gpu-error-filter);
128
- pop-error-scope: func() -> result<option<gpu-error>, pop-error-scope-error>;
129
- onuncapturederror-subscribe: func() -> pollable;
130
- connect-graphics-context: func(context: borrow<context>);
131
61
  }
62
+
63
+ enum gpu-blend-factor {
64
+ zero,
65
+ one,
66
+ src,
67
+ one-minus-src,
68
+ src-alpha,
69
+ one-minus-src-alpha,
70
+ dst,
71
+ one-minus-dst,
72
+ dst-alpha,
73
+ one-minus-dst-alpha,
74
+ src-alpha-saturated,
75
+ constant,
76
+ one-minus-constant,
77
+ src1,
78
+ one-minus-src1,
79
+ src1-alpha,
80
+ one-minus-src1-alpha,
81
+ }
82
+
83
+ enum gpu-blend-operation {
84
+ add,
85
+ subtract,
86
+ reverse-subtract,
87
+ min,
88
+ max,
89
+ }
90
+
91
+ record gpu-blend-component {
92
+ operation: option<gpu-blend-operation>,
93
+ src-factor: option<gpu-blend-factor>,
94
+ dst-factor: option<gpu-blend-factor>,
95
+ }
96
+
97
+ record gpu-blend-state {
98
+ color: gpu-blend-component,
99
+ alpha: gpu-blend-component,
100
+ }
101
+
132
102
  resource gpu-buffer {
133
103
  size: func() -> gpu-size64-out;
134
- usage: func() -> gpu-flags-constant;
104
+ usage: func() -> gpu-buffer-usage;
135
105
  map-state: func() -> gpu-buffer-map-state;
136
- map-async: func(mode: gpu-map-mode-flags, offset: option<gpu-size64>, size: option<gpu-size64>) -> result<_, map-async-error>;
106
+ map-async: async func(mode: gpu-map-mode, offset: option<gpu-size64>, size: option<gpu-size64>) -> result<_, map-async-error>;
137
107
  get-mapped-range-get-with-copy: func(offset: option<gpu-size64>, size: option<gpu-size64>) -> result<list<u8>, get-mapped-range-error>;
138
108
  unmap: func() -> result<_, unmap-error>;
139
109
  destroy: func();
@@ -141,188 +111,100 @@ interface webgpu {
141
111
  set-label: func(label: string);
142
112
  get-mapped-range-set-with-copy: func(data: list<u8>, offset: option<gpu-size64>, size: option<gpu-size64>) -> result<_, get-mapped-range-error>;
143
113
  }
114
+
115
+ enum gpu-buffer-binding-type {
116
+ uniform,
117
+ storage,
118
+ read-only-storage,
119
+ }
120
+
121
+ type gpu-buffer-dynamic-offset = u32;
122
+
144
123
  enum gpu-buffer-map-state {
145
124
  unmapped,
146
125
  pending,
147
126
  mapped,
148
127
  }
149
- type gpu-buffer-usage-flags = u32;
150
- resource gpu-buffer-usage {
151
- MAP-READ: static func() -> gpu-flags-constant;
152
- MAP-WRITE: static func() -> gpu-flags-constant;
153
- COPY-SRC: static func() -> gpu-flags-constant;
154
- COPY-DST: static func() -> gpu-flags-constant;
155
- INDEX: static func() -> gpu-flags-constant;
156
- VERTEX: static func() -> gpu-flags-constant;
157
- UNIFORM: static func() -> gpu-flags-constant;
158
- STORAGE: static func() -> gpu-flags-constant;
159
- INDIRECT: static func() -> gpu-flags-constant;
160
- QUERY-RESOLVE: static func() -> gpu-flags-constant;
161
- }
162
- type gpu-map-mode-flags = u32;
163
- resource gpu-map-mode {
164
- READ: static func() -> gpu-flags-constant;
165
- WRITE: static func() -> gpu-flags-constant;
128
+
129
+ flags gpu-buffer-usage {
130
+ map-read,
131
+ map-write,
132
+ copy-src,
133
+ copy-dst,
134
+ index,
135
+ vertex,
136
+ uniform,
137
+ storage,
138
+ indirect,
139
+ query-resolve,
166
140
  }
167
- resource gpu-texture {
168
- create-view: func(descriptor: option<gpu-texture-view-descriptor>) -> gpu-texture-view;
169
- destroy: func();
170
- width: func() -> gpu-integer-coordinate-out;
171
- height: func() -> gpu-integer-coordinate-out;
172
- depth-or-array-layers: func() -> gpu-integer-coordinate-out;
173
- mip-level-count: func() -> gpu-integer-coordinate-out;
174
- sample-count: func() -> gpu-size32-out;
175
- dimension: func() -> gpu-texture-dimension;
176
- format: func() -> gpu-texture-format;
177
- usage: func() -> gpu-flags-constant;
178
- label: func() -> string;
179
- set-label: func(label: string);
180
- from-graphics-buffer: static func(buffer: abstract-buffer) -> gpu-texture;
141
+
142
+ enum gpu-canvas-alpha-mode {
143
+ opaque,
144
+ premultiplied,
181
145
  }
182
- enum gpu-texture-dimension {
183
- d1,
184
- d2,
185
- d3,
146
+
147
+ resource gpu-canvas-context {
148
+ configure: func(configuration: gpu-canvas-configuration);
149
+ unconfigure: func();
150
+ get-configuration: func() -> option<gpu-canvas-configuration-owned>;
151
+ get-current-texture: func() -> gpu-texture;
186
152
  }
187
- type gpu-texture-usage-flags = u32;
188
- resource gpu-texture-usage {
189
- COPY-SRC: static func() -> gpu-flags-constant;
190
- COPY-DST: static func() -> gpu-flags-constant;
191
- TEXTURE-BINDING: static func() -> gpu-flags-constant;
192
- STORAGE-BINDING: static func() -> gpu-flags-constant;
193
- RENDER-ATTACHMENT: static func() -> gpu-flags-constant;
153
+
154
+ enum gpu-canvas-tone-mapping-mode {
155
+ standard,
156
+ extended,
194
157
  }
195
- resource gpu-texture-view {
196
- label: func() -> string;
197
- set-label: func(label: string);
158
+
159
+ record gpu-canvas-tone-mapping {
160
+ mode: option<gpu-canvas-tone-mapping-mode>,
198
161
  }
199
- enum gpu-texture-view-dimension {
200
- d1,
201
- d2,
202
- d2-array,
203
- cube,
204
- cube-array,
205
- d3,
162
+
163
+ record gpu-color {
164
+ r: f64,
165
+ g: f64,
166
+ b: f64,
167
+ a: f64,
206
168
  }
207
- enum gpu-texture-aspect {
169
+
170
+ flags gpu-color-write {
171
+ red,
172
+ green,
173
+ blue,
174
+ alpha,
208
175
  all,
209
- stencil-only,
210
- depth-only,
211
176
  }
212
- enum gpu-texture-format {
213
- r8unorm,
214
- r8snorm,
215
- r8uint,
216
- r8sint,
217
- r16uint,
218
- r16sint,
219
- r16float,
220
- rg8unorm,
221
- rg8snorm,
222
- rg8uint,
223
- rg8sint,
224
- r32uint,
225
- r32sint,
226
- r32float,
227
- rg16uint,
228
- rg16sint,
229
- rg16float,
230
- rgba8unorm,
231
- rgba8unorm-srgb,
232
- rgba8snorm,
233
- rgba8uint,
234
- rgba8sint,
235
- bgra8unorm,
236
- bgra8unorm-srgb,
237
- rgb9e5ufloat,
238
- rgb10a2uint,
239
- rgb10a2unorm,
240
- rg11b10ufloat,
241
- rg32uint,
242
- rg32sint,
243
- rg32float,
244
- rgba16uint,
245
- rgba16sint,
246
- rgba16float,
247
- rgba32uint,
248
- rgba32sint,
249
- rgba32float,
250
- stencil8,
251
- depth16unorm,
252
- depth24plus,
253
- depth24plus-stencil8,
254
- depth32float,
255
- depth32float-stencil8,
256
- bc1-rgba-unorm,
257
- bc1-rgba-unorm-srgb,
258
- bc2-rgba-unorm,
259
- bc2-rgba-unorm-srgb,
260
- bc3-rgba-unorm,
261
- bc3-rgba-unorm-srgb,
262
- bc4-r-unorm,
263
- bc4-r-snorm,
264
- bc5-rg-unorm,
265
- bc5-rg-snorm,
266
- bc6h-rgb-ufloat,
267
- bc6h-rgb-float,
268
- bc7-rgba-unorm,
269
- bc7-rgba-unorm-srgb,
270
- etc2-rgb8unorm,
271
- etc2-rgb8unorm-srgb,
272
- etc2-rgb8a1unorm,
273
- etc2-rgb8a1unorm-srgb,
274
- etc2-rgba8unorm,
275
- etc2-rgba8unorm-srgb,
276
- eac-r11unorm,
277
- eac-r11snorm,
278
- eac-rg11unorm,
279
- eac-rg11snorm,
280
- astc4x4-unorm,
281
- astc4x4-unorm-srgb,
282
- astc5x4-unorm,
283
- astc5x4-unorm-srgb,
284
- astc5x5-unorm,
285
- astc5x5-unorm-srgb,
286
- astc6x5-unorm,
287
- astc6x5-unorm-srgb,
288
- astc6x6-unorm,
289
- astc6x6-unorm-srgb,
290
- astc8x5-unorm,
291
- astc8x5-unorm-srgb,
292
- astc8x6-unorm,
293
- astc8x6-unorm-srgb,
294
- astc8x8-unorm,
295
- astc8x8-unorm-srgb,
296
- astc10x5-unorm,
297
- astc10x5-unorm-srgb,
298
- astc10x6-unorm,
299
- astc10x6-unorm-srgb,
300
- astc10x8-unorm,
301
- astc10x8-unorm-srgb,
302
- astc10x10-unorm,
303
- astc10x10-unorm-srgb,
304
- astc12x10-unorm,
305
- astc12x10-unorm-srgb,
306
- astc12x12-unorm,
307
- astc12x12-unorm-srgb,
308
- }
309
- resource gpu-sampler {
177
+
178
+ resource gpu-command-buffer {
310
179
  label: func() -> string;
311
180
  set-label: func(label: string);
312
181
  }
313
- enum gpu-address-mode {
314
- clamp-to-edge,
315
- repeat,
316
- mirror-repeat,
182
+
183
+ record gpu-command-buffer-descriptor {
184
+ label: option<string>,
317
185
  }
318
- enum gpu-filter-mode {
319
- nearest,
320
- linear,
186
+
187
+ resource gpu-command-encoder {
188
+ begin-render-pass: func(descriptor: gpu-render-pass-descriptor) -> gpu-render-pass-encoder;
189
+ begin-compute-pass: func(descriptor: option<gpu-compute-pass-descriptor>) -> gpu-compute-pass-encoder;
190
+ copy-buffer-to-buffer: func(source: borrow<gpu-buffer>, source-offset: option<gpu-size64>, destination: borrow<gpu-buffer>, destination-offset: option<gpu-size64>, size: option<gpu-size64>);
191
+ copy-buffer-to-texture: func(source: gpu-texel-copy-buffer-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d);
192
+ copy-texture-to-buffer: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-buffer-info, copy-size: gpu-extent3-d);
193
+ copy-texture-to-texture: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d);
194
+ clear-buffer: func(buffer: borrow<gpu-buffer>, offset: option<gpu-size64>, size: option<gpu-size64>);
195
+ resolve-query-set: func(query-set: borrow<gpu-query-set>, first-query: gpu-size32, query-count: gpu-size32, destination: borrow<gpu-buffer>, destination-offset: gpu-size64);
196
+ finish: func(descriptor: option<gpu-command-buffer-descriptor>) -> gpu-command-buffer;
197
+ label: func() -> string;
198
+ set-label: func(label: string);
199
+ push-debug-group: func(group-label: string);
200
+ pop-debug-group: func();
201
+ insert-debug-marker: func(marker-label: string);
321
202
  }
322
- enum gpu-mipmap-filter-mode {
323
- nearest,
324
- linear,
203
+
204
+ record gpu-command-encoder-descriptor {
205
+ label: option<string>,
325
206
  }
207
+
326
208
  enum gpu-compare-function {
327
209
  never,
328
210
  less,
@@ -333,86 +215,11 @@ interface webgpu {
333
215
  greater-equal,
334
216
  always,
335
217
  }
336
- record gpu-sampler-descriptor {
337
- address-mode-u: option<gpu-address-mode>,
338
- address-mode-v: option<gpu-address-mode>,
339
- address-mode-w: option<gpu-address-mode>,
340
- mag-filter: option<gpu-filter-mode>,
341
- min-filter: option<gpu-filter-mode>,
342
- mipmap-filter: option<gpu-mipmap-filter-mode>,
343
- lod-min-clamp: option<f32>,
344
- lod-max-clamp: option<f32>,
345
- compare: option<gpu-compare-function>,
346
- max-anisotropy: option<u16>,
347
- label: option<string>,
348
- }
349
- resource gpu-bind-group-layout {
350
- label: func() -> string;
351
- set-label: func(label: string);
352
- }
353
- type gpu-shader-stage-flags = u32;
354
- resource gpu-shader-stage {
355
- VERTEX: static func() -> gpu-flags-constant;
356
- FRAGMENT: static func() -> gpu-flags-constant;
357
- COMPUTE: static func() -> gpu-flags-constant;
358
- }
359
- enum gpu-buffer-binding-type {
360
- uniform,
361
- storage,
362
- read-only-storage,
363
- }
364
- enum gpu-sampler-binding-type {
365
- filtering,
366
- non-filtering,
367
- comparison,
368
- }
369
- record gpu-sampler-binding-layout {
370
- %type: option<gpu-sampler-binding-type>,
371
- }
372
- enum gpu-texture-sample-type {
373
- float,
374
- unfilterable-float,
375
- depth,
376
- sint,
377
- uint,
378
- }
379
- record gpu-texture-binding-layout {
380
- sample-type: option<gpu-texture-sample-type>,
381
- view-dimension: option<gpu-texture-view-dimension>,
382
- multisampled: option<bool>,
383
- }
384
- enum gpu-storage-texture-access {
385
- write-only,
386
- read-only,
387
- read-write,
388
- }
389
- record gpu-storage-texture-binding-layout {
390
- access: option<gpu-storage-texture-access>,
391
- format: gpu-texture-format,
392
- view-dimension: option<gpu-texture-view-dimension>,
393
- }
394
- resource gpu-bind-group {
395
- label: func() -> string;
396
- set-label: func(label: string);
397
- }
398
- resource gpu-pipeline-layout {
399
- label: func() -> string;
400
- set-label: func(label: string);
401
- }
402
- record gpu-pipeline-layout-descriptor {
403
- bind-group-layouts: list<option<borrow<gpu-bind-group-layout>>>,
404
- label: option<string>,
405
- }
406
- resource gpu-shader-module {
407
- get-compilation-info: func() -> gpu-compilation-info;
408
- label: func() -> string;
409
- set-label: func(label: string);
410
- }
411
- enum gpu-compilation-message-type {
412
- error,
413
- warning,
414
- info,
218
+
219
+ resource gpu-compilation-info {
220
+ messages: func() -> list<gpu-compilation-message>;
415
221
  }
222
+
416
223
  resource gpu-compilation-message {
417
224
  message: func() -> string;
418
225
  %type: func() -> gpu-compilation-message-type;
@@ -421,239 +228,269 @@ interface webgpu {
421
228
  offset: func() -> u64;
422
229
  length: func() -> u64;
423
230
  }
424
- resource gpu-compilation-info {
425
- messages: func() -> list<gpu-compilation-message>;
426
- }
427
- enum gpu-pipeline-error-reason {
428
- validation,
429
- internal,
430
- }
431
- variant gpu-layout-mode {
432
- specific(borrow<gpu-pipeline-layout>),
433
- auto,
434
- }
435
- record gpu-shader-module-compilation-hint {
436
- entry-point: string,
437
- layout: option<gpu-layout-mode>,
438
- }
439
- record gpu-shader-module-descriptor {
440
- code: string,
441
- compilation-hints: option<list<gpu-shader-module-compilation-hint>>,
442
- label: option<string>,
443
- }
444
- resource record-gpu-pipeline-constant-value {
445
- constructor();
446
- add: func(key: string, value: gpu-pipeline-constant-value);
447
- get: func(key: string) -> option<gpu-pipeline-constant-value>;
448
- has: func(key: string) -> bool;
449
- remove: func(key: string);
450
- keys: func() -> list<string>;
451
- values: func() -> list<gpu-pipeline-constant-value>;
452
- entries: func() -> list<tuple<string, gpu-pipeline-constant-value>>;
453
- }
454
- record gpu-programmable-stage {
455
- module: borrow<gpu-shader-module>,
456
- entry-point: option<string>,
457
- constants: option<record-gpu-pipeline-constant-value>,
231
+
232
+ enum gpu-compilation-message-type {
233
+ error,
234
+ warning,
235
+ info,
458
236
  }
459
- type gpu-pipeline-constant-value = f64;
460
- resource gpu-compute-pipeline {
237
+
238
+ resource gpu-compute-pass-encoder {
239
+ set-pipeline: func(pipeline: borrow<gpu-compute-pipeline>);
240
+ dispatch-workgroups: func(workgroup-count-x: gpu-size32, workgroup-count-y: option<gpu-size32>, workgroup-count-z: option<gpu-size32>);
241
+ dispatch-workgroups-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
242
+ end: func();
461
243
  label: func() -> string;
462
244
  set-label: func(label: string);
463
- get-bind-group-layout: func(index: u32) -> gpu-bind-group-layout;
464
- }
465
- record gpu-compute-pipeline-descriptor {
466
- compute: gpu-programmable-stage,
467
- layout: gpu-layout-mode,
468
- label: option<string>,
245
+ push-debug-group: func(group-label: string);
246
+ pop-debug-group: func();
247
+ insert-debug-marker: func(marker-label: string);
248
+ set-bind-group: func(index: gpu-index32, bind-group: option<borrow<gpu-bind-group>>, dynamic-offsets-data: option<list<gpu-buffer-dynamic-offset>>, dynamic-offsets-data-start: option<gpu-size64>, dynamic-offsets-data-length: option<gpu-size32>) -> result<_, set-bind-group-error>;
249
+ set-immediates: func(range-offset: gpu-size32, data: list<u8>, data-offset: option<gpu-size64>, data-size: option<gpu-size64>);
469
250
  }
470
- resource gpu-render-pipeline {
251
+
252
+ resource gpu-compute-pipeline {
471
253
  label: func() -> string;
472
254
  set-label: func(label: string);
473
255
  get-bind-group-layout: func(index: u32) -> gpu-bind-group-layout;
474
256
  }
475
- enum gpu-primitive-topology {
476
- point-list,
477
- line-list,
478
- line-strip,
479
- triangle-list,
480
- triangle-strip,
481
- }
482
- enum gpu-front-face {
483
- ccw,
484
- cw,
485
- }
257
+
486
258
  enum gpu-cull-mode {
487
259
  none,
488
260
  front,
489
261
  back,
490
262
  }
491
- type gpu-color-write-flags = u32;
492
- resource gpu-color-write {
493
- RED: static func() -> gpu-flags-constant;
494
- GREEN: static func() -> gpu-flags-constant;
495
- BLUE: static func() -> gpu-flags-constant;
496
- ALPHA: static func() -> gpu-flags-constant;
497
- ALL: static func() -> gpu-flags-constant;
263
+
264
+ type gpu-depth-bias = s32;
265
+
266
+ resource gpu-device {
267
+ features: func() -> gpu-supported-features;
268
+ limits: func() -> gpu-supported-limits;
269
+ adapter-info: func() -> gpu-adapter-info;
270
+ queue: func() -> gpu-queue;
271
+ destroy: func();
272
+ create-buffer: func(descriptor: gpu-buffer-descriptor) -> gpu-buffer;
273
+ create-texture: func(descriptor: gpu-texture-descriptor) -> gpu-texture;
274
+ create-sampler: func(descriptor: option<gpu-sampler-descriptor>) -> gpu-sampler;
275
+ create-bind-group-layout: func(descriptor: gpu-bind-group-layout-descriptor) -> gpu-bind-group-layout;
276
+ create-pipeline-layout: func(descriptor: gpu-pipeline-layout-descriptor) -> gpu-pipeline-layout;
277
+ create-bind-group: func(descriptor: gpu-bind-group-descriptor) -> gpu-bind-group;
278
+ create-shader-module: func(descriptor: gpu-shader-module-descriptor) -> gpu-shader-module;
279
+ create-compute-pipeline: func(descriptor: gpu-compute-pipeline-descriptor) -> gpu-compute-pipeline;
280
+ create-render-pipeline: func(descriptor: gpu-render-pipeline-descriptor) -> gpu-render-pipeline;
281
+ create-compute-pipeline-async: async func(descriptor: gpu-compute-pipeline-descriptor) -> result<gpu-compute-pipeline, create-pipeline-error>;
282
+ create-render-pipeline-async: async func(descriptor: gpu-render-pipeline-descriptor) -> result<gpu-render-pipeline, create-pipeline-error>;
283
+ create-command-encoder: func(descriptor: option<gpu-command-encoder-descriptor>) -> gpu-command-encoder;
284
+ create-render-bundle-encoder: func(descriptor: gpu-render-bundle-encoder-descriptor) -> gpu-render-bundle-encoder;
285
+ create-query-set: func(descriptor: gpu-query-set-descriptor) -> result<gpu-query-set, create-query-set-error>;
286
+ label: func() -> string;
287
+ set-label: func(label: string);
288
+ lost: func() -> future<gpu-device-lost-info>;
289
+ push-error-scope: func(filter: gpu-error-filter);
290
+ pop-error-scope: async func() -> result<option<gpu-error>, pop-error-scope-error>;
291
+ on-uncaptured-error: func() -> stream<gpu-error>;
498
292
  }
499
- enum gpu-blend-factor {
500
- zero,
501
- one,
502
- src,
503
- one-minus-src,
504
- src-alpha,
505
- one-minus-src-alpha,
506
- dst,
507
- one-minus-dst,
508
- dst-alpha,
509
- one-minus-dst-alpha,
510
- src-alpha-saturated,
511
- constant,
512
- one-minus-constant,
513
- src1,
514
- one-minus-src1,
515
- src1-alpha,
516
- one-minus-src1-alpha,
293
+
294
+ resource gpu-device-lost-info {
295
+ reason: func() -> gpu-device-lost-reason;
296
+ message: func() -> string;
517
297
  }
518
- enum gpu-blend-operation {
519
- add,
520
- subtract,
521
- reverse-subtract,
522
- min,
523
- max,
298
+
299
+ enum gpu-device-lost-reason {
300
+ unknown,
301
+ destroyed,
524
302
  }
525
- record gpu-blend-component {
526
- operation: option<gpu-blend-operation>,
527
- src-factor: option<gpu-blend-factor>,
528
- dst-factor: option<gpu-blend-factor>,
303
+
304
+ resource gpu-error {
305
+ message: func() -> string;
306
+ kind: func() -> gpu-error-kind;
529
307
  }
530
- record gpu-blend-state {
531
- color: gpu-blend-component,
532
- alpha: gpu-blend-component,
308
+
309
+ enum gpu-error-filter {
310
+ validation,
311
+ out-of-memory,
312
+ internal,
533
313
  }
534
- record gpu-color-target-state {
535
- format: gpu-texture-format,
536
- blend: option<gpu-blend-state>,
537
- write-mask: option<gpu-color-write-flags>,
314
+
315
+ variant gpu-error-kind {
316
+ validation-error,
317
+ out-of-memory-error,
318
+ internal-error,
538
319
  }
539
- record gpu-fragment-state {
540
- targets: list<option<gpu-color-target-state>>,
541
- module: borrow<gpu-shader-module>,
542
- entry-point: option<string>,
543
- constants: option<record-gpu-pipeline-constant-value>,
320
+
321
+ enum gpu-feature-name {
322
+ core-features-and-limits,
323
+ depth-clip-control,
324
+ depth32float-stencil8,
325
+ texture-compression-bc,
326
+ texture-compression-bc-sliced3d,
327
+ texture-compression-etc2,
328
+ texture-compression-astc,
329
+ texture-compression-astc-sliced3d,
330
+ timestamp-query,
331
+ indirect-first-instance,
332
+ shader-f16,
333
+ rg11b10ufloat-renderable,
334
+ bgra8unorm-storage,
335
+ float32-filterable,
336
+ float32-blendable,
337
+ clip-distances,
338
+ dual-source-blending,
339
+ subgroups,
340
+ texture-formats-tier1,
341
+ texture-formats-tier2,
342
+ primitive-index,
343
+ texture-component-swizzle,
544
344
  }
545
- enum gpu-stencil-operation {
546
- keep,
547
- zero,
548
- replace,
549
- invert,
550
- increment-clamp,
551
- decrement-clamp,
552
- increment-wrap,
553
- decrement-wrap,
345
+
346
+ enum gpu-filter-mode {
347
+ nearest,
348
+ linear,
554
349
  }
555
- record gpu-stencil-face-state {
556
- compare: option<gpu-compare-function>,
557
- fail-op: option<gpu-stencil-operation>,
558
- depth-fail-op: option<gpu-stencil-operation>,
559
- pass-op: option<gpu-stencil-operation>,
350
+
351
+ enum gpu-front-face {
352
+ ccw,
353
+ cw,
560
354
  }
355
+
561
356
  enum gpu-index-format {
562
357
  uint16,
563
358
  uint32,
564
359
  }
565
- record gpu-primitive-state {
566
- topology: option<gpu-primitive-topology>,
567
- strip-index-format: option<gpu-index-format>,
568
- front-face: option<gpu-front-face>,
569
- cull-mode: option<gpu-cull-mode>,
570
- unclipped-depth: option<bool>,
360
+
361
+ type gpu-index32 = u32;
362
+
363
+ type gpu-integer-coordinate = u32;
364
+
365
+ record gpu-extent3-d {
366
+ width: gpu-integer-coordinate,
367
+ height: option<gpu-integer-coordinate>,
368
+ depth-or-array-layers: option<gpu-integer-coordinate>,
571
369
  }
572
- enum gpu-vertex-format {
573
- uint8,
574
- uint8x2,
575
- uint8x4,
576
- sint8,
577
- sint8x2,
578
- sint8x4,
579
- unorm8,
580
- unorm8x2,
581
- unorm8x4,
582
- snorm8,
583
- snorm8x2,
584
- snorm8x4,
585
- uint16,
586
- uint16x2,
587
- uint16x4,
588
- sint16,
589
- sint16x2,
590
- sint16x4,
591
- unorm16,
592
- unorm16x2,
593
- unorm16x4,
594
- snorm16,
595
- snorm16x2,
596
- snorm16x4,
597
- float16,
598
- float16x2,
599
- float16x4,
600
- float32,
601
- float32x2,
602
- float32x3,
603
- float32x4,
604
- uint32,
605
- uint32x2,
606
- uint32x3,
607
- uint32x4,
608
- sint32,
609
- sint32x2,
610
- sint32x3,
611
- sint32x4,
612
- unorm1010102,
613
- unorm8x4-bgra,
370
+
371
+ type gpu-integer-coordinate-out = u32;
372
+
373
+ enum gpu-load-op {
374
+ load,
375
+ clear,
614
376
  }
615
- enum gpu-vertex-step-mode {
616
- vertex,
617
- instance,
377
+
378
+ flags gpu-map-mode {
379
+ read,
380
+ write,
618
381
  }
619
- resource gpu-command-buffer {
620
- label: func() -> string;
621
- set-label: func(label: string);
382
+
383
+ enum gpu-mipmap-filter-mode {
384
+ nearest,
385
+ linear,
622
386
  }
623
- record gpu-command-buffer-descriptor {
624
- label: option<string>,
387
+
388
+ record gpu-origin3-d {
389
+ x: option<gpu-integer-coordinate>,
390
+ y: option<gpu-integer-coordinate>,
391
+ z: option<gpu-integer-coordinate>,
625
392
  }
626
- resource gpu-command-encoder {
627
- begin-render-pass: func(descriptor: gpu-render-pass-descriptor) -> gpu-render-pass-encoder;
628
- begin-compute-pass: func(descriptor: option<gpu-compute-pass-descriptor>) -> gpu-compute-pass-encoder;
629
- copy-buffer-to-buffer: func(source: borrow<gpu-buffer>, source-offset: gpu-size64, destination: borrow<gpu-buffer>, destination-offset: gpu-size64, size: gpu-size64);
630
- copy-buffer-to-texture: func(source: gpu-texel-copy-buffer-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d);
631
- copy-texture-to-buffer: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-buffer-info, copy-size: gpu-extent3-d);
632
- copy-texture-to-texture: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d);
633
- clear-buffer: func(buffer: borrow<gpu-buffer>, offset: option<gpu-size64>, size: option<gpu-size64>);
634
- resolve-query-set: func(query-set: borrow<gpu-query-set>, first-query: gpu-size32, query-count: gpu-size32, destination: borrow<gpu-buffer>, destination-offset: gpu-size64);
635
- finish: func(descriptor: option<gpu-command-buffer-descriptor>) -> gpu-command-buffer;
636
- label: func() -> string;
637
- set-label: func(label: string);
638
- push-debug-group: func(group-label: string);
639
- pop-debug-group: func();
640
- insert-debug-marker: func(marker-label: string);
393
+
394
+ type gpu-pipeline-constant-value = f64;
395
+
396
+ enum gpu-pipeline-error-reason {
397
+ validation,
398
+ internal,
641
399
  }
642
- record gpu-command-encoder-descriptor {
643
- label: option<string>,
400
+
401
+ variant create-pipeline-error-kind {
402
+ gpu-pipeline-error(gpu-pipeline-error-reason),
644
403
  }
645
- resource gpu-compute-pass-encoder {
646
- set-pipeline: func(pipeline: borrow<gpu-compute-pipeline>);
647
- dispatch-workgroups: func(workgroup-count-x: gpu-size32, workgroup-count-y: option<gpu-size32>, workgroup-count-z: option<gpu-size32>);
648
- dispatch-workgroups-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
649
- end: func();
404
+
405
+ record create-pipeline-error {
406
+ kind: create-pipeline-error-kind,
407
+ message: string,
408
+ }
409
+
410
+ resource gpu-pipeline-layout {
650
411
  label: func() -> string;
651
412
  set-label: func(label: string);
652
- push-debug-group: func(group-label: string);
413
+ }
414
+
415
+ variant gpu-layout-mode {
416
+ specific(borrow<gpu-pipeline-layout>),
417
+ auto,
418
+ }
419
+
420
+ enum gpu-power-preference {
421
+ low-power,
422
+ high-performance,
423
+ }
424
+
425
+ enum gpu-primitive-topology {
426
+ point-list,
427
+ line-list,
428
+ line-strip,
429
+ triangle-list,
430
+ triangle-strip,
431
+ }
432
+
433
+ record gpu-primitive-state {
434
+ topology: option<gpu-primitive-topology>,
435
+ strip-index-format: option<gpu-index-format>,
436
+ front-face: option<gpu-front-face>,
437
+ cull-mode: option<gpu-cull-mode>,
438
+ unclipped-depth: option<bool>,
439
+ }
440
+
441
+ resource gpu-query-set {
442
+ destroy: func();
443
+ %type: func() -> gpu-query-type;
444
+ count: func() -> gpu-size32-out;
445
+ label: func() -> string;
446
+ set-label: func(label: string);
447
+ }
448
+
449
+ enum gpu-query-type {
450
+ occlusion,
451
+ timestamp,
452
+ }
453
+
454
+ resource gpu-queue {
455
+ submit: func(command-buffers: list<borrow<gpu-command-buffer>>);
456
+ on-submitted-work-done: async func();
457
+ write-buffer-with-copy: func(buffer: borrow<gpu-buffer>, buffer-offset: gpu-size64, data: list<u8>, data-offset: option<gpu-size64>, size: option<gpu-size64>) -> result<_, write-buffer-error>;
458
+ write-texture-with-copy: func(destination: gpu-texel-copy-texture-info, data: list<u8>, data-layout: gpu-texel-copy-buffer-layout, size: gpu-extent3-d);
459
+ label: func() -> string;
460
+ set-label: func(label: string);
461
+ }
462
+
463
+ record gpu-queue-descriptor {
464
+ label: option<string>,
465
+ }
466
+
467
+ resource gpu-render-bundle {
468
+ label: func() -> string;
469
+ set-label: func(label: string);
470
+ }
471
+
472
+ record gpu-render-bundle-descriptor {
473
+ label: option<string>,
474
+ }
475
+
476
+ resource gpu-render-bundle-encoder {
477
+ finish: func(descriptor: option<gpu-render-bundle-descriptor>) -> gpu-render-bundle;
478
+ label: func() -> string;
479
+ set-label: func(label: string);
480
+ push-debug-group: func(group-label: string);
653
481
  pop-debug-group: func();
654
482
  insert-debug-marker: func(marker-label: string);
655
483
  set-bind-group: func(index: gpu-index32, bind-group: option<borrow<gpu-bind-group>>, dynamic-offsets-data: option<list<gpu-buffer-dynamic-offset>>, dynamic-offsets-data-start: option<gpu-size64>, dynamic-offsets-data-length: option<gpu-size32>) -> result<_, set-bind-group-error>;
484
+ set-immediates: func(range-offset: gpu-size32, data: list<u8>, data-offset: option<gpu-size64>, data-size: option<gpu-size64>);
485
+ set-pipeline: func(pipeline: borrow<gpu-render-pipeline>);
486
+ set-index-buffer: func(buffer: borrow<gpu-buffer>, index-format: gpu-index-format, offset: option<gpu-size64>, size: option<gpu-size64>);
487
+ set-vertex-buffer: func(slot: gpu-index32, buffer: option<borrow<gpu-buffer>>, offset: option<gpu-size64>, size: option<gpu-size64>);
488
+ draw: func(vertex-count: gpu-size32, instance-count: option<gpu-size32>, first-vertex: option<gpu-size32>, first-instance: option<gpu-size32>);
489
+ draw-indexed: func(index-count: gpu-size32, instance-count: option<gpu-size32>, first-index: option<gpu-size32>, base-vertex: option<gpu-signed-offset32>, first-instance: option<gpu-size32>);
490
+ draw-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
491
+ draw-indexed-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
656
492
  }
493
+
657
494
  resource gpu-render-pass-encoder {
658
495
  set-viewport: func(x: f32, y: f32, width: f32, height: f32, min-depth: f32, max-depth: f32);
659
496
  set-scissor-rect: func(x: gpu-integer-coordinate, y: gpu-integer-coordinate, width: gpu-integer-coordinate, height: gpu-integer-coordinate);
@@ -669,6 +506,7 @@ interface webgpu {
669
506
  pop-debug-group: func();
670
507
  insert-debug-marker: func(marker-label: string);
671
508
  set-bind-group: func(index: gpu-index32, bind-group: option<borrow<gpu-bind-group>>, dynamic-offsets-data: option<list<gpu-buffer-dynamic-offset>>, dynamic-offsets-data-start: option<gpu-size64>, dynamic-offsets-data-length: option<gpu-size32>) -> result<_, set-bind-group-error>;
509
+ set-immediates: func(range-offset: gpu-size32, data: list<u8>, data-offset: option<gpu-size64>, data-size: option<gpu-size64>);
672
510
  set-pipeline: func(pipeline: borrow<gpu-render-pipeline>);
673
511
  set-index-buffer: func(buffer: borrow<gpu-buffer>, index-format: gpu-index-format, offset: option<gpu-size64>, size: option<gpu-size64>);
674
512
  set-vertex-buffer: func(slot: gpu-index32, buffer: option<borrow<gpu-buffer>>, offset: option<gpu-size64>, size: option<gpu-size64>);
@@ -677,126 +515,370 @@ interface webgpu {
677
515
  draw-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
678
516
  draw-indexed-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
679
517
  }
680
- enum gpu-load-op {
681
- load,
682
- clear,
518
+
519
+ resource gpu-render-pipeline {
520
+ label: func() -> string;
521
+ set-label: func(label: string);
522
+ get-bind-group-layout: func(index: u32) -> gpu-bind-group-layout;
683
523
  }
684
- enum gpu-store-op {
685
- store,
686
- discard,
524
+
525
+ record gpu-request-adapter-options {
526
+ feature-level: option<string>,
527
+ power-preference: option<gpu-power-preference>,
528
+ force-fallback-adapter: option<bool>,
529
+ xr-compatible: option<bool>,
687
530
  }
688
- resource gpu-render-bundle {
531
+
532
+ type gpu-sample-mask = u32;
533
+
534
+ resource gpu-sampler {
689
535
  label: func() -> string;
690
536
  set-label: func(label: string);
691
537
  }
692
- record gpu-render-bundle-descriptor {
538
+
539
+ enum gpu-sampler-binding-type {
540
+ filtering,
541
+ non-filtering,
542
+ comparison,
543
+ }
544
+
545
+ record gpu-sampler-binding-layout {
546
+ %type: option<gpu-sampler-binding-type>,
547
+ }
548
+
549
+ record gpu-sampler-descriptor {
550
+ address-mode-u: option<gpu-address-mode>,
551
+ address-mode-v: option<gpu-address-mode>,
552
+ address-mode-w: option<gpu-address-mode>,
553
+ mag-filter: option<gpu-filter-mode>,
554
+ min-filter: option<gpu-filter-mode>,
555
+ mipmap-filter: option<gpu-mipmap-filter-mode>,
556
+ lod-min-clamp: option<f32>,
557
+ lod-max-clamp: option<f32>,
558
+ compare: option<gpu-compare-function>,
559
+ max-anisotropy: option<u16>,
693
560
  label: option<string>,
694
561
  }
695
- resource gpu-render-bundle-encoder {
696
- finish: func(descriptor: option<gpu-render-bundle-descriptor>) -> gpu-render-bundle;
562
+
563
+ resource gpu-shader-module {
564
+ get-compilation-info: async func() -> gpu-compilation-info;
697
565
  label: func() -> string;
698
566
  set-label: func(label: string);
699
- push-debug-group: func(group-label: string);
700
- pop-debug-group: func();
701
- insert-debug-marker: func(marker-label: string);
702
- set-bind-group: func(index: gpu-index32, bind-group: option<borrow<gpu-bind-group>>, dynamic-offsets-data: option<list<gpu-buffer-dynamic-offset>>, dynamic-offsets-data-start: option<gpu-size64>, dynamic-offsets-data-length: option<gpu-size32>) -> result<_, set-bind-group-error>;
703
- set-pipeline: func(pipeline: borrow<gpu-render-pipeline>);
704
- set-index-buffer: func(buffer: borrow<gpu-buffer>, index-format: gpu-index-format, offset: option<gpu-size64>, size: option<gpu-size64>);
705
- set-vertex-buffer: func(slot: gpu-index32, buffer: option<borrow<gpu-buffer>>, offset: option<gpu-size64>, size: option<gpu-size64>);
706
- draw: func(vertex-count: gpu-size32, instance-count: option<gpu-size32>, first-vertex: option<gpu-size32>, first-instance: option<gpu-size32>);
707
- draw-indexed: func(index-count: gpu-size32, instance-count: option<gpu-size32>, first-index: option<gpu-size32>, base-vertex: option<gpu-signed-offset32>, first-instance: option<gpu-size32>);
708
- draw-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
709
- draw-indexed-indirect: func(indirect-buffer: borrow<gpu-buffer>, indirect-offset: gpu-size64);
710
567
  }
711
- record gpu-queue-descriptor {
568
+
569
+ record gpu-shader-module-compilation-hint {
570
+ entry-point: string,
571
+ layout: option<gpu-layout-mode>,
572
+ }
573
+
574
+ record gpu-shader-module-descriptor {
575
+ code: string,
576
+ compilation-hints: option<list<gpu-shader-module-compilation-hint>>,
712
577
  label: option<string>,
713
578
  }
714
- record gpu-device-descriptor {
715
- required-features: option<list<gpu-feature-name>>,
716
- required-limits: option<record-option-gpu-size64>,
717
- default-queue: option<gpu-queue-descriptor>,
579
+
580
+ flags gpu-shader-stage {
581
+ vertex,
582
+ fragment,
583
+ compute,
584
+ }
585
+
586
+ type gpu-signed-offset32 = s32;
587
+
588
+ type gpu-size32 = u32;
589
+
590
+ record gpu-compute-pass-timestamp-writes {
591
+ query-set: borrow<gpu-query-set>,
592
+ beginning-of-pass-write-index: option<gpu-size32>,
593
+ end-of-pass-write-index: option<gpu-size32>,
594
+ }
595
+
596
+ record gpu-compute-pass-descriptor {
597
+ timestamp-writes: option<gpu-compute-pass-timestamp-writes>,
718
598
  label: option<string>,
719
599
  }
720
- resource gpu-queue {
721
- submit: func(command-buffers: list<borrow<gpu-command-buffer>>);
722
- on-submitted-work-done: func();
723
- write-buffer-with-copy: func(buffer: borrow<gpu-buffer>, buffer-offset: gpu-size64, data: list<u8>, data-offset: option<gpu-size64>, size: option<gpu-size64>) -> result<_, write-buffer-error>;
724
- write-texture-with-copy: func(destination: gpu-texel-copy-texture-info, data: list<u8>, data-layout: gpu-texel-copy-buffer-layout, size: gpu-extent3-d);
725
- label: func() -> string;
726
- set-label: func(label: string);
600
+
601
+ record gpu-multisample-state {
602
+ count: option<gpu-size32>,
603
+ mask: option<gpu-sample-mask>,
604
+ alpha-to-coverage-enabled: option<bool>,
727
605
  }
728
- resource gpu-query-set {
606
+
607
+ record gpu-pipeline-layout-descriptor {
608
+ bind-group-layouts: list<option<borrow<gpu-bind-group-layout>>>,
609
+ immediate-size: option<gpu-size32>,
610
+ label: option<string>,
611
+ }
612
+
613
+ record gpu-query-set-descriptor {
614
+ %type: gpu-query-type,
615
+ count: gpu-size32,
616
+ label: option<string>,
617
+ }
618
+
619
+ record gpu-render-pass-timestamp-writes {
620
+ query-set: borrow<gpu-query-set>,
621
+ beginning-of-pass-write-index: option<gpu-size32>,
622
+ end-of-pass-write-index: option<gpu-size32>,
623
+ }
624
+
625
+ type gpu-size32-out = u32;
626
+
627
+ type gpu-size64 = u64;
628
+
629
+ record gpu-buffer-binding {
630
+ buffer: borrow<gpu-buffer>,
631
+ offset: option<gpu-size64>,
632
+ size: option<gpu-size64>,
633
+ }
634
+
635
+ record gpu-buffer-binding-layout {
636
+ %type: option<gpu-buffer-binding-type>,
637
+ has-dynamic-offset: option<bool>,
638
+ min-binding-size: option<gpu-size64>,
639
+ }
640
+
641
+ record gpu-buffer-descriptor {
642
+ size: gpu-size64,
643
+ usage: gpu-buffer-usage,
644
+ mapped-at-creation: option<bool>,
645
+ label: option<string>,
646
+ }
647
+
648
+ type gpu-size64-out = u64;
649
+
650
+ enum gpu-stencil-operation {
651
+ keep,
652
+ zero,
653
+ replace,
654
+ invert,
655
+ increment-clamp,
656
+ decrement-clamp,
657
+ increment-wrap,
658
+ decrement-wrap,
659
+ }
660
+
661
+ record gpu-stencil-face-state {
662
+ compare: option<gpu-compare-function>,
663
+ fail-op: option<gpu-stencil-operation>,
664
+ depth-fail-op: option<gpu-stencil-operation>,
665
+ pass-op: option<gpu-stencil-operation>,
666
+ }
667
+
668
+ type gpu-stencil-value = u32;
669
+
670
+ enum gpu-storage-texture-access {
671
+ write-only,
672
+ read-only,
673
+ read-write,
674
+ }
675
+
676
+ enum gpu-store-op {
677
+ store,
678
+ discard,
679
+ }
680
+
681
+ resource gpu-supported-features {
682
+ has: func(value: string) -> bool;
683
+ }
684
+
685
+ resource gpu-supported-limits {
686
+ max-texture-dimension1-d: func() -> u32;
687
+ max-texture-dimension2-d: func() -> u32;
688
+ max-texture-dimension3-d: func() -> u32;
689
+ max-texture-array-layers: func() -> u32;
690
+ max-bind-groups: func() -> u32;
691
+ max-bind-groups-plus-vertex-buffers: func() -> u32;
692
+ max-immediate-size: func() -> u32;
693
+ max-bindings-per-bind-group: func() -> u32;
694
+ max-dynamic-uniform-buffers-per-pipeline-layout: func() -> u32;
695
+ max-dynamic-storage-buffers-per-pipeline-layout: func() -> u32;
696
+ max-sampled-textures-per-shader-stage: func() -> u32;
697
+ max-samplers-per-shader-stage: func() -> u32;
698
+ max-storage-buffers-per-shader-stage: func() -> u32;
699
+ max-storage-buffers-in-vertex-stage: func() -> u32;
700
+ max-storage-buffers-in-fragment-stage: func() -> u32;
701
+ max-storage-textures-per-shader-stage: func() -> u32;
702
+ max-storage-textures-in-vertex-stage: func() -> u32;
703
+ max-storage-textures-in-fragment-stage: func() -> u32;
704
+ max-uniform-buffers-per-shader-stage: func() -> u32;
705
+ max-uniform-buffer-binding-size: func() -> u64;
706
+ max-storage-buffer-binding-size: func() -> u64;
707
+ min-uniform-buffer-offset-alignment: func() -> u32;
708
+ min-storage-buffer-offset-alignment: func() -> u32;
709
+ max-vertex-buffers: func() -> u32;
710
+ max-buffer-size: func() -> u64;
711
+ max-vertex-attributes: func() -> u32;
712
+ max-vertex-buffer-array-stride: func() -> u32;
713
+ max-inter-stage-shader-variables: func() -> u32;
714
+ max-color-attachments: func() -> u32;
715
+ max-color-attachment-bytes-per-sample: func() -> u32;
716
+ max-compute-workgroup-storage-size: func() -> u32;
717
+ max-compute-invocations-per-workgroup: func() -> u32;
718
+ max-compute-workgroup-size-x: func() -> u32;
719
+ max-compute-workgroup-size-y: func() -> u32;
720
+ max-compute-workgroup-size-z: func() -> u32;
721
+ max-compute-workgroups-per-dimension: func() -> u32;
722
+ }
723
+
724
+ record gpu-texel-copy-buffer-info {
725
+ buffer: borrow<gpu-buffer>,
726
+ offset: option<gpu-size64>,
727
+ bytes-per-row: option<gpu-size32>,
728
+ rows-per-image: option<gpu-size32>,
729
+ }
730
+
731
+ record gpu-texel-copy-buffer-layout {
732
+ offset: option<gpu-size64>,
733
+ bytes-per-row: option<gpu-size32>,
734
+ rows-per-image: option<gpu-size32>,
735
+ }
736
+
737
+ resource gpu-texture {
738
+ create-view: func(descriptor: option<gpu-texture-view-descriptor>) -> gpu-texture-view;
729
739
  destroy: func();
730
- %type: func() -> gpu-query-type;
731
- count: func() -> gpu-size32-out;
740
+ width: func() -> gpu-integer-coordinate-out;
741
+ height: func() -> gpu-integer-coordinate-out;
742
+ depth-or-array-layers: func() -> gpu-integer-coordinate-out;
743
+ mip-level-count: func() -> gpu-integer-coordinate-out;
744
+ sample-count: func() -> gpu-size32-out;
745
+ dimension: func() -> gpu-texture-dimension;
746
+ format: func() -> gpu-texture-format;
747
+ usage: func() -> gpu-texture-usage;
748
+ texture-binding-view-dimension: func() -> option<gpu-texture-view-dimension>;
732
749
  label: func() -> string;
733
750
  set-label: func(label: string);
734
751
  }
735
- enum gpu-query-type {
736
- occlusion,
737
- timestamp,
738
- }
739
- resource gpu-canvas-context {
740
- configure: func(configuration: gpu-canvas-configuration);
741
- unconfigure: func();
742
- get-configuration: func() -> option<gpu-canvas-configuration-owned>;
743
- get-current-texture: func() -> gpu-texture;
752
+
753
+ enum gpu-texture-aspect {
754
+ all,
755
+ stencil-only,
756
+ depth-only,
744
757
  }
745
- enum gpu-canvas-alpha-mode {
746
- opaque,
747
- premultiplied,
758
+
759
+ record gpu-texel-copy-texture-info {
760
+ texture: borrow<gpu-texture>,
761
+ mip-level: option<gpu-integer-coordinate>,
762
+ origin: option<gpu-origin3-d>,
763
+ aspect: option<gpu-texture-aspect>,
748
764
  }
749
- enum gpu-canvas-tone-mapping-mode {
750
- standard,
751
- extended,
765
+
766
+ enum gpu-texture-dimension {
767
+ d1,
768
+ d2,
769
+ d3,
752
770
  }
753
- record gpu-canvas-tone-mapping {
754
- mode: option<gpu-canvas-tone-mapping-mode>,
771
+
772
+ enum gpu-texture-format {
773
+ r8unorm,
774
+ r8snorm,
775
+ r8uint,
776
+ r8sint,
777
+ r16unorm,
778
+ r16snorm,
779
+ r16uint,
780
+ r16sint,
781
+ r16float,
782
+ rg8unorm,
783
+ rg8snorm,
784
+ rg8uint,
785
+ rg8sint,
786
+ r32uint,
787
+ r32sint,
788
+ r32float,
789
+ rg16unorm,
790
+ rg16snorm,
791
+ rg16uint,
792
+ rg16sint,
793
+ rg16float,
794
+ rgba8unorm,
795
+ rgba8unorm-srgb,
796
+ rgba8snorm,
797
+ rgba8uint,
798
+ rgba8sint,
799
+ bgra8unorm,
800
+ bgra8unorm-srgb,
801
+ rgb9e5ufloat,
802
+ rgb10a2uint,
803
+ rgb10a2unorm,
804
+ rg11b10ufloat,
805
+ rg32uint,
806
+ rg32sint,
807
+ rg32float,
808
+ rgba16unorm,
809
+ rgba16snorm,
810
+ rgba16uint,
811
+ rgba16sint,
812
+ rgba16float,
813
+ rgba32uint,
814
+ rgba32sint,
815
+ rgba32float,
816
+ stencil8,
817
+ depth16unorm,
818
+ depth24plus,
819
+ depth24plus-stencil8,
820
+ depth32float,
821
+ depth32float-stencil8,
822
+ bc1-rgba-unorm,
823
+ bc1-rgba-unorm-srgb,
824
+ bc2-rgba-unorm,
825
+ bc2-rgba-unorm-srgb,
826
+ bc3-rgba-unorm,
827
+ bc3-rgba-unorm-srgb,
828
+ bc4-r-unorm,
829
+ bc4-r-snorm,
830
+ bc5-rg-unorm,
831
+ bc5-rg-snorm,
832
+ bc6h-rgb-ufloat,
833
+ bc6h-rgb-float,
834
+ bc7-rgba-unorm,
835
+ bc7-rgba-unorm-srgb,
836
+ etc2-rgb8unorm,
837
+ etc2-rgb8unorm-srgb,
838
+ etc2-rgb8a1unorm,
839
+ etc2-rgb8a1unorm-srgb,
840
+ etc2-rgba8unorm,
841
+ etc2-rgba8unorm-srgb,
842
+ eac-r11unorm,
843
+ eac-r11snorm,
844
+ eac-rg11unorm,
845
+ eac-rg11snorm,
846
+ astc4x4-unorm,
847
+ astc4x4-unorm-srgb,
848
+ astc5x4-unorm,
849
+ astc5x4-unorm-srgb,
850
+ astc5x5-unorm,
851
+ astc5x5-unorm-srgb,
852
+ astc6x5-unorm,
853
+ astc6x5-unorm-srgb,
854
+ astc6x6-unorm,
855
+ astc6x6-unorm-srgb,
856
+ astc8x5-unorm,
857
+ astc8x5-unorm-srgb,
858
+ astc8x6-unorm,
859
+ astc8x6-unorm-srgb,
860
+ astc8x8-unorm,
861
+ astc8x8-unorm-srgb,
862
+ astc10x5-unorm,
863
+ astc10x5-unorm-srgb,
864
+ astc10x6-unorm,
865
+ astc10x6-unorm-srgb,
866
+ astc10x8-unorm,
867
+ astc10x8-unorm-srgb,
868
+ astc10x10-unorm,
869
+ astc10x10-unorm-srgb,
870
+ astc12x10-unorm,
871
+ astc12x10-unorm-srgb,
872
+ astc12x12-unorm,
873
+ astc12x12-unorm-srgb,
755
874
  }
756
- record gpu-canvas-configuration {
757
- device: borrow<gpu-device>,
875
+
876
+ record gpu-color-target-state {
758
877
  format: gpu-texture-format,
759
- usage: option<gpu-texture-usage-flags>,
760
- view-formats: option<list<gpu-texture-format>>,
761
- color-space: option<predefined-color-space>,
762
- tone-mapping: option<gpu-canvas-tone-mapping>,
763
- alpha-mode: option<gpu-canvas-alpha-mode>,
764
- }
765
- enum gpu-device-lost-reason {
766
- unknown,
767
- destroyed,
768
- }
769
- resource gpu-device-lost-info {
770
- reason: func() -> gpu-device-lost-reason;
771
- message: func() -> string;
772
- }
773
- resource gpu-error {
774
- message: func() -> string;
775
- kind: func() -> gpu-error-kind;
776
- }
777
- enum gpu-error-filter {
778
- validation,
779
- out-of-memory,
780
- internal,
781
- }
782
- resource gpu-uncaptured-error-event {
783
- error: func() -> gpu-error;
784
- }
785
- type gpu-buffer-dynamic-offset = u32;
786
- type gpu-stencil-value = u32;
787
- record gpu-render-pass-depth-stencil-attachment {
788
- view: borrow<gpu-texture-view>,
789
- depth-clear-value: option<f32>,
790
- depth-load-op: option<gpu-load-op>,
791
- depth-store-op: option<gpu-store-op>,
792
- depth-read-only: option<bool>,
793
- stencil-clear-value: option<gpu-stencil-value>,
794
- stencil-load-op: option<gpu-load-op>,
795
- stencil-store-op: option<gpu-store-op>,
796
- stencil-read-only: option<bool>,
878
+ blend: option<gpu-blend-state>,
879
+ write-mask: option<gpu-color-write>,
797
880
  }
798
- type gpu-sample-mask = u32;
799
- type gpu-depth-bias = s32;
881
+
800
882
  record gpu-depth-stencil-state {
801
883
  format: gpu-texture-format,
802
884
  depth-write-enabled: option<bool>,
@@ -809,277 +891,366 @@ interface webgpu {
809
891
  depth-bias-slope-scale: option<f32>,
810
892
  depth-bias-clamp: option<f32>,
811
893
  }
812
- type gpu-size64 = u64;
813
- record gpu-buffer-descriptor {
814
- size: gpu-size64,
815
- usage: gpu-buffer-usage-flags,
816
- mapped-at-creation: option<bool>,
894
+
895
+ record gpu-render-bundle-encoder-descriptor {
896
+ depth-read-only: option<bool>,
897
+ stencil-read-only: option<bool>,
898
+ color-formats: list<option<gpu-texture-format>>,
899
+ depth-stencil-format: option<gpu-texture-format>,
900
+ sample-count: option<gpu-size32>,
817
901
  label: option<string>,
818
902
  }
819
- record gpu-buffer-binding-layout {
820
- %type: option<gpu-buffer-binding-type>,
821
- has-dynamic-offset: option<bool>,
822
- min-binding-size: option<gpu-size64>,
903
+
904
+ enum gpu-texture-sample-type {
905
+ float,
906
+ unfilterable-float,
907
+ depth,
908
+ sint,
909
+ uint,
823
910
  }
824
- record gpu-buffer-binding {
825
- buffer: borrow<gpu-buffer>,
826
- offset: option<gpu-size64>,
827
- size: option<gpu-size64>,
911
+
912
+ flags gpu-texture-usage {
913
+ copy-src,
914
+ copy-dst,
915
+ texture-binding,
916
+ storage-binding,
917
+ render-attachment,
918
+ transient-attachment,
919
+ }
920
+
921
+ resource gpu-texture-view {
922
+ label: func() -> string;
923
+ set-label: func(label: string);
828
924
  }
925
+
829
926
  variant gpu-binding-resource {
927
+ gpu-buffer(borrow<gpu-buffer>),
830
928
  gpu-buffer-binding(gpu-buffer-binding),
831
929
  gpu-sampler(borrow<gpu-sampler>),
930
+ gpu-texture(borrow<gpu-texture>),
832
931
  gpu-texture-view(borrow<gpu-texture-view>),
833
932
  }
834
- type gpu-integer-coordinate = u32;
835
- record gpu-texture-view-descriptor {
836
- format: option<gpu-texture-format>,
837
- dimension: option<gpu-texture-view-dimension>,
838
- usage: option<gpu-texture-usage-flags>,
839
- aspect: option<gpu-texture-aspect>,
840
- base-mip-level: option<gpu-integer-coordinate>,
841
- mip-level-count: option<gpu-integer-coordinate>,
842
- base-array-layer: option<gpu-integer-coordinate>,
843
- array-layer-count: option<gpu-integer-coordinate>,
844
- label: option<string>,
845
- }
846
- type gpu-index32 = u32;
847
- record gpu-bind-group-layout-entry {
848
- binding: gpu-index32,
849
- visibility: gpu-shader-stage-flags,
850
- buffer: option<gpu-buffer-binding-layout>,
851
- sampler: option<gpu-sampler-binding-layout>,
852
- texture: option<gpu-texture-binding-layout>,
853
- storage-texture: option<gpu-storage-texture-binding-layout>,
854
- }
855
- record gpu-bind-group-layout-descriptor {
856
- entries: list<gpu-bind-group-layout-entry>,
857
- label: option<string>,
858
- }
933
+
859
934
  record gpu-bind-group-entry {
860
935
  binding: gpu-index32,
861
936
  %resource: gpu-binding-resource,
862
937
  }
938
+
863
939
  record gpu-bind-group-descriptor {
864
940
  layout: borrow<gpu-bind-group-layout>,
865
941
  entries: list<gpu-bind-group-entry>,
866
942
  label: option<string>,
867
943
  }
868
- record gpu-vertex-attribute {
869
- format: gpu-vertex-format,
870
- offset: gpu-size64,
871
- shader-location: gpu-index32,
872
- }
873
- record gpu-vertex-buffer-layout {
874
- array-stride: gpu-size64,
875
- step-mode: option<gpu-vertex-step-mode>,
876
- attributes: list<gpu-vertex-attribute>,
877
- }
878
- record gpu-vertex-state {
879
- buffers: option<list<option<gpu-vertex-buffer-layout>>>,
880
- module: borrow<gpu-shader-module>,
881
- entry-point: option<string>,
882
- constants: option<record-gpu-pipeline-constant-value>,
944
+
945
+ record gpu-render-pass-color-attachment {
946
+ view: borrow<gpu-texture-view>,
947
+ depth-slice: option<gpu-integer-coordinate>,
948
+ resolve-target: option<borrow<gpu-texture-view>>,
949
+ clear-value: option<gpu-color>,
950
+ load-op: gpu-load-op,
951
+ store-op: gpu-store-op,
883
952
  }
884
- type gpu-size32 = u32;
885
- record gpu-multisample-state {
886
- count: option<gpu-size32>,
887
- mask: option<gpu-sample-mask>,
888
- alpha-to-coverage-enabled: option<bool>,
953
+
954
+ record gpu-render-pass-depth-stencil-attachment {
955
+ view: borrow<gpu-texture-view>,
956
+ depth-clear-value: option<f32>,
957
+ depth-load-op: option<gpu-load-op>,
958
+ depth-store-op: option<gpu-store-op>,
959
+ depth-read-only: option<bool>,
960
+ stencil-clear-value: option<gpu-stencil-value>,
961
+ stencil-load-op: option<gpu-load-op>,
962
+ stencil-store-op: option<gpu-store-op>,
963
+ stencil-read-only: option<bool>,
889
964
  }
890
- record gpu-render-pipeline-descriptor {
891
- vertex: gpu-vertex-state,
892
- primitive: option<gpu-primitive-state>,
893
- depth-stencil: option<gpu-depth-stencil-state>,
894
- multisample: option<gpu-multisample-state>,
895
- fragment: option<gpu-fragment-state>,
896
- layout: gpu-layout-mode,
965
+
966
+ record gpu-render-pass-descriptor {
967
+ color-attachments: list<option<gpu-render-pass-color-attachment>>,
968
+ depth-stencil-attachment: option<gpu-render-pass-depth-stencil-attachment>,
969
+ occlusion-query-set: option<borrow<gpu-query-set>>,
970
+ timestamp-writes: option<gpu-render-pass-timestamp-writes>,
971
+ max-draw-count: option<gpu-size64>,
897
972
  label: option<string>,
898
973
  }
899
- record gpu-texel-copy-buffer-layout {
900
- offset: option<gpu-size64>,
901
- bytes-per-row: option<gpu-size32>,
902
- rows-per-image: option<gpu-size32>,
974
+
975
+ enum gpu-texture-view-dimension {
976
+ d1,
977
+ d2,
978
+ d2-array,
979
+ cube,
980
+ cube-array,
981
+ d3,
903
982
  }
904
- record gpu-texel-copy-buffer-info {
905
- buffer: borrow<gpu-buffer>,
906
- offset: option<gpu-size64>,
907
- bytes-per-row: option<gpu-size32>,
908
- rows-per-image: option<gpu-size32>,
983
+
984
+ record gpu-storage-texture-binding-layout {
985
+ access: option<gpu-storage-texture-access>,
986
+ format: gpu-texture-format,
987
+ view-dimension: option<gpu-texture-view-dimension>,
909
988
  }
910
- record gpu-compute-pass-timestamp-writes {
911
- query-set: borrow<gpu-query-set>,
912
- beginning-of-pass-write-index: option<gpu-size32>,
913
- end-of-pass-write-index: option<gpu-size32>,
989
+
990
+ record gpu-texture-binding-layout {
991
+ sample-type: option<gpu-texture-sample-type>,
992
+ view-dimension: option<gpu-texture-view-dimension>,
993
+ multisampled: option<bool>,
914
994
  }
915
- record gpu-compute-pass-descriptor {
916
- timestamp-writes: option<gpu-compute-pass-timestamp-writes>,
917
- label: option<string>,
995
+
996
+ record gpu-bind-group-layout-entry {
997
+ binding: gpu-index32,
998
+ visibility: gpu-shader-stage,
999
+ buffer: option<gpu-buffer-binding-layout>,
1000
+ sampler: option<gpu-sampler-binding-layout>,
1001
+ texture: option<gpu-texture-binding-layout>,
1002
+ storage-texture: option<gpu-storage-texture-binding-layout>,
918
1003
  }
919
- record gpu-render-pass-timestamp-writes {
920
- query-set: borrow<gpu-query-set>,
921
- beginning-of-pass-write-index: option<gpu-size32>,
922
- end-of-pass-write-index: option<gpu-size32>,
1004
+
1005
+ record gpu-bind-group-layout-descriptor {
1006
+ entries: list<gpu-bind-group-layout-entry>,
1007
+ label: option<string>,
923
1008
  }
924
- record gpu-render-bundle-encoder-descriptor {
925
- depth-read-only: option<bool>,
926
- stencil-read-only: option<bool>,
927
- color-formats: list<option<gpu-texture-format>>,
928
- depth-stencil-format: option<gpu-texture-format>,
1009
+
1010
+ record gpu-texture-descriptor {
1011
+ size: gpu-extent3-d,
1012
+ mip-level-count: option<gpu-integer-coordinate>,
929
1013
  sample-count: option<gpu-size32>,
1014
+ dimension: option<gpu-texture-dimension>,
1015
+ format: gpu-texture-format,
1016
+ usage: gpu-texture-usage,
1017
+ view-formats: option<list<gpu-texture-format>>,
1018
+ texture-binding-view-dimension: option<gpu-texture-view-dimension>,
1019
+ label: option<string>,
1020
+ }
1021
+
1022
+ record gpu-texture-view-descriptor {
1023
+ format: option<gpu-texture-format>,
1024
+ dimension: option<gpu-texture-view-dimension>,
1025
+ usage: option<gpu-texture-usage>,
1026
+ aspect: option<gpu-texture-aspect>,
1027
+ base-mip-level: option<gpu-integer-coordinate>,
1028
+ mip-level-count: option<gpu-integer-coordinate>,
1029
+ base-array-layer: option<gpu-integer-coordinate>,
1030
+ array-layer-count: option<gpu-integer-coordinate>,
1031
+ swizzle: option<string>,
930
1032
  label: option<string>,
931
1033
  }
932
- record gpu-query-set-descriptor {
933
- %type: gpu-query-type,
934
- count: gpu-size32,
935
- label: option<string>,
1034
+
1035
+ resource gpu-uncaptured-error-event {
1036
+ error: func() -> gpu-error;
1037
+ }
1038
+
1039
+ enum gpu-vertex-format {
1040
+ uint8,
1041
+ uint8x2,
1042
+ uint8x4,
1043
+ sint8,
1044
+ sint8x2,
1045
+ sint8x4,
1046
+ unorm8,
1047
+ unorm8x2,
1048
+ unorm8x4,
1049
+ snorm8,
1050
+ snorm8x2,
1051
+ snorm8x4,
1052
+ uint16,
1053
+ uint16x2,
1054
+ uint16x4,
1055
+ sint16,
1056
+ sint16x2,
1057
+ sint16x4,
1058
+ unorm16,
1059
+ unorm16x2,
1060
+ unorm16x4,
1061
+ snorm16,
1062
+ snorm16x2,
1063
+ snorm16x4,
1064
+ float16,
1065
+ float16x2,
1066
+ float16x4,
1067
+ %float32,
1068
+ float32x2,
1069
+ float32x3,
1070
+ float32x4,
1071
+ uint32,
1072
+ uint32x2,
1073
+ uint32x3,
1074
+ uint32x4,
1075
+ sint32,
1076
+ sint32x2,
1077
+ sint32x3,
1078
+ sint32x4,
1079
+ unorm1010102,
1080
+ unorm8x4-bgra,
1081
+ }
1082
+
1083
+ record gpu-vertex-attribute {
1084
+ format: gpu-vertex-format,
1085
+ offset: gpu-size64,
1086
+ shader-location: gpu-index32,
936
1087
  }
937
- type gpu-signed-offset32 = s32;
938
- type gpu-size64-out = u64;
939
- type gpu-integer-coordinate-out = u32;
940
- type gpu-size32-out = u32;
941
- type gpu-flags-constant = u32;
942
- record gpu-color {
943
- r: f64,
944
- g: f64,
945
- b: f64,
946
- a: f64,
1088
+
1089
+ enum gpu-vertex-step-mode {
1090
+ vertex,
1091
+ instance,
947
1092
  }
948
- record gpu-render-pass-color-attachment {
949
- view: borrow<gpu-texture-view>,
950
- depth-slice: option<gpu-integer-coordinate>,
951
- resolve-target: option<borrow<gpu-texture-view>>,
952
- clear-value: option<gpu-color>,
953
- load-op: gpu-load-op,
954
- store-op: gpu-store-op,
1093
+
1094
+ record gpu-vertex-buffer-layout {
1095
+ array-stride: gpu-size64,
1096
+ step-mode: option<gpu-vertex-step-mode>,
1097
+ attributes: list<gpu-vertex-attribute>,
955
1098
  }
956
- record gpu-render-pass-descriptor {
957
- color-attachments: list<option<gpu-render-pass-color-attachment>>,
958
- depth-stencil-attachment: option<gpu-render-pass-depth-stencil-attachment>,
959
- occlusion-query-set: option<borrow<gpu-query-set>>,
960
- timestamp-writes: option<gpu-render-pass-timestamp-writes>,
961
- max-draw-count: option<gpu-size64>,
962
- label: option<string>,
1099
+
1100
+ variant map-async-error-kind {
1101
+ operation-error,
1102
+ range-error,
1103
+ abort-error,
963
1104
  }
964
- record gpu-origin3-d {
965
- x: option<gpu-integer-coordinate>,
966
- y: option<gpu-integer-coordinate>,
967
- z: option<gpu-integer-coordinate>,
1105
+
1106
+ record map-async-error {
1107
+ kind: map-async-error-kind,
1108
+ message: string,
968
1109
  }
969
- record gpu-texel-copy-texture-info {
970
- texture: borrow<gpu-texture>,
971
- mip-level: option<gpu-integer-coordinate>,
972
- origin: option<gpu-origin3-d>,
973
- aspect: option<gpu-texture-aspect>,
1110
+
1111
+ variant pop-error-scope-error-kind {
1112
+ operation-error,
974
1113
  }
975
- record gpu-copy-external-image-dest-info {
976
- color-space: option<predefined-color-space>,
977
- premultiplied-alpha: option<bool>,
978
- texture: borrow<gpu-texture>,
979
- mip-level: option<gpu-integer-coordinate>,
980
- origin: option<gpu-origin3-d>,
981
- aspect: option<gpu-texture-aspect>,
1114
+
1115
+ record pop-error-scope-error {
1116
+ kind: pop-error-scope-error-kind,
1117
+ message: string,
982
1118
  }
983
- record gpu-extent3-d {
984
- width: gpu-integer-coordinate,
985
- height: option<gpu-integer-coordinate>,
986
- depth-or-array-layers: option<gpu-integer-coordinate>,
1119
+
1120
+ enum predefined-color-space {
1121
+ srgb,
1122
+ display-p3,
987
1123
  }
988
- record gpu-texture-descriptor {
989
- size: gpu-extent3-d,
990
- mip-level-count: option<gpu-integer-coordinate>,
991
- sample-count: option<gpu-size32>,
992
- dimension: option<gpu-texture-dimension>,
1124
+
1125
+ record gpu-canvas-configuration {
1126
+ device: borrow<gpu-device>,
993
1127
  format: gpu-texture-format,
994
- usage: gpu-texture-usage-flags,
1128
+ usage: option<gpu-texture-usage>,
995
1129
  view-formats: option<list<gpu-texture-format>>,
996
- label: option<string>,
1130
+ color-space: option<predefined-color-space>,
1131
+ tone-mapping: option<gpu-canvas-tone-mapping>,
1132
+ alpha-mode: option<gpu-canvas-alpha-mode>,
997
1133
  }
1134
+
998
1135
  record gpu-canvas-configuration-owned {
999
1136
  device: gpu-device,
1000
1137
  format: gpu-texture-format,
1001
- usage: option<gpu-texture-usage-flags>,
1138
+ usage: option<gpu-texture-usage>,
1002
1139
  view-formats: option<list<gpu-texture-format>>,
1003
1140
  color-space: option<predefined-color-space>,
1004
1141
  tone-mapping: option<gpu-canvas-tone-mapping>,
1005
1142
  alpha-mode: option<gpu-canvas-alpha-mode>,
1006
1143
  }
1007
- enum predefined-color-space {
1008
- srgb,
1009
- display-p3,
1010
- }
1011
- get-gpu: func() -> gpu;
1012
- variant gpu-error-kind {
1013
- validation-error,
1014
- out-of-memory-error,
1015
- internal-error,
1016
- }
1017
- variant request-device-error-kind {
1018
- type-error,
1019
- operation-error,
1144
+
1145
+ resource record-gpu-pipeline-constant-value {
1146
+ constructor();
1147
+ add: func(key: string, value: gpu-pipeline-constant-value);
1148
+ get: func(key: string) -> option<gpu-pipeline-constant-value>;
1149
+ has: func(key: string) -> bool;
1150
+ remove: func(key: string);
1151
+ keys: func() -> list<string>;
1152
+ values: func() -> list<gpu-pipeline-constant-value>;
1153
+ entries: func() -> list<tuple<string, gpu-pipeline-constant-value>>;
1020
1154
  }
1021
- record request-device-error {
1022
- kind: request-device-error-kind,
1023
- message: string,
1155
+
1156
+ record gpu-fragment-state {
1157
+ targets: list<option<gpu-color-target-state>>,
1158
+ module: borrow<gpu-shader-module>,
1159
+ entry-point: option<string>,
1160
+ constants: option<record-gpu-pipeline-constant-value>,
1024
1161
  }
1025
- variant create-pipeline-error-kind {
1026
- gpu-pipeline-error(gpu-pipeline-error-reason),
1162
+
1163
+ record gpu-programmable-stage {
1164
+ module: borrow<gpu-shader-module>,
1165
+ entry-point: option<string>,
1166
+ constants: option<record-gpu-pipeline-constant-value>,
1027
1167
  }
1028
- record create-pipeline-error {
1029
- kind: create-pipeline-error-kind,
1030
- message: string,
1168
+
1169
+ record gpu-compute-pipeline-descriptor {
1170
+ compute: gpu-programmable-stage,
1171
+ layout: gpu-layout-mode,
1172
+ label: option<string>,
1031
1173
  }
1032
- variant create-query-set-error-kind {
1033
- type-error,
1174
+
1175
+ record gpu-vertex-state {
1176
+ buffers: option<list<option<gpu-vertex-buffer-layout>>>,
1177
+ module: borrow<gpu-shader-module>,
1178
+ entry-point: option<string>,
1179
+ constants: option<record-gpu-pipeline-constant-value>,
1034
1180
  }
1035
- record create-query-set-error {
1036
- kind: create-query-set-error-kind,
1037
- message: string,
1181
+
1182
+ record gpu-render-pipeline-descriptor {
1183
+ vertex: gpu-vertex-state,
1184
+ primitive: option<gpu-primitive-state>,
1185
+ depth-stencil: option<gpu-depth-stencil-state>,
1186
+ multisample: option<gpu-multisample-state>,
1187
+ fragment: option<gpu-fragment-state>,
1188
+ layout: gpu-layout-mode,
1189
+ label: option<string>,
1038
1190
  }
1039
- variant pop-error-scope-error-kind {
1040
- operation-error,
1191
+
1192
+ resource record-option-gpu-size64 {
1193
+ constructor();
1194
+ add: func(key: string, value: option<gpu-size64>);
1195
+ get: func(key: string) -> option<option<gpu-size64>>;
1196
+ has: func(key: string) -> bool;
1197
+ remove: func(key: string);
1198
+ keys: func() -> list<string>;
1199
+ values: func() -> list<option<gpu-size64>>;
1200
+ entries: func() -> list<tuple<string, option<gpu-size64>>>;
1041
1201
  }
1042
- record pop-error-scope-error {
1043
- kind: pop-error-scope-error-kind,
1044
- message: string,
1202
+
1203
+ record gpu-device-descriptor {
1204
+ required-features: option<list<gpu-feature-name>>,
1205
+ required-limits: option<record-option-gpu-size64>,
1206
+ default-queue: option<gpu-queue-descriptor>,
1207
+ label: option<string>,
1045
1208
  }
1046
- variant map-async-error-kind {
1209
+
1210
+ variant request-device-error-kind {
1211
+ type-error,
1047
1212
  operation-error,
1048
- range-error,
1049
- abort-error,
1050
1213
  }
1051
- record map-async-error {
1052
- kind: map-async-error-kind,
1214
+
1215
+ record request-device-error {
1216
+ kind: request-device-error-kind,
1053
1217
  message: string,
1054
1218
  }
1055
- variant get-mapped-range-error-kind {
1056
- operation-error,
1219
+
1220
+ variant set-bind-group-error-kind {
1057
1221
  range-error,
1058
- type-error,
1059
1222
  }
1060
- record get-mapped-range-error {
1061
- kind: get-mapped-range-error-kind,
1223
+
1224
+ record set-bind-group-error {
1225
+ kind: set-bind-group-error-kind,
1062
1226
  message: string,
1063
1227
  }
1228
+
1064
1229
  variant unmap-error-kind {
1065
1230
  abort-error,
1066
1231
  }
1232
+
1067
1233
  record unmap-error {
1068
1234
  kind: unmap-error-kind,
1069
1235
  message: string,
1070
1236
  }
1071
- variant set-bind-group-error-kind {
1072
- range-error,
1073
- }
1074
- record set-bind-group-error {
1075
- kind: set-bind-group-error-kind,
1076
- message: string,
1237
+
1238
+ resource wgsl-language-features {
1239
+ has: func(value: string) -> bool;
1077
1240
  }
1241
+
1078
1242
  variant write-buffer-error-kind {
1079
1243
  operation-error,
1080
1244
  }
1245
+
1081
1246
  record write-buffer-error {
1082
1247
  kind: write-buffer-error-kind,
1083
1248
  message: string,
1084
1249
  }
1250
+
1251
+ get-gpu: func() -> gpu;
1252
+ }
1253
+
1254
+ world imports {
1255
+ import webgpu;
1085
1256
  }