Module: Mesa
Branch: main
Commit: fc5ea6a05437d729b22f37a4e96d4ca5354cd372
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc5ea6a05437d729b22f37a4e96d4ca5354cd372

Author: Zachary Michaels <[email protected]>
Date:   Wed Sep  8 16:34:17 2021 -0700

X11: Ensure that VK_SUBOPTIMAL_KHR propagates to user code

Commit 0245b825 switched from returning the error code VK_ERROR_OUT_OF_DATE_KHR
to returning the success code VK_SUBOPTIMAL_KHR. Prior to that commit, the error
code caused all code paths to fail immediately, but the success code does not.

Currently the success code is not recorded in some scenarios, resulting in a
result of VK_SUCCESS instead. This breaks applications that rely on the
result (per the spec) to trigger resizes.

This commit ensures that the proper VK_SUBOPTIMAL_KHR success code is set as a
sticky status (as comments indicate was intended), ensuring that it is
propagated to user code.

Fixes #5331

Reviewed-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Daniel Stone <[email protected]>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12782>

---

 src/vulkan/wsi/wsi_common_x11.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index aac45b38553..d8d5aaa6d0d 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -1078,9 +1078,11 @@ x11_acquire_next_image_poll_x11(struct x11_swapchain 
*chain,
        * in which case we need to update the status and continue.
        */
       VkResult result = x11_handle_dri3_present_event(chain, (void *)event);
+      /* Ensure that VK_SUBOPTIMAL_KHR is reported to the application */
+      result = x11_swapchain_result(chain, result);
       free(event);
       if (result < 0)
-         return x11_swapchain_result(chain, result);
+         return result;
    }
 }
 
@@ -1147,10 +1149,11 @@ x11_present_to_x11_dri3(struct x11_swapchain *chain, 
uint32_t image_index,
    xcb_generic_event_t *event;
    while ((event = xcb_poll_for_special_event(chain->conn, 
chain->special_event))) {
       VkResult result = x11_handle_dri3_present_event(chain, (void *)event);
+      /* Ensure that VK_SUBOPTIMAL_KHR is reported to the application */
+      result = x11_swapchain_result(chain, result);
       free(event);
       if (result < 0)
-         return x11_swapchain_result(chain, result);
-      x11_swapchain_result(chain, result);
+         return result;
    }
 
    xshmfence_reset(image->shm_fence);
@@ -1345,6 +1348,8 @@ x11_manage_fifo_queues(void *state)
             }
 
             result = x11_handle_dri3_present_event(chain, (void *)event);
+            /* Ensure that VK_SUBOPTIMAL_KHR is reported to the application */
+            result = x11_swapchain_result(chain, result);
             free(event);
             if (result < 0)
                goto fail;

Reply via email to