diff --git a/src/webgpu/api/validation/createTexture.spec.ts b/src/webgpu/api/validation/createTexture.spec.ts index 3de91245f19c..2cd5c0988338 100644 --- a/src/webgpu/api/validation/createTexture.spec.ts +++ b/src/webgpu/api/validation/createTexture.spec.ts @@ -101,7 +101,8 @@ g.test('zero_size_and_usage') g.test('dimension_type_and_format_compatibility') .desc( - `Test every dimension type on every format. Note that compressed formats and depth/stencil formats are not valid for 1D/3D dimension types.` + `Test every dimension type on every format. Depth/stencil formats only support 2d; + compressed formats support either 2d or 2d+3d.` ) .params(u => u // @@ -220,7 +221,6 @@ g.test('mipLevelCount,bound_check') ({ format, size, dimension }) => format === 'bc1-rgba-unorm' && (dimension === '1d' || - dimension === '3d' || size[0] % kTextureFormatInfo[format].blockWidth !== 0 || size[1] % kTextureFormatInfo[format].blockHeight !== 0) ) @@ -459,8 +459,8 @@ g.test('texture_size,default_value_and_smallest_size,compressed_format') ) .params(u => u - // Compressed formats are invalid for 1D and 3D. - .combine('dimension', [undefined, '2d'] as const) + // Compressed formats are invalid for 1D. + .combine('dimension', [undefined, '2d', '3d'] as const) .combine('format', kCompressedTextureFormats) .beginSubcases() .expandWithParams(p => { @@ -474,6 +474,10 @@ g.test('texture_size,default_value_and_smallest_size,compressed_format') { size: [blockWidth, blockHeight, 1], _success: true }, ]; }) + // Filter if the dimension is 3D and format is not compatible + .unless( + ({ dimension, format }) => dimension === '3d' && !kTextureFormatInfo[format].texture3D + ) ) .beforeAllSubcases(t => { const { format } = t.params; diff --git a/src/webgpu/format_info.ts b/src/webgpu/format_info.ts index cbebf8873428..bb227010059d 100644 --- a/src/webgpu/format_info.ts +++ b/src/webgpu/format_info.ts @@ -30,6 +30,8 @@ const kFormatUniversalDefaults = { feature: undefined, /** The base format for srgb formats. Specified on both srgb and equivalent non-srgb formats. */ baseFormat: undefined, + /** Whether the format can be used in textures with 3D dimension. */ + texture3D: undefined, /** @deprecated Use `.color.bytes`, `.depth.bytes`, or `.stencil.bytes`. */ bytesPerBlock: undefined, @@ -68,7 +70,7 @@ function formatTableWithDefaults 1 || info.depth || info.stencil) + return ( + !(dimension === '1d' && (info.blockWidth > 1 || info.depth || info.stencil)) && + !(dimension === '3d' && !info.texture3D) ); }