From 45e43445ce724c4d7f15457ac30fc23fd531bc80 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 27 Nov 2020 15:14:07 +0100 Subject: [PATCH] gallium/u_threaded: disable forced staging upload at runtime MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If a conflict caused by the forced staging optimization is detected, disable it. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 4 ++++ src/gallium/auxiliary/util/u_threaded_context.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 0227be3..248c38f 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -1504,6 +1504,7 @@ tc_improve_map_buffer_flags(struct threaded_context *tc, /* Try not to decrement the counter if it's not positive. Still racy, * but it makes it harder to wrap the counter from INT_MIN to INT_MAX. */ tres->max_forced_staging_uploads > 0 && + tc->use_forced_staging_uploads && p_atomic_dec_return(&tres->max_forced_staging_uploads) >= 0) { usage &= ~(PIPE_MAP_DISCARD_WHOLE_RESOURCE | PIPE_MAP_UNSYNCHRONIZED); @@ -1639,6 +1640,7 @@ tc_transfer_map(struct pipe_context *_pipe, * written range(s). */ usage &= ~PIPE_MAP_UNSYNCHRONIZED & ~TC_TRANSFER_MAP_THREADED_UNSYNC; + tc->use_forced_staging_uploads = false; } } @@ -2958,6 +2960,8 @@ threaded_context_create(struct pipe_context *pipe, if (!tc->base.stream_uploader || !tc->base.const_uploader) goto fail; + tc->use_forced_staging_uploads = true; + /* The queue size is the number of batches "waiting". Batches are removed * from the queue before being executed, so keep one tc_batch slot for that * execution. Also, keep one unused slot for an unflushed batch. diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h index 3adec8e..12cd653 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.h +++ b/src/gallium/auxiliary/util/u_threaded_context.h @@ -367,6 +367,8 @@ struct threaded_context { unsigned num_direct_slots; unsigned num_syncs; + bool use_forced_staging_uploads; + /* Estimation of how much vram/gtt bytes are mmap'd in * the current tc_batch. */ -- 2.7.4