vulkan/wsi: Fix structure chaining in wsi_create_buffer_image_mem

First, because we're using __vk_append_struct which attacks it on the
end, memory_wsi_info is modified even though it's const.  Make things
non-const so we aren't silently violating assumptions.  Also, we set a
pNext in memory_export_info which causes a loop in the pNext chain in
the handle_types != 0 case.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6826
Fixes: 124848bf9e ("vulkan/wsi: Support tiled CPU images")
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17434>
This commit is contained in:
Jason Ekstrand 2022-07-08 15:55:51 -05:00 committed by Marge Bot
parent a084ee7209
commit 048435b44c
1 changed files with 2 additions and 3 deletions

View File

@ -1350,12 +1350,12 @@ wsi_create_buffer_image_mem(const struct wsi_swapchain *chain,
wsi->GetBufferMemoryRequirements(chain->device, image->buffer.buffer, &reqs);
assert(reqs.size <= info->linear_size);
const struct wsi_memory_allocate_info memory_wsi_info = {
struct wsi_memory_allocate_info memory_wsi_info = {
.sType = VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA,
.pNext = NULL,
.implicit_sync = implicit_sync,
};
const VkMemoryDedicatedAllocateInfo buf_mem_dedicated_info = {
VkMemoryDedicatedAllocateInfo buf_mem_dedicated_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
.pNext = &memory_wsi_info,
.image = VK_NULL_HANDLE,
@ -1385,7 +1385,6 @@ wsi_create_buffer_image_mem(const struct wsi_swapchain *chain,
} else if (handle_types != 0) {
memory_export_info = (VkExportMemoryAllocateInfo) {
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,
.pNext = &memory_wsi_info,
.handleTypes = handle_types,
};
__vk_append_struct(&buf_mem_info, &memory_export_info);