diff options
Diffstat (limited to 'testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js')
-rw-r--r-- | testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js | 122 |
1 files changed, 74 insertions, 48 deletions
diff --git a/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js index c38d5f90ef..5455216d75 100644 --- a/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js +++ b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/validation/expression/call/builtin/exp2.spec.js @@ -7,24 +7,52 @@ import { makeTestGroup } from '../../../../../../common/framework/test_group.js' import { keysOf, objectsToRecord } from '../../../../../../common/util/data_tables.js'; import { kValue } from '../../../../../util/constants.js'; import { - TypeF16, - TypeF32, - elementType, - kAllFloatScalarsAndVectors, - kAllIntegerScalarsAndVectors } from + Type, + kConvertableToFloatScalarsAndVectors, + scalarTypeOf } from '../../../../../util/conversion.js'; import { isRepresentable } from '../../../../../util/floating_point.js'; import { ShaderValidationTest } from '../../../shader_validation_test.js'; import { kConstantAndOverrideStages, + rangeForType, stageSupportsType, validateConstOrOverrideBuiltinEval } from './const_override_validation.js'; export const g = makeTestGroup(ShaderValidationTest); -const kValuesTypes = objectsToRecord(kAllFloatScalarsAndVectors); +const kValuesTypes = objectsToRecord(kConvertableToFloatScalarsAndVectors); + +const valueForType = rangeForType( + [ + -1e2, + -1e3, + -4, + -3, + -2, + -1, + -1e-1, + -1e-2, + -1e-3, + 0, + 1e-3, + 1e-2, + 1e-1, + 1, + 2, + 3, + 4, + 1e2, + 1e3, + Math.log2(kValue.f16.positive.max) - 0.1, + Math.log2(kValue.f16.positive.max) + 0.1, + Math.log2(kValue.f32.positive.max) - 0.1, + Math.log2(kValue.f32.positive.max) + 0.1], + + [-100n, -1000n, -4n, -3n, -2n, -1n, 0n, 1n, 2n, 3n, 4n, 100n, 1000n] +); g.test('values'). desc( @@ -38,40 +66,20 @@ combine('stage', kConstantAndOverrideStages). combine('type', keysOf(kValuesTypes)). filter((u) => stageSupportsType(u.stage, kValuesTypes[u.type])). beginSubcases(). -combine('value', [ --1e2, --1e3, --4, --3, --2, --1, --1e-1, --1e-2, --1e-3, -0, -1e-3, -1e-2, -1e-1, -1, -2, -3, -4, -1e2, -1e3, -Math.log2(kValue.f16.positive.max) - 0.1, -Math.log2(kValue.f16.positive.max) + 0.1, -Math.log2(kValue.f32.positive.max) - 0.1, -Math.log2(kValue.f32.positive.max) + 0.1] -) +expand('value', (u) => valueForType(kValuesTypes[u.type])) ). beforeAllSubcases((t) => { - if (elementType(kValuesTypes[t.params.type]) === TypeF16) { + if (scalarTypeOf(kValuesTypes[t.params.type]) === Type.f16) { t.selectDeviceOrSkipTestCase('shader-f16'); } }). fn((t) => { const type = kValuesTypes[t.params.type]; - const expectedResult = isRepresentable(Math.pow(2, t.params.value), elementType(type)); + const expectedResult = isRepresentable( + Math.pow(2, Number(t.params.value)), + // AbstractInt is converted to AbstractFloat before calling into the builtin + scalarTypeOf(type).kind === 'abstract-int' ? Type.abstractFloat : scalarTypeOf(type) + ); validateConstOrOverrideBuiltinEval( t, builtin, @@ -81,22 +89,40 @@ fn((t) => { ); }); -const kIntegerArgumentTypes = objectsToRecord([TypeF32, ...kAllIntegerScalarsAndVectors]); +const kArgCases = { + good: '(1.2)', + bad_no_parens: '', + // Bad number of args + bad_0args: '()', + bad_2arg: '(1.2, 2.3)', + // Bad value for arg 0 + bad_0bool: '(false)', + bad_0array: '(array(1.1,2.2))', + bad_0struct: '(modf(2.2))', + bad_0uint: '(1u)', + bad_0int: '(1i)', + bad_0vec2i: '(vec2i())', + bad_0vec2u: '(vec2u())', + bad_0vec3i: '(vec3i())', + bad_0vec3u: '(vec3u())', + bad_0vec4i: '(vec4i())', + bad_0vec4u: '(vec4u())' +}; -g.test('integer_argument'). -desc( - ` -Validates that scalar and vector integer arguments are rejected by ${builtin}() -` -). -params((u) => u.combine('type', keysOf(kIntegerArgumentTypes))). +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 = kIntegerArgumentTypes[t.params.type]; - validateConstOrOverrideBuiltinEval( - t, - builtin, - /* expectedResult */type === TypeF32, - [type.create(0)], - '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']}; }`); });
\ No newline at end of file |