From 863591275cd0c171f74215fbd4857c6907f08e65 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 20 Jan 2025 17:12:32 +0100 Subject: [PATCH] [dxvk] Error out on surface creation again Unless it's NATIVE_WINDOW_IN_USE. Should fix a regression where D3D swapchain creation would succeed on out-of-memory errors. --- src/dxvk/dxvk_presenter.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dxvk/dxvk_presenter.cpp b/src/dxvk/dxvk_presenter.cpp index c51bcc4e6..096f2ffe2 100644 --- a/src/dxvk/dxvk_presenter.cpp +++ b/src/dxvk/dxvk_presenter.cpp @@ -30,16 +30,20 @@ namespace dxvk { ? VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT : VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT; + // Create Vulkan surface immediately if possible, but ignore + // certain errors since the app window may still be in use in + // some way at this point, e.g. by a different device. + if (!desc.deferSurfaceCreation) { + VkResult vr = createSurface(); + + if (vr != VK_SUCCESS && vr != VK_ERROR_NATIVE_WINDOW_IN_USE_KHR) + throw DxvkError(str::format("Failed to create Vulkan surface, ", vr)); + } + // If a frame signal was provided, launch thread that synchronizes // with present operations and periodically signals the event if (m_device->features().khrPresentWait.presentWait && m_signal != nullptr) m_frameThread = dxvk::thread([this] { runFrameThread(); }); - - // Create Vulkan surface immediately if possible, but ignore - // failures since the app window may still be in use in some - // way at this point, e.g. by a different device. - if (!desc.deferSurfaceCreation) - createSurface(); }