vbo: merge draws even when begin==0 or end==0
authorMarek Olšák <marek.olsak@amd.com>
Fri, 14 Feb 2020 19:18:45 +0000 (14:18 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 5 Mar 2020 00:57:22 +0000 (19:57 -0500)
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4052>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4052>

src/mesa/vbo/vbo_exec.c

index c1f2882..f54eb81 100644 (file)
@@ -175,12 +175,6 @@ bool
 vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
                 struct _mesa_prim *p0, const struct _mesa_prim *p1)
 {
-   if (!p0->begin ||
-       !p1->begin ||
-       !p0->end ||
-       !p1->end)
-      return false;
-
    /* The prim mode must match (ex: both GL_TRIANGLES) */
    if (p0->mode != p1->mode)
       return false;
@@ -189,6 +183,31 @@ vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
    if (p0->start + p0->count != p1->start)
       return false;
 
+   /* This checks whether mode is equal to any line primitive type, taking
+    * advantage of the fact that primitives types go from 0 to 14.
+    */
+   if ((1 << p0->mode) &
+       ((1 << GL_LINES) |
+        (1 << GL_LINE_LOOP) |
+        (1 << GL_LINE_STRIP) |
+        (1 << GL_LINES_ADJACENCY) |
+        (1 << GL_LINE_STRIP_ADJACENCY))) {
+      /* "begin" resets the line stipple pattern during line stipple emulation
+       * in tnl.
+       *
+       * StippleFlag can be unknown when compiling a display list.
+       *
+       * Other uses of "begin" are internal to the vbo module, and in those
+       * cases, "begin" is not used after merging draws.
+       */
+      if (p1->begin == 1 && (in_dlist || ctx->Line.StippleFlag))
+         return false;
+
+      /* _mesa_prim::end is irrelevant at this point and is only used
+       * before this function is called.
+       */
+   }
+
    assert(p0->basevertex == p1->basevertex);
 
    switch (p0->mode) {