wsi/wayland: Init outstanding list earlier.

Fixes a crash if swapchain free is called before the list is
initialized. This only happens when swapchain init fails, so
it is highly unlikely to happen in practical scenarios.

Fixes dEQP-VK.wsi.wayland.swapchain.simulate_oom.min_image_count.

Fixes: 0d51cd4808 ("wsi/wl: Improve fallback for present_wait.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10866

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
Tested-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28325>
This commit is contained in:
Hans-Kristian Arntzen 2024-03-21 16:56:12 +01:00 committed by Marge Bot
parent 2743adac7f
commit 1900617baf

View file

@ -2262,6 +2262,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
if (chain == NULL)
return VK_ERROR_OUT_OF_HOST_MEMORY;
wl_list_init(&chain->present_ids.outstanding_list);
/* We are taking ownership of the wsi_wl_surface, so remove ownership from
* oldSwapchain. If the surface is currently owned by a swapchain that is
* not oldSwapchain we return an error.
@ -2397,8 +2399,6 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
}
pthread_mutex_init(&chain->present_ids.lock, NULL);
wl_list_init(&chain->present_ids.outstanding_list);
char *queue_name = vk_asprintf(pAllocator,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT,
"mesa vk surface %d swapchain %d queue",