| #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 Immediate { |
| /* 0x0000 */ float scale; |
| /* 0x0004 */ half2 offsets; |
| /* 0x0008 */ half bias; |
| /* 0x000a */ tint_array<int8_t, 2> tint_pad; |
| }; |
| |
| struct tint_immediate_data_struct { |
| /* 0x0000 */ Immediate user_immediate_data; |
| /* 0x000c */ uint tint_non_constant_zero; |
| }; |
| |
| struct tint_module_vars_struct { |
| device float4* output; |
| const constant tint_immediate_data_struct* tint_immediate_data; |
| }; |
| |
| [[max_total_threads_per_threadgroup(1)]] |
| kernel void v(device float4* output [[buffer(0)]], const constant tint_immediate_data_struct* tint_immediate_data [[buffer(30)]]) { |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.output=output, .tint_immediate_data=tint_immediate_data}; |
| float const v_1 = (*tint_module_vars.tint_immediate_data).user_immediate_data.scale; |
| float2 const v_2 = float2((*tint_module_vars.tint_immediate_data).user_immediate_data.offsets); |
| (*tint_module_vars.output) = float4(v_1, v_2, float((*tint_module_vars.tint_immediate_data).user_immediate_data.bias)); |
| } |