Add ANGLE support for ESSL3 variant of mix()
This change adds support for ESSL3 variant of built-in function mix()
that takes last argument as a boolean vector. lerp() - HLSL equivalent
of mix() doesn't look to be supporting a variant that takes last
argument as a boolean vector so emulated it for HLSL.
BUG=angleproject:1006
TESTS=dEQP tests
Fixes "no matching overloaded function found " errors in below tests:
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.mix_*_b*
(Note: These tests still fail because of constant expression issues)
Change-Id: I79b353933cb450516b8678b1fdaeabe60417e9a7
Reviewed-on: https://chromium-review.googlesource.com/271751
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index dbdee4c..1f90aba 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -2253,7 +2253,22 @@
case EOpMin: outputTriplet(visit, "min(", ", ", ")"); break;
case EOpMax: outputTriplet(visit, "max(", ", ", ")"); break;
case EOpClamp: outputTriplet(visit, "clamp(", ", ", ")"); break;
- case EOpMix: outputTriplet(visit, "lerp(", ", ", ")"); break;
+ case EOpMix:
+ {
+ TIntermTyped *lastParamNode = (*(node->getSequence()))[2]->getAsTyped();
+ if (lastParamNode->getType().getBasicType() == EbtBool)
+ {
+ // There is no HLSL equivalent for ESSL3 built-in "genType mix (genType x, genType y, genBType a)",
+ // so use emulated version.
+ ASSERT(node->getUseEmulatedFunction());
+ writeEmulatedFunctionTriplet(visit, "mix(");
+ }
+ else
+ {
+ outputTriplet(visit, "lerp(", ", ", ")");
+ }
+ }
+ break;
case EOpStep: outputTriplet(visit, "step(", ", ", ")"); break;
case EOpSmoothStep: outputTriplet(visit, "smoothstep(", ", ", ")"); break;
case EOpDistance: outputTriplet(visit, "distance(", ", ", ")"); break;