From 53a22c4b89c860316e3c07a9f95ad4871339049e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 14 Feb 2020 14:18:45 -0500 Subject: [PATCH] vbo: merge draws even when begin==0 or end==0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Mathias Fröhlich Tested-by: Marge Bot Part-of: --- src/mesa/vbo/vbo_exec.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index c1f28822e3a..f54eb81fe17 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -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) { -- 2.30.2