From 048435b44caeafa5fa0d7a81fe2d77bc9fd5f6ea Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 8 Jul 2022 15:55:51 -0500 Subject: [PATCH] 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: 124848bf9efa ("vulkan/wsi: Support tiled CPU images") Reviewed-by: Jesse Natalie Part-of: --- src/vulkan/wsi/wsi_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 7a1c6e6ed2b..9be60dddf9c 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -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);