From 5464feed7380418a69ab0c9e0337f0a078f1540b Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 13 Mar 2024 13:00:17 +0100 Subject: [PATCH] zink: set handle type also for user memory Fixes the validation error VUID-vkBindBufferMemory-memory-02985 reported, e.g. by running piglit spec@amd_pinned_memory@map-buffer decrement-offset v2: move setting the export type for user_mem get_export_flags and also set alloc_info->external for user_mem to avoid adding a conditional when finning the external buffer create info (Mike) Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/zink/zink_resource.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index f2d8f667c74..289d77b466c 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -922,7 +922,11 @@ get_export_flags(struct zink_screen *screen, const struct pipe_resource *templ, return false; } } - + if (alloc_info->user_mem) { + assert(!alloc_info->whandle); + alloc_info->external = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + alloc_info->export_types = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + } /* we may export WINSYS_HANDLE_TYPE_FD handle which is dma-buf */ if (templ->bind & PIPE_BIND_SHARED && screen->info.have_EXT_external_memory_dma_buf) alloc_info->export_types |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT; @@ -1482,8 +1486,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t struct mem_alloc_info alloc_info = { .whandle = whandle, .need_dedicated = false, - .external = 0, - .export_types = user_mem ? VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT : ZINK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_BIT, + .export_types = ZINK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_BIT, .shared = templ->bind & PIPE_BIND_SHARED, .user_mem = user_mem };