twinaphex 420b7913d4 Squashed 'deps/SPIRV-Cross/' changes from 8aa6731925..2820ab0b51
2820ab0b51 Merge pull request #1076 from KhronosGroup/bitcast-pre-330-glsl
63bcbd511e GLSL: Need extension to use bitcast on GLSL < 330.
9f3bebe3d0 Merge pull request #1075 from lifpan/master
b11c20fc1d Remove unreasonable assertion for OpTypeImage Sampled parameter.
1a592b7c0f Merge pull request #1067 from cdavis5e/msl-scalar-block-layout
28454facbb MSL: Handle packed matrices.
ea5c0ed82f MSL: Fix alignment of packed types.
44f688bf0b Merge pull request #1070 from KhronosGroup/fix-1066
25c74b324e Forget loop variable enables after emitting block chain.
6b010e0cbc Merge pull request #1069 from KhronosGroup/fix-1053
f6f849397e MSL: Re-roll array expressions in initializers.
e5fa7edfd6 MSL: Support scalar block layout.

git-subtree-dir: deps/SPIRV-Cross
git-subtree-split: 2820ab0b51bf5e4187435d904b34e762b988f48b
2019-07-11 20:37:45 +02:00

67 lines
1.7 KiB
GLSL

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float _16[16] = { 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 };
constant float4 _60[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
constant float4 _104[4] = { float4(20.0), float4(30.0), float4(50.0), float4(60.0) };
struct main0_out
{
float FragColor [[color(0)]];
};
struct main0_in
{
int index [[user(locn0)]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopyFromStack1(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
template<typename T, uint N>
void spvArrayCopyFromConstant1(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
out.FragColor = _16[in.index];
if (in.index < 10)
{
out.FragColor += _16[in.index ^ 1];
}
else
{
out.FragColor += _16[in.index & 1];
}
if (in.index > 30)
{
out.FragColor += _60[in.index & 3].y;
}
else
{
out.FragColor += _60[in.index & 1].x;
}
float4 foobar[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
if (in.index > 30)
{
foobar[1].z = 20.0;
}
out.FragColor += foobar[in.index & 3].z;
float4 baz[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
spvArrayCopyFromConstant1(baz, _104);
out.FragColor += baz[in.index & 3].z;
return out;
}