summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-02-26 14:49:24 -0700
committerBrian Paul <brianp@vmware.com>2009-02-26 18:48:35 -0700
commit16144632354cb310f090c8713a11d3c65696969e (patch)
tree71070efc5e323e26bab61444bf2b07ba01a92691 /src
parentecdf3ce436c004365c4d3c468bf1f9ef9138853e (diff)
mesa: avoid extraneous calls to ctx->Driver.BindFramebuffer()
Only call this driver function when we really need to bind different buffers.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/fbobject.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 23b3fb68fb..151e29053a 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1229,19 +1229,26 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
ASSERT(newFb != &DummyFramebuffer);
/*
- * XXX check if re-binding same buffer and skip some of this code.
+ * OK, now bind the new Draw/Read framebuffers, if they're changing.
*/
if (bindReadBuf) {
- _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread);
+ if (ctx->ReadBuffer == newFbread)
+ bindReadBuf = GL_FALSE; /* no change */
+ else
+ _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread);
}
if (bindDrawBuf) {
/* check if old FB had any texture attachments */
- check_end_texture_render(ctx, ctx->DrawBuffer);
+ if (ctx->DrawBuffer->Name != 0) {
+ check_end_texture_render(ctx, ctx->DrawBuffer);
+ }
- /* check if time to delete this framebuffer */
- _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
+ if (ctx->DrawBuffer == newFb)
+ bindDrawBuf = GL_FALSE; /* no change */
+ else
+ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
if (newFb->Name != 0) {
/* check if newly bound framebuffer has any texture attachments */
@@ -1249,7 +1256,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
}
}
- if (ctx->Driver.BindFramebuffer) {
+ if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) {
ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread);
}
}