-
Notifications
You must be signed in to change notification settings - Fork 0
/
webgpu.d.ts
3020 lines (2828 loc) · 98.7 KB
/
webgpu.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// *********************************************************************************************
// This file is manually-edited by diffing against an autogenerated file. See README.md.
// *********************************************************************************************
// *********************************************************************************************
// Manually-written
// *********************************************************************************************
interface HTMLCanvasElement {
getContext(
contextId:
| "webgpu"
): GPUCanvasContext | null;
}
interface OffscreenCanvas {
getContext(
contextId:
| "webgpu"
): GPUCanvasContext | null;
}
// Defined as an empty interface here to prevent errors when using these types in a worker.
interface HTMLVideoElement {
}
type GPUOrigin2DStrict =
| Iterable<GPUIntegerCoordinate>
| GPUOrigin2DDictStrict;
interface GPUOrigin2DDictStrict
extends GPUOrigin2DDict {
/** @deprecated Does not exist for GPUOrigin2D. */
z?: undefined;
}
type GPUExtent3DStrict =
| Iterable<GPUIntegerCoordinate>
| GPUExtent3DDictStrict;
// GPUExtent3DDictStrict is defined to help developers catch a common class of errors.
// This interface defines depth as an undefined, which will cause a type check failure if someone
// attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.)
interface GPUExtent3DDictStrict
extends GPUExtent3DDict {
/** @deprecated The correct name is `depthOrArrayLayers`. */
depth?: undefined;
}
// *********************************************************************************************
// Semi-auto-generated (by manual diff with autogenerated types)
// *********************************************************************************************
type GPUBindingResource =
| GPUSampler
| GPUTextureView
| GPUBufferBinding
| GPUExternalTexture;
type GPUBufferDynamicOffset =
number;
type GPUBufferUsageFlags =
number;
type GPUColor =
| Iterable<number>
| GPUColorDict;
type GPUColorWriteFlags =
number;
type GPUComputePassTimestampWrites =
Iterable<GPUComputePassTimestampWrite>;
type GPUDepthBias =
number;
type GPUExtent3D =
| Iterable<GPUIntegerCoordinate>
| GPUExtent3DDict;
type GPUFlagsConstant =
number;
type GPUIndex32 =
number;
type GPUIntegerCoordinate =
number;
type GPUMapModeFlags =
number;
type GPUOrigin2D =
| Iterable<GPUIntegerCoordinate>
| GPUOrigin2DDict;
type GPUOrigin3D =
| Iterable<GPUIntegerCoordinate>
| GPUOrigin3DDict;
type GPUPipelineConstantValue =
number;
type GPURenderPassTimestampWrites =
Iterable<GPURenderPassTimestampWrite>;
type GPUSampleMask =
number;
type GPUShaderStageFlags =
number;
type GPUSignedOffset32 =
number;
type GPUSize32 =
number;
type GPUSize64 =
number;
type GPUStencilValue =
number;
type GPUTextureUsageFlags =
number;
type GPUAddressMode =
| "clamp-to-edge"
| "repeat"
| "mirror-repeat";
type GPUAutoLayoutMode =
"auto";
type GPUBlendFactor =
| "zero"
| "one"
| "src"
| "one-minus-src"
| "src-alpha"
| "one-minus-src-alpha"
| "dst"
| "one-minus-dst"
| "dst-alpha"
| "one-minus-dst-alpha"
| "src-alpha-saturated"
| "constant"
| "one-minus-constant";
type GPUBlendOperation =
| "add"
| "subtract"
| "reverse-subtract"
| "min"
| "max";
type GPUBufferBindingType =
| "uniform"
| "storage"
| "read-only-storage";
type GPUBufferMapState =
| "unmapped"
| "pending"
| "mapped";
type GPUCanvasAlphaMode =
| "opaque"
| "premultiplied";
/** @deprecated use GPUCanvasAlphaMode instead */
type GPUCanvasCompositingAlphaMode =
GPUCanvasAlphaMode;
type GPUCompareFunction =
| "never"
| "less"
| "equal"
| "less-equal"
| "greater"
| "not-equal"
| "greater-equal"
| "always";
type GPUCompilationMessageType =
| "error"
| "warning"
| "info";
type GPUComputePassTimestampLocation =
| "beginning"
| "end";
type GPUCullMode =
| "none"
| "front"
| "back";
type GPUDeviceLostReason =
"destroyed";
type GPUErrorFilter =
| "validation"
| "out-of-memory"
| "internal";
type GPUFeatureName =
| "depth-clip-control"
| "depth32float-stencil8"
| "texture-compression-bc"
| "texture-compression-etc2"
| "texture-compression-astc"
| "timestamp-query"
| "indirect-first-instance"
| "shader-f16"
| "bgra8unorm-storage"
| "rg11b10ufloat-renderable";
type GPUFilterMode =
| "nearest"
| "linear";
type GPUFrontFace =
| "ccw"
| "cw";
type GPUIndexFormat =
| "uint16"
| "uint32";
type GPULoadOp =
| "load"
| "clear";
type GPUMipmapFilterMode =
| "nearest"
| "linear";
type GPUPowerPreference =
| "low-power"
| "high-performance";
type GPUPrimitiveTopology =
| "point-list"
| "line-list"
| "line-strip"
| "triangle-list"
| "triangle-strip";
type GPUQueryType =
| "occlusion"
| "timestamp";
type GPURenderPassTimestampLocation =
| "beginning"
| "end";
type GPUSamplerBindingType =
| "filtering"
| "non-filtering"
| "comparison";
type GPUStencilOperation =
| "keep"
| "zero"
| "replace"
| "invert"
| "increment-clamp"
| "decrement-clamp"
| "increment-wrap"
| "decrement-wrap";
type GPUStorageTextureAccess =
"write-only";
type GPUStoreOp =
| "store"
| "discard";
type GPUTextureAspect =
| "all"
| "stencil-only"
| "depth-only";
type GPUTextureDimension =
| "1d"
| "2d"
| "3d";
type GPUTextureFormat =
| "r8unorm"
| "r8snorm"
| "r8uint"
| "r8sint"
| "r16uint"
| "r16sint"
| "r16float"
| "rg8unorm"
| "rg8snorm"
| "rg8uint"
| "rg8sint"
| "r32uint"
| "r32sint"
| "r32float"
| "rg16uint"
| "rg16sint"
| "rg16float"
| "rgba8unorm"
| "rgba8unorm-srgb"
| "rgba8snorm"
| "rgba8uint"
| "rgba8sint"
| "bgra8unorm"
| "bgra8unorm-srgb"
| "rgb9e5ufloat"
| "rgb10a2unorm"
| "rg11b10ufloat"
| "rg32uint"
| "rg32sint"
| "rg32float"
| "rgba16uint"
| "rgba16sint"
| "rgba16float"
| "rgba32uint"
| "rgba32sint"
| "rgba32float"
| "stencil8"
| "depth16unorm"
| "depth24plus"
| "depth24plus-stencil8"
| "depth32float"
| "depth32float-stencil8"
| "bc1-rgba-unorm"
| "bc1-rgba-unorm-srgb"
| "bc2-rgba-unorm"
| "bc2-rgba-unorm-srgb"
| "bc3-rgba-unorm"
| "bc3-rgba-unorm-srgb"
| "bc4-r-unorm"
| "bc4-r-snorm"
| "bc5-rg-unorm"
| "bc5-rg-snorm"
| "bc6h-rgb-ufloat"
| "bc6h-rgb-float"
| "bc7-rgba-unorm"
| "bc7-rgba-unorm-srgb"
| "etc2-rgb8unorm"
| "etc2-rgb8unorm-srgb"
| "etc2-rgb8a1unorm"
| "etc2-rgb8a1unorm-srgb"
| "etc2-rgba8unorm"
| "etc2-rgba8unorm-srgb"
| "eac-r11unorm"
| "eac-r11snorm"
| "eac-rg11unorm"
| "eac-rg11snorm"
| "astc-4x4-unorm"
| "astc-4x4-unorm-srgb"
| "astc-5x4-unorm"
| "astc-5x4-unorm-srgb"
| "astc-5x5-unorm"
| "astc-5x5-unorm-srgb"
| "astc-6x5-unorm"
| "astc-6x5-unorm-srgb"
| "astc-6x6-unorm"
| "astc-6x6-unorm-srgb"
| "astc-8x5-unorm"
| "astc-8x5-unorm-srgb"
| "astc-8x6-unorm"
| "astc-8x6-unorm-srgb"
| "astc-8x8-unorm"
| "astc-8x8-unorm-srgb"
| "astc-10x5-unorm"
| "astc-10x5-unorm-srgb"
| "astc-10x6-unorm"
| "astc-10x6-unorm-srgb"
| "astc-10x8-unorm"
| "astc-10x8-unorm-srgb"
| "astc-10x10-unorm"
| "astc-10x10-unorm-srgb"
| "astc-12x10-unorm"
| "astc-12x10-unorm-srgb"
| "astc-12x12-unorm"
| "astc-12x12-unorm-srgb";
type GPUTextureSampleType =
| "float"
| "unfilterable-float"
| "depth"
| "sint"
| "uint";
type GPUTextureViewDimension =
| "1d"
| "2d"
| "2d-array"
| "cube"
| "cube-array"
| "3d";
type GPUVertexFormat =
| "uint8x2"
| "uint8x4"
| "sint8x2"
| "sint8x4"
| "unorm8x2"
| "unorm8x4"
| "snorm8x2"
| "snorm8x4"
| "uint16x2"
| "uint16x4"
| "sint16x2"
| "sint16x4"
| "unorm16x2"
| "unorm16x4"
| "snorm16x2"
| "snorm16x4"
| "float16x2"
| "float16x4"
| "float32"
| "float32x2"
| "float32x3"
| "float32x4"
| "uint32"
| "uint32x2"
| "uint32x3"
| "uint32x4"
| "sint32"
| "sint32x2"
| "sint32x3"
| "sint32x4";
type GPUVertexStepMode =
| "vertex"
| "instance";
interface GPUBindGroupDescriptor
extends GPUObjectDescriptorBase {
/**
* The {@link GPUBindGroupLayout} the entries of this bind group will conform to.
*/
layout: GPUBindGroupLayout;
/**
* A list of entries describing the resources to expose to the shader for each binding
* described by the {@link GPUBindGroupDescriptor#layout}.
*/
entries: Iterable<GPUBindGroupEntry>;
}
interface GPUBindGroupEntry {
/**
* A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a
* {@link GPUBindGroupLayoutEntry#binding|GPUBindGroupLayoutEntry.binding} and a @binding
* attribute in the {@link GPUShaderModule}.
*/
binding: GPUIndex32;
/**
* The resource to bind, which may be a {@link GPUSampler}, {@link GPUTextureView},
* {@link GPUExternalTexture}, or {@link GPUBufferBinding}.
*/
resource: GPUBindingResource;
}
interface GPUBindGroupLayoutDescriptor
extends GPUObjectDescriptorBase {
entries: Iterable<GPUBindGroupLayoutEntry>;
}
interface GPUBindGroupLayoutEntry {
/**
* A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding
* to a {@link GPUBindGroupEntry#binding|GPUBindGroupEntry.binding} and a @binding
* attribute in the {@link GPUShaderModule}.
*/
binding: GPUIndex32;
/**
* A bitset of the members of {@link GPUShaderStage}.
* Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource
* will be accessible from the associated shader stage.
*/
visibility: GPUShaderStageFlags;
/**
* When not `undefined`, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUBufferBinding}.
*/
buffer?: GPUBufferBindingLayout;
/**
* When not `undefined`, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUSampler}.
*/
sampler?: GPUSamplerBindingLayout;
/**
* When not `undefined`, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUTextureView}.
*/
texture?: GPUTextureBindingLayout;
/**
* When not `undefined`, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUTextureView}.
*/
storageTexture?: GPUStorageTextureBindingLayout;
/**
* When not `undefined`, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
* is {@link GPUExternalTexture}.
*/
externalTexture?: GPUExternalTextureBindingLayout;
}
interface GPUBlendComponent {
/**
* Defines the {@link GPUBlendOperation} used to calculate the values written to the target
* attachment components.
*/
operation?: GPUBlendOperation;
/**
* Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.
*/
srcFactor?: GPUBlendFactor;
/**
* Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.
*/
dstFactor?: GPUBlendFactor;
}
interface GPUBlendState {
color: GPUBlendComponent;
alpha: GPUBlendComponent;
}
interface GPUBufferBinding {
/**
* The {@link GPUBuffer} to bind.
*/
buffer: GPUBuffer;
/**
* The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the
* beginning of the range exposed to the shader by the buffer binding.
*/
offset?: GPUSize64;
/**
* The size, in bytes, of the buffer binding. If `undefined`, specifies the range starting at
* {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}.
*/
size?: GPUSize64;
}
interface GPUBufferBindingLayout {
/**
* Indicates the type required for buffers bound to this bindings.
*/
type?: GPUBufferBindingType;
/**
* Indicates whether this binding requires a dynamic offset.
*/
hasDynamicOffset?: boolean;
/**
* Indicates the minimum buffer binding size.
* Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.
* If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]
* that this value is large enough for the bindings declared in the shader.
* If this *is* `0`, draw/dispatch commands additionally [$Validate encoder bind groups|validate$]
* that each binding in the {@link GPUBindGroup} is large enough for the bindings declared in the shader.
* Note:
* Similar execution-time validation is theoretically possible for other
* binding-related fields specified for early validation, like
* {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},
* which currently can only be validated in pipeline creation.
* However, such execution-time validation could be costly or unnecessarily complex, so it is
* available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the
* most ergonomic impact.
*/
minBindingSize?: GPUSize64;
}
interface GPUBufferDescriptor
extends GPUObjectDescriptorBase {
/**
* The size of the buffer in bytes.
*/
size: GPUSize64;
/**
* The allowed usages for the buffer.
*/
usage: GPUBufferUsageFlags;
/**
* If `true` creates the buffer in an already mapped state, allowing
* {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set
* {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage}
* does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be
* used to set the buffer's initial data.
* Guarantees that even if the buffer creation eventually fails, it will still appear as if the
* mapped range can be written/read to until it is unmapped.
*/
mappedAtCreation?: boolean;
}
interface GPUCanvasConfiguration {
/**
* The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be
* compatible with.
*/
device: GPUDevice;
/**
* The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.
* Must be one of the Supported context formats.
*/
format: GPUTextureFormat;
/**
* The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.
* {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included
* if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT}
* when setting a custom usage if you wish to use textures returned by
* {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass.
*/
usage?: GPUTextureUsageFlags;
/**
* The formats that views created from textures returned by
* {@link GPUCanvasContext#getCurrentTexture} may use.
*/
viewFormats?: Iterable<GPUTextureFormat>;
/**
* The color space that values written into textures returned by
* {@link GPUCanvasContext#getCurrentTexture} should be displayed with.
*/
colorSpace?: PredefinedColorSpace;
/**
* Determines the effect that alpha values will have on the content of textures returned by
* {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source.
*/
alphaMode?: GPUCanvasAlphaMode;
/** @deprecated use alphaMode instead (it is specified to affect the behavior of reading from the canvas) */
compositingAlphaMode?: GPUCanvasCompositingAlphaMode;
/** @deprecated use the canvas width/height instead */
size?: GPUExtent3D;
}
interface GPUColorDict {
r: number;
g: number;
b: number;
a: number;
}
interface GPUColorTargetState {
format: GPUTextureFormat;
blend?: GPUBlendState;
writeMask?: GPUColorWriteFlags;
}
type GPUCommandBufferDescriptor =
GPUObjectDescriptorBase;
type GPUCommandEncoderDescriptor =
GPUObjectDescriptorBase;
interface GPUComputePassDescriptor
extends GPUObjectDescriptorBase {
/**
* A sequence of {@link GPUComputePassTimestampWrite} values define where and when timestamp values will be written for this pass.
*/
timestampWrites?: GPUComputePassTimestampWrites;
}
interface GPUComputePassTimestampWrite {
querySet: GPUQuerySet;
queryIndex: GPUSize32;
location: GPUComputePassTimestampLocation;
}
interface GPUComputePipelineDescriptor
extends GPUPipelineDescriptorBase {
/**
* Describes the compute shader entry point of the pipeline.
*/
compute: GPUProgrammableStage;
}
interface GPUDepthStencilState {
/**
* The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment}
* this {@link GPURenderPipeline} will be compatible with.
*/
format: GPUTextureFormat;
/**
* Indicates if this {@link GPURenderPipeline} can modify
* {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.
*/
depthWriteEnabled?: boolean;
/**
* The comparison operation used to test fragment depths against
* {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.
*/
depthCompare?: GPUCompareFunction;
/**
* Defines how stencil comparisons and operations are performed for front-facing primitives.
*/
stencilFront?: GPUStencilFaceState;
/**
* Defines how stencil comparisons and operations are performed for back-facing primitives.
*/
stencilBack?: GPUStencilFaceState;
/**
* Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value
* bits are read when performing stencil comparison tests.
*/
stencilReadMask?: GPUStencilValue;
/**
* Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value
* bits are written to when performing stencil operations.
*/
stencilWriteMask?: GPUStencilValue;
/**
* Constant depth bias added to each fragment. See [$biased fragment depth$] for details.
*/
depthBias?: GPUDepthBias;
/**
* Depth bias that scales with the fragment’s slope. See [$biased fragment depth$] for details.
*/
depthBiasSlopeScale?: number;
/**
* The maximum depth bias of a fragment. See [$biased fragment depth$] for details.
*/
depthBiasClamp?: number;
}
interface GPUDeviceDescriptor
extends GPUObjectDescriptorBase {
/**
* Specifies the features that are required by the device request.
* The request will fail if the adapter cannot provide these features.
* Exactly the specified set of features, and no more or less, will be allowed in validation
* of API calls on the resulting device.
*/
requiredFeatures?: Iterable<GPUFeatureName>;
/**
* Specifies the limits that are required by the device request.
* The request will fail if the adapter cannot provide these limits.
* Each key must be the name of a member of supported limits.
* Exactly the specified limits, and no limit/better or worse,
* will be allowed in validation of API calls on the resulting device.
* <!-- If we ever need limit types other than GPUSize32/GPUSize64, we can change the value
* type to `double` or `any` in the future and write out the type conversion explicitly (by
* reference to WebIDL spec). Or change the entire type to `any` and add back a `dictionary
* GPULimits` and define the conversion of the whole object by reference to WebIDL. -->
*/
requiredLimits?: Record<
string,
GPUSize64
>;
/**
* The descriptor for the default {@link GPUQueue}.
*/
defaultQueue?: GPUQueueDescriptor;
}
interface GPUExtent3DDict {
width: GPUIntegerCoordinate;
height?: GPUIntegerCoordinate;
depthOrArrayLayers?: GPUIntegerCoordinate;
}
interface GPUExternalTextureBindingLayout {}
interface GPUExternalTextureDescriptor
extends GPUObjectDescriptorBase {
source: HTMLVideoElement;
colorSpace?: PredefinedColorSpace;
}
interface GPUFragmentState
extends GPUProgrammableStage {
targets: Iterable<GPUColorTargetState | null>;
}
interface GPUImageCopyBuffer
extends GPUImageDataLayout {
/**
* A buffer which either contains image data to be copied or will store the image data being
* copied, depending on the method it is being passed to.
*/
buffer: GPUBuffer;
}
interface GPUImageCopyExternalImage {
/**
* The source of the image copy. The copy source data is captured at the moment that
* {@link GPUQueue#copyExternalImageToTexture} is issued.
*/
source:
| ImageBitmap
| HTMLVideoElement
| HTMLCanvasElement
| OffscreenCanvas;
/**
* Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.
* Together with `copySize`, defines the full copy sub-region.
*/
origin?: GPUOrigin2DStrict;
/**
* Describes whether the source image is vertically flipped, or not.
* If this option is set to `true`, the copy is flipped vertically: the bottom row of the source
* region is copied into the first row of the destination region, and so on.
* The {@link GPUImageCopyExternalImage#origin} option is still relative to the top-left corner
* of the source image, increasing downward.
*/
flipY?: boolean;
}
interface GPUImageCopyTexture {
/**
* Texture to copy to/from.
*/
texture: GPUTexture;
/**
* Mip-map level of the {@link GPUImageCopyTexture#texture} to copy to/from.
*/
mipLevel?: GPUIntegerCoordinate;
/**
* Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.
* Together with `copySize`, defines the full copy sub-region.
*/
origin?: GPUOrigin3D;
/**
* Defines which aspects of the {@link GPUImageCopyTexture#texture} to copy to/from.
*/
aspect?: GPUTextureAspect;
}
interface GPUImageCopyTextureTagged
extends GPUImageCopyTexture {
/**
* Describes the color space and encoding used to encode data into the destination texture.
* This [[#color-space-conversions|may result]] in values outside of the range [0, 1]
* being written to the target texture, if its format can represent them.
* Otherwise, the results are clamped to the target texture format's range.
* Note:
* If {@link GPUImageCopyTextureTagged#colorSpace} matches the source image,
* conversion may not be necessary. See [[#color-space-conversion-elision]].
*/
colorSpace?: PredefinedColorSpace;
/**
* Describes whether the data written into the texture should have its RGB channels
* premultiplied by the alpha channel, or not.
* If this option is set to `true` and the {@link GPUImageCopyExternalImage#source} is also
* premultiplied, the source RGB values must be preserved even if they exceed their
* corresponding alpha values.
* Note:
* If {@link GPUImageCopyTextureTagged#premultipliedAlpha} matches the source image,
* conversion may not be necessary. See [[#color-space-conversion-elision]].
*/
premultipliedAlpha?: boolean;
}
interface GPUImageDataLayout {
/**
* The offset, in bytes, from the beginning of the image data source (such as a
* {@link GPUImageCopyBuffer#buffer|GPUImageCopyBuffer.buffer}) to the start of the image data
* within that source.
*/
offset?: GPUSize64;
/**
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
*/
bytesPerRow?: GPUSize32;
/**
* Number of block rows per single image of the texture.
* {@link GPUImageDataLayout#rowsPerImage} ×
* {@link GPUImageDataLayout#bytesPerRow} is the stride, in bytes, between the beginning of each image of data and the subsequent image.
* Required if there are multiple images (i.e. the copy depth is more than one).
*/
rowsPerImage?: GPUSize32;
}
interface GPUMultisampleState {
/**
* Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only
* with attachment textures ({@link GPURenderPassDescriptor#colorAttachments}
* and {@link GPURenderPassDescriptor#depthStencilAttachment})
* with matching {@link GPUTextureDescriptor#sampleCount}s.
*/
count?: GPUSize32;
/**
* Mask determining which samples are written to.
*/
mask?: GPUSampleMask;
/**
* When `true` indicates that a fragment's alpha channel should be used to generate a sample
* coverage mask.
*/
alphaToCoverageEnabled?: boolean;
}
interface GPUObjectDescriptorBase {
/**
* The initial value of {@link GPUObjectBase#label|GPUObjectBase.label}.
*/
label?: string;
}
interface GPUOrigin2DDict {
x?: GPUIntegerCoordinate;
y?: GPUIntegerCoordinate;
}
interface GPUOrigin3DDict {
x?: GPUIntegerCoordinate;
y?: GPUIntegerCoordinate;
z?: GPUIntegerCoordinate;
}
interface GPUPipelineDescriptorBase
extends GPUObjectDescriptorBase {
layout:
| GPUPipelineLayout
| GPUAutoLayoutMode;
}
interface GPUPipelineLayoutDescriptor
extends GPUObjectDescriptorBase {
/**
* A list of {@link GPUBindGroupLayout}s the pipline will use. Each element corresponds to a
* @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding with
* `@group(N)`.
*/
bindGroupLayouts: Iterable<GPUBindGroupLayout>;
}
interface GPUPrimitiveState {
/**
* The type of primitive to be constructed from the vertex inputs.
*/
topology?: GPUPrimitiveTopology;
/**
* For pipelines with strip topologies
* ({@link GPUPrimitiveTopology#"line-strip"} or {@link GPUPrimitiveTopology#"triangle-strip"}),
* this determines the index buffer format and primitive restart value
* ({@link GPUIndexFormat#"uint16"}/`0xFFFF` or {@link GPUIndexFormat#"uint32"}/`0xFFFFFFFF`).
* It is not allowed on pipelines with non-strip topologies.
* Note: Some implementations require knowledge of the primitive restart value to compile
* pipeline state objects.
* To use a strip-topology pipeline with an indexed draw call
* ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}),
* this must be set, and it must match the index buffer format used with the draw call
* (set in {@link GPURenderCommandsMixin#setIndexBuffer}).
* See [[#primitive-assembly]] for additional details.
*/
stripIndexFormat?: GPUIndexFormat;
/**
* Defines which polygons are considered front-facing.
*/
frontFace?: GPUFrontFace;
/**
* Defines which polygon orientation will be culled, if any.
*/
cullMode?: GPUCullMode;
/**
* If true, indicates that depth clipping is disabled. See [[#depth-clip-control]] for additional details.
* Requires the {@link GPUFeatureName#"depth-clip-control"} feature to be enabled.
*/
unclippedDepth?: boolean;
}
interface GPUProgrammableStage {
module: GPUShaderModule;
entryPoint: string;
constants?: Record<
string,
GPUPipelineConstantValue
>;
}
interface GPUQuerySetDescriptor
extends GPUObjectDescriptorBase {
/**
* The type of queries managed by {@link GPUQuerySet}.
*/
type: GPUQueryType;
/**
* The number of queries managed by {@link GPUQuerySet}.
*/
count: GPUSize32;
}
type GPUQueueDescriptor =
GPUObjectDescriptorBase;
type GPURenderBundleDescriptor =
GPUObjectDescriptorBase;
interface GPURenderBundleEncoderDescriptor
extends GPURenderPassLayout {
depthReadOnly?: boolean;
stencilReadOnly?: boolean;
}
interface GPURenderPassColorAttachment {
/**
* A {@link GPUTextureView} describing the texture subresource that will be output to for this
* color attachment.
*/
view: GPUTextureView;
/**
* A {@link GPUTextureView} describing the texture subresource that will receive the resolved
* output for this color attachment if {@link GPURenderPassColorAttachment#view} is
* multisampled.
*/
resolveTarget?: GPUTextureView;
/**
* Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the
* render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored
* if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp#"clear"}.
* The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.
* They are converted [$to a texel value of texture format$] matching the render attachment.
* If conversion fails, a validation error is generated.
*/
clearValue?: GPUColor;
/**