vbo: delay flagging FLUSH_STORED_VERTICES until glEnd
authorMarek Olšák <marek.olsak@amd.com>
Sat, 1 Feb 2020 01:33:14 +0000 (20:33 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 11 Feb 2020 00:34:57 +0000 (00:34 +0000)
Only state changes see this, which can't occur before glEnd.

Reviewed-by: Mathias Fröhlich <mathias.froehlich@web.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3766>

src/mesa/vbo/vbo_exec_api.c

index 597f07c0212fdfb1306b35173b6a97edd5cdd349..1d59f38bb287ed659bab291f35b38c8c146eb3fa 100644 (file)
@@ -525,11 +525,8 @@ do {                                                                    \
       /* dst now points at the beginning of the next vertex */          \
       exec->vtx.buffer_ptr = (fi_type*)dst;                             \
                                                                         \
-      /* Set FLUSH_STORED_VERTICES to indicate that there's now */      \
-      /* something to draw (not just updating a color or texcoord).*/   \
       /* Don't set FLUSH_UPDATE_CURRENT because */                      \
       /* Current.Attrib[VBO_ATTRIB_POS] is never used. */               \
-      ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;                   \
                                                                         \
       if (unlikely(++exec->vtx.vert_count >= exec->vtx.max_vert))       \
          vbo_exec_vtx_wrap(exec);                                       \
@@ -900,9 +897,13 @@ vbo_exec_End(void)
    if (exec->vtx.prim_count > 0) {
       /* close off current primitive */
       struct _mesa_prim *last_prim = &exec->vtx.prim[exec->vtx.prim_count - 1];
+      unsigned count = exec->vtx.vert_count - last_prim->start;
 
       last_prim->end = 1;
-      last_prim->count = exec->vtx.vert_count - last_prim->start;
+      last_prim->count = count;
+
+      if (count)
+         ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
 
       /* Special handling for GL_LINE_LOOP */
       if (last_prim->mode == GL_LINE_LOOP && last_prim->begin == 0) {