From 5818380f86bcd4744ddde9fb08930779ec1d00ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 11 May 2021 06:46:26 -0400 Subject: [PATCH] gallium/u_threaded: fix 32-bit breakage due to incorrect pointer arithmetic Fixes: 1233c90ab4a - gallium/u_threaded: rewrite slot layout to reduce wasted space Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4755 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4758 Acked-By: Mike Blumenkrantz Reviewed-by: Rob Clark Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 36ce49322c4..f3c3588c974 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -105,6 +105,7 @@ tc_clear_driver_thread(struct threaded_context *tc) #define call_size(type) size_to_slots(sizeof(struct type)) #define call_size_with_slots(type, num_slots) size_to_slots( \ sizeof(struct type) + sizeof(((struct type*)NULL)->slot[0]) * (num_slots)) +#define get_next_call(ptr, type) ((struct type*)((uint64_t*)ptr + call_size(type))) /* Assign src to dst while dst is uninitialized. */ static inline void @@ -245,10 +246,10 @@ tc_batch_execute(void *job, UNUSED int thread_index) tc_drop_resource_reference(next->info.index.resource); /* Find how many other draws can be merged. */ - next++; + next = get_next_call(next, tc_draw_single); for (; (uint64_t*)next != last && is_next_call_a_mergeable_draw(first, next); - next++, num_draws++) { + next = get_next_call(next, tc_draw_single), num_draws++) { /* u_threaded_context stores start/count in min/max_index for single draws. */ multi[num_draws].start = next->info.min_index; multi[num_draws].count = next->info.max_index;