diff options
Diffstat (limited to 'src/mesa/main/buffers.c')
-rw-r--r-- | src/mesa/main/buffers.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 96ee1ace728..63f53e2b080 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -340,6 +340,26 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE); } +/** + * Performs necessary state updates when _mesa_drawbuffers makes an + * actual change. + */ +static void +updated_drawbuffers(struct gl_context *ctx) +{ + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + +#if FEATURE_GL + if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) { + struct gl_framebuffer *fb = ctx->DrawBuffer; + + /* Flag the FBO as requiring validation. */ + if (fb->Name != 0) { + fb->_Status = 0; + } + } +#endif +} /** * Helper function to set the GL_DRAW_BUFFER state in the context and @@ -361,7 +381,6 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, { struct gl_framebuffer *fb = ctx->DrawBuffer; GLbitfield mask[MAX_DRAW_BUFFERS]; - GLboolean newState = GL_FALSE; if (!destMask) { /* compute destMask values now */ @@ -384,16 +403,16 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, while (destMask0) { GLint bufIndex = _mesa_ffs(destMask0) - 1; if (fb->_ColorDrawBufferIndexes[count] != bufIndex) { + updated_drawbuffers(ctx); fb->_ColorDrawBufferIndexes[count] = bufIndex; - newState = GL_TRUE; } count++; destMask0 &= ~(1 << bufIndex); } fb->ColorDrawBuffer[0] = buffers[0]; if (fb->_NumColorDrawBuffers != count) { + updated_drawbuffers(ctx); fb->_NumColorDrawBuffers = count; - newState = GL_TRUE; } } else { @@ -404,15 +423,15 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, /* only one bit should be set in the destMask[buf] field */ ASSERT(_mesa_bitcount(destMask[buf]) == 1); if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { + updated_drawbuffers(ctx); fb->_ColorDrawBufferIndexes[buf] = bufIndex; - newState = GL_TRUE; } count = buf + 1; } else { if (fb->_ColorDrawBufferIndexes[buf] != -1) { + updated_drawbuffers(ctx); fb->_ColorDrawBufferIndexes[buf] = -1; - newState = GL_TRUE; } } fb->ColorDrawBuffer[buf] = buffers[buf]; @@ -420,8 +439,8 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, /* set remaining outputs to -1 (GL_NONE) */ while (buf < ctx->Const.MaxDrawBuffers) { if (fb->_ColorDrawBufferIndexes[buf] != -1) { + updated_drawbuffers(ctx); fb->_ColorDrawBufferIndexes[buf] = -1; - newState = GL_TRUE; } fb->ColorDrawBuffer[buf] = GL_NONE; buf++; @@ -434,14 +453,11 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, GLuint buf; for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) { + updated_drawbuffers(ctx); ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf]; - newState = GL_TRUE; } } } - - if (newState) - FLUSH_VERTICES(ctx, _NEW_BUFFERS); } |