From: Brian Paul Date: Thu, 26 Feb 2009 21:49:24 +0000 (-0700) Subject: mesa: avoid extraneous calls to ctx->Driver.BindFramebuffer() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16144632354cb310f090c8713a11d3c65696969e;p=mesa.git mesa: avoid extraneous calls to ctx->Driver.BindFramebuffer() Only call this driver function when we really need to bind different buffers. --- diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 23b3fb68fbd..151e29053ab 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); } }