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

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Fri Mar 31 16:59:32 2023 +0200

util/vbuf: clarify indirect draws handling

It wasn't obvious from the u_vbuf code alone that num_draws
is guaranteed to be 1 in the indirect case.

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

---

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

diff --git a/src/gallium/auxiliary/util/u_vbuf.c 
b/src/gallium/auxiliary/util/u_vbuf.c
index c0ea0e22e50..c16861f2578 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -1512,6 +1512,9 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const 
struct pipe_draw_info *inf
       if (indirect && indirect->buffer) {
          unsigned draw_count = 0;
 
+         /* num_draws can only be 1 with indirect draws. */
+         assert(num_draws == 1);
+
          /* Get the number of draws. */
          if (indirect->indirect_draw_count) {
             pipe_buffer_read(pipe, indirect->indirect_draw_count,
@@ -1547,6 +1550,7 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const 
struct pipe_draw_info *inf
                u_vbuf_split_indexed_multidraw(mgr, &new_info, drawid_offset, 
data,
                                               indirect->stride, draw_count);
                free(data);
+               /* We're done (as num_draws is 1), so return early. */
                return;
             }
 
@@ -1563,6 +1567,7 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const 
struct pipe_draw_info *inf
                u_vbuf_split_indexed_multidraw(mgr, &new_info, drawid_offset, 
data,
                                               indirect->stride, draw_count);
                free(data);
+               /* We're done (as num_draws is 1), so return early. */
                return;
             }
 

Reply via email to