Skip to content

Commit 700448a

Browse files
Kangzkainino0x
andauthored
Update GPUWeb. (#160)
* Update GPUWeb. - Rename of dictionaries related to copies. - GPUPipelineLayoutDescriptor.bindGroupLayouts can contain nulls. - New vertex formats. * add back old names as deprecated aliases --------- Co-authored-by: Kai Ninomiya <kainino@chromium.org>
1 parent 97e05be commit 700448a

3 files changed

Lines changed: 284 additions & 251 deletions

File tree

dist/index.d.ts

Lines changed: 148 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,7 @@ type GPUColor =
6868
| GPUColorDict;
6969
type GPUColorWriteFlags =
7070
number;
71-
type GPUDepthBias =
72-
number;
73-
type GPUExtent3D =
74-
75-
| Iterable<GPUIntegerCoordinate>
76-
| GPUExtent3DDict;
77-
type GPUFlagsConstant =
78-
number;
79-
type GPUImageCopyExternalImageSource =
71+
type GPUCopyExternalImageSource =
8072

8173
| ImageBitmap
8274
| ImageData
@@ -85,6 +77,14 @@ type GPUImageCopyExternalImageSource =
8577
| VideoFrame
8678
| HTMLCanvasElement
8779
| OffscreenCanvas;
80+
type GPUDepthBias =
81+
number;
82+
type GPUExtent3D =
83+
84+
| Iterable<GPUIntegerCoordinate>
85+
| GPUExtent3DDict;
86+
type GPUFlagsConstant =
87+
number;
8888
type GPUIndex32 =
8989
number;
9090
type GPUIntegerCoordinate =
@@ -406,22 +406,31 @@ type GPUTextureViewDimension =
406406
| "3d";
407407
type GPUVertexFormat =
408408

409+
| "uint8"
409410
| "uint8x2"
410411
| "uint8x4"
412+
| "sint8"
411413
| "sint8x2"
412414
| "sint8x4"
415+
| "unorm8"
413416
| "unorm8x2"
414417
| "unorm8x4"
418+
| "snorm8"
415419
| "snorm8x2"
416420
| "snorm8x4"
421+
| "uint16"
417422
| "uint16x2"
418423
| "uint16x4"
424+
| "sint16"
419425
| "sint16x2"
420426
| "sint16x4"
427+
| "unorm16"
421428
| "unorm16x2"
422429
| "unorm16x4"
430+
| "snorm16"
423431
| "snorm16x2"
424432
| "snorm16x4"
433+
| "float16"
425434
| "float16x2"
426435
| "float16x4"
427436
| "float32"
@@ -436,7 +445,8 @@ type GPUVertexFormat =
436445
| "sint32x2"
437446
| "sint32x3"
438447
| "sint32x4"
439-
| "unorm10-10-10-2";
448+
| "unorm10-10-10-2"
449+
| "unorm8x4-bgra";
440450
type GPUVertexStepMode =
441451

442452
| "vertex"
@@ -739,6 +749,53 @@ interface GPUComputePipelineDescriptor
739749
compute: GPUProgrammableStage;
740750
}
741751

