| 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 BUF |
| 48 |
{ |
| 49 |
int a; |
| 50 |
float b; |
| 51 |
float c; |
| 52 |
}; |
| 53 |
|
| 54 |
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); |
| 55 |
|
| 56 |
constant spvUnsafeArray<float, 2> _16 = spvUnsafeArray<float, 2>({ 1.0, 2.0 }); |
| 57 |
constant spvUnsafeArray<float, 2> _19 = spvUnsafeArray<float, 2>({ 3.0, 4.0 }); |
| 58 |
constant spvUnsafeArray<spvUnsafeArray<float, 2>, 2> _20 = spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ spvUnsafeArray<float, 2>({ 1.0, 2.0 }), spvUnsafeArray<float, 2>({ 3.0, 4.0 }) }); |
| 59 |
constant spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> _21 = spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2>({ spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ spvUnsafeArray<float, 2>({ 1.0, 2.0 }), spvUnsafeArray<float, 2>({ 3.0, 4.0 }) }), spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ spvUnsafeArray<float, 2>({ 1.0, 2.0 }), spvUnsafeArray<float, 2>({ 3.0, 4.0 }) }) }); |
| 60 |
|
| 61 |
kernel void main0(device BUF& o [[buffer(0)]]) |
| 62 |
{ |
| 63 |
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> c; |
| 64 |
c = _21; |
| 65 |
o.a = int(c[1][1][1]); |
| 66 |
spvUnsafeArray<float, 2> _43 = spvUnsafeArray<float, 2>({ o.b, o.c }); |
| 67 |
spvUnsafeArray<float, 2> _48 = spvUnsafeArray<float, 2>({ o.b, o.b }); |
| 68 |
spvUnsafeArray<spvUnsafeArray<float, 2>, 2> _49 = spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ _43, _48 }); |
| 69 |
spvUnsafeArray<float, 2> _54 = spvUnsafeArray<float, 2>({ o.c, o.c }); |
| 70 |
spvUnsafeArray<float, 2> _59 = spvUnsafeArray<float, 2>({ o.c, o.b }); |
| 71 |
spvUnsafeArray<spvUnsafeArray<float, 2>, 2> _60 = spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ _54, _59 }); |
| 72 |
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> _61 = spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2>({ _49, _60 }); |
| 73 |
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> d; |
| 74 |
d = _61; |
| 75 |
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> e; |
| 76 |
e = d; |
| 77 |
o.b = e[1][0][1]; |
| 78 |
} |
| 79 |
|