@@ -9,7 +9,6 @@ Returns the arc tangent of e1 over e2. Component-wise when T is a vector.
9
9
10
10
import { makeTestGroup } from '../../../../../../common/framework/test_group.js' ;
11
11
import { GPUTest } from '../../../../../gpu_test.js' ;
12
- import { kValue } from '../../../../../util/constants.js' ;
13
12
import { TypeF32 , TypeF16 } from '../../../../../util/conversion.js' ;
14
13
import { FP } from '../../../../../util/floating_point.js' ;
15
14
import { linearRange , sparseF32Range , sparseF16Range } from '../../../../../util/math.js' ;
@@ -20,36 +19,29 @@ import { builtin } from './builtin.js';
20
19
21
20
export const g = makeTestGroup ( GPUTest ) ;
22
21
23
- export const d = makeCaseCache ( 'atan2' , {
24
- f32 : ( ) => {
25
- // Using sparse range since there are N^2 cases being generated, and also including extra values
26
- // around 0, where there is a discontinuity that implementations may behave badly at.
27
- const numeric_range = [
28
- ...sparseF32Range ( ) ,
29
- ...linearRange ( kValue . f32 . negative . max , kValue . f32 . positive . min , 10 ) ,
30
- ] ;
31
- return FP . f32 . generateScalarPairToIntervalCases (
32
- numeric_range ,
33
- numeric_range ,
34
- 'unfiltered' ,
35
- FP . f32 . atan2Interval
36
- ) ;
37
- } ,
38
- f16 : ( ) => {
39
- // Using sparse range since there are N^2 cases being generated, and also including extra values
40
- // around 0, where there is a discontinuity that implementations may behave badly at.
41
- const numeric_range = [
42
- ...sparseF16Range ( ) ,
43
- ...linearRange ( kValue . f16 . negative . max , kValue . f16 . positive . min , 10 ) ,
44
- ] ;
45
- return FP . f16 . generateScalarPairToIntervalCases (
46
- numeric_range ,
47
- numeric_range ,
48
- 'unfiltered' ,
49
- FP . f16 . atan2Interval
50
- ) ;
51
- } ,
52
- } ) ;
22
+ const cases = ( [ 'f32' , 'f16' ] as const )
23
+ . flatMap ( kind =>
24
+ ( [ true , false ] as const ) . map ( nonConst => ( {
25
+ [ `${ kind } _${ nonConst ? 'non_const' : 'const' } ` ] : ( ) => {
26
+ const fp = FP [ kind ] ;
27
+ // Using sparse range since there are N^2 cases being generated, and also including extra values
28
+ // around 0, where there is a discontinuity that implementations may behave badly at.
29
+ const numeric_range = [
30
+ ...( kind === 'f32' ? sparseF32Range ( ) : sparseF16Range ( ) ) ,
31
+ ...linearRange ( fp . constants ( ) . negative . max , fp . constants ( ) . positive . min , 10 ) ,
32
+ ] ;
33
+ return fp . generateScalarPairToIntervalCases (
34
+ numeric_range ,
35
+ numeric_range ,
36
+ nonConst ? 'unfiltered' : 'finite' ,
37
+ fp . atan2Interval
38
+ ) ;
39
+ } ,
40
+ } ) )
41
+ )
42
+ . reduce ( ( a , b ) => ( { ...a , ...b } ) , { } ) ;
43
+
44
+ export const d = makeCaseCache ( 'atan2' , cases ) ;
53
45
54
46
g . test ( 'abstract_float' )
55
47
. specURL ( 'https://www.w3.org/TR/WGSL/#float-builtin-functions' )
@@ -72,7 +64,7 @@ TODO(#792): Decide what the ground-truth is for these tests. [1]
72
64
u . combine ( 'inputSource' , allInputSources ) . combine ( 'vectorize' , [ undefined , 2 , 3 , 4 ] as const )
73
65
)
74
66
. fn ( async t => {
75
- const cases = await d . get ( 'f32' ) ;
67
+ const cases = await d . get ( `f32_ ${ t . params . inputSource === 'const' ? 'const' : 'non_const' } ` ) ;
76
68
await run ( t , builtin ( 'atan2' ) , [ TypeF32 , TypeF32 ] , TypeF32 , t . params , cases ) ;
77
69
} ) ;
78
70
@@ -86,6 +78,6 @@ g.test('f16')
86
78
t . selectDeviceOrSkipTestCase ( 'shader-f16' ) ;
87
79
} )
88
80
. fn ( async t => {
89
- const cases = await d . get ( 'f16' ) ;
81
+ const cases = await d . get ( `f16_ ${ t . params . inputSource === 'const' ? 'const' : 'non_const' } ` ) ;
90
82
await run ( t , builtin ( 'atan2' ) , [ TypeF16 , TypeF16 ] , TypeF16 , t . params , cases ) ;
91
83
} ) ;
0 commit comments