| 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 |
|
| 7 |
using namespace metal; |
| 8 |
|
| 9 |
template<typename T, size_t Num> |
| 10 |
struct 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 |
|
| 47 |
struct Vert |
| 48 |
{ |
| 49 |
float3x3 wMatrix; |
| 50 |
float4 wTmp; |
| 51 |
spvUnsafeArray<float, 4> arr; |
| 52 |
}; |
| 53 |
|
| 54 |
struct main0_out |
| 55 |
{ |
| 56 |
float4 FragColor [[color(0)]]; |
| 57 |
}; |
| 58 |
|
| 59 |
struct main0_in |
| 60 |
{ |
| 61 |
float3 vMatrix_0 [[user(locn0)]]; |
| 62 |
float3 vMatrix_1 [[user(locn1)]]; |
| 63 |
float3 vMatrix_2 [[user(locn2)]]; |
| 64 |
float3 Vert_wMatrix_0 [[user(locn4)]]; |
| 65 |
float3 Vert_wMatrix_1 [[user(locn5)]]; |
| 66 |
float3 Vert_wMatrix_2 [[user(locn6)]]; |
| 67 |
float4 Vert_wTmp [[user(locn7)]]; |
| 68 |
float Vert_arr_0 [[user(locn8)]]; |
| 69 |
float Vert_arr_1 [[user(locn9)]]; |
| 70 |
float Vert_arr_2 [[user(locn10)]]; |
| 71 |
float Vert_arr_3 [[user(locn11)]]; |
| 72 |
}; |
| 73 |
|
| 74 |
fragment main0_out main0(main0_in in [[stage_in]]) |
| 75 |
{ |
| 76 |
main0_out out = {}; |
| 77 |
Vert _17 = {}; |
| 78 |
float3x3 vMatrix = {}; |
| 79 |
_17.wMatrix[0] = in.Vert_wMatrix_0; |
| 80 |
_17.wMatrix[1] = in.Vert_wMatrix_1; |
| 81 |
_17.wMatrix[2] = in.Vert_wMatrix_2; |
| 82 |
_17.wTmp = in.Vert_wTmp; |
| 83 |
_17.arr[0] = in.Vert_arr_0; |
| 84 |
_17.arr[1] = in.Vert_arr_1; |
| 85 |
_17.arr[2] = in.Vert_arr_2; |
| 86 |
_17.arr[3] = in.Vert_arr_3; |
| 87 |
vMatrix[0] = in.vMatrix_0; |
| 88 |
vMatrix[1] = in.vMatrix_1; |
| 89 |
vMatrix[2] = in.vMatrix_2; |
| 90 |
out.FragColor = (_17.wMatrix[0].xxyy + _17.wTmp) + vMatrix[1].yyzz; |
| 91 |
for (int _56 = 0; _56 < 4; ) |
| 92 |
{ |
| 93 |
out.FragColor += float4(_17.arr[_56]); |
| 94 |
_56++; |
| 95 |
continue; |
| 96 |
} |
| 97 |
return out; |
| 98 |
} |
| 99 |
|