752+
interface GPUCopyExternalImageDestInfo
753+
extends GPUTexelCopyTextureInfo {
754+
/**
755+
* Describes the color space and encoding used to encode data into the destination texture.
756+
* This [[#color-space-conversions|may result]] in values outside of the range [0, 1]
757+
* being written to the target texture, if its format can represent them.
758+
* Otherwise, the results are clamped to the target texture format's range.
759+
* Note:
760+
* If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image,
761+
* conversion may not be necessary. See [[#color-space-conversion-elision]].
762+
*/
763+
colorSpace?: PredefinedColorSpace;
764+
/**
765+
* Describes whether the data written into the texture should have its RGB channels
766+
* premultiplied by the alpha channel, or not.
767+
* If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also
768+
* premultiplied, the source RGB values must be preserved even if they exceed their
769+
* corresponding alpha values.
770+
* Note:
771+
* If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image,
772+
* conversion may not be necessary. See [[#color-space-conversion-elision]].
773+
*/
774+
premultipliedAlpha?: boolean;
775+
}
776+
777+
interface GPUCopyExternalImageSourceInfo {
778+
/**
779+
* The source of the texel copy. The copy source data is captured at the moment that
780+
* {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described
781+
* by the external source dimensions table.
782+
*/
783+
source: GPUCopyExternalImageSource;
784+
/**
785+
* Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.
786+
* Together with `copySize`, defines the full copy sub-region.
787+
*/
788+
origin?: GPUOrigin2D;
789+
/**
790+
* Describes whether the source image is vertically flipped, or not.
791+
* If this option is set to `true`, the copy is flipped vertically: the bottom row of the source
792+
* region is copied into the first row of the destination region, and so on.
793+
* The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner
794+
* of the source image, increasing downward.
795+
*/
796+
flipY?: boolean;
797+
}
798+
742799
interface GPUDepthStencilState {
743800
/**
744801
* The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment}
@@ -863,106 +920,6 @@ interface GPUFragmentState
863920
targets: Iterable<GPUColorTargetState | null>;
864921
}
865922

866-
interface GPUImageCopyBuffer
867-
extends GPUImageDataLayout {
868-
/**
869-
* A buffer which either contains image data to be copied or will store the image data being
870-
* copied, depending on the method it is being passed to.
871-
*/
872-
buffer: GPUBuffer;
873-
}
874-
875-
interface GPUImageCopyExternalImage {
876-
/**
877-
* The source of the image copy. The copy source data is captured at the moment that
878-
* {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described
879-
* by the external source dimensions table.
880-
*/
881-
source: GPUImageCopyExternalImageSource;
882-
/**
883-
* Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.
884-
* Together with `copySize`, defines the full copy sub-region.
885-
*/
886-
origin?: GPUOrigin2DStrict;
887-
/**
888-
* Describes whether the source image is vertically flipped, or not.
889-
* If this option is set to `true`, the copy is flipped vertically: the bottom row of the source
890-
* region is copied into the first row of the destination region, and so on.
891-
* The {@link GPUImageCopyExternalImage#origin} option is still relative to the top-left corner
892-
* of the source image, increasing downward.
893-
*/
894-
flipY?: boolean;
895-
}
896-
897-
interface GPUImageCopyTexture {
898-
/**
899-
* Texture to copy to/from.
900-
*/
901-
texture: GPUTexture;
902-
/**
903-
* Mip-map level of the {@link GPUImageCopyTexture#texture} to copy to/from.
904-
*/
905-
mipLevel?: GPUIntegerCoordinate;
906-
/**
907-
* Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.
908-
* Together with `copySize`, defines the full copy sub-region.
909-
*/
910-
origin?: GPUOrigin3D;
911-
/**
912-
* Defines which aspects of the {@link GPUImageCopyTexture#texture} to copy to/from.
913-
*/
914-
aspect?: GPUTextureAspect;
915-
}
916-
917-
interface GPUImageCopyTextureTagged
918-
extends GPUImageCopyTexture {
919-
/**
920-
* Describes the color space and encoding used to encode data into the destination texture.
921-
* This [[#color-space-conversions|may result]] in values outside of the range [0, 1]
922-
* being written to the target texture, if its format can represent them.
923-
* Otherwise, the results are clamped to the target texture format's range.
924-
* Note:
925-
* If {@link GPUImageCopyTextureTagged#colorSpace} matches the source image,
926-
* conversion may not be necessary. See [[#color-space-conversion-elision]].
927-
*/
928-
colorSpace?: PredefinedColorSpace;
929-
/**
930-
* Describes whether the data written into the texture should have its RGB channels
931-
* premultiplied by the alpha channel, or not.
932-
* If this option is set to `true` and the {@link GPUImageCopyExternalImage#source} is also
933-
* premultiplied, the source RGB values must be preserved even if they exceed their
934-
* corresponding alpha values.
935-
* Note:
936-
* If {@link GPUImageCopyTextureTagged#premultipliedAlpha} matches the source image,
937-
* conversion may not be necessary. See [[#color-space-conversion-elision]].
938-
*/
939-
premultipliedAlpha?: boolean;
940-
}
941-
942-
interface GPUImageDataLayout {
943-
/**
944-
* The offset, in bytes, from the beginning of the image data source (such as a
945-
* {@link GPUImageCopyBuffer#buffer|GPUImageCopyBuffer.buffer}) to the start of the image data
946-
* within that source.
947-
*/
948-
offset?: GPUSize64;
949-
/**
950-
* The stride, in bytes, between the beginning of each texel block row and the subsequent
951-
* texel block row.
952-
* Required if there are multiple texel block rows (i.e. the copy height or depth is more
953-
* than one block).
954-
*/
955-
bytesPerRow?: GPUSize32;
956-
/**
957-
* Number of texel block rows per single texel image of the texture.
958-
* {@link GPUImageDataLayout#rowsPerImage} &times;
959-
* {@link GPUImageDataLayout#bytesPerRow} is the stride, in bytes, between the beginning of each
960-
* texel image of data and the subsequent texel image.
961-
* Required if there are multiple texel images (i.e. the copy depth is more than one).
962-
*/
963-
rowsPerImage?: GPUSize32;
964-
}
965-
966923
interface GPUMultisampleState {
967924
/**
968925
* Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only
@@ -1020,11 +977,11 @@ interface GPUPipelineErrorInit {
1020977
interface GPUPipelineLayoutDescriptor
1021978
extends GPUObjectDescriptorBase {
1022979
/**
1023-
* A list of {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds to a
1024-
* @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding with
1025-
* `@group(N)`.
980+
* A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds
981+
* to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding
982+
* with `@group(N)`.
1026983
*/
1027-
bindGroupLayouts: Iterable<GPUBindGroupLayout>;
984+
bindGroupLayouts: Iterable<GPUBindGroupLayout | null>;
1028985
}
1029986

