SPIRV-Cross/reference/shaders-msl/asm/comp/global-parameter-name-alias.asm.comp
2019-09-24 14:35:25 -04:00

73 lines
1.7 KiB
Plaintext

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
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 ssbo
{
spvUnsafeArray<uint, 1> _data;
};
static inline __attribute__((always_inline))
void Load(thread const uint& size, const device ssbo& ssbo_1)
{
int byteAddrTemp = int(size >> uint(2));
uint4 data = uint4(ssbo_1._data[byteAddrTemp], ssbo_1._data[byteAddrTemp + 1], ssbo_1._data[byteAddrTemp + 2], ssbo_1._data[byteAddrTemp + 3]);
}
static inline __attribute__((always_inline))
void _main(thread const uint3& id, const device ssbo& ssbo_1)
{
uint param = 4u;
Load(param, ssbo_1);
}
kernel void main0(const device ssbo& ssbo_1 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint3 id = gl_GlobalInvocationID;
uint3 param = id;
_main(param, ssbo_1);
}