summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-01-30 09:33:53 -0800
committerDylan Baker <[email protected]>2019-01-31 11:09:05 -0800
commit535cc4f1d511c147c4c9525e2f7b9fc742ea83ae (patch)
tree544feae835813b5f6f9258f3bb20bc0a07df019d /src/mesa
parent7f91ae20b9dc33bb609ab5e631963af67e53c84a (diff)
mesa: Skip partial InvalidateFramebuffer of packed depth/stencil.
One of the CTS cases tries to invalidate just stencil of packed depth/stencil, and we incorrectly lost the depth contents. Fixes dEQP-GLES3.functional.fbo.invalidate.whole.unbind_read_stencil Fixes: 0c42b5f3cb90 ("mesa: wire up InvalidateFramebuffer") Reviewed-by: Marek Olšák <[email protected]> (cherry picked from commit db2ae51121067b66d4ee8313ba7f74cecb201a03)
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/fbobject.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8290ea94dfc..87c33be7854 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -4691,6 +4691,29 @@ discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
if (!att)
continue;
+ /* If we're asked to invalidate just depth or just stencil, but the
+ * attachment is packed depth/stencil, then we can only use
+ * Driver.DiscardFramebuffer if the attachments list includes both depth
+ * and stencil and they both point at the same renderbuffer.
+ */
+ if ((attachments[i] == GL_DEPTH_ATTACHMENT ||
+ attachments[i] == GL_STENCIL_ATTACHMENT) &&
+ (!att->Renderbuffer ||
+ att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL)) {
+ GLenum other_format = (attachments[i] == GL_DEPTH_ATTACHMENT ?
+ GL_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT);
+ bool has_both = false;
+ for (int j = 0; j < numAttachments; j++) {
+ if (attachments[j] == other_format)
+ has_both = true;
+ break;
+ }
+
+ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer !=
+ fb->Attachment[BUFFER_STENCIL].Renderbuffer || !has_both)
+ continue;
+ }
+
ctx->Driver.DiscardFramebuffer(ctx, fb, att);
}
}