From 256645724bb15e4485851586345b17c9bdb77249 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 15 Apr 2018 15:36:10 +0200 Subject: [PATCH] [dxvk] Destroy old swap chain before creating a new one We no longer use the 'oldSwapchain' member in the swap chain description to replace an existing swap chain, but rather destroy it altogether and create a new swap chain. While this is less than optimal, it might help solve some swap chain-related issues such as #277. --- src/dxvk/dxvk_swapchain.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/dxvk/dxvk_swapchain.cpp b/src/dxvk/dxvk_swapchain.cpp index 56c3ab80..642a9eb8 100644 --- a/src/dxvk/dxvk_swapchain.cpp +++ b/src/dxvk/dxvk_swapchain.cpp @@ -93,12 +93,14 @@ namespace dxvk { void DxvkSwapchain::recreateSwapchain() { - VkSwapchainKHR oldSwapchain = m_handle; - // Wait until we can be certain that none of our // resources are still in use by the device. m_device->waitForIdle(); + // Destroy previous swapchain object + m_vkd->vkDestroySwapchainKHR( + m_vkd->device(), m_handle, nullptr); + // Recreate the actual swapchain object auto caps = m_surface->getSurfaceCapabilities(); auto fmt = m_surface->pickSurfaceFormat(1, &m_properties.preferredSurfaceFormat); @@ -122,7 +124,7 @@ namespace dxvk { swapInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; swapInfo.presentMode = mode; swapInfo.clipped = VK_TRUE; - swapInfo.oldSwapchain = oldSwapchain; + swapInfo.oldSwapchain = VK_NULL_HANDLE; Logger::debug(str::format( "DxvkSwapchain: Actual swap chain properties: ", @@ -134,10 +136,6 @@ namespace dxvk { if (m_vkd->vkCreateSwapchainKHR(m_vkd->device(), &swapInfo, nullptr, &m_handle) != VK_SUCCESS) throw DxvkError("DxvkSwapchain: Failed to recreate swap chain"); - // Destroy previous swapchain object - m_vkd->vkDestroySwapchainKHR( - m_vkd->device(), oldSwapchain, nullptr); - // Create the render pass object DxvkRenderPassFormat renderTargetFormat;