vk: don't die on VK_SUBOPTIMAL_KHR in AcquireNextImage, and recreate swapchain

vkAcquireNextImageKHR can also return VK_SUBOPTIMAL_KHR and is non-fatal.

However, it's a good idea to still recreate the swap chain later to maintain
optimal presentation paths after temporary occlusion.
This commit is contained in:
Pierre-Loup A. Griffais 2019-08-15 23:12:04 -07:00 committed by kd-11
parent 42ff93d30c
commit 56011cbddd
2 changed files with 7 additions and 1 deletions

View File

@ -2230,6 +2230,7 @@ void VKGSRender::present(frame_context_t *ctx)
case VK_SUCCESS:
break;
case VK_SUBOPTIMAL_KHR:
should_reinitialize_swapchain = true;
break;
case VK_ERROR_OUT_OF_DATE_KHR:
swapchain_unavailable = true;
@ -3110,6 +3111,7 @@ void VKGSRender::reinitialize_swapchain()
open_command_buffer();
swapchain_unavailable = false;
should_reinitialize_swapchain = false;
}
void VKGSRender::flip(int buffer, bool emu_flip)
@ -3124,7 +3126,7 @@ void VKGSRender::flip(int buffer, bool emu_flip)
}
}
if (swapchain_unavailable)
if (swapchain_unavailable || should_reinitialize_swapchain)
{
reinitialize_swapchain();
}
@ -3249,6 +3251,9 @@ void VKGSRender::flip(int buffer, bool emu_flip)
check_present_status();
continue;
}
case VK_SUBOPTIMAL_KHR:
should_reinitialize_swapchain = true;
break;
case VK_ERROR_OUT_OF_DATE_KHR:
LOG_WARNING(RSX, "vkAcquireNextImageKHR failed with VK_ERROR_OUT_OF_DATE_KHR. Flip request ignored until surface is recreated.");
swapchain_unavailable = true;

View File

@ -359,6 +359,7 @@ private:
sizeu m_swapchain_dims{};
bool swapchain_unavailable = false;
bool should_reinitialize_swapchain = false;
u64 m_last_heap_sync_time = 0;
u32 m_texbuffer_view_size = 0;