Skip to content

Commit db90237

Browse files
committed
Consider tier1 formats language feature in RO/RW storage texture test
1 parent 4cafebf commit db90237

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

src/webgpu/capability_info.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ export const kKnownWGSLLanguageFeatures = [
982982
'subgroup_uniformity',
983983
'swizzle_assignment',
984984
'linear_indexing',
985+
'texture_formats_tier1',
985986
] as const;
986987

987988
export type WGSLLanguageFeature = (typeof kKnownWGSLLanguageFeatures)[number];

src/webgpu/shader/validation/extension/readonly_and_readwrite_storage_textures.spec.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ Validation tests for the readonly_and_readwrite_storage_textures language featur
33
`;
44

55
import { 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';
711
import { ShaderValidationTest } from '../shader_validation_test.js';
812

913
export 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

1319
g.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

3662
g.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

Comments
 (0)