gallium/u_threaded: disable forced staging upload at runtime

If a conflict caused by the forced staging optimization is detected,
disable it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7098>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2020-11-27 15:14:07 +01:00
parent 2900f82e19
commit 45e43445ce
2 changed files with 6 additions and 0 deletions

View File

@ -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.

View File

@ -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.
*/