Commit 945dea36 by Joonatan Saarhelo Committed by Commit Bot

Clamp glClearDepthf and glDepthRangef

BUG=angleproject:2884 Change-Id: Ib1867fbd4c2ea3c3b29d2f987d384762f5851e8f Reviewed-on: https://chromium-review.googlesource.com/c/1276585 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 25843dd6
...@@ -121,6 +121,7 @@ NVIDIA Corporation ...@@ -121,6 +121,7 @@ NVIDIA Corporation
Kimmo Kinnunen Kimmo Kinnunen
Sami Väisänen Sami Väisänen
Martin Radev Martin Radev
Joonatan Saarhelo
Opera Software ASA Opera Software ASA
Daniel Bratell Daniel Bratell
......
...@@ -4555,7 +4555,7 @@ void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ...@@ -4555,7 +4555,7 @@ void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha
void Context::clearDepthf(GLfloat depth) void Context::clearDepthf(GLfloat depth)
{ {
mGLState.setDepthClearValue(depth); mGLState.setDepthClearValue(clamp01(depth));
} }
void Context::clearStencil(GLint s) void Context::clearStencil(GLint s)
...@@ -4586,7 +4586,7 @@ void Context::depthMask(GLboolean flag) ...@@ -4586,7 +4586,7 @@ void Context::depthMask(GLboolean flag)
void Context::depthRangef(GLfloat zNear, GLfloat zFar) void Context::depthRangef(GLfloat zNear, GLfloat zFar)
{ {
mGLState.setDepthRange(zNear, zFar); mGLState.setDepthRange(clamp01(zNear), clamp01(zFar));
} }
void Context::disable(GLenum cap) void Context::disable(GLenum cap)
......
...@@ -254,6 +254,29 @@ TEST_P(ClearTest, ClearIssue) ...@@ -254,6 +254,29 @@ TEST_P(ClearTest, ClearIssue)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Regression test for a bug where "glClearDepthf"'s argument was not clamped
// In GLES 2 they where declared as GLclampf and the behaviour is the same in GLES 3.2
TEST_P(ClearTest, ClearIsClamped)
{
glClearDepthf(5.0f);
GLfloat clear_depth;
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clear_depth);
EXPECT_EQ(1.0f, clear_depth);
}
// Regression test for a bug where "glDepthRangef"'s arguments were not clamped
// In GLES 2 they where declared as GLclampf and the behaviour is the same in GLES 3.2
TEST_P(ClearTest, DepthRangefIsClamped)
{
glDepthRangef(1.1f, -4.0f);
GLfloat depth_range[2];
glGetFloatv(GL_DEPTH_RANGE, depth_range);
EXPECT_EQ(1.0f, depth_range[0]);
EXPECT_EQ(0.0f, depth_range[1]);
}
// Requires ES3 // Requires ES3
// This tests a bug where in a masked clear when calling "ClearBuffer", we would // This tests a bug where in a masked clear when calling "ClearBuffer", we would
// mistakenly clear every channel (including the masked-out ones) // mistakenly clear every channel (including the masked-out ones)
......
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