Add constant folding support for min,max and clamp
This change adds necessary mechanism to support constant folding of
built-ins that take more than one parameter and also adds constant
folding support for min, max and clamp built-ins.
BUG=angleproject:913
TESTS=dEQP tests
(126 tests started passing with this change)
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.min_*
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.max_*
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.clamp_*
Change-Id: Iccc9bf503a536f2e3c144627e64572f2f95db9db
Reviewed-on: https://chromium-review.googlesource.com/271251
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index d3ab7d4..cdcc2a9 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -441,3 +441,19 @@
return true;
}
+
+TIntermTyped *TIntermediate::foldAggregateBuiltIn(TOperator op, TIntermAggregate *aggregate)
+{
+ switch (op)
+ {
+ case EOpMin:
+ case EOpMax:
+ case EOpClamp:
+ return TIntermConstantUnion::FoldAggregateBuiltIn(op, aggregate);
+ default:
+ // Constant folding not supported for the built-in.
+ return nullptr;
+ }
+
+ return nullptr;
+}