2019-09-17 19:11:19 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
#pragma clang diagnostic ignored "-Wmissing-braces"
|
|
|
|
|
2019-07-10 01:28:02 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
typedef float2x2 packed_float2x2;
|
|
|
|
typedef float2x3 packed_float2x3;
|
|
|
|
typedef float2x3 packed_rm_float3x2;
|
|
|
|
|
|
|
|
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-10 01:28:02 +00:00
|
|
|
|
|
|
|
struct S0
|
|
|
|
{
|
2019-10-09 21:59:47 +00:00
|
|
|
packed_float2 a[1];
|
2019-07-24 09:52:28 +00:00
|
|
|
float b;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S1
|
|
|
|
{
|
|
|
|
packed_float3 a;
|
2019-07-24 09:52:28 +00:00
|
|
|
float b;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S2
|
|
|
|
{
|
2019-10-09 21:59:47 +00:00
|
|
|
packed_float3 a[1];
|
2019-07-24 09:52:28 +00:00
|
|
|
float b;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S3
|
|
|
|
{
|
|
|
|
packed_float2 a;
|
2019-07-24 09:52:28 +00:00
|
|
|
float b;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Content
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<S0, 1> m0s;
|
|
|
|
spvUnsafeArray<S1, 1> m1s;
|
|
|
|
spvUnsafeArray<S2, 1> m2s;
|
2019-07-10 01:28:02 +00:00
|
|
|
S0 m0;
|
|
|
|
S1 m1;
|
|
|
|
S2 m2;
|
|
|
|
S3 m3;
|
|
|
|
float m4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSBO1
|
|
|
|
{
|
|
|
|
Content content;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<Content, 2> content1;
|
2019-07-10 01:28:02 +00:00
|
|
|
Content content2;
|
|
|
|
float2x2 m0;
|
|
|
|
float2x2 m1;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<packed_float2x3, 4> m2;
|
2019-07-10 01:28:02 +00:00
|
|
|
float3x2 m3;
|
|
|
|
float2x2 m4;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float2x2, 9> m5;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<float3x2, 4>, 2> m6;
|
2019-07-22 08:23:39 +00:00
|
|
|
packed_rm_float3x2 m7;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float, 1> array;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S0_1
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float4, 1> a;
|
2019-07-10 01:28:02 +00:00
|
|
|
float b;
|
2019-07-22 08:23:39 +00:00
|
|
|
char _m0_final_padding[12];
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S1_1
|
|
|
|
{
|
|
|
|
packed_float3 a;
|
|
|
|
float b;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct S2_1
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float3, 1> a;
|
2019-07-10 01:28:02 +00:00
|
|
|
float b;
|
2019-07-22 08:23:39 +00:00
|
|
|
char _m0_final_padding[12];
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct S3_1
|
|
|
|
{
|
|
|
|
float2 a;
|
|
|
|
float b;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Content_1
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<S0_1, 1> m0s;
|
|
|
|
spvUnsafeArray<S1_1, 1> m1s;
|
|
|
|
spvUnsafeArray<S2_1, 1> m2s;
|
2019-07-10 01:28:02 +00:00
|
|
|
S0_1 m0;
|
|
|
|
S1_1 m1;
|
|
|
|
S2_1 m2;
|
|
|
|
S3_1 m3;
|
|
|
|
float m4;
|
2019-07-22 08:23:39 +00:00
|
|
|
char _m0_final_padding[12];
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SSBO0
|
|
|
|
{
|
|
|
|
Content_1 content;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<Content_1, 2> content1;
|
2019-07-10 01:28:02 +00:00
|
|
|
Content_1 content2;
|
2019-07-22 08:23:39 +00:00
|
|
|
float2x4 m0;
|
|
|
|
float2x4 m1;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float2x3, 4> m2;
|
2019-07-22 08:23:39 +00:00
|
|
|
float3x4 m3;
|
|
|
|
float2x4 m4;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float2x4, 9> m5;
|
|
|
|
spvUnsafeArray<spvUnsafeArray<float3x4, 4>, 2> m6;
|
2019-07-22 08:23:39 +00:00
|
|
|
float2x3 m7;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float4, 1> array;
|
2019-07-10 01:28:02 +00:00
|
|
|
};
|
|
|
|
|
2019-07-10 23:37:31 +00:00
|
|
|
struct SSBO2
|
|
|
|
{
|
|
|
|
float m0;
|
|
|
|
packed_float2x2 m1;
|
|
|
|
packed_rm_float3x2 m2;
|
|
|
|
};
|
|
|
|
|
2019-09-24 22:13:04 +00:00
|
|
|
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
|
|
|
|
|
2019-07-10 23:37:31 +00:00
|
|
|
kernel void main0(device SSBO1& ssbo_scalar [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]], device SSBO2& ssbo_scalar2 [[buffer(2)]])
|
|
|
|
{
|
2019-10-09 21:59:47 +00:00
|
|
|
ssbo_scalar.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0].xy;
|
2019-07-10 23:37:31 +00:00
|
|
|
ssbo_scalar.content.m0s[0].b = ssbo_140.content.m0s[0].b;
|
|
|
|
ssbo_scalar.content.m1s[0].a = float3(ssbo_140.content.m1s[0].a);
|
|
|
|
ssbo_scalar.content.m1s[0].b = ssbo_140.content.m1s[0].b;
|
2019-10-09 21:59:47 +00:00
|
|
|
ssbo_scalar.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0];
|
2019-07-10 23:37:31 +00:00
|
|
|
ssbo_scalar.content.m2s[0].b = ssbo_140.content.m2s[0].b;
|
2019-10-09 21:59:47 +00:00
|
|
|
ssbo_scalar.content.m0.a[0] = ssbo_140.content.m0.a[0].xy;
|
2019-07-10 23:37:31 +00:00
|
|
|
ssbo_scalar.content.m0.b = ssbo_140.content.m0.b;
|
|
|
|
ssbo_scalar.content.m1.a = float3(ssbo_140.content.m1.a);
|
|
|
|
ssbo_scalar.content.m1.b = ssbo_140.content.m1.b;
|
2019-10-09 21:59:47 +00:00
|
|
|
ssbo_scalar.content.m2.a[0] = ssbo_140.content.m2.a[0];
|
2019-07-10 23:37:31 +00:00
|
|
|
ssbo_scalar.content.m2.b = ssbo_140.content.m2.b;
|
|
|
|
ssbo_scalar.content.m3.a = ssbo_140.content.m3.a;
|
|
|
|
ssbo_scalar.content.m3.b = ssbo_140.content.m3.b;
|
|
|
|
ssbo_scalar.content.m4 = ssbo_140.content.m4;
|
2019-10-09 21:59:47 +00:00
|
|
|
ssbo_scalar.content.m1.a = float2x3(float3(ssbo_scalar.m2[1][0]), float3(ssbo_scalar.m2[1][1])) * float2(ssbo_scalar.content.m0.a[0]);
|
2019-07-10 23:37:31 +00:00
|
|
|
ssbo_scalar.m0 = float2x2(float2(ssbo_scalar2.m1[0]), float2(ssbo_scalar2.m1[1]));
|
2019-07-22 13:49:17 +00:00
|
|
|
ssbo_scalar2.m1[0] = float2(ssbo_scalar.m4[0][0], ssbo_scalar.m4[1][0]);
|
|
|
|
ssbo_scalar2.m1[1] = float2(ssbo_scalar.m4[0][1], ssbo_scalar.m4[1][1]);
|
2019-07-22 10:56:14 +00:00
|
|
|
ssbo_scalar2.m2[0] = float3(ssbo_scalar.m3[0][0], ssbo_scalar.m3[1][0], ssbo_scalar.m3[2][0]);
|
|
|
|
ssbo_scalar2.m2[1] = float3(ssbo_scalar.m3[0][1], ssbo_scalar.m3[1][1], ssbo_scalar.m3[2][1]);
|
2019-07-10 01:28:02 +00:00
|
|
|
}
|
|
|
|
|