From 0f7c2004d07370ee83ff91df7feccbc16e766cea Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 11 Sep 2024 06:22:22 +0530 Subject: [PATCH] [d3d9,d3d11] recreate swapchain on VK_SUBOPTIMAL_KHR The vulkan wayland wsi returns suboptimal when the window is fullscreened and not directly scanned out, and there are modifiers available that would allow the window to be directly scanned out. Recreate the swapchain if we receive suboptimal result. This allows us recreate the swapchain to use a modifier that allows direct scan-out under winewayland on wayland compositors. --- src/d3d11/d3d11_swapchain.cpp | 5 ++++- src/d3d9/d3d9_swapchain.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index a707f7f36..9499a2b1c 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -281,7 +281,7 @@ namespace dxvk { VkResult status = m_presenter->acquireNextImage(sync, imageIndex); - while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) { + while (status != VK_SUCCESS) { RecreateSwapChain(m_vsync); if (!m_presenter->hasSwapChain()) @@ -289,6 +289,9 @@ namespace dxvk { info = m_presenter->info(); status = m_presenter->acquireNextImage(sync, imageIndex); + + if (status == VK_SUBOPTIMAL_KHR) + break; } // Resolve back buffer if it is multisampled. We diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 2089e61f3..fb905943c 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1155,14 +1155,17 @@ namespace dxvk { // NV-DXVK start: DLFG integration VkResult status = presenter->acquireNextImage(sync, imageIndex); // NV-DXVK end - - while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) { + + while (status != VK_SUCCESS) { RecreateSwapChain(m_vsync); // NV-DXVK start: DLFG integration info = presenter->info(); status = presenter->acquireNextImage(sync, imageIndex); // NV-DXVK end + + if (status == VK_SUBOPTIMAL_KHR) + break; } m_context->beginRecording(