From 1647569429f5f6406a0473d0e0a837716debe6ff Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Thu, 30 Nov 2023 14:34:01 -0800 Subject: [PATCH] Compat: test depthOrArrayLayers vs textureBindingViewFormat A texture with textureBindingViewFormat = '2d' should generate a validation error if depthOrArrayLayers is not 1 A texture with textureBindingViewFormat = 'cube' should generate a validation error if depthOrArrayLayers is not 6 --- .../validation/texture/createTexture.spec.ts | 34 +++++++++++++++++++ src/webgpu/listing_meta.json | 1 + 2 files changed, 35 insertions(+) diff --git a/src/webgpu/compat/api/validation/texture/createTexture.spec.ts b/src/webgpu/compat/api/validation/texture/createTexture.spec.ts index 2dfc4d94ea07..974f10082e7f 100644 --- a/src/webgpu/compat/api/validation/texture/createTexture.spec.ts +++ b/src/webgpu/compat/api/validation/texture/createTexture.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ export const description = ` Tests that you can not use bgra8unorm-srgb in compat mode. Tests that textureBindingViewDimension must compatible with texture dimension @@ -70,3 +71,36 @@ g.test('invalidTextureBindingViewDimension') shouldError ); }); + +g.test('depthOrArrayLayers_incompatible_with_textureBindingViewDimension') + .desc( + `Tests + * if textureBindingViewDimension is '2d' then depthOrArrayLayers must be 1 + * if textureBindingViewDimension is 'cube' then depthOrArrayLayers must be 6 + ` + ) + .params(u => + u // + .combine('textureBindingViewDimension', ['2d', 'cube']) + .combine('depthOrArrayLayers', [1, 3, 6, 12]) + ) + .fn(t => { + const { textureBindingViewDimension, depthOrArrayLayers } = t.params; + const shouldError = + (textureBindingViewDimension === '2d' && depthOrArrayLayers !== 1) || + (textureBindingViewDimension === 'cube' && depthOrArrayLayers !== 6); + t.expectGPUError( + 'validation', + () => { + const texture = t.device.createTexture({ + size: [1, 1, depthOrArrayLayers], + format: 'rgba8unorm', + usage: GPUTextureUsage.TEXTURE_BINDING, + textureBindingViewDimension, + } as GPUTextureDescriptor); // MAINTENANCE_TODO: remove cast once textureBindingViewDimension is added to IDL + t.trackForCleanup(texture); + }, + shouldError + ); + }); + diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index bfd9c808259e..6f4e63cf9b98 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -841,6 +841,7 @@ "webgpu:compat,api,validation,render_pipeline,fragment_state:colorState:*": { "subcaseMS": 32.604 }, "webgpu:compat,api,validation,render_pipeline,shader_module:sample_mask:*": { "subcaseMS": 14.801 }, "webgpu:compat,api,validation,render_pipeline,vertex_state:maxVertexAttributesVertexIndexInstanceIndex:*": { "subcaseMS": 3.700 }, + "webgpu:compat,api,validation,texture,createTexture:depthOrArrayLayers_incompatible_with_textureBindingViewDimension:*": { "subcaseMS": 12.712 }, "webgpu:compat,api,validation,texture,createTexture:invalidTextureBindingViewDimension:*": { "subcaseMS": 6.022 }, "webgpu:compat,api,validation,texture,createTexture:unsupportedTextureFormats:*": { "subcaseMS": 0.700 }, "webgpu:compat,api,validation,texture,createTexture:unsupportedTextureViewFormats:*": { "subcaseMS": 0.601 },