1#pragma clang diagnostic ignored "-Wmissing-prototypes" 2#pragma clang diagnostic ignored "-Wmissing-braces" 3 4#include <metal_stdlib> 5#include <simd/simd.h> 6 7using namespace metal; 8 9template<typename T, size_t Num> 10struct spvUnsafeArray 11{ 12 T elements[Num ? Num : 1]; 13 14 thread T& operator [] (size_t pos) thread 15 { 16 return elements[pos]; 17 } 18 constexpr const thread T& operator [] (size_t pos) const thread 19 { 20 return elements[pos]; 21 } 22 23 device T& operator [] (size_t pos) device 24 { 25 return elements[pos]; 26 } 27 constexpr const device T& operator [] (size_t pos) const device 28 { 29 return elements[pos]; 30 } 31 32 constexpr const constant T& operator [] (size_t pos) const constant 33 { 34 return elements[pos]; 35 } 36 37 threadgroup T& operator [] (size_t pos) threadgroup 38 { 39 return elements[pos]; 40 } 41 constexpr const threadgroup T& operator [] (size_t pos) const threadgroup 42 { 43 return elements[pos]; 44 } 45}; 46 47struct main0_out 48{ 49 float4x4 vOutputs; 50}; 51 52struct main0_in 53{ 54 float4x4 vInputs; 55}; 56 57kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) 58{ 59 device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; 60 device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; 61 uint gl_InvocationID = gl_GlobalInvocationID.x % 4; 62 uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); 63 spvUnsafeArray<float4x4, 32> _16 = spvUnsafeArray<float4x4, 32>({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); 64 spvUnsafeArray<float4x4, 32> tmp; 65 tmp = _16; 66 gl_out[gl_InvocationID].vOutputs = tmp[gl_InvocationID]; 67} 68 69