[Mesa-dev] [PATCH 1/2] gallium/u_threaded: disallow discard_range if map_buffer is unsynchronized

Marek Olšák maraeo at gmail.com
Fri Aug 25 13:41:31 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

The discard range codepath takes precedence, so if we get both
unsynchronized and discard_range, choose unsynchronized.
---
 src/gallium/auxiliary/util/u_threaded_context.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index cbcd405..8e3cc34 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1330,22 +1330,24 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
    usage &= ~PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
 
    /* GL_AMD_pinned_memory and persistent mappings can't use staging
     * buffers. */
    if (usage & (PIPE_TRANSFER_UNSYNCHRONIZED |
                 PIPE_TRANSFER_PERSISTENT) ||
        tres->is_user_ptr)
       usage &= ~PIPE_TRANSFER_DISCARD_RANGE;
 
    /* Unsychronized buffer mappings don't have to synchronize the thread. */
-   if (usage & PIPE_TRANSFER_UNSYNCHRONIZED)
+   if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) {
+      usage &= ~PIPE_TRANSFER_DISCARD_RANGE;
       usage |= TC_TRANSFER_MAP_THREADED_UNSYNC; /* notify the driver */
+   }
 
    /* Never invalidate inside the driver and never infer "unsynchronized". */
    return usage |
           TC_TRANSFER_MAP_NO_INVALIDATE |
           TC_TRANSFER_MAP_IGNORE_VALID_RANGE;
 }
 
 static void *
 tc_transfer_map(struct pipe_context *_pipe,
                 struct pipe_resource *resource, unsigned level,
-- 
2.7.4



More information about the mesa-dev mailing list