Commit ffe754b7 by Martin Radev Committed by Commit Bot

Disallow timer queries with multi-view draw framebuffers

According to the ANGLE_multiview spec Draw* commands should generate an INVALID_OPERATION error if there is an active query object for target TIME_ELAPSED_EXT and the number of views in the active draw framebuffer is greater than 1. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: I8a4434784ecec753a39c5ef82fa3ee46255a0851 Reviewed-on: https://chromium-review.googlesource.com/593315Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Martin Radev <mradev@nvidia.com>
parent 2803168e
...@@ -2800,8 +2800,8 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2800,8 +2800,8 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
// Note: these separate values are not supported in WebGL, due to D3D's limitations. See // Note: these separate values are not supported in WebGL, due to D3D's limitations. See
// Section 6.10 of the WebGL 1.0 spec. // Section 6.10 of the WebGL 1.0 spec.
Framebuffer *framebuffer = state.getDrawFramebuffer(); Framebuffer *framebuffer = state.getDrawFramebuffer();
if (context->getLimitations().noSeparateStencilRefsAndMasks || const Extensions &extensions = context->getExtensions();
context->getExtensions().webglCompatibility) if (context->getLimitations().noSeparateStencilRefsAndMasks || extensions.webglCompatibility)
{ {
const FramebufferAttachment *dsAttachment = const FramebufferAttachment *dsAttachment =
framebuffer->getStencilOrDepthStencilAttachment(); framebuffer->getStencilOrDepthStencilAttachment();
...@@ -2818,7 +2818,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2818,7 +2818,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
if (differentRefs || differentWritemasks || differentMasks) if (differentRefs || differentWritemasks || differentMasks)
{ {
if (!context->getExtensions().webglCompatibility) if (!extensions.webglCompatibility)
{ {
ERR() << "This ANGLE implementation does not support separate front/back stencil " ERR() << "This ANGLE implementation does not support separate front/back stencil "
"writemasks, reference values, or stencil mask values."; "writemasks, reference values, or stencil mask values.";
...@@ -2847,7 +2847,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2847,7 +2847,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
return false; return false;
} }
if (context->getExtensions().multiview) if (extensions.multiview)
{ {
const int programNumViews = program->getNumViews(); const int programNumViews = program->getNumViews();
const int framebufferNumViews = framebuffer->getNumViews(); const int framebufferNumViews = framebuffer->getNumViews();
...@@ -2868,6 +2868,16 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2868,6 +2868,16 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
"framebuffer is greater than 1."); "framebuffer is greater than 1.");
return false; return false;
} }
if (extensions.disjointTimerQuery && framebufferNumViews > 1 &&
state.isQueryActive(GL_TIME_ELAPSED_EXT))
{
context->handleError(InvalidOperation() << "There is an active query for target "
"GL_TIME_ELAPSED_EXT when the number of "
"views in the active draw framebuffer is "
"greater than 1.");
return false;
}
} }
// Uniform buffer validation // Uniform buffer validation
...@@ -2906,7 +2916,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2906,7 +2916,7 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
} }
// Do some additonal WebGL-specific validation // Do some additonal WebGL-specific validation
if (context->getExtensions().webglCompatibility) if (extensions.webglCompatibility)
{ {
// Detect rendering feedback loops for WebGL. // Detect rendering feedback loops for WebGL.
if (framebuffer->formsRenderingFeedbackLoopWith(state)) if (framebuffer->formsRenderingFeedbackLoopWith(state))
......
...@@ -289,4 +289,59 @@ TEST_P(MultiviewDrawValidationTest, ActiveTransformFeedback) ...@@ -289,4 +289,59 @@ TEST_P(MultiviewDrawValidationTest, ActiveTransformFeedback)
glEndTransformFeedback(); glEndTransformFeedback();
} }
// The test verifies that glDraw*:
// 1) generates an INVALID_OPERATION error if the number of views in the active draw framebuffer is
// greater than 1 and there is an active query for target GL_TIME_ELAPSED_EXT.
// 2) does not generate any error if the number of views in the draw framebuffer is 1.
TEST_P(MultiviewDrawValidationTest, ActiveTimeElapsedQuery)
{
if (!requestMultiviewExtension())
{
return;
}
if (!extensionEnabled("GL_EXT_disjoint_timer_query"))
{
std::cout << "Test skipped because GL_EXT_disjoint_timer_query is not available."
<< std::endl;
return;
}
const GLint viewportOffsets[4] = {0, 0, 2, 0};
const std::string &vsSource =
"#version 300 es\n"
"void main()\n"
"{}\n";
const std::string &fsSource =
"#version 300 es\n"
"precision mediump float;\n"
"void main()\n"
"{}\n";
ANGLE_GL_PROGRAM(program, vsSource, fsSource);
glUseProgram(program);
GLuint query = 0u;
glGenQueriesEXT(1, &query);
glBeginQueryEXT(GL_TIME_ELAPSED_EXT, query);
// Check first case.
{
glFramebufferTextureMultiviewSideBySideANGLE(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTex2d,
0, 2, &viewportOffsets[0]);
glDrawArrays(GL_TRIANGLES, 0, 3);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Check second case.
{
glFramebufferTextureMultiviewSideBySideANGLE(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTex2d,
0, 1, &viewportOffsets[0]);
glDrawArrays(GL_TRIANGLES, 0, 3);
EXPECT_GL_NO_ERROR();
}
glEndQueryEXT(GL_TIME_ELAPSED_EXT);
glDeleteQueries(1, &query);
}
ANGLE_INSTANTIATE_TEST(MultiviewDrawValidationTest, ES31_OPENGL()); ANGLE_INSTANTIATE_TEST(MultiviewDrawValidationTest, ES31_OPENGL());
\ No newline at end of file
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