gallium/util: add multi_draw_indirect to util_draw_indirect.
authorDave Airlie <airlied@redhat.com>
Mon, 23 Dec 2019 04:56:01 +0000 (14:56 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 9 Jan 2020 00:35:36 +0000 (10:35 +1000)
ARB_indirect_parameters needs drivers to deal with mutli_draw_indirect
themselves.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3234>

src/gallium/auxiliary/util/u_draw.c

index b7daa21c692bb945d1f52726bc1151fb2736acb9..4627d2bdbc4c7ee9358b04afc6238435df516863 100644 (file)
@@ -147,7 +147,7 @@ util_draw_indirect(struct pipe_context *pipe,
       pipe_buffer_map_range(pipe,
                             info_in->indirect->buffer,
                             info_in->indirect->offset,
-                            num_params * sizeof(uint32_t),
+                            (num_params * info_in->indirect->draw_count) * sizeof(uint32_t),
                             PIPE_TRANSFER_READ,
                             &transfer);
    if (!transfer) {
@@ -155,14 +155,18 @@ util_draw_indirect(struct pipe_context *pipe,
       return;
    }
 
-   info.count = params[0];
-   info.instance_count = params[1];
-   info.start = params[2];
-   info.index_bias = info_in->index_size ? params[3] : 0;
-   info.start_instance = info_in->index_size ? params[4] : params[3];
-   info.indirect = NULL;
+   for (unsigned i = 0; i < info_in->indirect->draw_count; i++) {
+      info.count = params[0];
+      info.instance_count = params[1];
+      info.start = params[2];
+      info.index_bias = info_in->index_size ? params[3] : 0;
+      info.start_instance = info_in->index_size ? params[4] : params[3];
+      info.drawid = i;
+      info.indirect = NULL;
 
-   pipe_buffer_unmap(pipe, transfer);
+      pipe->draw_vbo(pipe, &info);
 
-   pipe->draw_vbo(pipe, &info);
+      params += info_in->indirect->stride / 4;
+   }
+   pipe_buffer_unmap(pipe, transfer);
 }