From 2fe771f4e963cbb3a3032f1e148fb594c3c1a2a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 30 Jan 2020 17:49:13 -0500 Subject: [PATCH] vbo: use FlushVertices flags properly and clear NeedFlush correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Mathias Fröhlich Part-of: --- src/mesa/vbo/vbo_exec_api.c | 41 +++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 00953cc2873..a9a20ed66a5 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -648,17 +648,36 @@ vbo_exec_Materialfv(GLenum face, GLenum pname, const GLfloat *params) /** * Flush (draw) vertices. + * + * \param flags bitmask of FLUSH_STORED_VERTICES, FLUSH_UPDATE_CURRENT */ static void -vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec) +vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, unsigned flags) { - if (exec->vtx.vert_count) { - vbo_exec_vtx_flush(exec); - } + struct gl_context *ctx = exec->ctx; - if (exec->vtx.vertex_size) { + if (flags & FLUSH_STORED_VERTICES) { + if (exec->vtx.vert_count) { + vbo_exec_vtx_flush(exec); + } + + if (exec->vtx.vertex_size) { + vbo_exec_copy_to_current(exec); + vbo_reset_all_attr(exec); + } + + /* All done. */ + ctx->Driver.NeedFlush = 0; + } else { + assert(flags == FLUSH_UPDATE_CURRENT); + + /* Note that the vertex size is unchanged. + * (vbo_reset_all_attr isn't called) + */ vbo_exec_copy_to_current(exec); - vbo_reset_all_attr(exec); + + /* Only FLUSH_UPDATE_CURRENT is done. */ + ctx->Driver.NeedFlush = ~FLUSH_UPDATE_CURRENT; } } @@ -790,9 +809,12 @@ vbo_exec_Begin(GLenum mode) /* Heuristic: attempt to isolate attributes occurring outside * begin/end pairs. + * + * Use FLUSH_STORED_VERTICES, because it updates current attribs and + * sets vertex_size to 0. (FLUSH_UPDATE_CURRENT doesn't change vertex_size) */ if (exec->vtx.vertex_size && !exec->vtx.attr[VBO_ATTRIB_POS].size) - vbo_exec_FlushVertices_internal(exec); + vbo_exec_FlushVertices_internal(exec, FLUSH_STORED_VERTICES); i = exec->vtx.prim_count++; exec->vtx.prim[i].mode = mode; @@ -1079,10 +1101,7 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags) } /* Flush (draw). */ - vbo_exec_FlushVertices_internal(exec); - - /* Clear the dirty flush flags, because the flush is finished. */ - ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags); + vbo_exec_FlushVertices_internal(exec, flags); #ifndef NDEBUG exec->flush_call_depth--; -- 2.30.2