summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/x11/xm_api.c6
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c12
-rw-r--r--src/mesa/main/fbobject.c2
-rw-r--r--src/mesa/main/framebuffer.c7
4 files changed, 21 insertions, 6 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index a42de72827f..776928dec4d 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -383,8 +383,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
/*
* Front renderbuffer
*/
- b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_FALSE);
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE);
if (!b->frontxrb) {
_mesa_free(b);
return NULL;
@@ -399,8 +398,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
* Back renderbuffer
*/
if (vis->mesa_visual.doubleBufferMode) {
- b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_TRUE);
+ b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE);
if (!b->backxrb) {
/* XXX free front xrb too */
_mesa_free(b);
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index a358ec25aec..747971a6c30 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -418,6 +418,18 @@ xmesa_delete_framebuffer(struct gl_framebuffer *fb)
XMesaDestroyImage( b->rowimage );
}
+ /* Note that XMesaBuffer renderbuffers normally have a refcount of 2
+ * (creation + binding) so we need to explicitly delete/unbind them here.
+ */
+ if (b->frontxrb) {
+ _mesa_unreference_renderbuffer((struct gl_renderbuffer **) &b->frontxrb);
+ ASSERT(b->frontxrb == NULL);
+ }
+ if (b->backxrb) {
+ _mesa_unreference_renderbuffer((struct gl_renderbuffer **) &b->backxrb);
+ ASSERT(b->backxrb == NULL);
+ }
+
_mesa_free_framebuffer_data(fb);
_mesa_free(fb);
}
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 6608eefc6c0..f7e870b49cd 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1014,7 +1014,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
*/
if (bindReadBuf) {
- _mesa_unreference_framebuffer(&ctx->ReadBuffer);
_mesa_reference_framebuffer(&ctx->ReadBuffer, newFb);
}
@@ -1022,7 +1021,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
/* 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 */
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index c97d2f0077b..3136a950e08 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -253,6 +253,13 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr,
struct gl_framebuffer *fb)
{
assert(ptr);
+ if (*ptr == fb) {
+ /* no change */
+ return;
+ }
+ if (*ptr) {
+ _mesa_unreference_framebuffer(ptr);
+ }
assert(!*ptr);
assert(fb);
_glthread_LOCK_MUTEX(fb->Mutex);