Mesa (master): mesa: skip draws w/ count == 0 and instance_count == 0 in draw_gallium_fallback

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jan 9 07:10:54 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Jan  5 23:11:38 2021 -0500

mesa: skip draws w/ count == 0 and instance_count == 0 in draw_gallium_fallback

Fixes: 85b6ba136bdc2db5 "st/mesa: implement Driver.DrawGallium callbacks

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

---

 src/mesa/main/draw.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 326ac6a0165..eedf9c41167 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -94,6 +94,9 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
    unsigned min_index = info->index_bounds_valid ? info->min_index : 0;
    unsigned max_index = info->index_bounds_valid ? info->max_index : ~0;
 
+   if (!info->instance_count)
+      return;
+
    ib.index_size_shift = util_logbase2(index_size);
 
    /* Single draw or a fallback for user indices. */
@@ -101,6 +104,9 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
        (info->index_size && info->has_user_indices &&
         !ctx->Const.MultiDrawWithUserIndices)) {
       for (unsigned i = 0; i < num_draws; i++) {
+         if (!draws[i].count)
+            continue;
+
          if (index_size) {
             ib.count = draws[i].count;
 
@@ -136,19 +142,24 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
 
    struct _mesa_prim *prim;
    unsigned max_count = 0;
+   unsigned num_prims = 0;
 
    ALLOC_PRIMS(prim, num_draws, "DrawGallium");
 
    for (unsigned i = 0; i < num_draws; i++) {
-      prim[i].mode = info->mode;
-      prim[i].begin = 1;
-      prim[i].end = 1;
-      prim[i].start = draws[i].start;
-      prim[i].count = draws[i].count;
-      prim[i].basevertex = info->index_size ? info->index_bias : 0;
-      prim[i].draw_id = info->drawid + (info->increment_draw_id ? i : 0);
-
-      max_count = MAX2(max_count, prim[i].count);
+      if (!draws[i].count)
+         continue;
+
+      prim[num_prims].mode = info->mode;
+      prim[num_prims].begin = 1;
+      prim[num_prims].end = 1;
+      prim[num_prims].start = draws[i].start;
+      prim[num_prims].count = draws[i].count;
+      prim[num_prims].basevertex = info->index_size ? info->index_bias : 0;
+      prim[num_prims].draw_id = info->drawid + (info->increment_draw_id ? i : 0);
+
+      max_count = MAX2(max_count, prim[num_prims].count);
+      num_prims++;
    }
 
    if (info->index_size) {
@@ -164,7 +175,7 @@ _mesa_draw_gallium_fallback(struct gl_context *ctx,
       }
    }
 
-   ctx->Driver.Draw(ctx, prim, num_draws, index_size ? &ib : NULL,
+   ctx->Driver.Draw(ctx, prim, num_prims, index_size ? &ib : NULL,
                     info->index_bounds_valid, info->primitive_restart,
                     info->restart_index, min_index, max_index,
                     info->instance_count, info->start_instance);



More information about the mesa-commit mailing list