util/vbuf: clarify indirect draws handling
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fri, 31 Mar 2023 14:59:32 +0000 (16:59 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Apr 2023 11:50:58 +0000 (11:50 +0000)
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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22237>

src/gallium/auxiliary/util/u_vbuf.c

index c0ea0e2..c16861f 100644 (file)
@@ -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;
             }