Module: Mesa
Branch: main
Commit: 07437fa3bdd88a51c497aeaa7ee4dce8c2724579
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=07437fa3bdd88a51c497aeaa7ee4dce8c2724579

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Apr 19 16:06:44 2022 -0400

util/draw: handle draw_count=0 when reading indirect parameters

Fixes: 3eb99323172 ("aux/draw: add a util function for reading back indirect 
draw params")

Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15963>

---

 src/gallium/auxiliary/util/u_draw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_draw.c 
b/src/gallium/auxiliary/util/u_draw.c
index 70721586738..273724f2a0a 100644
--- a/src/gallium/auxiliary/util/u_draw.c
+++ b/src/gallium/auxiliary/util/u_draw.c
@@ -154,6 +154,10 @@ util_draw_indirect_read(struct pipe_context *pipe,
          draw_count = dc_param[0];
       pipe_buffer_unmap(pipe, dc_transfer);
    }
+   if (!draw_count) {
+      *num_draws = draw_count;
+      return NULL;
+   }
    draws = malloc(sizeof(struct u_indirect_params) * draw_count);
    if (!draws)
       return NULL;

Reply via email to