vulkan/wsi/wayland: fix unset present_mode
authorSimon Ser <contact@emersion.fr>
Fri, 25 Aug 2023 13:43:58 +0000 (15:43 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 29 Aug 2023 02:37:10 +0000 (02:37 +0000)
chain->base.present_mode is unset at this point, ie. it's
zero-initialized. VK_PRESENT_MODE_IMMEDIATE_KHR happens to be 0,
so the WSI will attempt to use tearing-control on compositors that
don't support it.

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 5ceba97c2e18 ("vulkan/wsi/wayland: add support for IMMEDIATE")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24885>

src/vulkan/wsi/wsi_common_wayland.c

index 4402f77..51b9e18 100644 (file)
@@ -2272,7 +2272,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    if (result != VK_SUCCESS)
       goto fail;
 
-   if (chain->base.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) {
+   VkPresentModeKHR present_mode = wsi_swapchain_get_present_mode(wsi_device, pCreateInfo);
+   if (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) {
       chain->tearing_control =
          wp_tearing_control_manager_v1_get_tearing_control(wsi_wl_surface->display->tearing_control_manager,
                                                            wsi_wl_surface->surface);
@@ -2351,7 +2352,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    chain->base.release_images = wsi_wl_swapchain_release_images;
    chain->base.set_present_mode = wsi_wl_swapchain_set_present_mode;
    chain->base.wait_for_present = wsi_wl_swapchain_wait_for_present;
-   chain->base.present_mode = wsi_swapchain_get_present_mode(wsi_device, pCreateInfo);
+   chain->base.present_mode = present_mode;
    chain->base.image_count = num_images;
    chain->extent = pCreateInfo->imageExtent;
    chain->vk_format = pCreateInfo->imageFormat;