summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/expression/call/builtin/fract.cache.ts
blob: 5d0933554b6bd85c7e95e64ac45e264f5e7ad57a (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { FP } from '../../../../../util/floating_point.js';
import { makeCaseCache } from '../../case_cache.js';

const kCommonValues = [
  0.5, // 0.5 -> 0.5
  0.9, // ~0.9 -> ~0.9
  1, // 1 -> 0
  2, // 2 -> 0
  1.11, // ~1.11 -> ~0.11
  -0.1, // ~-0.1 -> ~0.9
  -0.5, // -0.5 -> 0.5
  -0.9, // ~-0.9 -> ~0.1
  -1, // -1 -> 0
  -2, // -2 -> 0
  -1.11, // ~-1.11 -> ~0.89
];

const kTraitSpecificValues = {
  f32: [
    10.0001, // ~10.0001 -> ~0.0001
    -10.0001, // -10.0001 -> ~0.9999
    0x8000_0000, // https://github.com/gpuweb/cts/issues/2766
  ],
  f16: [
    10.0078125, // 10.0078125 -> 0.0078125
    -10.0078125, // -10.0078125 -> 0.9921875
    658.5, // 658.5 -> 0.5
    0x8000, // https://github.com/gpuweb/cts/issues/2766
  ],
  abstract: [
    10.0001, // ~10.0001 -> ~0.0001
    -10.0001, // -10.0001 -> ~0.9999
    0x8000_0000, // https://github.com/gpuweb/cts/issues/2766
  ],
};

// Cases: [f32|f16|abstract]
const cases = (['f32', 'f16', 'abstract'] as const)
  .map(trait => ({
    [`${trait}`]: () => {
      return FP[trait].generateScalarToIntervalCases(
        [...kCommonValues, ...kTraitSpecificValues[trait], ...FP[trait].scalarRange()],
        trait === 'abstract' ? 'finite' : 'unfiltered',
        FP[trait].fractInterval
      );
    },
  }))
  .reduce((a, b) => ({ ...a, ...b }), {});

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