Skip to content

Commit 7d725b7

Browse files
authored
Add GPUCommandEncoder (#2403)
Co-authored-by: saschanaz <saschanaz@users.noreply.github.com>
1 parent 06cc7ee commit 7d725b7

29 files changed

+2304
-3
lines changed

baselines/dom.generated.d.ts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,19 @@ interface GPUColorDict {
812812
r: number;
813813
}
814814

815+
interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {
816+
}
817+
818+
interface GPUComputePassDescriptor extends GPUObjectDescriptorBase {
819+
timestampWrites?: GPUComputePassTimestampWrites;
820+
}
821+
822+
interface GPUComputePassTimestampWrites {
823+
beginningOfPassWriteIndex?: GPUSize32;
824+
endOfPassWriteIndex?: GPUSize32;
825+
querySet: GPUQuerySet;
826+
}
827+
815828
interface GPUCopyExternalImageDestInfo extends GPUTexelCopyTextureInfo {
816829
colorSpace?: PredefinedColorSpace;
817830
premultipliedAlpha?: boolean;
@@ -851,6 +864,45 @@ interface GPUPipelineErrorInit {
851864
interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase {
852865
}
853866

867+
interface GPURenderPassColorAttachment {
868+
clearValue?: GPUColor;
869+
depthSlice?: GPUIntegerCoordinate;
870+
loadOp: GPULoadOp;
871+
resolveTarget?: GPUTexture | GPUTextureView;
872+
storeOp: GPUStoreOp;
873+
view: GPUTexture | GPUTextureView;
874+
}
875+
876+
interface GPURenderPassDepthStencilAttachment {
877+
depthClearValue?: number;
878+
depthLoadOp?: GPULoadOp;
879+
depthReadOnly?: boolean;
880+
depthStoreOp?: GPUStoreOp;
881+
stencilClearValue?: GPUStencilValue;
882+
stencilLoadOp?: GPULoadOp;
883+
stencilReadOnly?: boolean;
884+
stencilStoreOp?: GPUStoreOp;
885+
view: GPUTexture | GPUTextureView;
886+
}
887+
888+
interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
889+
colorAttachments: (GPURenderPassColorAttachment | null)[];
890+
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
891+
maxDrawCount?: GPUSize64;
892+
occlusionQuerySet?: GPUQuerySet;
893+
timestampWrites?: GPURenderPassTimestampWrites;
894+
}
895+
896+
interface GPURenderPassTimestampWrites {
897+
beginningOfPassWriteIndex?: GPUSize32;
898+
endOfPassWriteIndex?: GPUSize32;
899+
querySet: GPUQuerySet;
900+
}
901+
902+
interface GPUTexelCopyBufferInfo extends GPUTexelCopyBufferLayout {
903+
buffer: GPUBuffer;
904+
}
905+
854906
interface GPUTexelCopyBufferLayout {
855907
bytesPerRow?: GPUSize32;
856908
offset?: GPUSize64;
@@ -14965,6 +15017,75 @@ declare var GPUCommandBuffer: {
1496515017
new(): GPUCommandBuffer;
1496615018
};
1496715019

15020+
/**
15021+
* The **`GPUCommandEncoder`** interface of the WebGPU API represents an encoder that collects a sequence of GPU commands to be issued to the GPU.
15022+
* Available only in secure contexts.
15023+
*
15024+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder)
15025+
*/
15026+
interface GPUCommandEncoder extends GPUDebugCommandsMixin, GPUObjectBase {
15027+
/**
15028+
* The **`beginComputePass()`** method of the GPUCommandEncoder interface starts encoding a compute pass, returning a GPUComputePassEncoder that can be used to control computation.
15029+
*
15030+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/beginComputePass)
15031+
*/
15032+
beginComputePass(descriptor?: GPUComputePassDescriptor): GPUComputePassEncoder;
15033+
/**
15034+
* The **`beginRenderPass()`** method of the GPUCommandEncoder interface starts encoding a render pass, returning a GPURenderPassEncoder that can be used to control rendering.
15035+
*
15036+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/beginRenderPass)
15037+
*/
15038+
beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
15039+
/**
15040+
* The **`clearBuffer()`** method of the GPUCommandEncoder interface encodes a command that fills a region of a GPUBuffer with zeroes.
15041+
*
15042+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/clearBuffer)
15043+
*/
15044+
clearBuffer(buffer: GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
15045+
/**
15046+
* The **`copyBufferToBuffer()`** method of the GPUCommandEncoder interface encodes a command that copies data from one GPUBuffer to another.
15047+
*
15048+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)
15049+
*/
15050+
copyBufferToBuffer(source: GPUBuffer, destination: GPUBuffer, size?: GPUSize64): void;
15051+
copyBufferToBuffer(source: GPUBuffer, sourceOffset: GPUSize64, destination: GPUBuffer, destinationOffset: GPUSize64, size?: GPUSize64): void;
15052+
/**
15053+
* The **`copyBufferToTexture()`** method of the GPUCommandEncoder interface encodes a command that copies data from a GPUBuffer to a GPUTexture.
15054+
*
15055+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)
15056+
*/
15057+
copyBufferToTexture(source: GPUTexelCopyBufferInfo, destination: GPUTexelCopyTextureInfo, copySize: GPUExtent3D): void;
15058+
/**
15059+
* The **`copyTextureToBuffer()`** method of the GPUCommandEncoder interface encodes a command that copies data from a GPUTexture to a GPUBuffer.
15060+
*
15061+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)
15062+
*/
15063+
copyTextureToBuffer(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyBufferInfo, copySize: GPUExtent3D): void;
15064+
/**
15065+
* The **`copyTextureToTexture()`** method of the GPUCommandEncoder interface encodes a command that copies data from one GPUTexture to another.
15066+
*
15067+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)
15068+
*/
15069+
copyTextureToTexture(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyTextureInfo, copySize: GPUExtent3D): void;
15070+
/**
15071+
* The **`finish()`** method of the GPUCommandEncoder interface completes recording of the command sequence encoded on this GPUCommandEncoder, returning a corresponding GPUCommandBuffer.
15072+
*
15073+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/finish)
15074+
*/
15075+
finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
15076+
/**
15077+
* The **`resolveQuerySet()`** method of the GPUCommandEncoder interface encodes a command that resolves a GPUQuerySet, copying the results into a specified GPUBuffer.
15078+
*
15079+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/resolveQuerySet)
15080+
*/
15081+
resolveQuerySet(querySet: GPUQuerySet, firstQuery: GPUSize32, queryCount: GPUSize32, destination: GPUBuffer, destinationOffset: GPUSize64): void;
15082+
}
15083+
15084+
declare var GPUCommandEncoder: {
15085+
prototype: GPUCommandEncoder;
15086+
new(): GPUCommandEncoder;
15087+
};
15088+
1496815089
/**
1496915090
* The **`GPUCompilationInfo`** interface of the WebGPU API represents an array of GPUCompilationMessage objects generated by the GPU shader module compiler to help diagnose problems with shader code.
1497015091
* Available only in secure contexts.
@@ -43623,8 +43744,10 @@ type GPUBufferMapState = "mapped" | "pending" | "unmapped";
4362343744
type GPUCompilationMessageType = "error" | "info" | "warning";
4362443745
type GPUDeviceLostReason = "destroyed" | "unknown";
4362543746
type GPUIndexFormat = "uint16" | "uint32";
43747+
type GPULoadOp = "clear" | "load";
4362643748
type GPUPipelineErrorReason = "internal" | "validation";
4362743749
type GPUQueryType = "occlusion" | "timestamp";
43750+
type GPUStoreOp = "discard" | "store";
4362843751
type GPUTextureAspect = "all" | "depth-only" | "stencil-only";
4362943752
type GPUTextureDimension = "1d" | "2d" | "3d";
4363043753
type GPUTextureFormat = "astc-10x10-unorm" | "astc-10x10-unorm-srgb" | "astc-10x5-unorm" | "astc-10x5-unorm-srgb" | "astc-10x6-unorm" | "astc-10x6-unorm-srgb" | "astc-10x8-unorm" | "astc-10x8-unorm-srgb" | "astc-12x10-unorm" | "astc-12x10-unorm-srgb" | "astc-12x12-unorm" | "astc-12x12-unorm-srgb" | "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" | "bc1-rgba-unorm" | "bc1-rgba-unorm-srgb" | "bc2-rgba-unorm" | "bc2-rgba-unorm-srgb" | "bc3-rgba-unorm" | "bc3-rgba-unorm-srgb" | "bc4-r-snorm" | "bc4-r-unorm" | "bc5-rg-snorm" | "bc5-rg-unorm" | "bc6h-rgb-float" | "bc6h-rgb-ufloat" | "bc7-rgba-unorm" | "bc7-rgba-unorm-srgb" | "bgra8unorm" | "bgra8unorm-srgb" | "depth16unorm" | "depth24plus" | "depth24plus-stencil8" | "depth32float" | "depth32float-stencil8" | "eac-r11snorm" | "eac-r11unorm" | "eac-rg11snorm" | "eac-rg11unorm" | "etc2-rgb8a1unorm" | "etc2-rgb8a1unorm-srgb" | "etc2-rgb8unorm" | "etc2-rgb8unorm-srgb" | "etc2-rgba8unorm" | "etc2-rgba8unorm-srgb" | "r16float" | "r16sint" | "r16snorm" | "r16uint" | "r16unorm" | "r32float" | "r32sint" | "r32uint" | "r8sint" | "r8snorm" | "r8uint" | "r8unorm" | "rg11b10ufloat" | "rg16float" | "rg16sint" | "rg16snorm" | "rg16uint" | "rg16unorm" | "rg32float" | "rg32sint" | "rg32uint" | "rg8sint" | "rg8snorm" | "rg8uint" | "rg8unorm" | "rgb10a2uint" | "rgb10a2unorm" | "rgb9e5ufloat" | "rgba16float" | "rgba16sint" | "rgba16snorm" | "rgba16uint" | "rgba16unorm" | "rgba32float" | "rgba32sint" | "rgba32uint" | "rgba8sint" | "rgba8snorm" | "rgba8uint" | "rgba8unorm" | "rgba8unorm-srgb" | "stencil8";
@@ -43918,6 +44041,27 @@ interface GPUBindingCommandsMixin {
4391844041
setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsets?: Iterable<GPUBufferDynamicOffset>): void;
4391944042
}
4392044043

44044+
interface GPUCommandEncoder {
44045+
/**
44046+
* The **`copyBufferToTexture()`** method of the GPUCommandEncoder interface encodes a command that copies data from a GPUBuffer to a GPUTexture.
44047+
*
44048+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)
44049+
*/
44050+
copyBufferToTexture(source: GPUTexelCopyBufferInfo, destination: GPUTexelCopyTextureInfo, copySize: Iterable<GPUIntegerCoordinate>): void;
44051+
/**
44052+
* The **`copyTextureToBuffer()`** method of the GPUCommandEncoder interface encodes a command that copies data from a GPUTexture to a GPUBuffer.
44053+
*
44054+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)
44055+
*/
44056+
copyTextureToBuffer(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyBufferInfo, copySize: Iterable<GPUIntegerCoordinate>): void;
44057+
/**
44058+
* The **`copyTextureToTexture()`** method of the GPUCommandEncoder interface encodes a command that copies data from one GPUTexture to another.
44059+
*
44060+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)
44061+
*/
44062+
copyTextureToTexture(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyTextureInfo, copySize: Iterable<GPUIntegerCoordinate>): void;
44063+
}
44064+
4392144065
interface GPUQueue {
4392244066
/**
4392344067
* The **`copyExternalImageToTexture()`** method of the GPUQueue interface copies a snapshot taken from a source image, video, or canvas into a given GPUTexture.

0 commit comments

Comments
 (0)