|
| 1 | +#pragma clang diagnostic ignored "-Wmissing-prototypes" |
| 2 | + |
| 3 | +#include <metal_stdlib> |
| 4 | +#include <simd/simd.h> |
| 5 | + |
| 6 | +using namespace metal; |
| 7 | + |
| 8 | +constant float4 _68[4] = { float4(0.0), float4(1.0), float4(2.0), float4(3.0) }; |
| 9 | + |
| 10 | +struct main0_out |
| 11 | +{ |
| 12 | + float4 gl_Position [[position]]; |
| 13 | +}; |
| 14 | + |
| 15 | +struct main0_in |
| 16 | +{ |
| 17 | + int Index1 [[attribute(0)]]; |
| 18 | + int Index2 [[attribute(1)]]; |
| 19 | +}; |
| 20 | + |
| 21 | +template<typename T, uint A> |
| 22 | +inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) |
| 23 | +{ |
| 24 | + for (uint i = 0; i < A; i++) |
| 25 | + { |
| 26 | + dst[i] = src[i]; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +template<typename T, uint A> |
| 31 | +inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) |
| 32 | +{ |
| 33 | + for (uint i = 0; i < A; i++) |
| 34 | + { |
| 35 | + dst[i] = src[i]; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +template<typename T, uint A> |
| 40 | +inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) |
| 41 | +{ |
| 42 | + for (uint i = 0; i < A; i++) |
| 43 | + { |
| 44 | + dst[i] = src[i]; |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +template<typename T, uint A> |
| 49 | +inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) |
| 50 | +{ |
| 51 | + for (uint i = 0; i < A; i++) |
| 52 | + { |
| 53 | + dst[i] = src[i]; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +template<typename T, uint A> |
| 58 | +inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) |
| 59 | +{ |
| 60 | + for (uint i = 0; i < A; i++) |
| 61 | + { |
| 62 | + dst[i] = src[i]; |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +template<typename T, uint A> |
| 67 | +inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) |
| 68 | +{ |
| 69 | + for (uint i = 0; i < A; i++) |
| 70 | + { |
| 71 | + dst[i] = src[i]; |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +static inline __attribute__((always_inline)) |
| 76 | +float4 consume_constant_arrays2(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], thread int& Index1, thread int& Index2) |
| 77 | +{ |
| 78 | + float4 indexable[4]; |
| 79 | + spvArrayCopyFromStackToStack1(indexable, positions); |
| 80 | + float4 indexable_1[4]; |
| 81 | + spvArrayCopyFromStackToStack1(indexable_1, positions2); |
| 82 | + return indexable[Index1] + indexable_1[Index2]; |
| 83 | +} |
| 84 | + |
| 85 | +static inline __attribute__((always_inline)) |
| 86 | +float4 consume_constant_arrays(thread const float4 (&positions)[4], thread const float4 (&positions2)[4], thread int& Index1, thread int& Index2) |
| 87 | +{ |
| 88 | + return consume_constant_arrays2(positions, positions2, Index1, Index2); |
| 89 | +} |
| 90 | + |
| 91 | +vertex main0_out main0(main0_in in [[stage_in]]) |
| 92 | +{ |
| 93 | + float4 _68_array_copy[4] = { float4(0.0), float4(1.0), float4(2.0), float4(3.0) }; |
| 94 | + main0_out out = {}; |
| 95 | + float4 LUT2[4]; |
| 96 | + LUT2[0] = float4(10.0); |
| 97 | + LUT2[1] = float4(11.0); |
| 98 | + LUT2[2] = float4(12.0); |
| 99 | + LUT2[3] = float4(13.0); |
| 100 | + out.gl_Position = consume_constant_arrays(_68_array_copy, LUT2, in.Index1, in.Index2); |
| 101 | + return out; |
| 102 | +} |
| 103 | + |
0 commit comments