| 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 main0_out |
| 48 |
{ |
| 49 |
float4 FragColor [[color(0)]]; |
| 50 |
}; |
| 51 |
|
| 52 |
struct main0_in |
| 53 |
{ |
| 54 |
ushort2 a [[user(locn0)]]; |
| 55 |
uint3 b [[user(locn1)]]; |
| 56 |
ushort c_0 [[user(locn2)]]; |
| 57 |
ushort c_1 [[user(locn3)]]; |
| 58 |
uint4 e_0 [[user(locn4)]]; |
| 59 |
uint4 e_1 [[user(locn5)]]; |
| 60 |
float4 d [[user(locn6)]]; |
| 61 |
}; |
| 62 |
|
| 63 |
fragment main0_out main0(main0_in in [[stage_in]]) |
| 64 |
{ |
| 65 |
main0_out out = {}; |
| 66 |
spvUnsafeArray<ushort, 2> c = {}; |
| 67 |
spvUnsafeArray<uint4, 2> e = {}; |
| 68 |
c[0] = in.c_0; |
| 69 |
c[1] = in.c_1; |
| 70 |
e[0] = in.e_0; |
| 71 |
e[1] = in.e_1; |
| 72 |
out.FragColor = float4(float(int(in.a.x)), float(in.b.x), float2(float(uint(c[1])), float(e[0].w)) + in.d.xy); |
| 73 |
return out; |
| 74 |
} |
| 75 |
|