diff options
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts')
-rw-r--r-- | dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts index f844961aee..2f1e33b101 100644 --- a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts +++ b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/sign.spec.ts @@ -6,11 +6,10 @@ Validation tests for the ${builtin}() builtin. import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { keysOf, objectsToRecord } from '../../../../../../common/util/data_tables.js'; import { - TypeF16, - TypeF32, - elementType, - kAllFloatAndSignedIntegerScalarsAndVectors, - kAllUnsignedIntegerScalarsAndVectors, + Type, + kFloatScalarsAndVectors, + kConcreteSignedIntegerScalarsAndVectors, + scalarTypeOf, } from '../../../../../util/conversion.js'; import { ShaderValidationTest } from '../../../shader_validation_test.js'; @@ -23,7 +22,10 @@ import { export const g = makeTestGroup(ShaderValidationTest); -const kValuesTypes = objectsToRecord(kAllFloatAndSignedIntegerScalarsAndVectors); +const kValuesTypes = objectsToRecord([ + ...kFloatScalarsAndVectors, + ...kConcreteSignedIntegerScalarsAndVectors, +]); g.test('values') .desc( @@ -40,7 +42,7 @@ Validates that constant evaluation and override evaluation of ${builtin}() input .expand('value', u => fullRangeForType(kValuesTypes[u.type])) ) .beforeAllSubcases(t => { - if (elementType(kValuesTypes[t.params.type]) === TypeF16) { + if (scalarTypeOf(kValuesTypes[t.params.type]) === Type.f16) { t.selectDeviceOrSkipTestCase('shader-f16'); } }) @@ -55,25 +57,36 @@ Validates that constant evaluation and override evaluation of ${builtin}() input ); }); -const kUnsignedIntegerArgumentTypes = objectsToRecord([ - TypeF32, - ...kAllUnsignedIntegerScalarsAndVectors, -]); +const kArgCases = { + good: '(1.0)', + bad_no_parens: '', + // Bad number of args + bad_0args: '()', + bad_2arg: '(1.0, 1.0)', + // Bad value for arg 0 + bad_0bool: '(false)', + bad_0array: '(array(1.1,2.2))', + bad_0struct: '(modf(2.2))', + bad_0uint: '(1u)', + bad_0vec2u: '(vec2u(1))', + bad_0vec3u: '(vec3u(1))', + bad_0vec4u: '(vec4u(1))', +}; -g.test('unsigned_integer_argument') - .desc( - ` -Validates that scalar and vector integer arguments are rejected by ${builtin}() -` - ) - .params(u => u.combine('type', keysOf(kUnsignedIntegerArgumentTypes))) +g.test('args') + .desc(`Test compilation failure of ${builtin} with variously shaped and typed arguments`) + .params(u => u.combine('arg', keysOf(kArgCases))) .fn(t => { - const type = kUnsignedIntegerArgumentTypes[t.params.type]; - validateConstOrOverrideBuiltinEval( - t, - builtin, - /* expectedResult */ type === TypeF32, - [type.create(1)], - 'constant' + t.expectCompileResult( + t.params.arg === 'good', + `const c = ${builtin}${kArgCases[t.params.arg]};` ); }); + +g.test('must_use') + .desc(`Result of ${builtin} must be used`) + .params(u => u.combine('use', [true, false])) + .fn(t => { + const use_it = t.params.use ? '_ = ' : ''; + t.expectCompileResult(t.params.use, `fn f() { ${use_it}${builtin}${kArgCases['good']}; }`); + }); |