SPIRV-Cross/reference/shaders-msl/tese/set-from-function.tese
Chip Davis 6b7988046d Handle blocks of patch I/O.
In this case, each member of the block will be decorated with
`DecorationPatch`, rather than the block variable having the decoration.
2019-02-15 17:21:38 -06:00

63 lines
1.3 KiB
GLSL

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Block
{
float4 a;
float4 b;
};
struct Foo
{
float4 a;
float4 b;
};
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float4 vColor [[attribute(0)]];
float4 Block_a [[attribute(2)]];
float4 Block_b [[attribute(3)]];
};
struct main0_patchIn
{
float4 vColors [[attribute(1)]];
float4 Foo_a [[attribute(4)]];
float4 Foo_b [[attribute(5)]];
patch_control_point<main0_in> gl_in;
};
void set_from_function(thread float4& gl_Position, thread patch_control_point<main0_in>& gl_in, thread float4& vColors, thread Foo& vFoo)
{
gl_Position = gl_in[0].Block_a;
gl_Position += gl_in[0].Block_b;
gl_Position += gl_in[1].Block_a;
gl_Position += gl_in[1].Block_b;
gl_Position += gl_in[0].vColor;
gl_Position += gl_in[1].vColor;
gl_Position += vColors;
gl_Position += vFoo.a;
gl_Position += vFoo.b;
}
[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]])
{
main0_out out = {};
Foo vFoo = {};
vFoo.a = patchIn.Foo_a;
vFoo.b = patchIn.Foo_b;
set_from_function(out.gl_Position, patchIn.gl_in, patchIn.vColors, vFoo);
return out;
}