Commit 4052dfc8 by Jamie Madill

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/269747Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 4ea209f1
...@@ -1109,3 +1109,44 @@ TYPED_TEST(GLSLTest, DepthRangeUniforms) ...@@ -1109,3 +1109,44 @@ TYPED_TEST(GLSLTest, DepthRangeUniforms)
glDeleteProgram(program); 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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment