vbo: remove _mesa_prim parameter from vbo_merge_draws
authorMarek Olšák <marek.olsak@amd.com>
Mon, 2 Nov 2020 06:46:24 +0000 (01:46 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 5 Jan 2021 00:22:33 +0000 (19:22 -0500)
glBegin/End won't use _mesa_prim, so we need to stop using it.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7679>

src/mesa/vbo/vbo_exec.c
src/mesa/vbo/vbo_exec_api.c
src/mesa/vbo/vbo_private.h
src/mesa/vbo/vbo_save_api.c

index 15de7ac..1be0784 100644 (file)
@@ -170,20 +170,24 @@ vbo_try_prim_conversion(GLubyte *mode, unsigned *count)
  */
 bool
 vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
-                struct _mesa_prim *p0, const struct _mesa_prim *p1)
+                GLubyte mode0, GLubyte mode1,
+                unsigned start0, unsigned start1,
+                unsigned *count0, unsigned count1,
+                unsigned basevertex0, unsigned basevertex1,
+                bool *end0, bool begin1, bool end1)
 {
    /* The prim mode must match (ex: both GL_TRIANGLES) */
-   if (p0->mode != p1->mode)
+   if (mode0 != mode1)
       return false;
 
    /* p1's vertices must come right after p0 */
-   if (p0->start + p0->count != p1->start)
+   if (start0 + *count0 != start1)
       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) &
+   if ((1 << mode0) &
        ((1 << GL_LINES) |
         (1 << GL_LINE_LOOP) |
         (1 << GL_LINE_STRIP) |
@@ -197,7 +201,7 @@ vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
        * 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))
+      if (begin1 == 1 && (in_dlist || ctx->Line.StippleFlag))
          return false;
 
       /* _mesa_prim::end is irrelevant at this point and is only used
@@ -205,34 +209,34 @@ vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
        */
    }
 
-   assert(p0->basevertex == p1->basevertex);
+   assert(basevertex0 == basevertex1);
 
-   switch (p0->mode) {
+   switch (mode0) {
    case GL_POINTS:
       /* can always merge subsequent GL_POINTS primitives */
       break;
    /* check independent primitives with no extra vertices */
    case GL_LINES:
-      if (p0->count % 2)
+      if (*count0 % 2)
          return false;
       break;
    case GL_TRIANGLES:
-      if (p0->count % 3)
+      if (*count0 % 3)
          return false;
       break;
    case GL_QUADS:
    case GL_LINES_ADJACENCY:
-      if (p0->count % 4)
+      if (*count0 % 4)
          return false;
       break;
    case GL_TRIANGLES_ADJACENCY:
-      if (p0->count % 6)
+      if (*count0 % 6)
          return false;
       break;
    case GL_PATCHES:
       /* "patch_vertices" can be unknown when compiling a display list. */
       if (in_dlist ||
-          p0->count % ctx->TessCtrlProgram.patch_vertices)
+          *count0 % ctx->TessCtrlProgram.patch_vertices)
          return false;
       break;
    default:
@@ -240,8 +244,8 @@ vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
    }
 
    /* Merge draws. */
-   p0->count += p1->count;
-   p0->end = p1->end;
+   *count0 += count1;
+   *end0 = end1;
    return true;
 }
 
index 27b35f3..c25a7ea 100644 (file)
@@ -875,7 +875,11 @@ try_vbo_merge(struct vbo_exec_context *exec)
       struct _mesa_prim *prev = &exec->vtx.prim[exec->vtx.prim_count - 2];
       assert(prev == cur - 1);
 
-      if (vbo_merge_draws(ctx, false, prev, cur))
+      if (vbo_merge_draws(ctx, false,
+                          prev->mode, cur->mode, prev->start, cur->start,
+                          &prev->count, cur->count,
+                          prev->basevertex, cur->basevertex,
+                          &prev->end, cur->begin, cur->end))
          exec->vtx.prim_count--;  /* drop the last primitive */
    }
 }
index 85caf36..8e0c016 100644 (file)
@@ -190,7 +190,11 @@ vbo_try_prim_conversion(GLubyte *mode, unsigned *count);
 
 bool
 vbo_merge_draws(struct gl_context *ctx, bool in_dlist,
-                struct _mesa_prim *p0, const struct _mesa_prim *p1);
+                GLubyte mode0, GLubyte mode1,
+                unsigned start0, unsigned start1,
+                unsigned *count0, unsigned count1,
+                unsigned basevertex0, unsigned basevertex1,
+                bool *end0, bool begin1, bool end1);
 
 unsigned
 vbo_copy_vertices(struct gl_context *ctx,
index fae2f4a..789344b 100644 (file)
@@ -298,7 +298,13 @@ merge_prims(struct gl_context *ctx, struct _mesa_prim *prim_list,
 
       vbo_try_prim_conversion(&this_prim->mode, &this_prim->count);
 
-      if (vbo_merge_draws(ctx, true, prev_prim, this_prim)) {
+      if (vbo_merge_draws(ctx, true,
+                          prev_prim->mode, this_prim->mode,
+                          prev_prim->start, this_prim->start,
+                          &prev_prim->count, this_prim->count,
+                          prev_prim->basevertex, this_prim->basevertex,
+                          &prev_prim->end,
+                          this_prim->begin, this_prim->end)) {
          /* We've found a prim that just extend the previous one.  Tack it
           * onto the previous one, and let this primitive struct get dropped.
           */