diff options
author | Jouk <joukj@tarantella.nano.tudelft.nl> | 2007-10-02 15:17:23 +0200 |
---|---|---|
committer | Jouk <joukj@tarantella.nano.tudelft.nl> | 2007-10-02 15:17:23 +0200 |
commit | 584b84256b07e106cd7295495355eb21226465d7 (patch) | |
tree | 028d47d265d01f3f96787792fbd41d495d60856c /src/mesa/main/framebuffer.c | |
parent | eb9a5b6d5127858b01ec12672c999e7d25cd7aed (diff) | |
parent | de1d725f442caa4d8ecbac3256b5a33d1f4a1257 (diff) |
Merge branch 'master' of git+ssh://joukj@git.freedesktop.org/git/mesa/mesa
Diffstat (limited to 'src/mesa/main/framebuffer.c')
-rw-r--r-- | src/mesa/main/framebuffer.c | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index c9b30d3252..3e36197d88 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -32,12 +32,14 @@ #include "glheader.h" #include "imports.h" +#include "buffers.h" #include "context.h" #include "depthstencil.h" #include "mtypes.h" #include "fbobject.h" #include "framebuffer.h" #include "renderbuffer.h" +#include "texobj.h" @@ -137,7 +139,7 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual) /* save the visual */ fb->Visual = *visual; - /* Init glRead/DrawBuffer state */ + /* Init read/draw renderbuffer state */ if (visual->doubleBufferMode) { fb->ColorDrawBuffer[0] = GL_BACK; fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT; @@ -192,17 +194,11 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); } if (att->Texture) { - /* render to texture */ - att->Texture->RefCount--; - if (att->Texture->RefCount == 0) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) { - ctx->Driver.DeleteTexture(ctx, att->Texture); - } - } + _mesa_reference_texobj(&att->Texture, NULL); } + ASSERT(!att->Renderbuffer); + ASSERT(!att->Texture); att->Type = GL_NONE; - att->Texture = NULL; } /* unbind _Depth/_StencilBuffer to decr ref counts */ @@ -588,7 +584,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx, /** - * Update the list of color drawing renderbuffer pointers. + * Update the (derived) list of color drawing renderbuffer pointers. * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers * writing colors. */ @@ -632,7 +628,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) /** - * Update the color read renderbuffer pointer. + * Update the (derived) color read renderbuffer pointer. * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. */ static void @@ -654,19 +650,51 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } +/** + * Update a gl_framebuffer's derived state. + * + * Specifically, update these framebuffer fields: + * _ColorDrawBuffers + * _NumColorDrawBuffers + * _ColorReadBuffer + * _DepthBuffer + * _StencilBuffer + * + * If the framebuffer is user-created, make sure it's complete. + * + * The following functions (at least) can effect framebuffer state: + * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, + * glRenderbufferStorageEXT. + */ static void update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { - /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) { - /* XXX: EXT_framebuffer_blit: - framebuffer must still be complete wrt read/draw? */ + if (fb->Name == 0) { + /* This is a window-system framebuffer */ + /* Need to update the FB's GL_DRAW_BUFFER state to match the + * context state (GL_READ_BUFFER too). + */ + if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, + ctx->Color.DrawBuffer, NULL); + } + if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) { + + } + } + else { + /* This is a user-created framebuffer. + * Completeness only matters for user-created framebuffers. + */ _mesa_test_framebuffer_completeness(ctx, fb); _mesa_update_framebuffer_visual(fb); } - /* update_color_draw/read_buffers not needed for - read/draw only fb, but shouldn't hurt ??? */ + /* Strictly speaking, we don't need to update the draw-state + * if this FB is bound as ctx->ReadBuffer (and conversely, the + * read-state if this FB is bound as ctx->DrawBuffer), but no + * harm. + */ update_color_draw_buffers(ctx, fb); update_color_read_buffer(ctx, fb); _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); @@ -675,28 +703,19 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) compute_depth_max(fb); } + /** * Update state related to the current draw/read framebuffers. - * Specifically, update these framebuffer fields: - * _ColorDrawBuffers - * _NumColorDrawBuffers - * _ColorReadBuffer - * _DepthBuffer - * _StencilBuffer - * If the current framebuffer is user-created, make sure it's complete. - * The following functions can effect this state: glReadBuffer, - * glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, - * glRenderbufferStorageEXT. */ void _mesa_update_framebuffer(GLcontext *ctx) { - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_framebuffer *fbread = ctx->ReadBuffer; + struct gl_framebuffer *drawFb = ctx->DrawBuffer; + struct gl_framebuffer *readFb = ctx->ReadBuffer; - update_framebuffer(ctx, fb); - if (fbread != fb) - update_framebuffer(ctx, fbread); + update_framebuffer(ctx, drawFb); + if (readFb != drawFb) + update_framebuffer(ctx, readFb); } |