diff options
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts')
-rw-r--r-- | dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts | 161 |
1 files changed, 149 insertions, 12 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts index 8af7706169..16a193aec4 100644 --- a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts +++ b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/asin.spec.ts @@ -6,18 +6,18 @@ 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, - kAllFloatScalarsAndVectors, - kAllIntegerScalarsAndVectors, + Type, + kConcreteIntegerScalarsAndVectors, + kConvertableToFloatScalarsAndVectors, + scalarTypeOf, } from '../../../../../util/conversion.js'; +import { absBigInt } from '../../../../../util/math.js'; import { ShaderValidationTest } from '../../../shader_validation_test.js'; import { fullRangeForType, kConstantAndOverrideStages, - kMinusTwoToTwo, + minusTwoToTwoRangeForType, stageSupportsType, unique, validateConstOrOverrideBuiltinEval, @@ -25,7 +25,7 @@ import { export const g = makeTestGroup(ShaderValidationTest); -const kValuesTypes = objectsToRecord(kAllFloatScalarsAndVectors); +const kValuesTypes = objectsToRecord(kConvertableToFloatScalarsAndVectors); g.test('values') .desc( @@ -39,15 +39,23 @@ Validates that constant evaluation and override evaluation of ${builtin}() rejec .combine('type', keysOf(kValuesTypes)) .filter(u => stageSupportsType(u.stage, kValuesTypes[u.type])) .beginSubcases() - .expand('value', u => unique(kMinusTwoToTwo, fullRangeForType(kValuesTypes[u.type]))) + .expand('value', u => + unique( + minusTwoToTwoRangeForType(kValuesTypes[u.type]), + 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'); } }) .fn(t => { - const expectedResult = Math.abs(t.params.value) <= 1; + const expectedResult = + typeof t.params.value === 'bigint' + ? absBigInt(t.params.value) <= 1n + : Math.abs(t.params.value) <= 1; validateConstOrOverrideBuiltinEval( t, builtin, @@ -57,7 +65,7 @@ Validates that constant evaluation and override evaluation of ${builtin}() rejec ); }); -const kIntegerArgumentTypes = objectsToRecord([TypeF32, ...kAllIntegerScalarsAndVectors]); +const kIntegerArgumentTypes = objectsToRecord([Type.f32, ...kConcreteIntegerScalarsAndVectors]); g.test('integer_argument') .desc( @@ -71,8 +79,137 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}() validateConstOrOverrideBuiltinEval( t, builtin, - /* expectedResult */ type === TypeF32, + /* expectedResult */ type === Type.f32, [type.create(0)], 'constant' ); }); + +const kTests = { + valid: { + src: `_ = asin(1);`, + pass: true, + }, + alias: { + src: `_ = asin(f32_alias(1));`, + pass: true, + }, + + bool: { + src: `_ = asin(false);`, + pass: false, + }, + i32: { + src: `_ = asin(1i);`, + pass: false, + }, + u32: { + src: `_ = asin(1u);`, + pass: false, + }, + vec_bool: { + src: `_ = asin(vec2<bool>(false, true));`, + pass: false, + }, + vec_i32: { + src: `_ = asin(vec2<i32>(1, 1));`, + pass: false, + }, + vec_u32: { + src: `_ = asin(vec2<u32>(1, 1));`, + pass: false, + }, + matrix: { + src: `_ = asin(mat2x2(1, 1, 1, 1));`, + pass: false, + }, + atomic: { + src: ` _ = asin(a);`, + pass: false, + }, + array: { + src: `var a: array<u32, 5>; + _ = asin(a);`, + pass: false, + }, + array_runtime: { + src: `_ = asin(k.arry);`, + pass: false, + }, + struct: { + src: `var a: A; + _ = asin(a);`, + pass: false, + }, + enumerant: { + src: `_ = asin(read_write);`, + pass: false, + }, + ptr: { + src: `var<function> a = 1f; + let p: ptr<function, f32> = &a; + _ = asin(p);`, + pass: false, + }, + ptr_deref: { + src: `var<function> a = 1f; + let p: ptr<function, f32> = &a; + _ = asin(*p);`, + pass: true, + }, + sampler: { + src: `_ = asin(s);`, + pass: false, + }, + texture: { + src: `_ = asin(t);`, + pass: false, + }, + no_params: { + src: `_ = asin();`, + pass: false, + }, + too_many_params: { + src: `_ = asin(1, 2);`, + pass: false, + }, + + greater_then_one: { + src: `_ = asin(1.1f);`, + pass: false, + }, + less_then_negative_one: { + src: `_ = asin(-1.1f);`, + pass: false, + }, +}; + +g.test('parameters') + .desc(`Test that ${builtin} is validated correctly.`) + .params(u => u.combine('test', keysOf(kTests))) + .fn(t => { + const src = kTests[t.params.test].src; + const code = ` +alias f32_alias = f32; + +@group(0) @binding(0) var s: sampler; +@group(0) @binding(1) var t: texture_2d<f32>; + +var<workgroup> a: atomic<u32>; + +struct A { + i: u32, +} +struct B { + arry: array<u32>, +} +@group(0) @binding(3) var<storage> k: B; + + +@vertex +fn main() -> @builtin(position) vec4<f32> { + ${src} + return vec4<f32>(.4, .2, .3, .1); +}`; + t.expectCompileResult(kTests[t.params.test].pass, code); + }); |