From 6eeeaf723f2a31a66fce0bf2619bd8d5d07ade83 Mon Sep 17 00:00:00 2001 From: Shrek Shao Date: Thu, 14 Mar 2024 13:39:26 -0700 Subject: [PATCH] Update types,textures and bgra8unorm_storage tests --- .../texture/bgra8unorm_storage.spec.ts | 31 ----------------- src/webgpu/listing_meta.json | 3 +- .../shader/validation/types/textures.spec.ts | 34 ++++++++++++++++++- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts b/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts index 80872fd5d33d..0ae600eb49ce 100644 --- a/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts +++ b/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts @@ -81,37 +81,6 @@ validation cases where this feature is not enabled, which are skipped here. }); }); -g.test('create_shader_module_with_bgra8unorm_storage') - .desc( - ` -Test that it is valid to declare the format of a storage texture as bgra8unorm in a shader module if -the feature bgra8unorm-storage is enabled. -` - ) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('bgra8unorm-storage'); - }) - .params(u => u.combine('shaderType', ['fragment', 'compute'] as const)) - .fn(t => { - const { shaderType } = t.params; - - t.testCreateShaderModuleWithBGRA8UnormStorage(shaderType, true); - }); - -g.test('create_shader_module_without_bgra8unorm_storage') - .desc( - ` -Test that it is invalid to declare the format of a storage texture as bgra8unorm in a shader module -if the feature bgra8unorm-storage is not enabled. -` - ) - .params(u => u.combine('shaderType', ['fragment', 'compute'] as const)) - .fn(t => { - const { shaderType } = t.params; - - t.testCreateShaderModuleWithBGRA8UnormStorage(shaderType, false); - }); - g.test('configure_storage_usage_on_canvas_context_without_bgra8unorm_storage') .desc( ` diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index b6cd790bd4db..ccabdf9f20a6 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -836,8 +836,6 @@ "webgpu:api,validation,texture,bgra8unorm_storage:configure_storage_usage_on_canvas_context_with_bgra8unorm_storage:*": { "subcaseMS": 3.230 }, "webgpu:api,validation,texture,bgra8unorm_storage:configure_storage_usage_on_canvas_context_without_bgra8unorm_storage:*": { "subcaseMS": 1.767 }, "webgpu:api,validation,texture,bgra8unorm_storage:create_bind_group_layout:*": { "subcaseMS": 21.500 }, - "webgpu:api,validation,texture,bgra8unorm_storage:create_shader_module_with_bgra8unorm_storage:*": { "subcaseMS": 11.201 }, - "webgpu:api,validation,texture,bgra8unorm_storage:create_shader_module_without_bgra8unorm_storage:*": { "subcaseMS": 1.601 }, "webgpu:api,validation,texture,bgra8unorm_storage:create_texture:*": { "subcaseMS": 22.900 }, "webgpu:api,validation,texture,destroy:base:*": { "subcaseMS": 4.000 }, "webgpu:api,validation,texture,destroy:invalid_texture:*": { "subcaseMS": 27.200 }, @@ -2182,6 +2180,7 @@ "webgpu:shader,validation,types,struct:no_indirect_recursion_via_array_size:*": { "subcaseMS": 0.900 }, "webgpu:shader,validation,types,struct:no_indirect_recursion_via_struct_attribute:*": { "subcaseMS": 1.467 }, "webgpu:shader,validation,types,struct:no_indirect_recursion_via_struct_member_nested_in_alias:*": { "subcaseMS": 0.950 }, + "webgpu:shader,validation,types,textures:sampled_texture_types:*": { "subcaseMS": 7.634 }, "webgpu:shader,validation,types,textures:storage_texture_types:*": { "subcaseMS": 167.510 }, "webgpu:shader,validation,types,textures:texel_formats,as_value:*": { "subcaseMS": 0.518 }, "webgpu:shader,validation,types,textures:texel_formats:*": { "subcaseMS": 1707.432 }, diff --git a/src/webgpu/shader/validation/types/textures.spec.ts b/src/webgpu/shader/validation/types/textures.spec.ts index 904fa4721b8d..c1c39f66466e 100644 --- a/src/webgpu/shader/validation/types/textures.spec.ts +++ b/src/webgpu/shader/validation/types/textures.spec.ts @@ -67,6 +67,34 @@ g.test('texel_formats,as_value') t.expectCompileResult(false, wgsl); }); +const kValidTextureSampledTypes = ['f32', 'i32', 'u32']; + +g.test('sampled_texture_types') + .desc( + `Test that for texture_xx +- The sampled type T must be f32, i32, or u32 +` + ) + .params(u => + u + .combine('textureType', ['texture_2d', 'texture_multisampled_2d']) + .beginSubcases() + .combine('sampledType', [ + ...kValidTextureSampledTypes, + 'bool', + 'vec2', + 'mat2x2', + '1.0', + '1', + '1u', + ] as const) + ) + .fn(t => { + const { textureType, sampledType } = t.params; + const wgsl = `@group(0) @binding(0) var tex: ${textureType}<${sampledType}>;`; + t.expectCompileResult(kValidTextureSampledTypes.includes(sampledType), wgsl); + }); + const kAccessModes = ['read', 'write', 'read_write']; g.test('storage_texture_types') @@ -84,8 +112,12 @@ Besides, the shader compilation should always pass regardless of whether the for .fn(t => { const { format, access } = t.params; const info = kTextureFormatInfo[format]; + // bgra8unorm is considered a valid storage format at shader compilation stage const isFormatValid = - info.color?.storage || info.depth?.storage || info.stencil?.storage || false; + info.color?.storage || + info.depth?.storage || + info.stencil?.storage || + format === 'bgra8unorm'; const isAccessValid = kAccessModes.includes(access); const wgsl = `@group(0) @binding(0) var tex: texture_storage_2d<${format}, ${access}>;`; t.expectCompileResult(isFormatValid && isAccessValid, wgsl);