Commit 66a41a28 by He Yunchao Committed by Commit Bot

Generate errors when read buffers are missing in BlitFramebuffer.

The corresponding gl_tests has been updated too. BUG=672719 Change-Id: Ief37bc397f7aa065bf99d6ebad0a1b50b1917dac Reviewed-on: https://chromium-review.googlesource.com/420469Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 51f522f1
......@@ -1987,10 +1987,9 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
if (mask & GL_COLOR_BUFFER_BIT)
{
const gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer();
const gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer();
const Extensions &extensions = context->getExtensions();
if (readColorBuffer && drawColorBuffer)
if (readColorBuffer)
{
const Format &readFormat = readColorBuffer->getFormat();
......@@ -2070,6 +2069,17 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
return false;
}
}
// WebGL 2.0 BlitFramebuffer when blitting from a missing attachment
// In OpenGL ES it is undefined what happens when an operation tries to blit from a missing
// attachment and WebGL defines it to be an error. We do the check unconditionally as the
// situation is an application error that would lead to a crash in ANGLE.
else if (drawFramebuffer->hasEnabledDrawBuffer())
{
context->handleError(Error(
GL_INVALID_OPERATION,
"Attempt to read from a missing color attachment of a complete framebuffer."));
return false;
}
}
GLenum masks[] = {GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT};
......@@ -2097,6 +2107,14 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
return false;
}
}
// WebGL 2.0 BlitFramebuffer when blitting from a missing attachment
else if (drawBuffer)
{
context->handleError(Error(GL_INVALID_OPERATION,
"Attempt to read from a missing depth/stencil "
"attachment of a complete framebuffer."));
return false;
}
}
}
......@@ -2974,7 +2992,7 @@ bool ValidateCopyTexImageParametersBase(ValidationContext *context,
// WebGL 1.0 [Section 6.26] Reading From a Missing Attachment
// In OpenGL ES it is undefined what happens when an operation tries to read from a missing
// attachment and WebGL defines it to be an error. We do the check unconditionnaly as the
// attachment and WebGL defines it to be an error. We do the check unconditionally as the
// situation is an application error that would lead to a crash in ANGLE.
if (readFramebuffer->getReadColorbuffer() == nullptr)
{
......
......@@ -678,29 +678,26 @@ TEST_P(BlitFramebufferANGLETest, BlitWithMissingAttachments)
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// depth blit request should be silently ignored, because the read FBO has no depth attachment
glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
// generate INVALID_OPERATION if the read FBO has no depth attachment
glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
GL_NEAREST);
EXPECT_GL_NO_ERROR();
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
// generate INVALID_OPERATION if the read FBO has no stencil attachment
glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
// unlike in the depth blit tests, this *should* draw a blue quad, because depth info
// has not been copied
glEnable(GL_DEPTH_TEST);
drawQuad(mBlueProgram, "position", 0.8f);
glDisable(GL_DEPTH_TEST);
// generate INVALID_OPERATION if we read from a missing color attachment
glReadBuffer(GL_COLOR_ATTACHMENT1);
glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
TEST_P(BlitFramebufferANGLETest, BlitStencil)
......@@ -1067,4 +1064,4 @@ ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest,
ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE),
ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE));
ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11());
\ No newline at end of file
ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11());
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