SPIRV-Cross/reference/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag
Hans-Kristian Arntzen d1479f871a MSL: Do not generate UnsafeArray<> for any array inside buffer objects.
This avoids a lot of huge code changes.
Arrays generally cannot be copied in and out of buffers, at least no
compiler frontend seems to do it.

Also avoids a lot of issues surrounding packed vectors and matrices.
2019-10-24 12:22:30 +02:00

32 lines
734 B
GLSL

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Vertices
{
float2 uvs[1];
};
struct main0_out
{
float2 value [[color(0)]];
};
struct main0_in
{
float3 gl_BaryCoordNoPerspNV [[barycentric_coord, center_no_perspective]];
};
fragment main0_out main0(main0_in in [[stage_in]], const device Vertices& _19 [[buffer(0)]], uint gl_PrimitiveID [[primitive_id]])
{
main0_out out = {};
int prim = int(gl_PrimitiveID);
float2 uv0 = _19.uvs[(3 * prim) + 0];
float2 uv1 = _19.uvs[(3 * prim) + 1];
float2 uv2 = _19.uvs[(3 * prim) + 2];
out.value = ((uv0 * in.gl_BaryCoordNoPerspNV.x) + (uv1 * in.gl_BaryCoordNoPerspNV.y)) + (uv2 * in.gl_BaryCoordNoPerspNV.z);
return out;
}