diff --git a/src/webgpu/capability_info.ts b/src/webgpu/capability_info.ts index e2cf0e71400d..46da76f7f9cc 100644 --- a/src/webgpu/capability_info.ts +++ b/src/webgpu/capability_info.ts @@ -982,6 +982,7 @@ export const kKnownWGSLLanguageFeatures = [ 'subgroup_uniformity', 'swizzle_assignment', 'linear_indexing', + 'texture_formats_tier1', ] as const; export type WGSLLanguageFeature = (typeof kKnownWGSLLanguageFeatures)[number]; diff --git a/src/webgpu/shader/validation/extension/readonly_and_readwrite_storage_textures.spec.ts b/src/webgpu/shader/validation/extension/readonly_and_readwrite_storage_textures.spec.ts index 3614381ca9aa..cb0069e388a1 100644 --- a/src/webgpu/shader/validation/extension/readonly_and_readwrite_storage_textures.spec.ts +++ b/src/webgpu/shader/validation/extension/readonly_and_readwrite_storage_textures.spec.ts @@ -3,16 +3,25 @@ Validation tests for the readonly_and_readwrite_storage_textures language featur `; import { makeTestGroup } from '../../../../common/framework/test_group.js'; -import { kPossibleStorageTextureFormats } from '../../../format_info.js'; +import { hasFeature } from '../../../../common/util/util.js'; +import { + kPossibleStorageTextureFormats, + kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly, +} from '../../../format_info.js'; import { ShaderValidationTest } from '../shader_validation_test.js'; export const g = makeTestGroup(ShaderValidationTest); -const kFeatureName = 'readonly_and_readwrite_storage_textures'; +const kAccessModeFeatureName = 'readonly_and_readwrite_storage_textures'; +const kTier1FeatureName = 'texture_formats_tier1'; +const kTier1DeviceFeatureName = 'texture-formats-tier1'; g.test('var_decl') .desc( - `Checks that the read and read_write access modes are only allowed with the language feature present` + `Checks that the read and read_write access modes are only allowed with the language feature present + + TODO(https://github.com/gpuweb/cts/issues/4612): Stop checking the device feature + ` ) .paramsSubcasesOnly(u => u @@ -28,9 +37,26 @@ g.test('var_decl') .fn(t => { const { type, format, access } = t.params; + let valid = true; + if (access !== 'write') { + valid &&= t.hasLanguageFeature(kAccessModeFeatureName); + } + + if (kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly.indexOf(format) >= 0) { + // Even though some of these formats do not support read-write access + // without the tier2 adapter feature, their validity in WGSL should + // depend only on the language feature for tier1. + + // However, because the language feature is new, also check the device + // feature. MAINTENANCE_TODO(https://github.com/gpuweb/cts/issues/4612): + // Stop doing this; make `if` body unconditional + if (!hasFeature(t.device.features, kTier1DeviceFeatureName)) { + valid &&= t.hasLanguageFeature(kTier1FeatureName); + } + } + const source = `@group(0) @binding(0) var t : ${type}<${format}, ${access}>;`; - const requiresFeature = access !== 'write'; - t.expectCompileResult(t.hasLanguageFeature(kFeatureName) || !requiresFeature, source); + t.expectCompileResult(valid, source); }); g.test('textureBarrier') @@ -39,7 +65,7 @@ g.test('textureBarrier') ) .fn(t => { t.expectCompileResult( - t.hasLanguageFeature(kFeatureName), + t.hasLanguageFeature(kAccessModeFeatureName), ` @workgroup_size(1) @compute fn main() { textureBarrier();