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 <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
diff --git a/src/dawn_native/vulkan/SwapChainVk.cpp b/src/dawn_native/vulkan/SwapChainVk.cpp
index ad88c9d..8d0804b 100644
--- a/src/dawn_native/vulkan/SwapChainVk.cpp
+++ b/src/dawn_native/vulkan/SwapChainVk.cpp
@@ -463,11 +463,15 @@
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?