diff --git a/.pick_status.json b/.pick_status.json index 76f9a282db4..2afafb6fc85 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -364,7 +364,7 @@ "description": "mesa: Fix discard_framebuffer for fbo vs winsys", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "db2ae51121067b66d4ee8313ba7f74cecb201a03" }, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index a848c1df799..9f6c6397bc8 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -5192,9 +5192,19 @@ static void discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, GLsizei numAttachments, const GLenum *attachments) { + GLenum depth_att, stencil_att; + if (!ctx->Driver.DiscardFramebuffer) return; + if (_mesa_is_user_fbo(fb)) { + depth_att = GL_DEPTH_ATTACHMENT; + stencil_att = GL_STENCIL_ATTACHMENT; + } else { + depth_att = GL_DEPTH; + stencil_att = GL_STENCIL; + } + for (int i = 0; i < numAttachments; i++) { struct gl_renderbuffer_attachment *att = get_fb_attachment(ctx, fb, attachments[i]); @@ -5207,12 +5217,12 @@ discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, * 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) && + if ((attachments[i] == depth_att || + attachments[i] == stencil_att) && (!att->Renderbuffer || att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL)) { - GLenum other_format = (attachments[i] == GL_DEPTH_ATTACHMENT ? - GL_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT); + GLenum other_format = (attachments[i] == depth_att ? + stencil_att : depth_att); bool has_both = false; for (int j = 0; j < numAttachments; j++) { if (attachments[j] == other_format) {