Fix issues with clearing deleted attachments
Deleting an object that was acting as a framebuffer color attachment
in the current framebuffer didn't previously update all of the
framebuffer state correctly. Fix this by going through the usual
resetAttachment path when any framebuffer attachment is deleted
instead of having custom code that only updated part of the state.
Also early out from clearbuffer calls in case of a missing color
buffer - even now that the draw buffer mask is being updated correctly,
some backend code doesn't take it into account. One example is
querying attachment format when the SRGB clear for linear framebuffer
attachments workaround is active.
BUG=angleproject:2831
TEST=angle_end2end_tests
Change-Id: I1071a60dc0251946fed00e88e43a244fe59f4863
Reviewed-on: https://chromium-review.googlesource.com/1235656
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index ec16547..1837199 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -3545,9 +3545,14 @@
void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values)
{
+ // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
+ // that the backend doesn't need to take this case into account.
if (buffer == GL_DEPTH && !getGLState().getDrawFramebuffer()->getDepthbuffer())
{
- // It's not an error to try to clear a non-existent depth buffer, but it's a no-op.
+ return;
+ }
+ if (buffer == GL_COLOR && !getGLState().getDrawFramebuffer()->getColorbuffer(drawbuffer))
+ {
return;
}
ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
@@ -3557,6 +3562,12 @@
void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values)
{
+ // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
+ // that the backend doesn't need to take this case into account.
+ if (buffer == GL_COLOR && !getGLState().getDrawFramebuffer()->getColorbuffer(drawbuffer))
+ {
+ return;
+ }
ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
ANGLE_CONTEXT_TRY(
mGLState.getDrawFramebuffer()->clearBufferuiv(this, buffer, drawbuffer, values));
@@ -3564,9 +3575,14 @@
void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values)
{
+ // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so
+ // that the backend doesn't need to take this case into account.
if (buffer == GL_STENCIL && !getGLState().getDrawFramebuffer()->getStencilbuffer())
{
- // It's not an error to try to clear a non-existent stencil buffer, but it's a no-op.
+ return;
+ }
+ if (buffer == GL_COLOR && !getGLState().getDrawFramebuffer()->getColorbuffer(drawbuffer))
+ {
return;
}
ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));