Work around atan(y, x) bug on NVIDIA
atan(y, x) is not always returning expected results on NVIDIA OpenGL
drivers between versions 367 and 375. Work around this by emulating
atan(y, x) using the regular atan(x) function. A fix to the driver is
expected in a future release.
It is most convenient to implement the vector atan(y, x) functions by
using the scalar atan(y, x) function. Support for simple dependencies
between emulated functions is added to BuiltInFunctionEmulator. In the
current implementation one function is allowed to have at most one
other function as its dependency.
BUG=chromium:672380
TEST=angle_end2end_tests
Change-Id: I9eba8b0b7979c7c7eaed353b264932e41830beb1
Reviewed-on: https://chromium-review.googlesource.com/419016
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp
index 18622ef..7a835ef 100644
--- a/src/tests/gl_tests/GLSLTest.cpp
+++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -2170,13 +2170,6 @@
// Test that -float calculation is correct.
TEST_P(GLSLTest_ES3, UnaryMinusOperatorFloat)
{
- // TODO(oetuaho@nvidia.com): re-enable once http://crbug.com/672380 is fixed.
- if ((IsWindows() || IsLinux()) && IsNVIDIA() && IsOpenGL())
- {
- std::cout << "Test disabled on this OpenGL configuration." << std::endl;
- return;
- }
-
const std::string &vert =
"#version 300 es\n"
"in highp vec4 position;\n"
@@ -2198,6 +2191,31 @@
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
+// Test that atan(vec2, vec2) calculation is correct.
+TEST_P(GLSLTest_ES3, AtanVec2)
+{
+ const std::string &vert =
+ "#version 300 es\n"
+ "in highp vec4 position;\n"
+ "void main() {\n"
+ " gl_Position = position;\n"
+ "}\n";
+ const std::string &frag =
+ "#version 300 es\n"
+ "out highp vec4 o_color;\n"
+ "void main() {\n"
+ " highp float f = 1.0;\n"
+ " // atan(tan(0.5), f) should be 0.5.\n"
+ " highp vec2 v = atan(vec2(tan(0.5)), vec2(f));\n"
+ " o_color = (abs(v[0] - 0.5) < 0.001 && abs(v[1] - 0.5) < 0.001) ? vec4(0, 1, 0, 1) : "
+ "vec4(1, 0, 0, 1);\n"
+ "}\n";
+
+ ANGLE_GL_PROGRAM(prog, vert, frag);
+ drawQuad(prog.get(), "position", 0.5f);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
+}
+
// Convers a bug with the unary minus operator on signed integer workaround.
TEST_P(GLSLTest_ES3, UnaryMinusOperatorSignedInt)
{