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

Author: Marek Olšák <[email protected]>
Date:   Thu Nov  2 01:06:43 2017 +0100

gallium/u_threaded: clean up tc_improve_map_buffer_flags and prevent reentry

Reviewed-by: Nicolai Hähnle <[email protected]>

---

 src/gallium/auxiliary/util/u_threaded_context.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index 7e28b87a7f..0f23258053 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1276,6 +1276,14 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
                             struct threaded_resource *tres, unsigned usage,
                             unsigned offset, unsigned size)
 {
+   /* Never invalidate inside the driver and never infer "unsynchronized". */
+   unsigned tc_flags = TC_TRANSFER_MAP_NO_INVALIDATE |
+                       TC_TRANSFER_MAP_NO_INFER_UNSYNCHRONIZED;
+
+   /* Prevent a reentry. */
+   if (usage & tc_flags)
+      return usage;
+
    /* Sparse buffers can't be mapped directly and can't be reallocated
     * (fully invalidated). That may just be a radeonsi limitation, but
     * the threaded context must obey it with radeonsi.
@@ -1295,12 +1303,12 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
       return usage;
    }
 
+   usage |= tc_flags;
+
    /* Handle CPU reads trivially. */
    if (usage & PIPE_TRANSFER_READ) {
       /* Drivers aren't allowed to do buffer invalidations. */
-      return (usage & ~PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) |
-             TC_TRANSFER_MAP_NO_INVALIDATE |
-             TC_TRANSFER_MAP_NO_INFER_UNSYNCHRONIZED;
+      return usage & ~PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
    }
 
    /* See if the buffer range being mapped has never been initialized,
@@ -1342,10 +1350,7 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
       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_NO_INFER_UNSYNCHRONIZED;
+   return usage;
 }
 
 static void *

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

Reply via email to