| #include <metal_stdlib> |
| using namespace metal; |
| |
| struct Constants { |
| int level; |
| }; |
| |
| 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 Result { |
| /* 0x0000 */ tint_array<float, 1> values; |
| }; |
| |
| struct tint_module_vars_struct { |
| const constant Constants* constants; |
| texture2d_array<float, access::sample> myTexture; |
| device Result* result; |
| }; |
| |
| #define TINT_ISOLATE_UB(VOLATILE_NAME) \ |
| {volatile bool VOLATILE_NAME = false; if (VOLATILE_NAME) break;} |
| |
| void tint_symbol_inner(uint3 GlobalInvocationID, tint_module_vars_struct tint_module_vars) { |
| uint flatIndex = (((4u * GlobalInvocationID[2u]) + (2u * GlobalInvocationID[1u])) + GlobalInvocationID[0u]); |
| flatIndex = (flatIndex * 1u); |
| float4 texel = tint_module_vars.myTexture.read(uint2(int2(GlobalInvocationID.xy)), 0, 0); |
| { |
| uint i = 0u; |
| while(true) { |
| TINT_ISOLATE_UB(tint_volatile_false) |
| if ((i < 1u)) { |
| } else { |
| break; |
| } |
| (*tint_module_vars.result).values[(flatIndex + i)] = texel[0u]; |
| { |
| i = (i + 1u); |
| } |
| continue; |
| } |
| } |
| } |
| |
| kernel void tint_symbol(uint3 GlobalInvocationID [[thread_position_in_grid]], texture2d_array<float, access::sample> myTexture [[texture(0)]], device Result* result [[buffer(0)]]) { |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.myTexture=myTexture, .result=result}; |
| tint_symbol_inner(GlobalInvocationID, tint_module_vars); |
| } |