Skip to content
Open
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 @@ -937,6 +937,7 @@ export const kKnownWGSLLanguageFeatures = [
'unrestricted_pointer_parameters',
'pointer_composite_access',
'uniform_buffer_standard_layout',
'texture_and_sampler_let',
] as const;

export type WGSLLanguageFeature = (typeof kKnownWGSLLanguageFeatures)[number];
1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@
"webgpu:shader,validation,decl,context_dependent_resolution:language_names:*": { "subcaseMS": 4.920 },
"webgpu:shader,validation,decl,context_dependent_resolution:swizzle_names:*": { "subcaseMS": 27.579 },
"webgpu:shader,validation,decl,let:initializer:*": { "subcaseMS": 0.706 },
"webgpu:shader,validation,decl,let:initializer_type:*": { "subcaseMS": 423.312 },
"webgpu:shader,validation,decl,let:module_scope:*": { "subcaseMS": 0.619 },
"webgpu:shader,validation,decl,let:type:*": { "subcaseMS": 122.199 },
"webgpu:shader,validation,decl,override:array_size:*": { "subcaseMS": 44.868 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,16 @@ function run(
values: TestValues
) {
const outputType = values.expected.length > 1 ? `vec${values.expected.length}u` : 'u32';
const allowLet = t.hasLanguageFeature('texture_and_sampler_let');
const decl = allowLet ? 'let t = texture;' : '';
const tex = allowLet ? 't' : 'texture';
const wgsl = `
@group(0) @binding(0) var texture : ${textureType};

fn getValue() -> ${outputType} {
${decl}
return ${
levelArg !== undefined
? `textureDimensions(texture, ${levelArg})`
: 'textureDimensions(texture)'
levelArg !== undefined ? `textureDimensions(${tex}, ${levelArg})` : `textureDimensions(${tex})`
};
}
`;
Expand Down
29 changes: 26 additions & 3 deletions src/webgpu/shader/validation/decl/let.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const g = makeTestGroup(ShaderValidationTest);

interface Case {
code: string;
valid: boolean;
valid: boolean | 'texture_and_sampler_let';
decls?: string;
}

Expand Down Expand Up @@ -89,6 +89,26 @@ const kTypeCases: Record<string, Case> = {
let y : i32 = x;`,
valid: true,
},
texture_2d: {
code: `let x = tex2d;`,
valid: 'texture_and_sampler_let',
decls: `@group(0) @binding(0) var tex2d : texture_2d<f32>;`,
},
texture_storage_1d: {
code: `let x : texture_storage_1d<write, rgba32float> = tex1d;`,
valid: 'texture_and_sampler_let',
decls: `@group(0) @binding(0) var tex1d : texture_storage_1d<write, rgba32float>;`,
},
sampler: {
code: `let s = samp;`,
valid: 'texture_and_sampler_let',
decls: `@group(0) @binding(0) var samp : sampler;`,
},
sampler_comparison: {
code: `let s : sampler_comparison = samp_comp;`,
valid: 'texture_and_sampler_let',
decls: `@group(0) @binding(0) var samp_comp : sampler_comparison;`,
},
};

g.test('type')
Expand All @@ -106,7 +126,10 @@ ${testcase.decls ?? ''}
fn foo() {
${testcase.code}
}`;
const expect = testcase.valid;
let expect: boolean = testcase.valid === true;
if (testcase.valid === 'texture_and_sampler_let') {
expect = t.hasLanguageFeature('texture_and_sampler_let');
}
t.expectCompileResult(expect, code);
});

Expand Down Expand Up @@ -168,7 +191,7 @@ fn foo() {
${testcase.code}
}`;
const expect = testcase.valid;
t.expectCompileResult(expect, code);
t.expectCompileResult(expect === true, code);
});

g.test('module_scope')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ Validates the return type of ${builtin} is the expected type.
.combine('returnType', keysOf(kValuesTypes))
.combine('textureType', kNonStorageTextureTypes)
.beginSubcases()
.combine('let', [false, true] as const)
.expand('texelType', t =>
kNonStorageTextureTypeInfo[t.textureType].texelTypes.map(v => v.toString())
)
)
.fn(t => {
if (t.params.let) {
t.skipIfLanguageFeatureNotSupported('texture_and_sampler_let');
}
const { returnType, textureType, texelType } = t.params;
const returnVarType = kValuesTypes[returnType];
const { returnType: returnRequiredType, hasLevelArg } =
Expand All @@ -132,11 +136,14 @@ Validates the return type of ${builtin} is the expected type.
const texelArgType = stringToType(texelType);
const textureWGSL = getNonStorageTextureTypeWGSL(textureType, texelArgType);
const levelWGSL = hasLevelArg ? ', 0' : '';
const t_let = t.params.let ? `let t_let = t${levelWGSL};` : ``;
const param = t.params.let ? t_let : `t${levelWGSL}`;

const code = `
@group(0) @binding(0) var t: ${textureWGSL};
@fragment fn fs() -> @location(0) vec4f {
let v: ${varWGSL} = textureDimensions(t${levelWGSL});
${t_let}
let v: ${varWGSL} = textureDimensions(${param});
return vec4f(0);
}
`;
Expand Down