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 float4 v0 [[user(locn0)]]; 50 float4 v1 [[user(locn1)]]; 51 float4 gl_Position [[position]]; 52 float gl_PointSize [[point_size]]; 53}; 54 55static inline __attribute__((always_inline)) 56void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread spvUnsafeArray<float, 2>& gl_ClipDistance) 57{ 58 v0 = float4(1.0); 59 v1 = float4(2.0); 60 gl_Position = float4(3.0); 61 gl_PointSize = 4.0; 62 gl_ClipDistance[0] = 1.0; 63 gl_ClipDistance[1] = 0.5; 64} 65 66vertex main0_out main0() 67{ 68 main0_out out = {}; 69 spvUnsafeArray<float, 2> gl_ClipDistance = {}; 70 write_in_func(out.v0, out.v1, out.gl_Position, out.gl_PointSize, gl_ClipDistance); 71 return out; 72} 73 74