diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 3d960f962d4..1a045a36b78 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -682,10 +682,14 @@ _mesa_PopAttrib(void) unsigned mask = attr->Mask; /* Flush current attribs. This must be done before PopAttribState is - * applied. + * applied. Also reset the attributes stored in vbo, as after this we'll + * change Current directly, and these changed values would've been then + * overridden by another flush in the future. */ - if (mask & GL_CURRENT_BIT) + if ((mask & GL_CURRENT_BIT) && ctx->Driver.NeedFlush) { FLUSH_CURRENT(ctx, 0); + vbo_reset_all_attr(ctx); + } /* Only restore states that have been changed since glPushAttrib. */ mask &= ctx->PopAttribState; diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index f11824cdaa4..ecc326840d9 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -202,6 +202,9 @@ vbo_install_save_vtxfmt_noop(struct gl_context *ctx); void vbo_exec_update_eval_maps(struct gl_context *ctx); +void +vbo_reset_all_attr(struct gl_context *ctx); + void vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index be79ce9ef61..5c7da0483fc 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -51,10 +51,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define IMM_BUFFER_NAME 0xaabbccdd -static void -vbo_reset_all_attr(struct vbo_exec_context *exec); - - /** * Close off the last primitive, execute the buffer, restart the * primitive. This is called when we fill a vertex buffer before @@ -294,7 +290,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, if (!_mesa_inside_begin_end(ctx) && !oldSize && lastcount > 8 && exec->vtx.vertex_size) { vbo_exec_copy_to_current(exec); - vbo_reset_all_attr(exec); + vbo_reset_all_attr(ctx); } /* Fix up sizes: @@ -695,7 +691,7 @@ vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, unsigned flags) if (exec->vtx.vertex_size) { vbo_exec_copy_to_current(exec); - vbo_reset_all_attr(exec); + vbo_reset_all_attr(ctx); } /* All done. */ @@ -1105,9 +1101,11 @@ vbo_init_dispatch_begin_end(struct gl_context *ctx) } -static void -vbo_reset_all_attr(struct vbo_exec_context *exec) +void +vbo_reset_all_attr(struct gl_context *ctx) { + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + while (exec->vtx.enabled) { const int i = u_bit_scan64(&exec->vtx.enabled); @@ -1130,7 +1128,7 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec) exec->vtx.bufferobj = _mesa_bufferobj_alloc(ctx, IMM_BUFFER_NAME); exec->vtx.enabled = u_bit_consecutive64(0, VBO_ATTRIB_MAX); /* reset all */ - vbo_reset_all_attr(exec); + vbo_reset_all_attr(ctx); exec->vtx.info.instance_count = 1; exec->vtx.info.max_index = ~0;