Commit e491578f by Geoff Lang Committed by Commit Bot

WebGL: Validate the read and write buffers for BlitFramebuffer are unique.

TEST=conformance2/rendering/blitframebuffer-test BUG=angleproject:1990 Change-Id: I0caeaac824f1689867134f34f74e5ef2c2f1b016 Reviewed-on: https://chromium-review.googlesource.com/475990Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 94ba36a7
......@@ -2648,6 +2648,15 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
if (context->getExtensions().webglCompatibility &&
*readColorBuffer == *attachment)
{
context->handleError(
Error(GL_INVALID_OPERATION,
"Read and write color attachments cannot be the same image."));
return false;
}
}
}
......@@ -2696,6 +2705,14 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
if (context->getExtensions().webglCompatibility && *readBuffer == *drawBuffer)
{
context->handleError(Error(
GL_INVALID_OPERATION,
"Read and write depth stencil attachments cannot be the same image."));
return false;
}
}
// WebGL 2.0 BlitFramebuffer when blitting from a missing attachment
else if (drawBuffer)
......
......@@ -1550,6 +1550,73 @@ TEST_P(WebGL2CompatibilityTest, ClearBufferTypeCompatibity)
EXPECT_GL_NO_ERROR();
}
// Verify that errors are generate when trying to blit from an image to itself
TEST_P(WebGL2CompatibilityTest, BlitFramebufferSameImage)
{
GLTexture textures[2];
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
GLRenderbuffer renderbuffers[2];
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffers[0]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 4, 4);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffers[1]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 4, 4);
GLFramebuffer framebuffers[2];
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]);
ASSERT_GL_NO_ERROR();
// Same texture
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
0);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
0);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
// Same textures but different renderbuffers
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
renderbuffers[0]);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
renderbuffers[1]);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
// Same renderbuffers but different textures
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
0);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
0);
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
renderbuffers[0]);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
renderbuffers[0]);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
glBlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest,
......
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