Work around pow() issue in NVIDIA 331.x drivers
pow(x, y) when y is a certain kind of a constant vector can cause issues on
NVIDIA 331 series drivers. Add an option to replace pow(x, y) with
exp2(y * log2(x)) when y is a constant to work around this issue.
This is done with an AST traverser instead of BuiltInFunctionEmulator, since
there's no mechanism in BuiltInFunctionEmulator to apply the replacements
only to calls where the second parameter is constant.
TEST=WebGL conformance tests
BUG=chromium:477306
Change-Id: Ifb327d72659fca36868439f24705203014b3ce53
Reviewed-on: https://chromium-review.googlesource.com/274279
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 721e297..911a8f2 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -13,6 +13,7 @@
#include "compiler/translator/ParseContext.h"
#include "compiler/translator/PruneEmptyDeclarations.h"
#include "compiler/translator/RegenerateStructNames.h"
+#include "compiler/translator/RemovePow.h"
#include "compiler/translator/RenameFunction.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
#include "compiler/translator/UnfoldShortCircuitAST.h"
@@ -312,6 +313,11 @@
unfoldShortCircuit.updateTree();
}
+ if (success && (compileOptions & SH_REMOVE_POW_WITH_CONSTANT_EXPONENT))
+ {
+ RemovePow(root);
+ }
+
if (success && (compileOptions & SH_VARIABLES))
{
collectVariables(root);