Add test for HLSL "pow" constant folding bug.
This covers 'pow-of-small-constant-in-user-defined-function' from
the WebGL CTS. Leave disabled until we have a proper fix.
BUG=angleproject:851
Change-Id: I41a4ad9354e32bb2d48894d75676a9dfe226e9d8
Reviewed-on: https://chromium-review.googlesource.com/269747
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/tests/end2end_tests/GLSLTest.cpp b/src/tests/end2end_tests/GLSLTest.cpp
index da7f590..c0528fe 100644
--- a/src/tests/end2end_tests/GLSLTest.cpp
+++ b/src/tests/end2end_tests/GLSLTest.cpp
@@ -1109,3 +1109,44 @@
glDeleteProgram(program);
}
+
+// Covers the WebGL test 'glsl/bugs/pow-of-small-constant-in-user-defined-function'
+// See https://code.google.com/p/angleproject/issues/detail?id=851
+// TODO(jmadill): ANGLE constant folding can fix this
+TYPED_TEST(GLSLTest, DISABLED_PowOfSmallConstant)
+{
+ const std::string &fragmentShaderSource = SHADER_SOURCE
+ (
+ precision highp float;
+
+ float fun(float arg)
+ {
+ // These values are still easily within the highp range.
+ // The minimum range in terms of 10's exponent is around -19 to 19, and IEEE-754 single precision range is higher than that.
+ return pow(arg, 2.0);
+ }
+
+ void main()
+ {
+ // Note that the bug did not reproduce if an uniform was passed to the function instead of a constant,
+ // or if the expression was moved outside the user-defined function.
+ const float a = 1.0e-6;
+ float b = 1.0e12 * fun(a);
+ if (abs(b - 1.0) < 0.01)
+ {
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); // green
+ }
+ else
+ {
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // red
+ }
+ }
+ );
+
+ GLuint program = CompileProgram(mSimpleVSSource, fragmentShaderSource);
+ EXPECT_NE(0u, program);
+
+ drawQuad(program, "inputAttribute", 0.5f);
+ EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
+ EXPECT_GL_NO_ERROR();
+}