From f0d63e70f1c19f79c343bf33efa881f39401ba18 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 6 Feb 2023 10:14:24 -0500 Subject: [PATCH] util/vbuf: fix multidraw unrolling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * drawid needs to be incremented at end of loop * rescope draw structs to initialize at top of loop fix #8191 Fixes: 6b07893b31f ("util/vbuf: handle multidraws") Reviewed-by: Kenneth Graunke Tested-by: Mark Janes Reviewed-by: Marek Olšák Part-of: (cherry picked from commit 8f5a63ebfe84f0bdaa7959fae79e9d42a17113ac) --- .pick_status.json | 2 +- src/gallium/auxiliary/util/u_vbuf.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3f905f29ddf..9084335a2b7 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -166,7 +166,7 @@ "description": "util/vbuf: fix multidraw unrolling", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "6b07893b31fe4e6cac7bc73155770672ce7753cb" }, diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 3e005f73bed..c0ea0e22e50 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -1467,8 +1467,6 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *inf boolean unroll_indices = FALSE; const uint32_t used_vb_mask = mgr->ve->used_vb_mask; uint32_t user_vb_mask = mgr->user_vb_mask & used_vb_mask; - struct pipe_draw_info new_info; - struct pipe_draw_start_count_bias new_draw; unsigned fixed_restart_index = info->index_size ? util_prim_restart_index_from_size(info->index_size) : 0; uint32_t misaligned = 0; @@ -1505,12 +1503,10 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *inf */ if (num_draws > 1 && info->take_index_buffer_ownership) p_atomic_add(&info->index.resource->reference.count, num_draws - 1); - new_info = *info; for (unsigned d = 0; d < num_draws; d++) { - new_draw = draws[d]; - if (info->increment_draw_id) - drawid_offset++; + struct pipe_draw_info new_info = *info; + struct pipe_draw_start_count_bias new_draw = draws[d]; /* Handle indirect (multi)draws. */ if (indirect && indirect->buffer) { @@ -1786,6 +1782,8 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *inf util_primconvert_draw_vbo(mgr->pc, &new_info, drawid_offset, indirect, &new_draw, 1); } else pipe->draw_vbo(pipe, &new_info, drawid_offset, indirect, &new_draw, 1); + if (info->increment_draw_id) + drawid_offset++; } if (mgr->using_translate) {