From 2178b6d10f7fb17075a9d1271ca9da08feb0f835 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 21 Jan 2018 04:40:01 +0100 Subject: [PATCH] Vulkan temporary workaround for swapchain recycling (nvidia) - Both swapchain recreation methods are proper andwithin the Vulkan specs. The differnece is retroarch follows method (apparently proposed in vulkan samples) that "hopes" the driver will reuse some of the old swapchain resources, while the other method destroys everything and recreates from scratch. At the moment on Nvidia drivers the second method is stable while the first method is unreliable in all cases today. --- gfx/common/vulkan_common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 91990eadb4..95186b4f95 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -2552,6 +2552,15 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, old_swapchain = vk->swapchain; + if (/* NVIDIA WAR */ + vk->context.gpu_properties.vendorID == 0x10DE && + old_swapchain != VK_NULL_HANDLE) + { + RARCH_LOG("[Vulkan]: Old swapchain destroyed.\n"); + vkDestroySwapchainKHR(vk->context.device, old_swapchain, NULL); + old_swapchain = VK_NULL_HANDLE; + } + info.surface = vk->vk_surface; info.minImageCount = desired_swapchain_images; info.imageFormat = format.format; @@ -2575,7 +2584,8 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, return false; } - if (old_swapchain != VK_NULL_HANDLE) + if ( vk->context.gpu_properties.vendorID != 0x10DE && + old_swapchain != VK_NULL_HANDLE) { RARCH_LOG("[Vulkan]: Recycled old swapchain.\n"); vkDestroySwapchainKHR(vk->context.device, old_swapchain, NULL);