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"
|
|
|
|
|
2017-11-22 11:08:06 +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];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-22 11:08:06 +00:00
|
|
|
struct PushMe
|
|
|
|
{
|
|
|
|
float4x4 MVP;
|
|
|
|
float2x2 Rot;
|
2019-09-17 19:11:19 +00:00
|
|
|
spvUnsafeArray<float, 4> Arr;
|
2017-11-22 11:08:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct main0_out
|
|
|
|
{
|
|
|
|
float2 vRot [[user(locn0)]];
|
|
|
|
float4 gl_Position [[position]];
|
|
|
|
};
|
|
|
|
|
2018-06-12 15:41:35 +00:00
|
|
|
struct main0_in
|
|
|
|
{
|
|
|
|
float2 Rot [[attribute(0)]];
|
|
|
|
float4 Pos [[attribute(1)]];
|
|
|
|
};
|
|
|
|
|
2017-11-22 11:08:06 +00:00
|
|
|
vertex main0_out main0(main0_in in [[stage_in]], constant PushMe& registers [[buffer(0)]])
|
|
|
|
{
|
|
|
|
main0_out out = {};
|
|
|
|
out.gl_Position = registers.MVP * in.Pos;
|
|
|
|
out.vRot = (registers.Rot * in.Rot) + float2(registers.Arr[2]);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|