blob: b9966d0bce4e2183d04c1b68f90095d359033dd6 [file] [log] [blame]
James Priceb1504b72024-06-06 19:47:09 +00001#include <metal_stdlib>
2
3using namespace metal;
4
5template<typename T, size_t N>
6struct tint_array {
7 const constant T& operator[](size_t i) const constant { return elements[i]; }
8 device T& operator[](size_t i) device { return elements[i]; }
9 const device T& operator[](size_t i) const device { return elements[i]; }
10 thread T& operator[](size_t i) thread { return elements[i]; }
11 const thread T& operator[](size_t i) const thread { return elements[i]; }
12 threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
13 const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
14 T elements[N];
15};
16
17#define TINT_ISOLATE_UB(VOLATILE_NAME) \
18 volatile bool VOLATILE_NAME = true; \
19 if (VOLATILE_NAME)
20
21void foo(device tint_array<int, 4>* const arg) {
22 bool tint_continue = false;
23 TINT_ISOLATE_UB(tint_volatile_true) for(int i = 0; (i < 4); i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
24 tint_continue = false;
25 switch((*(arg))[i]) {
26 case 1: {
27 tint_continue = true;
28 break;
29 }
30 default: {
31 (*(arg))[i] = 2;
32 break;
33 }
34 }
35 if (tint_continue) {
36 continue;
37 }
38 }
39}
40
41fragment void tint_symbol_1(device tint_array<int, 4>* tint_symbol_2 [[buffer(0)]]) {
42 foo(tint_symbol_2);
43 return;
44}
45