Add ESSL 3.10 ldexp/frexp builtins
This adds new built-ins found in ESSL 3.10 section 8.3 Common
Functions.
This includes constant folding support for ldexp and support for both
GLSL and HLSL output. In HLSL these functions need to be emulated.
BUG=angleproject:1730
TEST=angle_unittests
Change-Id: I1330e69978b0cf53efbc3416150194764414e96c
Reviewed-on: https://chromium-review.googlesource.com/435342
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 4039305..1401af7 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -3012,6 +3012,25 @@
break;
}
+ case EOpLdexp:
+ {
+ resultArray = new TConstantUnion[maxObjectSize];
+ for (size_t i = 0; i < maxObjectSize; i++)
+ {
+ float x = unionArrays[0][i].getFConst();
+ int exp = unionArrays[1][i].getIConst();
+ if (exp > 128)
+ {
+ UndefinedConstantFoldingError(loc, op, basicType, diagnostics, &resultArray[i]);
+ }
+ else
+ {
+ resultArray[i].setFConst(gl::Ldexp(x, exp));
+ }
+ }
+ break;
+ }
+
case EOpFaceForward:
{
ASSERT(basicType == EbtFloat);