From ead65b0d8c7baa3aea429b3ddb225941e29454a7 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 31 Jan 2020 19:11:43 +1000 Subject: [PATCH 1/2] Vulkan: Log when a swap chain resize is occurring This may help us debug performance problems in the future. --- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 0628a5482b..9d096e19e4 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -305,6 +305,7 @@ void Renderer::BindBackbuffer(const ClearColor& clear_color) } else if (res == VK_SUBOPTIMAL_KHR || res == VK_ERROR_OUT_OF_DATE_KHR) { + INFO_LOG(VIDEO, "Resizing swap chain due to suboptimal/out-of-date"); m_swap_chain->ResizeSwapChain(); } else From 08cc73108a2b77c2918610b7e521d2deb847a2ba Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 31 Jan 2020 19:12:10 +1000 Subject: [PATCH 2/2] Vulkan: Treat VK_SUBOPTIMAL_KHR as VK_SUCCESS on Android Android 10 seems to expect a prerotated/transformed swap chain for optimal presentation. For now, until we implement that, just ignore the hint. --- .../VideoBackends/Vulkan/CommandBufferManager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp index 59382166a9..e51831455e 100644 --- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp @@ -375,12 +375,21 @@ void CommandBufferManager::SubmitCommandBuffer(u32 command_buffer_index, if (m_last_present_result != VK_SUCCESS) { // VK_ERROR_OUT_OF_DATE_KHR is not fatal, just means we need to recreate our swap chain. - if (m_last_present_result != VK_ERROR_OUT_OF_DATE_KHR && res != VK_SUBOPTIMAL_KHR && + if (m_last_present_result != VK_ERROR_OUT_OF_DATE_KHR && + m_last_present_result != VK_SUBOPTIMAL_KHR && m_last_present_result != VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) { LOG_VULKAN_ERROR(m_last_present_result, "vkQueuePresentKHR failed: "); } + + // Don't treat VK_SUBOPTIMAL_KHR as fatal on Android. Android 10+ requires prerotation. + // See https://twitter.com/Themaister/status/1207062674011574273 +#ifdef VK_USE_PLATFORM_ANDROID_KHR + if (m_last_present_result != VK_SUBOPTIMAL_KHR) + m_last_present_failed.Set(); +#else m_last_present_failed.Set(); +#endif } }