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 <marek.olsak@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18189>
This commit is contained in:
Max Kellermann 2022-08-22 20:11:18 +02:00 committed by Marek Olšák
parent 0a0fb7cbc6
commit b830091cb6

View 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) {