From 16144632354cb310f090c8713a11d3c65696969e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 26 Feb 2009 14:49:24 -0700 Subject: mesa: avoid extraneous calls to ctx->Driver.BindFramebuffer() Only call this driver function when we really need to bind different buffers. --- src/mesa/main/fbobject.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/mesa/main') 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); } } -- cgit v1.2.3