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);
}
}