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 C 48{ 49 float4 v; 50}; 51 52struct P 53{ 54 float4 v; 55}; 56 57struct gl_PerVertex 58{ 59 float4 gl_Position; 60 float gl_PointSize; 61 spvUnsafeArray<float, 1> gl_ClipDistance; 62 spvUnsafeArray<float, 1> gl_CullDistance; 63}; 64 65constant spvUnsafeArray<float, 1> _51 = spvUnsafeArray<float, 1>({ 0.0 }); 66constant spvUnsafeArray<float, 1> _52 = spvUnsafeArray<float, 1>({ 0.0 }); 67 68struct main0_out 69{ 70 float4 C_v; 71 float gl_PointSize; 72 spvUnsafeArray<float, 1> gl_ClipDistance; 73 spvUnsafeArray<float, 1> gl_CullDistance; 74}; 75 76struct main0_patchOut 77{ 78 float4 P_v; 79}; 80 81kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) 82{ 83 spvUnsafeArray<C, 4> _18 = spvUnsafeArray<C, 4>({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); 84 spvUnsafeArray<gl_PerVertex, 4> _33 = spvUnsafeArray<gl_PerVertex, 4>({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } }); 85 86 threadgroup gl_PerVertex gl_out_masked[4]; 87 device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; 88 gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v; 89 gl_out[gl_InvocationID].gl_PointSize = _33[gl_InvocationID].gl_PointSize; 90 gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance; 91 gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance; 92 gl_out_masked[gl_InvocationID] = _33[gl_InvocationID]; 93 device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; 94 patchOut.P_v = float4(0.0); 95 gl_out[gl_InvocationID].C_v = float4(1.0); 96 patchOut.P_v = float4(2.0); 97 gl_out_masked[gl_InvocationID].gl_Position = float4(3.0); 98 gl_out[gl_InvocationID].gl_PointSize = 4.0; 99} 100 101