@@ -3,16 +3,25 @@ Validation tests for the readonly_and_readwrite_storage_textures language featur
33` ;
44
55import { makeTestGroup } from '../../../../common/framework/test_group.js' ;
6- import { kPossibleStorageTextureFormats } from '../../../format_info.js' ;
6+ import { hasFeature } from '../../../../common/util/util.js' ;
7+ import {
8+ kPossibleStorageTextureFormats ,
9+ kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly ,
10+ } from '../../../format_info.js' ;
711import { ShaderValidationTest } from '../shader_validation_test.js' ;
812
913export const g = makeTestGroup ( ShaderValidationTest ) ;
1014
11- const kFeatureName = 'readonly_and_readwrite_storage_textures' ;
15+ const kAccessModeFeatureName = 'readonly_and_readwrite_storage_textures' ;
16+ const kTier1FeatureName = 'texture_formats_tier1' ;
17+ const kTier1DeviceFeatureName = 'texture-formats-tier1' ;
1218
1319g . test ( 'var_decl' )
1420 . desc (
15- `Checks that the read and read_write access modes are only allowed with the language feature present`
21+ `Checks that the read and read_write access modes are only allowed with the language feature present
22+
23+ TODO(https://github.com/gpuweb/cts/issues/4612): Stop checking the device feature
24+ `
1625 )
1726 . paramsSubcasesOnly ( u =>
1827 u
@@ -28,9 +37,26 @@ g.test('var_decl')
2837 . fn ( t => {
2938 const { type, format, access } = t . params ;
3039
40+ let valid = true ;
41+ if ( access !== 'write' ) {
42+ valid &&= t . hasLanguageFeature ( kAccessModeFeatureName ) ;
43+ }
44+
45+ if ( kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly . indexOf ( format ) >= 0 ) {
46+ // Even though some of these formats do not support read-write access
47+ // without the tier2 adapter feature, their validity in WGSL should
48+ // depend only on the language feature for tier1.
49+
50+ // However, because the language feature is new, also check the device
51+ // feature. MAINTENANCE_TODO(https://github.com/gpuweb/cts/issues/4612):
52+ // Stop doing this; make `if` body unconditional
53+ if ( ! hasFeature ( t . device . features , kTier1DeviceFeatureName ) ) {
54+ valid &&= t . hasLanguageFeature ( kTier1FeatureName ) ;
55+ }
56+ }
57+
3158 const source = `@group(0) @binding(0) var t : ${ type } <${ format } , ${ access } >;` ;
32- const requiresFeature = access !== 'write' ;
33- t . expectCompileResult ( t . hasLanguageFeature ( kFeatureName ) || ! requiresFeature , source ) ;
59+ t . expectCompileResult ( valid , source ) ;
3460 } ) ;
3561
3662g . test ( 'textureBarrier' )
@@ -39,7 +65,7 @@ g.test('textureBarrier')
3965 )
4066 . fn ( t => {
4167 t . expectCompileResult (
42- t . hasLanguageFeature ( kFeatureName ) ,
68+ t . hasLanguageFeature ( kAccessModeFeatureName ) ,
4369 `
4470 @workgroup_size(1) @compute fn main() {
4571 textureBarrier();
0 commit comments