SPIRV-Cross/reference/shaders-msl/comp/copy-array-of-arrays.comp

80 lines
2.8 KiB
Plaintext
Raw Normal View History

2018-09-11 10:58:03 +00:00
#pragma clang diagnostic ignored "-Wmissing-prototypes"
2019-09-17 19:11:19 +00:00
#pragma clang diagnostic ignored "-Wmissing-braces"
2018-09-11 10:58:03 +00:00
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
2019-09-17 19:11:19 +00:00
template<typename T, size_t Num>
struct spvUnsafeArray
2018-09-11 10:58:03 +00:00
{
2019-09-17 19:11:19 +00:00
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
constexpr const thread T& operator [] (size_t pos) const thread
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
device T& operator [] (size_t pos) device
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
constexpr const device T& operator [] (size_t pos) const device
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
constexpr const constant T& operator [] (size_t pos) const constant
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
threadgroup T& operator [] (size_t pos) threadgroup
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
2019-09-17 19:11:19 +00:00
return elements[pos];
}
2019-09-17 19:11:19 +00:00
};
2018-09-11 10:58:03 +00:00
2019-09-17 19:11:19 +00:00
struct BUF
2018-09-11 10:58:03 +00:00
{
2019-09-17 19:11:19 +00:00
int a;
float b;
float c;
};
2018-09-11 10:58:03 +00:00
2019-09-24 22:13:04 +00:00
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
2019-09-17 19:11:19 +00:00
constant spvUnsafeArray<float, 2> _16 = spvUnsafeArray<float, 2>({ 1.0, 2.0 });
constant spvUnsafeArray<float, 2> _19 = spvUnsafeArray<float, 2>({ 3.0, 4.0 });
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 }) });
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 }) }) });
2018-09-11 10:58:03 +00:00
kernel void main0(device BUF& o [[buffer(0)]])
{
2019-09-17 19:11:19 +00:00
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> c;
c = _21;
2018-09-11 10:58:03 +00:00
o.a = int(c[1][1][1]);
spvUnsafeArray<float, 2> _43 = spvUnsafeArray<float, 2>({ o.b, o.c });
spvUnsafeArray<float, 2> _48 = spvUnsafeArray<float, 2>({ o.b, o.b });
spvUnsafeArray<spvUnsafeArray<float, 2>, 2> _49 = spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ _43, _48 });
spvUnsafeArray<float, 2> _54 = spvUnsafeArray<float, 2>({ o.c, o.c });
spvUnsafeArray<float, 2> _59 = spvUnsafeArray<float, 2>({ o.c, o.b });
spvUnsafeArray<spvUnsafeArray<float, 2>, 2> _60 = spvUnsafeArray<spvUnsafeArray<float, 2>, 2>({ _54, _59 });
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> _61 = spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2>({ _49, _60 });
2019-09-17 19:11:19 +00:00
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> d;
d = _61;
spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<float, 2>, 2>, 2> e;
e = d;
o.b = e[1][0][1];
2018-09-11 10:58:03 +00:00
}