diff --git a/cts_runner/test.lst b/cts_runner/test.lst index e21e12d3e..8f047b602 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -3,6 +3,7 @@ // cargo xtask cts -- --list // ``` unittests:* +webgpu:api,operation,buffers,createBindGroup:buffer_binding_resource:* webgpu:api,operation,command_buffer,basic:* webgpu:api,operation,command_buffer,copyBufferToBuffer:* fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth24plus" @@ -23,6 +24,8 @@ fails-if(vulkan) webgpu:api,operation,vertex_state,correctness:array_stride_zero fails-if(metal) webgpu:api,operation,vertex_state,correctness:setVertexBuffer_offset_and_attribute_offset:* fails-if(dx12) webgpu:api,validation,capability_checks,limits,maxBindGroups:setBindGroup,* webgpu:api,validation,createBindGroup:buffer,effective_buffer_binding_size:* +// Fails because we coerce a size of 0 in `GPUDevice.createBindGroup(…)` to `buffer.size - offset`. +// FAIL webgpu:api,validation,createBindGroup:buffer_offset_and_size_for_bind_groups_match:* webgpu:api,validation,encoding,beginComputePass:* webgpu:api,validation,encoding,beginRenderPass:* webgpu:api,validation,encoding,cmds,clearBuffer:* diff --git a/deno_webgpu/bind_group.rs b/deno_webgpu/bind_group.rs index d003ede44..40ea9aab0 100644 --- a/deno_webgpu/bind_group.rs +++ b/deno_webgpu/bind_group.rs @@ -94,6 +94,7 @@ pub(crate) struct GPUBufferBinding { pub(crate) enum GPUBindingResource { Sampler(Ptr), TextureView(Ptr), + Buffer(Ptr), BufferBinding(GPUBufferBinding), } @@ -125,6 +126,16 @@ impl<'a> WebIdlConverter<'a> for GPUBindingResource { ) .map(Self::TextureView) }) + .or_else(|_| { + >::convert( + scope, + value, + prefix.clone(), + context.borrowed(), + options, + ) + .map(Self::Buffer) + }) .or_else(|_| { GPUBufferBinding::convert(scope, value, prefix, context, options) .map(Self::BufferBinding) diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index aef52607f..037caaef6 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -406,6 +406,13 @@ impl GPUDevice { GPUBindingResource::TextureView(texture_view) => { BindingResource::TextureView(texture_view.id) } + GPUBindingResource::Buffer(buffer) => { + BindingResource::Buffer(wgpu_core::binding_model::BufferBinding { + buffer: buffer.id, + offset: 0, + size: NonZeroU64::new(buffer.size), + }) + } GPUBindingResource::BufferBinding(buffer_binding) => { BindingResource::Buffer(wgpu_core::binding_model::BufferBinding { buffer: buffer_binding.buffer.id,