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 <lionel.g.landwerlin@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12782>
This commit is contained in:
Zachary Michaels 2021-09-08 16:34:17 -07:00 committed by Marge Bot
parent 0be0ad102e
commit fc5ea6a054

View file

@ -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;