SPIRV-Cross/reference/shaders-msl/asm/frag/locations-components.asm.frag
Chip Davis 4b99fdd5d0 MSL: Account for components when assigning locations to varyings.
Two varyings (vertex outputs/fragment inputs) might have the same
location but be in different components--e.g. the compiler may have
packed what were two different varyings into a single varying vector.
Giving both varyings the same `[[user]]` attribute won't work--it may
yield unexpected results, or flat out fail to link. We could eventually
pack such varyings into a single vector, but that would require us to
handle the case where the varyings are different types--e.g. a `float`
and a `uint` packed into the same vector. For now, it seems most
prudent to give them unique `[[user]]` locations and let Apple's
compiler work out the best way to pack them.
2018-09-06 13:52:33 -05:00

38 lines
801 B
GLSL

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 o0 [[color(0)]];
};
struct main0_in
{
float2 m_2 [[user(locn1)]];
float m_3 [[user(locn1_2)]];
float m_4 [[user(locn2), flat]];
uint m_5 [[user(locn2_1)]];
uint m_6 [[user(locn2_2)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float4 v1;
v1 = float4(in.m_2.x, in.m_2.y, v1.z, v1.w);
v1.z = in.m_3;
float4 v2;
v2.x = in.m_4;
v2.y = as_type<float>(in.m_5);
v2.z = as_type<float>(in.m_6);
float4 r0;
r0.x = as_type<float>(as_type<int>(v2.y) + as_type<int>(v2.z));
out.o0.y = float(as_type<uint>(r0.x));
out.o0.x = v1.y + v2.x;
out.o0 = float4(out.o0.x, out.o0.y, v1.z, v1.x);
return out;
}