mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-08 21:30:05 +00:00
Support fma() in older GLSL targets.
This commit is contained in:
parent
133ea8fd82
commit
3ca8bc5e0d
13
reference/opt/shaders/legacy/fragment/fma.legacy.frag
Normal file
13
reference/opt/shaders/legacy/fragment/fma.legacy.frag
Normal file
@ -0,0 +1,13 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
varying highp vec4 vA;
|
||||
varying highp vec4 vB;
|
||||
varying highp vec4 vC;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragData[0] = vA * vB + vC;
|
||||
}
|
||||
|
13
reference/shaders/legacy/fragment/fma.legacy.frag
Normal file
13
reference/shaders/legacy/fragment/fma.legacy.frag
Normal file
@ -0,0 +1,13 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
varying highp vec4 vA;
|
||||
varying highp vec4 vB;
|
||||
varying highp vec4 vC;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragData[0] = vA * vB + vC;
|
||||
}
|
||||
|
11
shaders/legacy/fragment/fma.legacy.frag
Normal file
11
shaders/legacy/fragment/fma.legacy.frag
Normal file
@ -0,0 +1,11 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec4 vA;
|
||||
layout(location = 1) in vec4 vB;
|
||||
layout(location = 2) in vec4 vC;
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = fma(vA, vB, vC);
|
||||
}
|
@ -4818,7 +4818,18 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
|
||||
emit_unary_func_op(result_type, id, args[0], "degrees");
|
||||
break;
|
||||
case GLSLstd450Fma:
|
||||
emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "fma");
|
||||
if ((!options.es && options.version < 400) || (options.es && options.version < 320))
|
||||
{
|
||||
auto expr = join(to_enclosed_expression(args[0]), " * ", to_enclosed_expression(args[1]), " + ",
|
||||
to_enclosed_expression(args[2]));
|
||||
|
||||
emit_op(result_type, id, expr,
|
||||
should_forward(args[0]) && should_forward(args[1]) && should_forward(args[2]));
|
||||
for (uint32_t i = 0; i < 3; i++)
|
||||
inherit_expression_dependencies(id, args[i]);
|
||||
}
|
||||
else
|
||||
emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "fma");
|
||||
break;
|
||||
case GLSLstd450Modf:
|
||||
register_call_out_argument(args[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user