diff options
Diffstat (limited to 'testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js')
-rw-r--r-- | testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js | 98 |
1 files changed, 38 insertions, 60 deletions
diff --git a/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js index 0b1bc58c3e..05bd9dd0e4 100644 --- a/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js +++ b/testing/web-platform/mozilla/tests/webgpu/webgpu/shader/execution/expression/call/builtin/min.spec.js @@ -3,12 +3,12 @@ **/export const description = ` Execution tests for the 'min' builtin function -S is AbstractInt, i32, or u32 +S is abstract-int, i32, or u32 T is S or vecN<S> @const fn min(e1: T ,e2: T) -> T Returns e1 if e1 is less than e2, and e2 otherwise. Component-wise when T is a vector. -S is AbstractFloat, f32, f16 +S is abstract-float, f32, f16 T is S or vecN<S> @const fn min(e1: T ,e2: T) -> T Returns e2 if e2 is less than e1, and e1 otherwise. @@ -17,72 +17,50 @@ If both operands are NaNs, a NaN is returned. Component-wise when T is a vector. `;import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { GPUTest } from '../../../../../gpu_test.js'; -import { - i32, - TypeF32, - TypeF16, - TypeI32, - TypeU32, - u32, - TypeAbstractFloat } from -'../../../../../util/conversion.js'; -import { FP } from '../../../../../util/floating_point.js'; -import { fullF32Range, fullF16Range, sparseF64Range } from '../../../../../util/math.js'; -import { makeCaseCache } from '../../case_cache.js'; +import { Type, i32, u32, abstractInt } from '../../../../../util/conversion.js'; +import { minBigInt } from '../../../../../util/math.js'; + import { allInputSources, onlyConstInputSource, run } from '../../expression.js'; -import { abstractBuiltin, builtin } from './builtin.js'; +import { abstractFloatBuiltin, abstractIntBuiltin, builtin } from './builtin.js'; +import { d } from './min.cache.js'; export const g = makeTestGroup(GPUTest); -export const d = makeCaseCache('min', { - f32: () => { - return FP.f32.generateScalarPairToIntervalCases( - fullF32Range(), - fullF32Range(), - 'unfiltered', - FP.f32.minInterval - ); - }, - f16: () => { - return FP.f16.generateScalarPairToIntervalCases( - fullF16Range(), - fullF16Range(), - 'unfiltered', - FP.f16.minInterval - ); - }, - abstract: () => { - return FP.abstract.generateScalarPairToIntervalCases( - sparseF64Range(), - sparseF64Range(), - 'unfiltered', - FP.abstract.minInterval - ); - } -}); - /** Generate set of min test cases from list of interesting values */ -function generateTestCases( -values, -makeCase) -{ - const cases = new Array(); - values.forEach((e) => { - values.forEach((f) => { - cases.push(makeCase(e, f)); +function generateTestCases(values, makeCase) { + return values.flatMap((e) => { + return values.map((f) => { + return makeCase(e, f); }); }); - return cases; } g.test('abstract_int'). specURL('https://www.w3.org/TR/WGSL/#integer-builtin-functions'). desc(`abstract int tests`). params((u) => -u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4]) +u. +combine('inputSource', onlyConstInputSource). +combine('vectorize', [undefined, 2, 3, 4]) ). -unimplemented(); +fn(async (t) => { + const makeCase = (x, y) => { + return { input: [abstractInt(x), abstractInt(y)], expected: abstractInt(minBigInt(x, y)) }; + }; + + const test_values = [-0x70000000n, -2n, -1n, 0n, 1n, 2n, 0x70000000n]; + const cases = generateTestCases(test_values, makeCase); + + await run( + t, + abstractIntBuiltin('min'), + [Type.abstractInt, Type.abstractInt], + Type.abstractInt, + t.params, + cases + ); +}); g.test('u32'). specURL('https://www.w3.org/TR/WGSL/#integer-builtin-functions'). @@ -98,7 +76,7 @@ fn(async (t) => { const test_values = [0, 1, 2, 0x70000000, 0x80000000, 0xffffffff]; const cases = generateTestCases(test_values, makeCase); - await run(t, builtin('min'), [TypeU32, TypeU32], TypeU32, t.params, cases); + await run(t, builtin('min'), [Type.u32, Type.u32], Type.u32, t.params, cases); }); g.test('i32'). @@ -115,7 +93,7 @@ fn(async (t) => { const test_values = [-0x70000000, -2, -1, 0, 1, 2, 0x70000000]; const cases = generateTestCases(test_values, makeCase); - await run(t, builtin('min'), [TypeI32, TypeI32], TypeI32, t.params, cases); + await run(t, builtin('min'), [Type.i32, Type.i32], Type.i32, t.params, cases); }); g.test('abstract_float'). @@ -130,9 +108,9 @@ fn(async (t) => { const cases = await d.get('abstract'); await run( t, - abstractBuiltin('min'), - [TypeAbstractFloat, TypeAbstractFloat], - TypeAbstractFloat, + abstractFloatBuiltin('min'), + [Type.abstractFloat, Type.abstractFloat], + Type.abstractFloat, t.params, cases ); @@ -146,7 +124,7 @@ u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, ). fn(async (t) => { const cases = await d.get('f32'); - await run(t, builtin('min'), [TypeF32, TypeF32], TypeF32, t.params, cases); + await run(t, builtin('min'), [Type.f32, Type.f32], Type.f32, t.params, cases); }); g.test('f16'). @@ -160,5 +138,5 @@ beforeAllSubcases((t) => { }). fn(async (t) => { const cases = await d.get('f16'); - await run(t, builtin('min'), [TypeF16, TypeF16], TypeF16, t.params, cases); + await run(t, builtin('min'), [Type.f16, Type.f16], Type.f16, t.params, cases); });
\ No newline at end of file |