gallium/u_threaded: don't call simplify_draw_info redundantly
authorMarek Olšák <marek.olsak@amd.com>
Sat, 13 Aug 2022 14:04:22 +0000 (10:04 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 19 Oct 2022 04:23:05 +0000 (04:23 +0000)
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 <michael.blumenkrantz@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18199>

src/gallium/auxiliary/util/u_threaded_context.c

index 080744a..5cb8f78 100644 (file)
@@ -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. */