diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index 447170fbcbb..611b40686f4 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -140,7 +140,7 @@ color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx) * \param mask bit-mask indicating the buffers to be cleared. * * Flushes the vertices and verifies the parameter. - * If __struct gl_contextRec::NewState is set then calls _mesa_update_state() + * If __struct gl_contextRec::NewState is set then calls _mesa_update_clear_state() * to update gl_frame_buffer::_Xmin, etc. If the rasterization mode is set to * GL_RENDER then requests the driver to clear the buffers, via the * dd_function_table::Clear callback. @@ -170,7 +170,7 @@ clear(struct gl_context *ctx, GLbitfield mask, bool no_error) } if (ctx->NewState) { - _mesa_update_state( ctx ); /* update _Xmin, etc */ + _mesa_update_clear_state( ctx ); /* update _Xmin, etc */ } if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { @@ -349,7 +349,7 @@ clear_bufferiv(struct gl_context *ctx, GLenum buffer, GLint drawbuffer, FLUSH_VERTICES(ctx, 0, 0); if (ctx->NewState) { - _mesa_update_state( ctx ); + _mesa_update_clear_state( ctx ); } if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { @@ -468,7 +468,7 @@ clear_bufferuiv(struct gl_context *ctx, GLenum buffer, GLint drawbuffer, FLUSH_VERTICES(ctx, 0, 0); if (ctx->NewState) { - _mesa_update_state( ctx ); + _mesa_update_clear_state( ctx ); } if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) { @@ -562,7 +562,7 @@ clear_bufferfv(struct gl_context *ctx, GLenum buffer, GLint drawbuffer, FLUSH_VERTICES(ctx, 0, 0); if (ctx->NewState) { - _mesa_update_state( ctx ); + _mesa_update_clear_state( ctx ); } if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) { @@ -722,7 +722,7 @@ clear_bufferfi(struct gl_context *ctx, GLenum buffer, GLint drawbuffer, return; if (ctx->NewState) { - _mesa_update_state( ctx ); + _mesa_update_clear_state( ctx ); } if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 43440bc638b..d6133a238c8 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -503,6 +503,23 @@ _mesa_update_state( struct gl_context *ctx ) _mesa_unlock_context_textures(ctx); } +/* This is the usual entrypoint for state updates in glClear calls: + */ +void +_mesa_update_clear_state( struct gl_context *ctx ) +{ + GLbitfield new_state = ctx->NewState; + + if (MESA_VERBOSE & VERBOSE_STATE) + _mesa_print_state("_mesa_update_clear_state", new_state); + + if (new_state & _NEW_BUFFERS) { + _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer); + + st_invalidate_buffers(st_context(ctx)); + ctx->NewState &= ~_NEW_BUFFERS; + } +} /** * Used by drivers to tell core Mesa that the driver is going to diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index d23a34834f2..411cbcc3adc 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -40,6 +40,12 @@ _mesa_update_state(struct gl_context *ctx); extern void _mesa_update_state_locked(struct gl_context *ctx); +/* + * Update state for glClear calls +*/ +extern void +_mesa_update_clear_state(struct gl_context *ctx); + extern void _mesa_set_vp_override(struct gl_context *ctx, GLboolean flag);