Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/webgpu/capability_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ export const kKnownWGSLLanguageFeatures = [
'subgroup_uniformity',
'swizzle_assignment',
'linear_indexing',
'texture_formats_tier1',
] as const;

export type WGSLLanguageFeature = (typeof kKnownWGSLLanguageFeatures)[number];
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand All @@ -39,7 +65,7 @@ g.test('textureBarrier')
)
.fn(t => {
t.expectCompileResult(
t.hasLanguageFeature(kFeatureName),
t.hasLanguageFeature(kAccessModeFeatureName),
`
@workgroup_size(1) @compute fn main() {
textureBarrier();
Expand Down
Loading