From 5db7dc599a642e19eb59223d492997c8fecd3fc3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 13 Aug 2022 10:04:22 -0400 Subject: [PATCH] gallium/u_threaded: don't call simplify_draw_info redundantly It's always called for the first and second draw in a row, and if they can't be merged, the second draw becomes the first draw in the next call, and simplify_draw_info is called again on that. Thus, it's called twice on any draw that isn't merged. To prevent that, call it when we add the draws. Acked-By: Mike Blumenkrantz Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 080744a..5cb8f78 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -3271,8 +3271,6 @@ is_next_call_a_mergeable_draw(struct tc_draw_single *first, if (next->base.call_id != TC_CALL_draw_single) return false; - simplify_draw_info(&next->info); - STATIC_ASSERT(offsetof(struct pipe_draw_info, min_index) == sizeof(struct pipe_draw_info) - 8); STATIC_ASSERT(offsetof(struct pipe_draw_info, max_index) == @@ -3294,8 +3292,6 @@ tc_call_draw_single(struct pipe_context *pipe, void *call, uint64_t *last_ptr) /* If at least 2 consecutive draw calls can be merged... */ if (next != last && next->base.call_id == TC_CALL_draw_single) { - simplify_draw_info(&first->info); - if (is_next_call_a_mergeable_draw(first, next)) { /* The maximum number of merged draws is given by the batch size. */ struct pipe_draw_start_count_bias multi[TC_SLOTS_PER_BATCH / call_size(tc_draw_single)]; @@ -3487,6 +3483,7 @@ tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info, p->info.min_index = offset >> util_logbase2(index_size); p->info.max_index = draws[0].count; p->index_bias = draws[0].index_bias; + simplify_draw_info(&p->info); } else { /* Non-indexed call or indexed with a real index buffer. */ struct tc_draw_single *p = drawid_offset > 0 ? @@ -3506,6 +3503,7 @@ tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info, p->info.min_index = draws[0].start; p->info.max_index = draws[0].count; p->index_bias = draws[0].index_bias; + simplify_draw_info(&p->info); } /* This must be after tc_add_call, which can flush the batch. */ -- 2.7.4