2018-05-02 10:38:41 +03:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
|
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
struct SSBO0
|
|
|
|
{
|
|
|
|
float4 as[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSBO1
|
|
|
|
{
|
|
|
|
float4 bs[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Composite
|
|
|
|
{
|
2018-05-02 11:01:08 +03:00
|
|
|
float4 a;
|
|
|
|
float4 b;
|
2018-05-02 10:38:41 +03:00
|
|
|
};
|
|
|
|
|
2018-09-10 11:04:17 +03:00
|
|
|
constant float4 _43[2] = { float4(20.0), float4(40.0) };
|
2018-05-02 10:38:41 +03:00
|
|
|
|
|
|
|
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
|
|
|
|
template<typename T, uint N>
|
2018-09-11 13:58:03 +03:00
|
|
|
void spvArrayCopyFromStack1(thread T (&dst)[N], thread const T (&src)[N])
|
2018-05-02 10:38:41 +03:00
|
|
|
{
|
|
|
|
for (uint i = 0; i < N; dst[i] = src[i], i++);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T, uint N>
|
2018-09-11 13:58:03 +03:00
|
|
|
void spvArrayCopyFromConstant1(thread T (&dst)[N], constant T (&src)[N])
|
2018-05-02 10:38:41 +03:00
|
|
|
{
|
|
|
|
for (uint i = 0; i < N; dst[i] = src[i], i++);
|
|
|
|
}
|
|
|
|
|
2018-05-02 11:01:08 +03:00
|
|
|
kernel void main0(device SSBO0& _16 [[buffer(0)]], device SSBO1& _32 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
|
2018-05-02 10:38:41 +03:00
|
|
|
{
|
2018-05-02 11:01:08 +03:00
|
|
|
float4 _37[2] = { _16.as[gl_GlobalInvocationID.x], _32.bs[gl_GlobalInvocationID.x] };
|
2018-05-02 10:38:41 +03:00
|
|
|
float4 values[2];
|
2018-09-11 13:58:03 +03:00
|
|
|
spvArrayCopyFromStack1(values, _37);
|
2018-07-05 14:25:57 +03:00
|
|
|
Composite c = Composite{ values[0], _43[1] };
|
2018-05-02 11:01:08 +03:00
|
|
|
_16.as[0] = values[gl_LocalInvocationIndex];
|
|
|
|
_32.bs[1] = c.b;
|
2018-05-02 10:38:41 +03:00
|
|
|
}
|
|
|
|
|