From 007e1015875a0a91794edbc14feb3ad5fe60f90b Mon Sep 17 00:00:00 2001 From: alan-baker Date: Fri, 17 May 2024 08:10:29 -0400 Subject: [PATCH] Refactor const parse tests (#3752) Refs #3741 * Move parse/const tests into decl/const --- src/webgpu/listing_meta.json | 2 +- .../shader/validation/decl/const.spec.ts | 51 +++++++++++++++++ .../shader/validation/parse/const.spec.ts | 57 ------------------- 3 files changed, 52 insertions(+), 58 deletions(-) delete mode 100644 src/webgpu/shader/validation/parse/const.spec.ts diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index ab73a145b3ec..f0f5ecb0731a 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1903,6 +1903,7 @@ "webgpu:shader,validation,decl,const:no_indirect_recursion:*": { "subcaseMS": 0.950 }, "webgpu:shader,validation,decl,const:no_indirect_recursion_via_array_size:*": { "subcaseMS": 2.601 }, "webgpu:shader,validation,decl,const:no_indirect_recursion_via_struct_attribute:*": { "subcaseMS": 1.034 }, + "webgpu:shader,validation,decl,const:placement:*": { "subcaseMS": 1.167 }, "webgpu:shader,validation,decl,const:type:*": { "subcaseMS": 10.651 }, "webgpu:shader,validation,decl,context_dependent_resolution:attribute_names:*": { "subcaseMS": 533.132 }, "webgpu:shader,validation,decl,context_dependent_resolution:builtin_value_names:*": { "subcaseMS": 25.538 }, @@ -2502,7 +2503,6 @@ "webgpu:shader,validation,parse,comments:line_comment_eof:*": { "subcaseMS": 4.500 }, "webgpu:shader,validation,parse,comments:line_comment_terminators:*": { "subcaseMS": 1.021 }, "webgpu:shader,validation,parse,comments:unterminated_block_comment:*": { "subcaseMS": 8.950 }, - "webgpu:shader,validation,parse,const:placement:*": { "subcaseMS": 1.167 }, "webgpu:shader,validation,parse,diagnostic:after_other_directives:*": { "subcaseMS": 1.000 }, "webgpu:shader,validation,parse,diagnostic:conflicting_attribute_different_location:*": { "subcaseMS": 2.257 }, "webgpu:shader,validation,parse,diagnostic:conflicting_directive:*": { "subcaseMS": 1.244 }, diff --git a/src/webgpu/shader/validation/decl/const.spec.ts b/src/webgpu/shader/validation/decl/const.spec.ts index d1be3569e3e6..a12b711d5d49 100644 --- a/src/webgpu/shader/validation/decl/const.spec.ts +++ b/src/webgpu/shader/validation/decl/const.spec.ts @@ -250,3 +250,54 @@ g.test('assert') const_assert x == 0;`; t.expectCompileResult(true, code); }); + +g.test('placement') + .desc('Tests @const is not allowed to appear') + .params(u => + u.combine('scope', [ + 'private-var', + 'storage-var', + 'struct-member', + 'fn-decl', + 'fn-param', + 'fn-var', + 'fn-return', + 'while-stmt', + undefined, + ] as const) + ) + .fn(t => { + const scope = t.params.scope; + + const attr = '@const'; + const code = ` + ${scope === 'private-var' ? attr : ''} + var priv_var : i32; + + ${scope === 'storage-var' ? attr : ''} + @group(0) @binding(0) + var stor_var : i32; + + struct A { + ${scope === 'struct-member' ? attr : ''} + a : i32, + } + + @vertex + ${scope === 'fn-decl' ? attr : ''} + fn f( + ${scope === 'fn-param' ? attr : ''} + @location(0) b : i32, + ) -> ${scope === 'fn-return' ? attr : ''} @builtin(position) vec4f { + ${scope === 'fn-var' ? attr : ''} + var func_v : i32; + + ${scope === 'while-stmt' ? attr : ''} + while false {} + + return vec4(1, 1, 1, 1); + } + `; + + t.expectCompileResult(scope === undefined, code); + }); diff --git a/src/webgpu/shader/validation/parse/const.spec.ts b/src/webgpu/shader/validation/parse/const.spec.ts deleted file mode 100644 index 5a50f7d21062..000000000000 --- a/src/webgpu/shader/validation/parse/const.spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -export const description = `Validation tests for @const`; - -import { makeTestGroup } from '../../../../common/framework/test_group.js'; -import { ShaderValidationTest } from '../shader_validation_test.js'; - -export const g = makeTestGroup(ShaderValidationTest); - -g.test('placement') - .desc('Tests @const is not allowed to appear') - .params(u => - u.combine('scope', [ - 'private-var', - 'storage-var', - 'struct-member', - 'fn-decl', - 'fn-param', - 'fn-var', - 'fn-return', - 'while-stmt', - undefined, - ] as const) - ) - .fn(t => { - const scope = t.params.scope; - - const attr = '@const'; - const code = ` - ${scope === 'private-var' ? attr : ''} - var priv_var : i32; - - ${scope === 'storage-var' ? attr : ''} - @group(0) @binding(0) - var stor_var : i32; - - struct A { - ${scope === 'struct-member' ? attr : ''} - a : i32, - } - - @vertex - ${scope === 'fn-decl' ? attr : ''} - fn f( - ${scope === 'fn-param' ? attr : ''} - @location(0) b : i32, - ) -> ${scope === 'fn-return' ? attr : ''} @builtin(position) vec4f { - ${scope === 'fn-var' ? attr : ''} - var func_v : i32; - - ${scope === 'while-stmt' ? attr : ''} - while false {} - - return vec4(1, 1, 1, 1); - } - `; - - t.expectCompileResult(scope === undefined, code); - });