Commit 6137ddc5 by Frank Henigman Committed by Commit Bot

WebGL validation for depthRange.

Generate INVALID_OPERATION for depthRange(zNear, zFar) if zNear > zFar. Add corresponding test. BUG=angleproject:1816 Change-Id: I28b5876a74c9765c0eef1e0f6e5e96d0380586d0 Reviewed-on: https://chromium-review.googlesource.com/441207 Commit-Queue: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 14154827
...@@ -4015,4 +4015,15 @@ bool ValidateVertexAttribPointer(ValidationContext *context, ...@@ -4015,4 +4015,15 @@ bool ValidateVertexAttribPointer(ValidationContext *context,
return true; return true;
} }
bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zFar)
{
if (context->getExtensions().webglCompatibility && zNear > zFar)
{
context->handleError(Error(GL_INVALID_OPERATION, "Depth near > far."));
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -380,6 +380,8 @@ bool ValidateVertexAttribPointer(ValidationContext *context, ...@@ -380,6 +380,8 @@ bool ValidateVertexAttribPointer(ValidationContext *context,
GLsizei stride, GLsizei stride,
const GLvoid *ptr); const GLvoid *ptr);
bool ValidateDepthRangef(ValidationContext *context, GLclampf zNear, GLclampf zFar);
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES2_H_ #endif // LIBANGLE_VALIDATION_ES2_H_
...@@ -687,6 +687,11 @@ void GL_APIENTRY DepthRangef(GLclampf zNear, GLclampf zFar) ...@@ -687,6 +687,11 @@ void GL_APIENTRY DepthRangef(GLclampf zNear, GLclampf zFar)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!context->skipValidation() && !ValidateDepthRangef(context, zNear, zFar))
{
return;
}
context->depthRangef(zNear, zFar); context->depthRangef(zNear, zFar);
} }
} }
......
...@@ -423,6 +423,19 @@ TEST_P(WebGLCompatibilityTest, DrawElementsBufferOutOfBoundsInIndexBuffer) ...@@ -423,6 +423,19 @@ TEST_P(WebGLCompatibilityTest, DrawElementsBufferOutOfBoundsInIndexBuffer)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test depth range with 'near' more or less than 'far.'
TEST_P(WebGLCompatibilityTest, DepthRange)
{
glDepthRangef(0, 1);
ASSERT_GL_NO_ERROR();
glDepthRangef(.5, .5);
ASSERT_GL_NO_ERROR();
glDepthRangef(1, 0);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test the checks for OOB reads in the vertex buffers, instanced version // Test the checks for OOB reads in the vertex buffers, instanced version
TEST_P(WebGL2CompatibilityTest, DrawArraysBufferOutOfBoundsInstanced) TEST_P(WebGL2CompatibilityTest, DrawArraysBufferOutOfBoundsInstanced)
{ {
......
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