2018-02-08 12:06:29 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
|
2018-02-02 09:10:17 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
struct Foo
|
|
|
|
{
|
|
|
|
float a;
|
|
|
|
float b;
|
|
|
|
};
|
|
|
|
|
2018-02-08 12:06:29 +00:00
|
|
|
constant float _16[4] = {1.0, 4.0, 3.0, 2.0};
|
|
|
|
constant Foo _28[2] = {{10.0, 20.0}, {30.0, 40.0}};
|
|
|
|
|
2018-02-02 09:10:17 +00:00
|
|
|
struct main0_in
|
|
|
|
{
|
2018-04-03 13:36:35 +00:00
|
|
|
int _line [[user(locn0)]];
|
2018-02-02 09:10:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct main0_out
|
|
|
|
{
|
|
|
|
float4 FragColor [[color(0)]];
|
|
|
|
};
|
|
|
|
|
2018-02-08 12:06:29 +00:00
|
|
|
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
|
2018-02-08 16:58:46 +00:00
|
|
|
template<typename T, uint N>
|
|
|
|
void spvArrayCopy(thread T (&dst)[N], thread const T (&src)[N])
|
|
|
|
{
|
|
|
|
for (uint i = 0; i < N; dst[i] = src[i], i++);
|
|
|
|
}
|
|
|
|
|
|
|
|
// An overload for constant arrays.
|
|
|
|
template<typename T, uint N>
|
|
|
|
void spvArrayCopyConstant(thread T (&dst)[N], constant T (&src)[N])
|
2018-02-08 12:06:29 +00:00
|
|
|
{
|
|
|
|
for (uint i = 0; i < N; dst[i] = src[i], i++);
|
|
|
|
}
|
|
|
|
|
2018-02-02 09:10:17 +00:00
|
|
|
fragment main0_out main0(main0_in in [[stage_in]])
|
|
|
|
{
|
|
|
|
main0_out out = {};
|
|
|
|
float lut[4] = {1.0, 4.0, 3.0, 2.0};
|
|
|
|
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
|
2018-04-03 13:36:35 +00:00
|
|
|
out.FragColor = float4(lut[in._line]);
|
|
|
|
out.FragColor += float4(foos[in._line].a * (foos[1 - in._line].a));
|
2018-02-02 09:10:17 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|