diff options
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts')
-rw-r--r-- | dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts | 151 |
1 files changed, 56 insertions, 95 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts index 2614c4e686..e36558d30c 100644 --- a/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts +++ b/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/reflect.spec.ts @@ -1,7 +1,7 @@ export const description = ` Execution tests for the 'reflect' builtin function -T is vecN<AbstractFloat>, vecN<f32>, or vecN<f16> +T is vecN<Type.abstractFloat>, vecN<f32>, or vecN<f16> @const fn reflect(e1: T, e2: T ) -> T For the incident vector e1 and surface orientation e2, returns the reflection direction e1-2*dot(e2,e1)*e2. @@ -9,58 +9,61 @@ direction e1-2*dot(e2,e1)*e2. import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { GPUTest } from '../../../../../gpu_test.js'; -import { TypeF32, TypeF16, TypeVec } from '../../../../../util/conversion.js'; -import { FP } from '../../../../../util/floating_point.js'; -import { sparseVectorF32Range, sparseVectorF16Range } from '../../../../../util/math.js'; -import { makeCaseCache } from '../../case_cache.js'; -import { allInputSources, run } from '../../expression.js'; +import { Type } from '../../../../../util/conversion.js'; +import { allInputSources, onlyConstInputSource, run } from '../../expression.js'; -import { builtin } from './builtin.js'; +import { abstractFloatBuiltin, builtin } from './builtin.js'; +import { d } from './reflect.cache.js'; export const g = makeTestGroup(GPUTest); -// Cases: f32_vecN_[non_]const -const f32_vec_cases = ([2, 3, 4] as const) - .flatMap(n => - ([true, false] as const).map(nonConst => ({ - [`f32_vec${n}_${nonConst ? 'non_const' : 'const'}`]: () => { - return FP.f32.generateVectorPairToVectorCases( - sparseVectorF32Range(n), - sparseVectorF32Range(n), - nonConst ? 'unfiltered' : 'finite', - FP.f32.reflectInterval - ); - }, - })) - ) - .reduce((a, b) => ({ ...a, ...b }), {}); - -// Cases: f16_vecN_[non_]const -const f16_vec_cases = ([2, 3, 4] as const) - .flatMap(n => - ([true, false] as const).map(nonConst => ({ - [`f16_vec${n}_${nonConst ? 'non_const' : 'const'}`]: () => { - return FP.f16.generateVectorPairToVectorCases( - sparseVectorF16Range(n), - sparseVectorF16Range(n), - nonConst ? 'unfiltered' : 'finite', - FP.f16.reflectInterval - ); - }, - })) - ) - .reduce((a, b) => ({ ...a, ...b }), {}); +g.test('abstract_float_vec2') + .specURL('https://www.w3.org/TR/WGSL/#numeric-builtin-functions') + .desc(`abstract float tests using vec2s`) + .params(u => u.combine('inputSource', onlyConstInputSource)) + .fn(async t => { + const cases = await d.get('abstract_vec2_const'); + await run( + t, + abstractFloatBuiltin('reflect'), + [Type.vec2af, Type.vec2af], + Type.vec2af, + t.params, + cases + ); + }); -export const d = makeCaseCache('reflect', { - ...f32_vec_cases, - ...f16_vec_cases, -}); +g.test('abstract_float_vec3') + .specURL('https://www.w3.org/TR/WGSL/#numeric-builtin-functions') + .desc(`abstract float tests using vec3s`) + .params(u => u.combine('inputSource', onlyConstInputSource)) + .fn(async t => { + const cases = await d.get('abstract_vec3_const'); + await run( + t, + abstractFloatBuiltin('reflect'), + [Type.vec3af, Type.vec3af], + Type.vec3af, + t.params, + cases + ); + }); -g.test('abstract_float') - .specURL('https://www.w3.org/TR/WGSL/#float-builtin-functions') - .desc(`abstract float tests`) - .params(u => u.combine('inputSource', allInputSources).combine('vectorize', [2, 3, 4] as const)) - .unimplemented(); +g.test('abstract_float_vec4') + .specURL('https://www.w3.org/TR/WGSL/#numeric-builtin-functions') + .desc(`abstract float tests using vec4s`) + .params(u => u.combine('inputSource', onlyConstInputSource)) + .fn(async t => { + const cases = await d.get('abstract_vec4_const'); + await run( + t, + abstractFloatBuiltin('reflect'), + [Type.vec4af, Type.vec4af], + Type.vec4af, + t.params, + cases + ); + }); g.test('f32_vec2') .specURL('https://www.w3.org/TR/WGSL/#numeric-builtin-functions') @@ -70,14 +73,7 @@ g.test('f32_vec2') const cases = await d.get( t.params.inputSource === 'const' ? 'f32_vec2_const' : 'f32_vec2_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(2, TypeF32), TypeVec(2, TypeF32)], - TypeVec(2, TypeF32), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec2f, Type.vec2f], Type.vec2f, t.params, cases); }); g.test('f32_vec3') @@ -88,14 +84,7 @@ g.test('f32_vec3') const cases = await d.get( t.params.inputSource === 'const' ? 'f32_vec3_const' : 'f32_vec3_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(3, TypeF32), TypeVec(3, TypeF32)], - TypeVec(3, TypeF32), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec3f, Type.vec3f], Type.vec3f, t.params, cases); }); g.test('f32_vec4') @@ -106,14 +95,7 @@ g.test('f32_vec4') const cases = await d.get( t.params.inputSource === 'const' ? 'f32_vec4_const' : 'f32_vec4_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(4, TypeF32), TypeVec(4, TypeF32)], - TypeVec(4, TypeF32), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec4f, Type.vec4f], Type.vec4f, t.params, cases); }); g.test('f16_vec2') @@ -127,14 +109,7 @@ g.test('f16_vec2') const cases = await d.get( t.params.inputSource === 'const' ? 'f16_vec2_const' : 'f16_vec2_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(2, TypeF16), TypeVec(2, TypeF16)], - TypeVec(2, TypeF16), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec2h, Type.vec2h], Type.vec2h, t.params, cases); }); g.test('f16_vec3') @@ -148,14 +123,7 @@ g.test('f16_vec3') const cases = await d.get( t.params.inputSource === 'const' ? 'f16_vec3_const' : 'f16_vec3_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(3, TypeF16), TypeVec(3, TypeF16)], - TypeVec(3, TypeF16), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec3h, Type.vec3h], Type.vec3h, t.params, cases); }); g.test('f16_vec4') @@ -169,12 +137,5 @@ g.test('f16_vec4') const cases = await d.get( t.params.inputSource === 'const' ? 'f16_vec4_const' : 'f16_vec4_non_const' ); - await run( - t, - builtin('reflect'), - [TypeVec(4, TypeF16), TypeVec(4, TypeF16)], - TypeVec(4, TypeF16), - t.params, - cases - ); + await run(t, builtin('reflect'), [Type.vec4h, Type.vec4h], Type.vec4h, t.params, cases); }); |