util/draw: fix map size of indirect buffer in util_draw_indirect_read

this was incorrectly calculating too small of a map region if
the stride was less than the size of the struct

Fixes: 3eb9932317 ("aux/draw: add a util function for reading back indirect draw params")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15963>
This commit is contained in:
Mike Blumenkrantz 2022-04-15 10:34:03 -04:00 committed by Marge Bot
parent 31727f114a
commit efca37d415

View file

@ -158,12 +158,11 @@ util_draw_indirect_read(struct pipe_context *pipe,
if (!draws)
return NULL;
if (indirect->stride)
num_params = MIN2(indirect->stride / 4, num_params);
unsigned map_size = (draw_count - 1) * indirect->stride + (num_params * sizeof(uint32_t));
params = pipe_buffer_map_range(pipe,
indirect->buffer,
indirect->offset,
(num_params * indirect->draw_count) * sizeof(uint32_t),
map_size,
PIPE_MAP_READ,
&transfer);
if (!transfer) {