| 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 |
constant spvUnsafeArray<float, 16> _46 = spvUnsafeArray<float, 16>({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 }); |
| 48 |
constant spvUnsafeArray<float4, 4> _76 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); |
| 49 |
constant spvUnsafeArray<float4, 4> _90 = spvUnsafeArray<float4, 4>({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) }); |
| 50 |
|
| 51 |
struct main0_out |
| 52 |
{ |
| 53 |
float FragColor [[color(0)]]; |
| 54 |
}; |
| 55 |
|
| 56 |
struct main0_in |
| 57 |
{ |
| 58 |
int index [[user(locn0)]]; |
| 59 |
}; |
| 60 |
|
| 61 |
fragment main0_out main0(main0_in in [[stage_in]]) |
| 62 |
{ |
| 63 |
spvUnsafeArray<float4, 4> foobar = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); |
| 64 |
spvUnsafeArray<float4, 4> baz = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) }); |
| 65 |
main0_out out = {}; |
| 66 |
out.FragColor = _46[in.index]; |
| 67 |
if (in.index < 10) |
| 68 |
{ |
| 69 |
out.FragColor += _46[in.index ^ 1]; |
| 70 |
} |
| 71 |
else |
| 72 |
{ |
| 73 |
out.FragColor += _46[in.index & 1]; |
| 74 |
} |
| 75 |
if (in.index > 30) |
| 76 |
{ |
| 77 |
out.FragColor += _76[in.index & 3].y; |
| 78 |
} |
| 79 |
else |
| 80 |
{ |
| 81 |
out.FragColor += _76[in.index & 1].x; |
| 82 |
} |
| 83 |
if (in.index > 30) |
| 84 |
{ |
| 85 |
foobar[1].z = 20.0; |
| 86 |
} |
| 87 |
out.FragColor += foobar[in.index & 3].z; |
| 88 |
baz = _90; |
| 89 |
out.FragColor += baz[in.index & 3].z; |
| 90 |
return out; |
| 91 |
} |
| 92 |
|