vulkan/wsi: fix crash with debug names on swapchain

If you set a name of on a swapchain object, because the base object
struct has not been initialized with a VkDevice,
vk_object_base_finish() will segfault when trying to free the object
name.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: cb1e0db23e ("vulkan/wsi: Make wsi_swapchain inherit from vk_object_base")
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17165>
(cherry picked from commit efc398c722)
This commit is contained in:
Lionel Landwerlin 2022-06-20 13:00:38 +00:00 committed by Dylan Baker
parent 839cd82865
commit 940cb75c93
2 changed files with 7 additions and 6 deletions

View file

@ -1057,7 +1057,7 @@
"description": "vulkan/wsi: fix crash with debug names on swapchain",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "cb1e0db23e3fa17562bb276b125aeab0b85582cb"
},

View file

@ -222,24 +222,25 @@ wsi_device_setup_syncobj_fd(struct wsi_device *wsi_device,
VkResult
wsi_swapchain_init(const struct wsi_device *wsi,
struct wsi_swapchain *chain,
VkDevice device,
VkDevice _device,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
bool use_buffer_blit)
{
VK_FROM_HANDLE(vk_device, device, _device);
VkResult result;
memset(chain, 0, sizeof(*chain));
vk_object_base_init(NULL, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
vk_object_base_init(device, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
chain->wsi = wsi;
chain->device = device;
chain->device = _device;
chain->alloc = *pAllocator;
chain->use_buffer_blit = use_buffer_blit;
chain->buffer_blit_queue = VK_NULL_HANDLE;
if (use_buffer_blit && wsi->get_buffer_blit_queue)
chain->buffer_blit_queue = wsi->get_buffer_blit_queue(device);
chain->buffer_blit_queue = wsi->get_buffer_blit_queue(_device);
int cmd_pools_count = chain->buffer_blit_queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count;
@ -262,7 +263,7 @@ wsi_swapchain_init(const struct wsi_device *wsi,
.flags = 0,
.queueFamilyIndex = queue_family_index,
};
result = wsi->CreateCommandPool(device, &cmd_pool_info, &chain->alloc,
result = wsi->CreateCommandPool(_device, &cmd_pool_info, &chain->alloc,
&chain->cmd_pools[i]);
if (result != VK_SUCCESS)
goto fail;