2019-09-17 19:11:19 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
2019-08-14 15:09:39 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-braces"
|
|
|
|
|
2019-01-04 11:15:43 +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-01-04 11:15:43 +00:00
|
|
|
struct A
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct A_1
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<A, 1> Data;
|
2019-01-04 11:15:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct A_2
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
int b;
|
2019-07-22 08:23:39 +00:00
|
|
|
char _m0_final_padding[8];
|
2019-01-04 11:15:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct A_3
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<A_2, 1024> Data;
|
2019-01-04 11:15:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct B
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<A, 1> Data;
|
2019-01-04 11:15:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct B_1
|
|
|
|
{
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<A_2, 1024> Data;
|
2019-01-04 11:15:43 +00:00
|
|
|
};
|
|
|
|
|
2019-06-21 10:44:33 +00:00
|
|
|
kernel void main0(device A_1& C1 [[buffer(0)]], constant A_3& C2 [[buffer(1)]], device B& C3 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
|
2019-01-04 11:15:43 +00:00
|
|
|
{
|
|
|
|
C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].a;
|
|
|
|
C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].b;
|
|
|
|
C3.Data[gl_GlobalInvocationID.x].a = C4.Data[gl_GlobalInvocationID.x].a;
|
|
|
|
C3.Data[gl_GlobalInvocationID.x].b = C4.Data[gl_GlobalInvocationID.x].b;
|
|
|
|
}
|
|
|
|
|