From eb4bd06ef45f8643130ece8fde4b341c48e23dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 22 Jan 2022 11:22:40 -0500 Subject: [PATCH] gallium: add PIPE_RESOURCE_FLAG_UNMAPPABLE for shared unmappable buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- 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 */ /**