diff --git a/src/webgpu/api/operation/command_buffer/image_copy.spec.ts b/src/webgpu/api/operation/command_buffer/image_copy.spec.ts index beb87c02c38f..451ef8a97687 100644 --- a/src/webgpu/api/operation/command_buffer/image_copy.spec.ts +++ b/src/webgpu/api/operation/command_buffer/image_copy.spec.ts @@ -1132,6 +1132,10 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) { copySize ); + const use2DArray = this.isCompatibility && inputTexture.depthOrArrayLayers > 1; + const [textureType, layerCode] = use2DArray + ? ['texture_2d_array', ', baseArrayLayer'] + : ['texture_2d', '']; const renderPipeline = this.device.createRenderPipeline({ layout: 'auto', vertex: { @@ -1154,10 +1158,11 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) { fragment: { module: this.device.createShaderModule({ code: ` - @group(0) @binding(0) var inputTexture: texture_2d; + @group(0) @binding(0) var inputTexture: ${textureType}; + @group(0) @binding(1) var baseArrayLayer: u32; @fragment fn main(@builtin(position) fragcoord : vec4) -> @builtin(frag_depth) f32 { - var depthValue : vec4 = textureLoad(inputTexture, vec2(fragcoord.xy), 0); + var depthValue : vec4 = textureLoad(inputTexture, vec2(fragcoord.xy)${layerCode}, 0); return depthValue.x; }`, }), @@ -1200,19 +1205,26 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) { }); renderPass.setPipeline(renderPipeline); + const uniformBufferEntry = use2DArray + ? [this.createUniformBufferAndBindGroupEntryForBaseArrayLayer(z)] + : []; + const bindGroup = this.device.createBindGroup({ layout: renderPipeline.getBindGroupLayout(0), entries: [ { binding: 0, resource: inputTexture.createView({ - dimension: '2d', - baseArrayLayer: z, - arrayLayerCount: 1, + dimension: use2DArray ? '2d-array' : '2d', + ...(use2DArray && { + baseArrayLayer: z, + arrayLayerCount: 1, + }), baseMipLevel: 0, mipLevelCount: 1, }), }, + ...uniformBufferEntry, ], }); renderPass.setBindGroup(0, bindGroup); @@ -1223,6 +1235,23 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) { this.queue.submit([encoder.finish()]); } + createUniformBufferAndBindGroupEntryForBaseArrayLayer(z: number) { + const buffer = this.device.createBuffer({ + usage: GPUBufferUsage.UNIFORM, + size: 4, + mappedAtCreation: true, + }); + this.trackForCleanup(buffer); + new Uint32Array(buffer.getMappedRange()).set([z]); + buffer.unmap(); + return { + binding: 1, + resource: { + buffer, + }, + }; + } + DoCopyTextureToBufferWithDepthAspectTest( format: DepthStencilFormat, copySize: readonly [number, number, number], @@ -1413,7 +1442,6 @@ bytes in copy works for every format. .beforeAllSubcases(t => { const info = kTextureFormatInfo[t.params.format]; t.skipIfTextureFormatNotSupported(t.params.format); - t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format); t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => { @@ -1511,7 +1539,6 @@ works for every format with 2d and 2d-array textures. .beforeAllSubcases(t => { const info = kTextureFormatInfo[t.params.format]; t.skipIfTextureFormatNotSupported(t.params.format); - t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format); t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => { @@ -1592,7 +1619,6 @@ for all formats. We pass origin and copyExtent as [number, number, number].` .beforeAllSubcases(t => { const info = kTextureFormatInfo[t.params.format]; t.skipIfTextureFormatNotSupported(t.params.format); - t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format); t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => { @@ -1793,7 +1819,6 @@ TODO: Make a variant for depth-stencil formats. .beforeAllSubcases(t => { const info = kTextureFormatInfo[t.params.format]; t.skipIfTextureFormatNotSupported(t.params.format); - t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format); t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => {