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-09-10 08:04:17 +00:00
|
|
|
constant float _16[4] = { 1.0, 4.0, 3.0, 2.0 };
|
|
|
|
constant Foo _28[2] = { Foo{ 10.0, 20.0 }, Foo{ 30.0, 40.0 } };
|
2018-02-08 12:06:29 +00:00
|
|
|
|
2018-06-12 15:41:35 +00:00
|
|
|
struct main0_out
|
2018-02-02 09:10:17 +00:00
|
|
|
{
|
2018-06-12 15:41:35 +00:00
|
|
|
float4 FragColor [[color(0)]];
|
2018-02-02 09:10:17 +00:00
|
|
|
};
|
|
|
|
|
2018-06-12 15:41:35 +00:00
|
|
|
struct main0_in
|
2018-02-02 09:10:17 +00:00
|
|
|
{
|
2018-06-12 15:41:35 +00:00
|
|
|
int line [[user(locn0)]];
|
2018-02-02 09:10:17 +00:00
|
|
|
};
|
|
|
|
|
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>
|
2018-09-11 10:58:03 +00:00
|
|
|
void spvArrayCopyFromStack1(thread T (&dst)[N], thread const T (&src)[N])
|
2018-02-08 16:58:46 +00:00
|
|
|
{
|
|
|
|
for (uint i = 0; i < N; dst[i] = src[i], i++);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T, uint N>
|
2018-09-11 10:58:03 +00:00
|
|
|
void spvArrayCopyFromConstant1(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 = {};
|
2018-09-10 08:04:17 +00:00
|
|
|
float lut[4] = { 1.0, 4.0, 3.0, 2.0 };
|
|
|
|
Foo foos[2] = { Foo{ 10.0, 20.0 }, Foo{ 30.0, 40.0 } };
|
2018-05-04 21:53:32 +00:00
|
|
|
out.FragColor = float4(lut[in.line]);
|
2018-07-05 12:14:18 +00:00
|
|
|
out.FragColor += float4(foos[in.line].a * foos[1 - in.line].a);
|
2018-02-02 09:10:17 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|