summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/atan2.cache.ts
blob: be25c2dffb4bbc2f335f6c89c03435973b6218a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { FP } from '../../../../../util/floating_point.js';
import { linearRange } from '../../../../../util/math.js';
import { makeCaseCache } from '../../case_cache.js';

// Cases: [f32|f16|abstract]_[non_]const
const cases = (['f32', 'f16', 'abstract'] as const)
  .flatMap(trait =>
    ([true, false] as const).map(nonConst => ({
      [`${trait}_${nonConst ? 'non_const' : 'const'}`]: () => {
        if (trait === 'abstract' && nonConst) {
          return [];
        }
        // Using sparse range since there are N^2 cases being generated, and also including extra values
        // around 0, where there is a discontinuity that implementations may behave badly at.
        const numeric_range = [
          ...FP[trait].sparseScalarRange(),
          ...linearRange(
            FP[trait].constants().negative.max,
            FP[trait].constants().positive.min,
            10
          ),
        ];
        return FP[trait].generateScalarPairToIntervalCases(
          numeric_range,
          numeric_range,
          nonConst ? 'unfiltered' : 'finite',
          // atan2 has an ulp accuracy, so is only expected to be as accurate as f32
          FP[trait !== 'abstract' ? trait : 'f32'].atan2Interval
        );
      },
    }))
  )
  .reduce((a, b) => ({ ...a, ...b }), {});

export const d = makeCaseCache('atan2', cases);