diff --git a/reference/opt/shaders-msl/frag/mrt-array.frag b/reference/opt/shaders-msl/frag/mrt-array.frag new file mode 100644 index 00000000..1a84e620 --- /dev/null +++ b/reference/opt/shaders-msl/frag/mrt-array.frag @@ -0,0 +1,35 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 vB [[user(locn1)]]; + float4 vA [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]][4]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor[0] = mod(in.vA, in.vB); + out.FragColor[1] = in.vA + in.vB; + out.FragColor[2] = in.vA - in.vB; + out.FragColor[3] = in.vA * in.vB; + return out; +} + diff --git a/reference/shaders-msl/frag/mrt-array.frag b/reference/shaders-msl/frag/mrt-array.frag new file mode 100644 index 00000000..1a84e620 --- /dev/null +++ b/reference/shaders-msl/frag/mrt-array.frag @@ -0,0 +1,35 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_in +{ + float4 vB [[user(locn1)]]; + float4 vA [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]][4]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template +Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor[0] = mod(in.vA, in.vB); + out.FragColor[1] = in.vA + in.vB; + out.FragColor[2] = in.vA - in.vB; + out.FragColor[3] = in.vA * in.vB; + return out; +} + diff --git a/shaders-msl/frag/mrt-array.frag b/shaders-msl/frag/mrt-array.frag new file mode 100644 index 00000000..a8a8e492 --- /dev/null +++ b/shaders-msl/frag/mrt-array.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor[4]; +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; + +void main() +{ + FragColor[0] = mod(vA, vB); + FragColor[1] = vA + vB; + FragColor[2] = vA - vB; + FragColor[3] = vA * vB; +} diff --git a/spirv_msl.cpp b/spirv_msl.cpp index c210b541..50d56562 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -604,8 +604,9 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage) BuiltIn builtin = BuiltIn(get_decoration(p_var->self, DecorationBuiltIn)); if (should_move_to_input_buffer(type_id, is_builtin, storage)) + { move_to_input_buffer(*p_var); - + } else if (!is_builtin || has_active_builtin(builtin, storage)) { // Add a reference to the variable type to the interface struct. @@ -679,8 +680,8 @@ bool CompilerMSL::should_move_to_input_buffer(uint32_t type_id, bool is_builtin, if (storage == StorageClassInput) SPIRV_CROSS_THROW("The fragment function stage_in structure may not include a matrix or array."); - if (storage == StorageClassOutput) - SPIRV_CROSS_THROW("The fragment function output structure may not include a matrix or array."); + //if (storage == StorageClassOutput) + // SPIRV_CROSS_THROW("The fragment function output structure may not include a matrix or array."); } }