Mesa (master): mesa: optimize glMultiDrawArrays, call Draw only once (v2)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 28 01:10:27 UTC 2020


Module: Mesa
Branch: master
Commit: a1f402344314cb7e773cebb7ef5c77b3c941de13
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1f402344314cb7e773cebb7ef5c77b3c941de13

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Wed Feb 12 17:16:45 2020 -0500

mesa: optimize glMultiDrawArrays, call Draw only once (v2)

v2: use the macros

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3990>

---

 src/mesa/main/draw.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index aa4934fdb27..a997fcb670e 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -657,24 +657,30 @@ _mesa_exec_MultiDrawArrays(GLenum mode, const GLint *first,
          return;
    }
 
-   for (i = 0; i < primcount; i++) {
-      if (count[i] > 0) {
-         if (0)
-            check_draw_arrays_data(ctx, first[i], count[i]);
-
-         /* The GL_ARB_shader_draw_parameters spec adds the following after the
-          * pseudo-code describing glMultiDrawArrays:
-          *
-          *    "The index of the draw (<i> in the above pseudo-code) may be
-          *     read by a vertex shader as <gl_DrawIDARB>, as described in
-          *     Section 11.1.3.9."
-          */
-         _mesa_draw_arrays(ctx, mode, first[i], count[i], 1, 0, i);
+   if (skip_validated_draw(ctx))
+      return;
 
-         if (0)
-            print_draw_arrays(ctx, mode, first[i], count[i]);
-      }
+   struct _mesa_prim *prim;
+
+   ALLOC_PRIMS(prim, primcount, "glMultiDrawElements");
+
+   for (i = 0; i < primcount; i++) {
+      prim[i].begin = 1;
+      prim[i].end = 1;
+      prim[i].mode = mode;
+      prim[i].draw_id = i;
+      prim[i].start = first[i];
+      prim[i].count = count[i];
+      prim[i].basevertex = 0;
    }
+
+   ctx->Driver.Draw(ctx, prim, primcount, NULL, GL_FALSE, 0, 0, 1, 0,
+                    NULL, 0);
+
+   if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
+      _mesa_flush(ctx);
+
+   FREE_PRIMS(prim, primcount);
 }
 
 



More information about the mesa-commit mailing list