From 90181a79596b0f46b0a87fa5d5b856c1379f7fd7 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Mon, 27 Nov 2023 10:15:45 -0800 Subject: [PATCH 1/2] Revert "Reapply "Skip compressed image_copy tests in Compatibility mode. (#3140)" (#3161)" This reverts commit 0e06340de1e50169093ea5951d55a4dce983f719. These tests test writeBuffer, copyBufferToTexture, and copyTextureToBuffer as it says at the top of the file. They should not have been disabled for textures that don't support copyTextureToBuffer. For those cases they use rendering compare results. --- src/webgpu/api/operation/command_buffer/image_copy.spec.ts | 4 ---- 1 file changed, 4 deletions(-) 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..4eebc3d611e4 100644 --- a/src/webgpu/api/operation/command_buffer/image_copy.spec.ts +++ b/src/webgpu/api/operation/command_buffer/image_copy.spec.ts @@ -1413,7 +1413,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 +1510,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 +1590,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 +1790,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 => { From 6a6cffd0d11cee332af28fed410cd37ce2e107a0 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Mon, 27 Nov 2023 11:11:38 -0800 Subject: [PATCH 2/2] Fix depth and stencil image_copy tests for compat --- .../command_buffer/image_copy.spec.ts | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) 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 4eebc3d611e4..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],