diff options
Diffstat (limited to 'src/mesa/main/framebuffer.c')
-rw-r--r-- | src/mesa/main/framebuffer.c | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index af78363ad3a..351bf6959af 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -35,6 +35,7 @@ #include "buffers.h" #include "context.h" #include "depthstencil.h" +#include "macros.h" #include "mtypes.h" #include "fbobject.h" #include "framebuffer.h" @@ -222,19 +223,36 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr, /* no change */ return; } + if (*ptr) { - _mesa_unreference_framebuffer(ptr); + /* unreference old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_framebuffer *oldFb = *ptr; + + _glthread_LOCK_MUTEX(oldFb->Mutex); + ASSERT(oldFb->RefCount > 0); + oldFb->RefCount--; + deleteFlag = (oldFb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldFb->Mutex); + + if (deleteFlag) + oldFb->Delete(oldFb); + + *ptr = NULL; } assert(!*ptr); - assert(fb); - _glthread_LOCK_MUTEX(fb->Mutex); - fb->RefCount++; - _glthread_UNLOCK_MUTEX(fb->Mutex); - *ptr = fb; + + if (fb) { + _glthread_LOCK_MUTEX(fb->Mutex); + fb->RefCount++; + _glthread_UNLOCK_MUTEX(fb->Mutex); + *ptr = fb; + } } /** + * XXX this function is deprecated. * Undo/remove a reference to a framebuffer object. * Decrement the framebuffer object's reference count and delete it when * the refcount hits zero. @@ -243,21 +261,7 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr, void _mesa_unreference_framebuffer(struct gl_framebuffer **fb) { - assert(fb); - if (*fb) { - GLboolean deleteFlag = GL_FALSE; - - _glthread_LOCK_MUTEX((*fb)->Mutex); - ASSERT((*fb)->RefCount > 0); - (*fb)->RefCount--; - deleteFlag = ((*fb)->RefCount == 0); - _glthread_UNLOCK_MUTEX((*fb)->Mutex); - - if (deleteFlag) - (*fb)->Delete(*fb); - - *fb = NULL; - } + _mesa_reference_framebuffer(fb, NULL); } @@ -418,14 +422,14 @@ _mesa_ResizeBuffersMESA( void ) /** * Examine all the framebuffer's renderbuffers to update the Width/Height * fields of the framebuffer. If we have renderbuffers with different - * sizes, set the framebuffer's width and height to zero. + * sizes, set the framebuffer's width and height to the min size. * Note: this is only intended for user-created framebuffers, not * window-system framebuffes. */ static void -update_framebuffer_size(struct gl_framebuffer *fb) +update_framebuffer_size(GLcontext *ctx, struct gl_framebuffer *fb) { - GLboolean haveSize = GL_FALSE; + GLuint minWidth = ~0, minHeight = ~0; GLuint i; /* user-created framebuffers only */ @@ -435,21 +439,19 @@ update_framebuffer_size(struct gl_framebuffer *fb) struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; const struct gl_renderbuffer *rb = att->Renderbuffer; if (rb) { - if (haveSize) { - if (rb->Width != fb->Width && rb->Height != fb->Height) { - /* size mismatch! */ - fb->Width = 0; - fb->Height = 0; - return; - } - } - else { - fb->Width = rb->Width; - fb->Height = rb->Height; - haveSize = GL_TRUE; - } + minWidth = MIN2(minWidth, rb->Width); + minHeight = MIN2(minHeight, rb->Height); } } + + if (minWidth != ~0) { + fb->Width = minWidth; + fb->Height = minHeight; + } + else { + fb->Width = 0; + fb->Height = 0; + } } @@ -469,7 +471,7 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx) if (buffer->Name) { /* user-created framebuffer size depends on the renderbuffers */ - update_framebuffer_size(buffer); + update_framebuffer_size(ctx, buffer); } buffer->_Xmin = 0; @@ -544,6 +546,7 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) fb->Visual.rgbBits = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits; fb->Visual.floatMode = GL_FALSE; + fb->Visual.samples = rb->NumSamples; break; } else if (rb->_BaseFormat == GL_COLOR_INDEX) { @@ -793,8 +796,9 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) /* This is a user-created framebuffer. * Completeness only matters for user-created framebuffers. */ - _mesa_test_framebuffer_completeness(ctx, fb); - _mesa_update_framebuffer_visual(fb); + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { + _mesa_test_framebuffer_completeness(ctx, fb); + } } /* Strictly speaking, we don't need to update the draw-state |