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/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp
index f2a7dec..0081845 100644
--- a/src/libANGLE/Framebuffer.cpp
+++ b/src/libANGLE/Framebuffer.cpp
@@ -746,7 +746,7 @@
for (size_t colorIndex = 0; colorIndex < mState.mColorAttachments.size(); ++colorIndex)
{
if (detachMatchingAttachment(context, &mState.mColorAttachments[colorIndex], resourceType,
- resourceId, DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex))
+ resourceId))
{
found = true;
}
@@ -759,23 +759,19 @@
&mState.mWebGLStencilAttachment}};
for (FramebufferAttachment *attachment : attachments)
{
- if (attachment->isAttached() && attachment->type() == resourceType &&
- attachment->id() == resourceId)
+ if (detachMatchingAttachment(context, attachment, resourceType, resourceId))
{
- resetAttachment(context, attachment->getBinding());
found = true;
}
}
}
else
{
- if (detachMatchingAttachment(context, &mState.mDepthAttachment, resourceType, resourceId,
- DIRTY_BIT_DEPTH_ATTACHMENT))
+ if (detachMatchingAttachment(context, &mState.mDepthAttachment, resourceType, resourceId))
{
found = true;
}
- if (detachMatchingAttachment(context, &mState.mStencilAttachment, resourceType, resourceId,
- DIRTY_BIT_STENCIL_ATTACHMENT))
+ if (detachMatchingAttachment(context, &mState.mStencilAttachment, resourceType, resourceId))
{
found = true;
}
@@ -787,14 +783,13 @@
bool Framebuffer::detachMatchingAttachment(const Context *context,
FramebufferAttachment *attachment,
GLenum matchType,
- GLuint matchId,
- size_t dirtyBit)
+ GLuint matchId)
{
if (attachment->isAttached() && attachment->type() == matchType && attachment->id() == matchId)
{
- attachment->detach(context);
- mDirtyBits.set(dirtyBit);
- mState.mResourceNeedsInit.set(dirtyBit, false);
+ // We go through resetAttachment to make sure that all the required bookkeeping will be done
+ // such as updating enabled draw buffer state.
+ resetAttachment(context, attachment->getBinding());
return true;
}