SPIRV-Cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp

88 lines
1.8 KiB
Plaintext
Raw Normal View History

2019-09-17 19:11:19 +00:00
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#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];
}
};
struct A
{
int a;
int b;
};
struct A_1
{
2019-09-17 19:11:19 +00:00
spvUnsafeArray<A, 1> Data;
};
struct A_2
{
int a;
int b;
2019-07-22 08:23:39 +00:00
char _m0_final_padding[8];
};
struct A_3
{
2019-09-17 19:11:19 +00:00
spvUnsafeArray<A_2, 1024> Data;
};
struct B
{
2019-09-17 19:11:19 +00:00
spvUnsafeArray<A, 1> Data;
};
struct B_1
{
2019-09-17 19:11:19 +00:00
spvUnsafeArray<A_2, 1024> Data;
};
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]])
{
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;
}