Mesa (main): gallium: add PIPE_RESOURCE_FLAG_UNMAPPABLE for shared unmappable buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 22 01:26:43 UTC 2022


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sat Jan 22 11:22:40 2022 -0500

gallium: add PIPE_RESOURCE_FLAG_UNMAPPABLE for shared unmappable buffers

We need to handle this in u_threaded_context for GL-VK interop.

Drivers should set this when importing buffers if needed.

Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14750>

---

 src/gallium/auxiliary/util/u_threaded_context.c | 4 ++--
 src/gallium/include/pipe/p_defines.h            | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index cbeba1ea94a..8522d7e84e2 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -2013,7 +2013,7 @@ tc_invalidate_buffer(struct threaded_context *tc,
    /* Shared, pinned, and sparse buffers can't be reallocated. */
    if (tbuf->is_shared ||
        tbuf->is_user_ptr ||
-       tbuf->b.flags & PIPE_RESOURCE_FLAG_SPARSE)
+       tbuf->b.flags & (PIPE_RESOURCE_FLAG_SPARSE | PIPE_RESOURCE_FLAG_UNMAPPABLE))
       return false;
 
    /* Allocate a new one. */
@@ -2085,7 +2085,7 @@ tc_improve_map_buffer_flags(struct threaded_context *tc,
     * (fully invalidated). That may just be a radeonsi limitation, but
     * the threaded context must obey it with radeonsi.
     */
-   if (tres->b.flags & PIPE_RESOURCE_FLAG_SPARSE) {
+   if (tres->b.flags & (PIPE_RESOURCE_FLAG_SPARSE | PIPE_RESOURCE_FLAG_UNMAPPABLE)) {
       /* We can use DISCARD_RANGE instead of full discard. This is the only
        * fast path for sparse buffers that doesn't need thread synchronization.
        */
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 952033ffb9b..793b0a71385 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -530,7 +530,8 @@ enum pipe_flush_flags
 #define PIPE_RESOURCE_FLAG_ENCRYPTED             (1 << 5)
 #define PIPE_RESOURCE_FLAG_DONT_OVER_ALLOCATE    (1 << 6)
 #define PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY     (1 << 7) /* for small visible VRAM */
-#define PIPE_RESOURCE_FLAG_DRV_PRIV    (1 << 8) /* driver/winsys private */
+#define PIPE_RESOURCE_FLAG_UNMAPPABLE            (1 << 8) /* implies staging transfers due to VK interop */
+#define PIPE_RESOURCE_FLAG_DRV_PRIV              (1 << 9) /* driver/winsys private */
 #define PIPE_RESOURCE_FLAG_FRONTEND_PRIV         (1 << 24) /* gallium frontend private */
 
 /**



More information about the mesa-commit mailing list