aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/buffers.c7
-rw-r--r--src/mesa/main/framebuffer.c46
2 files changed, 33 insertions, 20 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 0e6ca8ea1c2..82dd059e4b2 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -479,9 +479,12 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer,
/* not really needed, will be set later */
fb->_NumColorDrawBuffers[output] = 0;
- if (fb->Name == 0)
- /* Set traditional state var */
+ if (fb->Name == 0) {
+ /* Only set the per-context DrawBuffer state if we're currently
+ * drawing to a window system framebuffer.
+ */
ctx->Color.DrawBuffer[output] = buffer;
+ }
}
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 0a6de12fb85..72d85f6f892 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -138,7 +138,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;
@@ -649,6 +649,22 @@ 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)
{
@@ -660,8 +676,11 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *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);
@@ -670,28 +689,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);
}