1030987
interface GPUPrimitiveState {
@@ -1504,6 +1461,59 @@ interface GPUStorageTextureBindingLayout {
15041461
viewDimension?: GPUTextureViewDimension;
15051462
}
15061463

1464+
interface GPUTexelCopyBufferInfo
1465+
extends GPUTexelCopyBufferLayout {
1466+
/**
1467+
* A buffer which either contains texel data to be copied or will store the texel data being
1468+
* copied, depending on the method it is being passed to.
1469+
*/
1470+
buffer: GPUBuffer;
1471+
}
1472+
1473+
interface GPUTexelCopyBufferLayout {
1474+
/**
1475+
* The offset, in bytes, from the beginning of the texel data source (such as a
1476+
* {@link GPUTexelCopyBufferInfo#buffer|GPUTexelCopyBufferInfo.buffer}) to the start of the texel data
1477+
* within that source.
1478+
*/
1479+
offset?: GPUSize64;
1480+
/**
1481+
* The stride, in bytes, between the beginning of each texel block row and the subsequent
1482+
* texel block row.
1483+
* Required if there are multiple texel block rows (i.e. the copy height or depth is more
1484+
* than one block).
1485+
*/
1486+
bytesPerRow?: GPUSize32;
1487+
/**
1488+
* Number of texel block rows per single texel image of the texture.
1489+
* {@link GPUTexelCopyBufferLayout#rowsPerImage} &times;
1490+
* {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each
1491+
* texel image of data and the subsequent texel image.
1492+
* Required if there are multiple texel images (i.e. the copy depth is more than one).
1493+
*/
1494+
rowsPerImage?: GPUSize32;
1495+
}
1496+
1497+
interface GPUTexelCopyTextureInfo {
1498+
/**
1499+
* Texture to copy to/from.
1500+
*/
1501+
texture: GPUTexture;
1502+
/**
1503+
* Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.
1504+
*/
1505+
mipLevel?: GPUIntegerCoordinate;
1506+
/**
1507+
* Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.
1508+
* Together with `copySize`, defines the full copy sub-region.
1509+
*/
1510+
origin?: GPUOrigin3D;
1511+
/**
1512+
* Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.
1513+
*/
1514+
aspect?: GPUTextureAspect;
1515+
}
1516+
15071517
interface GPUTextureBindingLayout {
15081518
/**
15091519
* Indicates the type required for texture views bound to this binding.
@@ -2154,8 +2164,8 @@ interface GPUCommandEncoder
21542164
* `copySize`:
21552165
*/
21562166
copyBufferToTexture(
2157-
source: GPUImageCopyBuffer,
2158-
destination: GPUImageCopyTexture,
2167+
source: GPUTexelCopyBufferInfo,
2168+
destination: GPUTexelCopyTextureInfo,
21592169
copySize: GPUExtent3DStrict
21602170
): undefined;
21612171
/**
@@ -2166,8 +2176,8 @@ interface GPUCommandEncoder
21662176
* `copySize`:
21672177
*/
21682178
copyTextureToBuffer(
2169-
source: GPUImageCopyTexture,
2170-
destination: GPUImageCopyBuffer,
2179+
source: GPUTexelCopyTextureInfo,
2180+
destination: GPUTexelCopyBufferInfo,
21712181
copySize: GPUExtent3DStrict
21722182
): undefined;
21732183
/**
@@ -2179,8 +2189,8 @@ interface GPUCommandEncoder
21792189
* `copySize`:
21802190
*/
21812191
copyTextureToTexture(
2182-
source: GPUImageCopyTexture,
2183-
destination: GPUImageCopyTexture,
2192+
source: GPUTexelCopyTextureInfo,
2193+
destination: GPUTexelCopyTextureInfo,
21842194
copySize: GPUExtent3DStrict
21852195
): undefined;
21862196
/**
@@ -2766,18 +2776,18 @@ interface GPUQueue
27662776
* @param size - Extents of the content to write from `data` to `destination`.
27672777
*/
27682778
writeTexture(
2769-
destination: GPUImageCopyTexture,
2779+
destination: GPUTexelCopyTextureInfo,
27702780
data:
27712781
| BufferSource
27722782
| SharedArrayBuffer,
2773-
dataLayout: GPUImageDataLayout,
2783+
dataLayout: GPUTexelCopyBufferLayout,
27742784
size: GPUExtent3DStrict
27752785
): undefined;
27762786
/**
27772787
* Issues a copy operation of the contents of a platform image/canvas
27782788
* into the destination texture.
27792789
* This operation performs [[#color-space-conversions|color encoding]] into the destination
2780-
* encoding according to the parameters of {@link GPUImageCopyTextureTagged}.
2790+
* encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}.
27812791
* Copying into a `-srgb` texture results in the same texture bytes, not the same decoded
27822792
* values, as copying into the corresponding non-`-srgb` format.
27832793
* Thus, after a copy operation, sampling the destination texture has
@@ -2788,8 +2798,8 @@ interface GPUQueue
27882798
* @param copySize - Extents of the content to write from `source` to `destination`.
27892799
*/
27902800
copyExternalImageToTexture(
2791-
source: GPUImageCopyExternalImage,
2792-
destination: GPUImageCopyTextureTagged,
2801+
source: GPUCopyExternalImageSourceInfo,
2802+
destination: GPUCopyExternalImageDestInfo,
27932803
copySize: GPUExtent3DStrict
27942804
): undefined;
27952805
}
@@ -3195,3 +3205,16 @@ declare var GPUTextureUsage: {
31953205
readonly STORAGE_BINDING: GPUFlagsConstant;
31963206
readonly RENDER_ATTACHMENT: GPUFlagsConstant;
31973207
};
3208+
3209+
/** @deprecated Use {@link GPUTexelCopyBufferLayout} */
3210+
type GPUImageDataLayout = GPUTexelCopyBufferLayout;
3211+
/** @deprecated Use {@link GPUTexelCopyBufferInfo} */
3212+
type GPUImageCopyBuffer = GPUTexelCopyBufferInfo;
3213+
/** @deprecated Use {@link GPUTexelCopyTextureInfo} */
3214+
type GPUImageCopyTexture = GPUTexelCopyTextureInfo;
3215+
/** @deprecated Use {@link GPUCopyExternalImageDestInfo} */
3216+
type GPUImageCopyTextureTagged = GPUCopyExternalImageDestInfo;
3217+
/** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */
3218+
type GPUImageCopyExternalImage = GPUCopyExternalImageSourceInfo;
3219+
/** @deprecated Use {@link GPUCopyExternalImageSource} */
3220+
type GPUImageCopyExternalImageSource = GPUCopyExternalImageSource;

0 commit comments

Comments
 (0)