diff --git a/cts_runner/test.lst b/cts_runner/test.lst index 88ac12a10..dfa3995aa 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -31,6 +31,8 @@ webgpu:api,operation,render_pass,storeOp:* fails-if(vulkan) webgpu:api,operation,vertex_state,correctness:array_stride_zero:* // Presumably vertex pulling, revisit after https://github.com/gfx-rs/wgpu/issues/7981 is fixed. fails-if(metal) webgpu:api,operation,vertex_state,correctness:setVertexBuffer_offset_and_attribute_offset:* +webgpu:api,validation,buffer,create:* +webgpu:api,validation,buffer,destroy:* 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`. diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index 86893dff6..300d3a09a 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -150,7 +150,21 @@ impl GPUDevice { fn create_buffer( &self, #[webidl] descriptor: super::buffer::GPUBufferDescriptor, - ) -> GPUBuffer { + ) -> Result { + // wgpu-core would also check this, but it needs to be reported via a JS + // error, not a validation error. (WebGPU specifies this check on the + // content timeline.) + if descriptor.mapped_at_creation + && descriptor.size % wgpu_types::COPY_BUFFER_ALIGNMENT != 0 + { + return Err(JsErrorBox::range_error( + format!( + "The size of a buffer that is mapped at creation must be a multiple of {}", + wgpu_types::COPY_BUFFER_ALIGNMENT, + ) + )); + } + // Validation of the usage needs to happen on the device timeline, so // don't raise an error immediately if it isn't valid. wgpu will // reject `BufferUsages::empty()`. @@ -171,7 +185,7 @@ impl GPUDevice { self.error_handler.push_error(err); - GPUBuffer { + Ok(GPUBuffer { instance: self.instance.clone(), error_handler: self.error_handler.clone(), id, @@ -190,7 +204,7 @@ impl GPUDevice { None }), mapped_js_buffers: RefCell::new(vec![]), - } + }) } #[required(1)]