Attempt MRT-as-array in MSL.
This commit is contained in:
parent
fbfe13657a
commit
6e6ca0b237
35
reference/opt/shaders-msl/frag/mrt-array.frag
Normal file
35
reference/opt/shaders-msl/frag/mrt-array.frag
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
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<typename Tx, typename Ty>
|
||||
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;
|
||||
}
|
||||
|
35
reference/shaders-msl/frag/mrt-array.frag
Normal file
35
reference/shaders-msl/frag/mrt-array.frag
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
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<typename Tx, typename Ty>
|
||||
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;
|
||||
}
|
||||
|
14
shaders-msl/frag/mrt-array.frag
Normal file
14
shaders-msl/frag/mrt-array.frag
Normal file
@ -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;
|
||||
}
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user