diff options
author | Brian <[email protected]> | 2007-03-06 10:07:59 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-03-06 10:07:59 -0700 |
commit | a510bc3ee1a696da120c09ee4ec33dc033f671ac (patch) | |
tree | c4c594f5f39f060f507dc13fc5e9383956bce909 /src/mesa/main/fbobject.c | |
parent | 593802c0b0f451299ac2598c6de61e884fb44830 (diff) |
Fix/improve framebuffer object reference counting.
Use _mesa_reference_framebuffer() and _mesa_unreference_framebuffer() functions
to be sure reference counting is done correctly. Additional assertions are
done too. Note _mesa_dereference_framebuffer() renamed to "unreference" as
that's more accurate.
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index a99ff9dc97e..6608eefc6c0 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -602,7 +602,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) oldRb = ctx->CurrentRenderbuffer; if (oldRb) { - _mesa_dereference_renderbuffer(&oldRb); + _mesa_unreference_renderbuffer(&oldRb); } ASSERT(newRb != &DummyRenderbuffer); @@ -639,7 +639,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&rb); } } } @@ -998,12 +998,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } - _glthread_LOCK_MUTEX(newFb->Mutex); - if (bindReadBuf) - newFb->RefCount++; - if (bindDrawBuf) - newFb->RefCount++; - _glthread_UNLOCK_MUTEX(newFb->Mutex); } else { /* Binding the window system framebuffer (which was originally set @@ -1020,22 +1014,16 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - struct gl_framebuffer *oldFb = ctx->ReadBuffer; - if (oldFb && oldFb->Name != 0) { - _mesa_dereference_framebuffer(&oldFb); - } - ctx->ReadBuffer = newFb; + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); } if (bindDrawBuf) { - struct gl_framebuffer *oldFb = ctx->DrawBuffer; - if (oldFb && oldFb->Name != 0) { - /* check if old FB had any texture attachments */ - check_end_texture_render(ctx, oldFb); - /* check if time to delete this framebuffer */ - _mesa_dereference_framebuffer(&oldFb); - } - ctx->DrawBuffer = newFb; + /* check if old FB had any texture attachments */ + check_end_texture_render(ctx, ctx->DrawBuffer); + /* check if time to delete this framebuffer */ + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); @@ -1083,7 +1071,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_framebuffer(&fb); + _mesa_unreference_framebuffer(&fb); } } } |