summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/execution/flow_control/call.spec.ts
blob: b86134a58c787d8c745fe8ebae5de5335f3f4887 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
export const description = `
Flow control tests for function calls.
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { GPUTest } from '../../../gpu_test.js';

import { runFlowControlTest } from './harness.js';

export const g = makeTestGroup(GPUTest);

g.test('call_basic')
  .desc('Test that flow control enters a called function')
  .params(u => u.combine('preventValueOptimizations', [true, false]))
  .fn(t => {
    runFlowControlTest(t, f => ({
      entrypoint: `
  ${f.expect_order(0)}
  f();
  ${f.expect_order(2)}
`,
      extra: `
fn f() {
  ${f.expect_order(1)}
}`,
    }));
  });

g.test('call_nested')
  .desc('Test that flow control enters a nested function calls')
  .params(u => u.combine('preventValueOptimizations', [true, false]))
  .fn(t => {
    runFlowControlTest(t, f => ({
      entrypoint: `
  ${f.expect_order(0)}
  a();
  ${f.expect_order(6)}
`,
      extra: `
fn a() {
  ${f.expect_order(1)}
  b();
  ${f.expect_order(5)}
}
fn b() {
  ${f.expect_order(2)}
  c();
  ${f.expect_order(4)}
}
fn c() {
  ${f.expect_order(3)}
}`,
    }));
  });

g.test('call_repeated')
  .desc('Test that flow control enters a nested function calls')
  .params(u => u.combine('preventValueOptimizations', [true, false]))
  .fn(t => {
    runFlowControlTest(t, f => ({
      entrypoint: `
  ${f.expect_order(0)}
  a();
  ${f.expect_order(10)}
`,
      extra: `
fn a() {
  ${f.expect_order(1)}
  b();
  ${f.expect_order(5)}
  b();
  ${f.expect_order(9)}
}
fn b() {
  ${f.expect_order(2, 6)}
  c();
  ${f.expect_order(4, 8)}
}
fn c() {
  ${f.expect_order(3, 7)}
}`,
    }));
  });