summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/shader_module/overrides.spec.ts
blob: ac3645a4a4f6451059aabe60e3e11fce2e454056 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
export const description = `
This tests overrides numeric identifiers should not conflict.
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { ValidationTest } from '../validation_test.js';

export const g = makeTestGroup(ValidationTest);

g.test('id_conflict')
  .desc(
    `
Tests that overrides' explicit numeric identifier should not conflict.
`
  )
  .fn(async t => {
    t.expectValidationError(() => {
      t.device.createShaderModule({
        code: `
@id(1234) override c0: u32;
@id(4321) override c1: u32;

@compute @workgroup_size(1) fn main() {
  // make sure the overridable constants are not optimized out
  _ = c0;
  _ = c1;
}
          `,
      });
    }, false);

    t.expectValidationError(() => {
      t.device.createShaderModule({
        code: `
@id(1234) override c0: u32;
@id(1234) override c1: u32;

@compute @workgroup_size(1) fn main() {
  // make sure the overridable constants are not optimized out
  _ = c0;
  _ = c1;
}
          `,
      });
    }, true);
  });

g.test('name_conflict')
  .desc(
    `
Tests that overrides' variable name should not conflict, regardless of their numeric identifiers.
`
  )
  .fn(async t => {
    t.expectValidationError(() => {
      t.device.createShaderModule({
        code: `
override c0: u32;
override c0: u32;

@compute @workgroup_size(1) fn main() {
  // make sure the overridable constants are not optimized out
  _ = c0;
}
          `,
      });
    }, true);

    t.expectValidationError(() => {
      t.device.createShaderModule({
        code: `
@id(1) override c0: u32;
override c0: u32;

@compute @workgroup_size(1) fn main() {
  // make sure the overridable constants are not optimized out
  _ = c0;
}
          `,
      });
    }, true);

    t.expectValidationError(() => {
      t.device.createShaderModule({
        code: `
@id(1) override c0: u32;
@id(2) override c0: u32;

@compute @workgroup_size(1) fn main() {
  // make sure the overridable constants are not optimized out
  _ = c0;
}
          `,
      });
    }, true);
  });