Module: Mesa
Branch: master
Commit: 45e43445ce724c4d7f15457ac30fc23fd531bc80
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=45e43445ce724c4d7f15457ac30fc23fd531bc80

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Fri Nov 27 15:14:07 2020 +0100

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7098>

---

 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 0227be371ba..248c38f4575 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 3adec8e61f7..12cd6534be0 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.
     */

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to