Skip to content

Commit ecce0c3

Browse files
authored
Roll gpuweb 2f5c6f6c -> 06282f66 (with hack to fix include) (#126)
The generator doesn't handle bikeshed includes correctly, so the `generated` version was generated by hand-pasting the include in before generation.
1 parent 78c397c commit ecce0c3

File tree

5 files changed

+302
-65
lines changed

5 files changed

+302
-65
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/node_modules/
33
/out/
44
/generated/webgpu.ts
5+
.DS_Store

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Please contribute a PR to add instructions for other setups or improve existing
6262
- Make sure the submodule is checked out: `git submodule update --init`
6363
- Pull `gpuweb` changes: `pushd gpuweb && git checkout main && git pull && popd`
6464
- Install dependencies: `npm ci`
65+
- Bug workaround: paste the `copies.bs` contents in place of its include in `index.bs` (generator doesn't support includes).
6566
- Generate `generated/index.d.ts`: `npm run generate`
6667
- Open a diff between `generated/index.d.ts` and `dist/index.d.ts`.
6768
The generated file is tracked by Git so you can see what has changed.

dist/index.d.ts

Lines changed: 128 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,19 @@ type GPUExtent3D =
7676
| GPUExtent3DDict;
7777
type GPUFlagsConstant =
7878
number;
79+
type GPUImageCopyExternalImageSource =
80+
81+
| ImageBitmap
82+
| HTMLVideoElement
83+
| VideoFrame
84+
| HTMLCanvasElement
85+
| OffscreenCanvas;
7986
type GPUIndex32 =
8087
number;
8188
type GPUIntegerCoordinate =
8289
number;
90+
type GPUIntegerCoordinateOut =
91+
number;
8392
type GPUMapModeFlags =
8493
number;
8594
type GPUOrigin2D =
@@ -100,8 +109,12 @@ type GPUSignedOffset32 =
100109
number;
101110
type GPUSize32 =
102111
number;
112+
type GPUSize32Out =
113+
number;
103114
type GPUSize64 =
104115
number;
116+
type GPUSize64Out =
117+
number;
105118
type GPUStencilValue =
106119
number;
107120
type GPUTextureUsageFlags =
@@ -615,27 +628,27 @@ interface GPUCanvasConfiguration {
615628

616629
interface GPUColorDict {
617630
/**
618-
* The red channel value
631+
* The red channel value.
619632
*/
620633
r: number;
621634
/**
622-
* The green channel value
635+
* The green channel value.
623636
*/
624637
g: number;
625638
/**
626-
* The blue channel value
639+
* The blue channel value.
627640
*/
628641
b: number;
629642
/**
630-
* The alpha channel value
643+
* The alpha channel value.
631644
*/
632645
a: number;
633646
}
634647

635648
interface GPUColorTargetState {
636649
/**
637650
* The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with
638-
* {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of the same format in the
651+
* {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the
639652
* corresponding color attachment.
640653
*/
641654
format: GPUTextureFormat;
@@ -670,12 +683,12 @@ interface GPUComputePassTimestampWrites {
670683
*/
671684
querySet: GPUQuerySet;
672685
/**
673-
* If defined indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
686+
* If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
674687
* which the timestamp at the beginning of the compute pass will be written.
675688
*/
676689
beginningOfPassWriteIndex?: GPUSize32;
677690
/**
678-
* If defined indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
691+
* If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
679692
* which the timestamp at the end of the compute pass will be written.
680693
*/
681694
endOfPassWriteIndex?: GPUSize32;
@@ -769,11 +782,11 @@ interface GPUDeviceDescriptor
769782

770783
interface GPUExtent3DDict {
771784
/**
772-
* The width of the extent
785+
* The width of the extent.
773786
*/
774787
width: GPUIntegerCoordinate;
775788
/**
776-
* The height of the extent
789+
* The height of the extent.
777790
*/
778791
height?: GPUIntegerCoordinate;
779792
/**
@@ -816,13 +829,41 @@ interface GPUImageCopyBuffer
816829
interface GPUImageCopyExternalImage {
817830
/**
818831
* The source of the image copy. The copy source data is captured at the moment that
819-
* {@link GPUQueue#copyExternalImageToTexture} is issued.
820-
*/
821-
source:
822-
| ImageBitmap
823-
| HTMLVideoElement
824-
| HTMLCanvasElement
825-
| OffscreenCanvas;
832+
* {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is defined by source
833+
* type, given by this table:
834+
*
835+
* <table class=data>
836+
* <thead>
837+
* <tr>
838+
* <th>Source type
839+
* <th>Width
840+
* <th>Height
841+
* </thead>
842+
* <tbody>
843+
* <tr>
844+
* <td>{@link ImageBitmap}
845+
* <td>{@link ImageBitmap#width|ImageBitmap.width}
846+
* <td>{@link ImageBitmap#height|ImageBitmap.height}
847+
* <tr>
848+
* <td>{@link HTMLVideoElement}
849+
* <td>video/intrinsic width|intrinsic width of the frame
850+
* <td>video/intrinsic height|intrinsic height of the frame
851+
* <tr>
852+
* <td>{@link VideoFrame}
853+
* <td>{@link VideoFrame#codedWidth|VideoFrame.codedWidth}
854+
* <td>{@link VideoFrame#codedHeight|VideoFrame.codedHeight}
855+
* <tr>
856+
* <td>{@link HTMLCanvasElement}
857+
* <td>{@link HTMLCanvasElement#width|HTMLCanvasElement.width}
858+
* <td>{@link HTMLCanvasElement#height|HTMLCanvasElement.height}
859+
* <tr>
860+
* <td>{@link OffscreenCanvas}
861+
* <td>{@link OffscreenCanvas#width|OffscreenCanvas.width}
862+
* <td>{@link OffscreenCanvas#height|OffscreenCanvas.height}
863+
* </tbody>
864+
* </table>
865+
*/
866+
source: GPUImageCopyExternalImageSource;
826867
/**
827868
* Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.
828869
* Together with `copySize`, defines the full copy sub-region.
@@ -944,7 +985,7 @@ interface GPUOrigin3DDict {
944985
interface GPUPipelineDescriptorBase
945986
extends GPUObjectDescriptorBase {
946987
/**
947-
* The {@link GPUPipelineLayout} for this pipeline or {@link GPUAutoLayoutMode#"auto"}, to generate
988+
* The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode#"auto"} to generate
948989
* the pipeline layout automatically.
949990
* Note: If {@link GPUAutoLayoutMode#"auto"} is used the pipeline cannot share {@link GPUBindGroup}s
950991
* with any other pipelines.
@@ -1016,6 +1057,57 @@ interface GPUProgrammableStage {
10161057
/**
10171058
* Specifies the values of pipeline-overridable constants in the shader module
10181059
* {@link GPUProgrammableStage#module}.
1060+
* Each such pipeline-overridable constant is uniquely identified by a single
1061+
* pipeline-overridable constant identifier string (representing the numeric ID of the
1062+
* constant, if one is specified, and otherwise the constant's identifier name).
1063+
* WGSL names (identifiers) in source maps follow the rules defined in WGSL identifier comparison.
1064+
* The key of each key-value pair must equal the identifier string of one such constant.
1065+
* When the pipeline is executed, that constant will have the specified value.
1066+
* Values are specified as <dfn typedef for="">GPUPipelineConstantValue</dfn>, which is a {@link double}.
1067+
* They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`).
1068+
* If conversion fails, a validation error is generated.
1069+
* <div class=example>
1070+
* Pipeline-overridable constants defined in WGSL:
1071+
* <pre highlight=wgsl>
1072+
* @id(0) override has_point_light: bool = true; // Algorithmic control.
1073+
* @id(1200) override specular_param: f32 = 2.3; // Numeric control.
1074+
* @id(1300) override gain: f32; // Must be overridden.
1075+
* override width: f32 = 0.0; // Specifed at the API level
1076+
* // using the name "width".
1077+
* override depth: f32; // Specifed at the API level
1078+
* // using the name "depth".
1079+
* // Must be overridden.
1080+
* override height = 2 * depth; // The default value
1081+
* // (if not set at the API level),
1082+
* // depends on another
1083+
* // overridable constant.
1084+
* </pre>
1085+
* Corresponding JavaScript code, providing only the overrides which are required
1086+
* (have no defaults):
1087+
* <pre highlight=js>
1088+
* {
1089+
* // ...
1090+
* constants: {
1091+
* 1300: 2.0, // "gain"
1092+
* depth: -1, // "depth"
1093+
* }
1094+
* }
1095+
* </pre>
1096+
* Corresponding JavaScript code, overriding all constants:
1097+
* <pre highlight=js>
1098+
* {
1099+
* // ...
1100+
* constants: {
1101+
* 0: false, // "has_point_light"
1102+
* 1200: 3.0, // "specular_param"
1103+
* 1300: 2.0, // "gain"
1104+
* width: 20, // "width"
1105+
* depth: -1, // "depth"
1106+
* height: 15, // "height"
1107+
* }
1108+
* }
1109+
* </pre>
1110+
* </div>
10191111
*/
10201112
constants?: Record<
10211113
string,
@@ -1040,7 +1132,7 @@ type GPUQueueDescriptor =
10401132
type GPURenderBundleDescriptor =
10411133
GPUObjectDescriptorBase;
10421134

1043-
interface GPURenderBundleEncoderDescriptor
1135+
interface GPURenderBundleEncoderDescriptor
10441136
extends GPURenderPassLayout {
10451137
/**
10461138
* If `true`, indicates that the render bundle does not modify the depth component of the
@@ -1200,12 +1292,12 @@ interface GPURenderPassTimestampWrites {
12001292
*/
12011293
querySet: GPUQuerySet;
12021294
/**
1203-
* If defined indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
1295+
* If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
12041296
* which the timestamp at the beginning of the render pass will be written.
12051297
*/
12061298
beginningOfPassWriteIndex?: GPUSize32;
12071299
/**
1208-
* If defined indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
1300+
* If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
12091301
* which the timestamp at the end of the render pass will be written.
12101302
*/
12111303
endOfPassWriteIndex?: GPUSize32;
@@ -1477,7 +1569,7 @@ interface GPUTextureDescriptor
14771569
* </div>
14781570
* Formats in this list must be texture view format compatible with the texture format.
14791571
* <div algorithm>
1480-
* Two {@link GPUTextureFormat}s `format` and `viewFormat` are <dfn dfn for=>texture view format compatible</dfn> if:
1572+
* Two {@link GPUTextureFormat}s `format` and `viewFormat` are <dfn dfn for="">texture view format compatible</dfn> if:
14811573
* - `format` equals `viewFormat`, or
14821574
* - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix).
14831575
* </div>
@@ -1737,7 +1829,7 @@ interface GPURenderCommandsMixin {
17371829

17381830
interface NavigatorGPU {
17391831
/**
1740-
* Provides access to interfaces related to WebGPU.
1832+
* A global singleton providing top-level entry points like {@link GPU#requestAdapter}.
17411833
*/
17421834
readonly gpu: GPU;
17431835
}
@@ -1900,8 +1992,8 @@ interface GPUBuffer
19001992
* @internal
19011993
*/
19021994
readonly __brand: "GPUBuffer";
1903-
readonly size: GPUSize64;
1904-
readonly usage: GPUBufferUsageFlags;
1995+
readonly size: GPUSize64Out;
1996+
readonly usage: GPUFlagsConstant;
19051997
readonly mapState: GPUBufferMapState;
19061998
/**
19071999
* Maps the given range of the {@link GPUBuffer} and resolves the returned {@link Promise} when the
@@ -2098,6 +2190,8 @@ interface GPUCommandEncoder
20982190
): undefined;
20992191
/**
21002192
* Writes a timestamp value into a querySet when all previous commands have completed executing.
2193+
* Note: Timestamp query values are written in nanoseconds, but how the value is determined is
2194+
* implementation-defined and may not increase monotonically. See [[#timestamp]] for details.
21012195
* @param querySet - The query set that will store the timestamp values.
21022196
* @param queryIndex - The index of the query in the query set.
21032197
*/
@@ -2562,7 +2656,7 @@ interface GPUPipelineError
25622656
readonly __brand: "GPUPipelineError";
25632657
/**
25642658
* A read-only slot-backed attribute exposing the type of error encountered in pipeline creation
2565-
* as a <dfn enum for=>GPUPipelineErrorReason</dfn>:
2659+
* as a <dfn enum for="">GPUPipelineErrorReason</dfn>:
25662660
* <ul dfn-type=enum-value dfn-for=GPUPipelineErrorReason>
25672661
* - <dfn>"validation"</dfn>: A [$validation error$].
25682662
* - <dfn>"internal"</dfn>: An [$internal error$].
@@ -2615,7 +2709,7 @@ interface GPUQuerySet
26152709
/**
26162710
* The number of queries managed by this {@link GPUQuerySet}.
26172711
*/
2618-
readonly count: GPUSize32;
2712+
readonly count: GPUSize32Out;
26192713
}
26202714

26212715
declare var GPUQuerySet: {
@@ -2761,8 +2855,8 @@ interface GPURenderPassEncoder
27612855
*/
27622856
readonly __brand: "GPURenderPassEncoder";
27632857
/**
2764-
* Sets the viewport used during the rasterization stage to linearly map from normalized device
2765-
* coordinates to viewport coordinates.
2858+
* Sets the viewport used during the rasterization stage to linearly map from
2859+
* NDC|normalized device coordinates to viewport coordinates.
27662860
* @param x - Minimum X value of the viewport in pixels.
27672861
* @param y - Minimum Y value of the viewport in pixels.
27682862
* @param width - Width of the viewport in pixels.
@@ -2965,23 +3059,23 @@ interface GPUTexture
29653059
/**
29663060
* The width of this {@link GPUTexture}.
29673061
*/
2968-
readonly width: GPUIntegerCoordinate;
3062+
readonly width: GPUIntegerCoordinateOut;
29693063
/**
29703064
* The height of this {@link GPUTexture}.
29713065
*/
2972-
readonly height: GPUIntegerCoordinate;
3066+
readonly height: GPUIntegerCoordinateOut;
29733067
/**
29743068
* The depth or layer count of this {@link GPUTexture}.
29753069
*/
2976-
readonly depthOrArrayLayers: GPUIntegerCoordinate;
3070+
readonly depthOrArrayLayers: GPUIntegerCoordinateOut;
29773071
/**
29783072
* The number of mip levels of this {@link GPUTexture}.
29793073
*/
2980-
readonly mipLevelCount: GPUIntegerCoordinate;
3074+
readonly mipLevelCount: GPUIntegerCoordinateOut;
29813075
/**
29823076
* The number of sample count of this {@link GPUTexture}.
29833077
*/
2984-
readonly sampleCount: GPUSize32;
3078+
readonly sampleCount: GPUSize32Out;
29853079
/**
29863080
* The dimension of the set of texel for each of this {@link GPUTexture}'s subresources.
29873081
*/
@@ -2993,7 +3087,7 @@ interface GPUTexture
29933087
/**
29943088
* The allowed usages for this {@link GPUTexture}.
29953089
*/
2996-
readonly usage: GPUTextureUsageFlags;
3090+
readonly usage: GPUFlagsConstant;
29973091
}
29983092

29993093
declare var GPUTexture: {

0 commit comments

Comments
 (0)