Skip to content

Commit

Permalink
Update types,textures and bgra8unorm_storage tests (#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrekshao authored Mar 15, 2024
1 parent 358481f commit 1042b2f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
31 changes: 0 additions & 31 deletions src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
`
Expand Down
3 changes: 1 addition & 2 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -2192,6 +2190,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 },
Expand Down
34 changes: 33 additions & 1 deletion src/webgpu/shader/validation/types/textures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>
- 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')
Expand All @@ -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);
Expand Down

0 comments on commit 1042b2f

Please sign in to comment.