Module: Mesa
Branch: staging/22.2
Commit: c916ec76ee4da3e4df852f41e80bbf506eb67dab
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c916ec76ee4da3e4df852f41e80bbf506eb67dab

Author: Max Kellermann <[email protected]>
Date:   Mon Aug 22 20:11:18 2022 +0200

gallium/u_threaded: fix offset calculation for draw_multi slots

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 <[email protected]>
Reviewed-By: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18189>
(cherry picked from commit b830091cb6c0414f3a875d48e5c625101327e02f)

---

 .pick_status.json                               | 2 +-
 src/gallium/auxiliary/util/u_threaded_context.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 4578d4ab612..b0fcc474973 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4288,7 +4288,7 @@
         "description": "gallium/u_threaded: fix offset calculation for 
draw_multi slots",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index 8b28276c615..a26bda9670a 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -3355,6 +3355,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];
 
@@ -3382,7 +3383,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) {

Reply via email to