webgpu: Clean up GPUCommandEncoders and add some validation (#33223)

* TextureUsages::from_bits_retain

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Fixup CreateBindGroupLayout

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* GPUExtent3D checking and converting

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Cleanup GPUCommandEncoders and some TODOs

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* validate gpuorigin3d

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* validate GPUColor

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* set good expect

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-30 13:23:17 +02:00 committed by GitHub
parent 83a40c5180
commit 817a91f2ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 276 additions and 361 deletions

View file

@ -462,10 +462,12 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
dictionary GPUBindGroupLayoutEntry {
required GPUIndex32 binding;
required GPUShaderStageFlags visibility;
GPUBufferBindingLayout buffer;
GPUSamplerBindingLayout sampler;
GPUTextureBindingLayout texture;
GPUStorageTextureBindingLayout storageTexture;
GPUExternalTextureBindingLayout externalTexture;
};
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
@ -514,6 +516,8 @@ dictionary GPUTextureBindingLayout {
enum GPUStorageTextureAccess {
"write-only",
"read-only",
"read-write",
};
dictionary GPUStorageTextureBindingLayout {
@ -522,6 +526,9 @@ dictionary GPUStorageTextureBindingLayout {
GPUTextureViewDimension viewDimension = "2d";
};
dictionary GPUExternalTextureBindingLayout {
};
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUBindGroup {
};
@ -867,7 +874,7 @@ dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
interface GPUCommandEncoder {
[NewObject]
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
[NewObject]
[NewObject, Throws]
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
undefined copyBufferToBuffer(
@ -877,16 +884,19 @@ interface GPUCommandEncoder {
GPUSize64 destinationOffset,
GPUSize64 size);
[Throws]
undefined copyBufferToTexture(
GPUImageCopyBuffer source,
GPUImageCopyTexture destination,
GPUExtent3D copySize);
[Throws]
undefined copyTextureToBuffer(
GPUImageCopyTexture source,
GPUImageCopyBuffer destination,
GPUExtent3D copySize);
[Throws]
undefined copyTextureToTexture(
GPUImageCopyTexture source,
GPUImageCopyTexture destination,
@ -942,6 +952,7 @@ interface GPURenderPassEncoder {
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
[Throws]
undefined setBlendConstant(GPUColor color);
undefined setStencilReference(GPUStencilValue reference);