SPIRV-Cross/reference/shaders-msl/frag/array-lut-no-loop-variable.frag
Hans-Kristian Arntzen 922420e346 Disallow arrays and structs from becoming loop variables.
Fixes awkward code-gen issue.
2018-03-07 14:54:11 +01:00

39 lines
873 B
GLSL

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float _17[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
struct main0_out
{
float4 FragColor [[color(0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
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])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0()
{
main0_out out = {};
float lut[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
for (int i = 0; i < 4; i++, out.FragColor += float4(lut[i]))
{
}
return out;
}