gallium/u_threaded: fix offset calculation for draw_multi slots
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 22 Aug 2022 18:11:18 +0000 (20:11 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 5 Sep 2022 01:16:12 +0000 (21:16 -0400)
This fixes a buffer corruption bug with glMultiDrawElementsEXT(): the
offset for the source index buffer is reset for each draw_multi slot,
copying only the first `dr` values to each slot's index buffer.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18189>

src/gallium/auxiliary/util/u_threaded_context.c

index b4a2e37..fdd1997 100644 (file)
@@ -3501,6 +3501,7 @@ tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info,
          return;
 
       int total_offset = 0;
+      unsigned offset = 0;
       while (num_draws) {
          struct tc_batch *next = &tc->batch_slots[tc->next];
 
@@ -3528,7 +3529,7 @@ tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info,
          p->num_draws = dr;
 
          /* Upload index buffers. */
-         for (unsigned i = 0, offset = 0; i < dr; i++) {
+         for (unsigned i = 0; i < dr; i++) {
             unsigned count = draws[i + total_offset].count;
 
             if (!count) {