From dea50199a152a144c4da46b63dc3d3d18a5b9cfd Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 26 Oct 2023 11:00:57 -0400 Subject: [PATCH] zink: always set VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT for usermem required by spec backport-to: 23.3 Part-of: (cherry picked from commit 009d4a5fda58d5bb4c642fe711e19cb91c4bc1f4) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_resource.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 34ccc2a..f92b55b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -874,7 +874,7 @@ "description": "zink: always set VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT for usermem", "nominated": true, "nomination_type": 4, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 02ed8b8..40a1b15 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -847,6 +847,14 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t return obj; } else if (templ->target == PIPE_BUFFER) { VkBufferCreateInfo bci = create_bci(screen, templ, templ->bind); + VkExternalMemoryBufferCreateInfo embci; + + if (user_mem) { + embci.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO; + embci.pNext = bci.pNext; + embci.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + bci.pNext = &embci; + } if (VKSCR(CreateBuffer)(screen->dev, &bci, NULL, &obj->buffer) != VK_SUCCESS) { mesa_loge("ZINK: vkCreateBuffer failed"); @@ -983,6 +991,11 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t } else if (ici.tiling == VK_IMAGE_TILING_OPTIMAL) { shared = false; } + } else if (user_mem) { + emici.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; + emici.pNext = ici.pNext; + emici.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + ici.pNext = &emici; } if (linear) -- 2.7.4