From 89e49690f58505c7f0b7f8b3b61400bbbd5b8384 Mon Sep 17 00:00:00 2001 From: DH Date: Sat, 29 Mar 2025 01:00:53 +0300 Subject: [PATCH] android: fix rsx shutdown --- rpcs3/rpcs3/Emu/RSX/VK/VKPresent.cpp | 11 +++++++++-- rpcs3/rpcs3/Emu/RSX/VK/vkutils/swapchain.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/rpcs3/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/rpcs3/Emu/RSX/VK/VKPresent.cpp index c3c580ac8..b393b8017 100644 --- a/rpcs3/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -90,6 +90,7 @@ void VKGSRender::reinitialize_swapchain() { rsx_log.warning("Swapchain initialization failed. Request ignored [%dx%d]", m_swapchain_dims.width, m_swapchain_dims.height); swapchain_unavailable = true; + surface_lost = true; return; } @@ -586,7 +587,13 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) ensure(m_current_frame->present_image == umax); ensure(m_current_frame->swap_command_buffer == nullptr); - u64 timeout = m_swapchain->get_swap_image_count() <= VK_MAX_ASYNC_FRAMES? 0ull: 100000000ull; + u64 timeout = m_swapchain->get_swap_image_count() <= VK_MAX_ASYNC_FRAMES? 0ull : +#ifdef ANDROID + 1000ull +#else + 100000000ull +#endif + ; while (VkResult status = m_swapchain->acquire_next_swapchain_image(m_current_frame->acquire_signal_semaphore, timeout, &m_current_frame->present_image)) { switch (status) @@ -619,7 +626,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) surface_lost = true; swapchain_unavailable = true; reinitialize_swapchain(); - break; + return; default: vk::die_with_error(status); diff --git a/rpcs3/rpcs3/Emu/RSX/VK/vkutils/swapchain.cpp b/rpcs3/rpcs3/Emu/RSX/VK/vkutils/swapchain.cpp index 85398d0ef..56a731f5d 100644 --- a/rpcs3/rpcs3/Emu/RSX/VK/vkutils/swapchain.cpp +++ b/rpcs3/rpcs3/Emu/RSX/VK/vkutils/swapchain.cpp @@ -208,7 +208,15 @@ namespace vk } #endif VkSurfaceCapabilitiesKHR surface_descriptors = {}; - CHECK_RESULT(VK_GET_SYMBOL(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(dev.gpu(), m_surface, &surface_descriptors)); + auto result = VK_GET_SYMBOL(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(dev.gpu(), m_surface, &surface_descriptors); +#ifdef ANDROID + if (result != VK_ERROR_SURFACE_LOST_KHR) + { + CHECK_RESULT(result); + } +#else + CHECK_RESULT(result); +#endif return { surface_descriptors, false }; }