mesa: Reset vbo attributes after flushing them to Current in glPopAttrib

Fixes: 2fe771f4 ("vbo: use FlushVertices flags properly and clear NeedFlush correctly")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11498
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31107>
This commit is contained in:
Sviatoslav Peleshko 2024-09-10 01:01:08 +03:00 committed by Marge Bot
parent a9d64fa1bd
commit 1aa7218a1f
3 changed files with 16 additions and 11 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;