From ebdbc03b777eac27fa84939ec8115f77245b1ba8 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Sat, 24 Oct 2020 02:46:13 +0000 Subject: [PATCH] Treat VK_SUBOPTIMAL_KHR as a valid return value of vkQueuePresentKHR vkQueuePresentKHR() may return VK_SUBOPTIMAL_KHR when "a swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully", so it can also be treated as a valid return value that indicates vkQueuePresentKHR() has returned successfully. This patch fixes the crash when we run the dawn_end2end_test SwapChainTests.ResizingWindowOnly on the latest Intel Vulkan Windows driver. BUG=dawn:269 TEST=dawn_end2end_tests Change-Id: I571ee74ea75b7a7f6fa59c7eebeed87a2429180d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30842 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Jiawei Shao --- src/dawn_native/vulkan/SwapChainVk.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dawn_native/vulkan/SwapChainVk.cpp b/src/dawn_native/vulkan/SwapChainVk.cpp index ad88c9d6a3..8d0804b013 100644 --- a/src/dawn_native/vulkan/SwapChainVk.cpp +++ b/src/dawn_native/vulkan/SwapChainVk.cpp @@ -463,11 +463,15 @@ namespace dawn_native { namespace vulkan { switch (result) { case VK_SUCCESS: + // VK_SUBOPTIMAL_KHR means "a swapchain no longer matches the surface properties + // exactly, but can still be used to present to the surface successfully", so we + // can also treat it as a "success" error code of vkQueuePresentKHR(). + case VK_SUBOPTIMAL_KHR: return {}; + // This present cannot be recovered. Re-initialize the VkSwapchain so that future + // presents work.. case VK_ERROR_OUT_OF_DATE_KHR: - // This present cannot be recovered. Re-initialize the VkSwapchain so that future - // presents work.. return Initialize(this); // TODO(cwallez@chromium.org): Allow losing the surface at Dawn's API level?