summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts')
-rw-r--r--dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts50
1 files changed, 41 insertions, 9 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts
index 60f32d99c7..d242e1a410 100644
--- a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.spec.ts
+++ b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/expression/call/builtin/log2.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,
- kAllFloatScalarsAndVectors,
- kAllIntegerScalarsAndVectors,
+ Type,
+ kConcreteIntegerScalarsAndVectors,
+ kConvertableToFloatScalarsAndVectors,
+ scalarTypeOf,
} from '../../../../../util/conversion.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';
@@ -23,7 +22,7 @@ import {
export const g = makeTestGroup(ShaderValidationTest);
-const kValuesTypes = objectsToRecord(kAllFloatScalarsAndVectors);
+const kValuesTypes = objectsToRecord(kConvertableToFloatScalarsAndVectors);
g.test('values')
.desc(
@@ -40,7 +39,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,7 +54,7 @@ Validates that constant evaluation and override evaluation of ${builtin}() input
);
});
-const kIntegerArgumentTypes = objectsToRecord([TypeF32, ...kAllIntegerScalarsAndVectors]);
+const kIntegerArgumentTypes = objectsToRecord([Type.f32, ...kConcreteIntegerScalarsAndVectors]);
g.test('integer_argument')
.desc(
@@ -69,8 +68,41 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}()
validateConstOrOverrideBuiltinEval(
t,
builtin,
- /* expectedResult */ type === TypeF32,
+ /* expectedResult */ type === Type.f32,
[type.create(1)],
'constant'
);
});
+
+const kArgCases = {
+ good: '(1.1)',
+ bad_no_parens: '',
+ // Bad number of args
+ bad_0args: '()',
+ bad_2args: '(1.0,2.0)',
+ // Bad value type for arg 0
+ bad_0i32: '(1i)',
+ bad_0u32: '(1u)',
+ bad_0bool: '(false)',
+ bad_0vec2u: '(vec2u())',
+ bad_0array: '(array(1.1,2.2))',
+ bad_0struct: '(modf(2.2))',
+};
+
+g.test('args')
+ .desc(`Test compilation failure of ${builtin} with variously shaped and typed arguments`)
+ .params(u => u.combine('arg', keysOf(kArgCases)))
+ .fn(t => {
+ 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']}; }`);
+ });