| #include <metal_stdlib> |
| using namespace metal; |
| template<typename T, size_t N> |
| struct tint_array { |
| const constant T& operator[](size_t i) const constant { return elements[i]; } |
| device T& operator[](size_t i) device { return elements[i]; } |
| const device T& operator[](size_t i) const device { return elements[i]; } |
| thread T& operator[](size_t i) thread { return elements[i]; } |
| const thread T& operator[](size_t i) const thread { return elements[i]; } |
| threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } |
| const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } |
| T elements[N]; |
| }; |
| |
| struct Inner { |
| float3x4 m; |
| }; |
| struct Outer { |
| tint_array<Inner, 4> a; |
| }; |
| struct tint_module_vars_struct { |
| const constant tint_array<Outer, 4>* a; |
| thread int* counter; |
| }; |
| |
| int i(tint_module_vars_struct tint_module_vars) { |
| (*tint_module_vars.counter) = ((*tint_module_vars.counter) + 1); |
| return (*tint_module_vars.counter); |
| } |
| kernel void f(const constant tint_array<Outer, 4>* a [[buffer(0)]]) { |
| thread int counter = 0; |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.a=a, .counter=(&counter)}; |
| const constant tint_array<Outer, 4>* const p_a = tint_module_vars.a; |
| const constant Outer* const p_a_i = (&(*p_a)[i(tint_module_vars)]); |
| const constant tint_array<Inner, 4>* const p_a_i_a = (&(*p_a_i).a); |
| const constant Inner* const p_a_i_a_i = (&(*p_a_i_a)[i(tint_module_vars)]); |
| const constant float3x4* const p_a_i_a_i_m = (&(*p_a_i_a_i).m); |
| const constant float4* const p_a_i_a_i_m_i = (&(*p_a_i_a_i_m)[i(tint_module_vars)]); |
| tint_array<Outer, 4> const l_a = (*p_a); |
| Outer const l_a_i = (*p_a_i); |
| tint_array<Inner, 4> const l_a_i_a = (*p_a_i_a); |
| Inner const l_a_i_a_i = (*p_a_i_a_i); |
| float3x4 const l_a_i_a_i_m = (*p_a_i_a_i_m); |
| float4 const l_a_i_a_i_m_i = (*p_a_i_a_i_m_i); |
| float const l_a_i_a_i_m_i_i = (*p_a_i_a_i_m_i)[i(tint_module_vars)]; |
| } |