2019-09-17 19:11:19 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
#pragma clang diagnostic ignored "-Wmissing-braces"
|
|
|
|
|
2019-07-23 08:30:37 +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
|
|
|
|
{
|
|
|
|
T elements[Num ? Num : 1];
|
|
|
|
|
|
|
|
thread T& operator [] (size_t pos) thread
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
constexpr const thread T& operator [] (size_t pos) const thread
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
|
|
|
|
device T& operator [] (size_t pos) device
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
constexpr const device T& operator [] (size_t pos) const device
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr const constant T& operator [] (size_t pos) const constant
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
|
|
|
|
threadgroup T& operator [] (size_t pos) threadgroup
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
|
|
|
|
{
|
|
|
|
return elements[pos];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-23 08:30:37 +00:00
|
|
|
struct A
|
|
|
|
{
|
|
|
|
float v;
|
|
|
|
char _m0_final_padding[12];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B
|
|
|
|
{
|
|
|
|
float2 v;
|
|
|
|
char _m0_final_padding[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct C
|
|
|
|
{
|
|
|
|
float3 v;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D
|
|
|
|
{
|
|
|
|
float4 v;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct E
|
|
|
|
{
|
|
|
|
float4 a;
|
|
|
|
float2 b;
|
|
|
|
char _m0_final_padding[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSBO
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<spvUnsafeArray<A, 2>, 4> a;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<B, 2>, 4> b;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<C, 2>, 4> c;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<D, 2>, 4> d;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<float2x4, 2>, 4> e;
|
|
|
|
spvUnsafeArray<E, 1> f;
|
2019-07-23 08:30:37 +00:00
|
|
|
};
|
|
|
|
|
2019-09-24 22:13:04 +00:00
|
|
|
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
|
|
|
|
|
2019-07-23 08:30:37 +00:00
|
|
|
kernel void main0(device SSBO& _32 [[buffer(0)]])
|
|
|
|
{
|
|
|
|
_32.f[0].a = float4(2.0);
|
|
|
|
float2x2 tmp = float2x2(_32.e[0][1][0].xy, _32.e[0][1][1].xy);
|
|
|
|
_32.e[1][2][0].xy = tmp[0];
|
|
|
|
_32.e[1][2][1].xy = tmp[1];
|
|
|
|
}
|
|
|
|
|