mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
Android: Handle some possible surface loss cases
This commit is contained in:
parent
141fac0481
commit
20afc1c4a1
|
@ -754,13 +754,13 @@ void AndroidHostInterface::SurfaceChanged(ANativeWindow* surface, int format, in
|
|||
wi.surface_refresh_rate = GetRefreshRate();
|
||||
wi.surface_scale = GetSurfaceScale(width, height);
|
||||
|
||||
m_display->ChangeRenderWindow(wi);
|
||||
if (surface)
|
||||
const bool surface_valid = m_display->ChangeRenderWindow(wi) && surface;
|
||||
if (surface_valid)
|
||||
OnHostDisplayResized();
|
||||
|
||||
if (surface && System::GetState() == System::State::Paused)
|
||||
if (surface_valid && System::GetState() == System::State::Paused)
|
||||
PauseSystem(false);
|
||||
else if (!surface && System::IsRunning())
|
||||
else if (!surface_valid && System::IsRunning())
|
||||
PauseSystem(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -742,7 +742,8 @@ bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 *
|
|||
|
||||
if (!CreateSwapChain() || !SetupSwapChainImages())
|
||||
{
|
||||
Panic("Failed to re-configure swap chain images, this is fatal (for now)");
|
||||
DestroySwapChainImages();
|
||||
DestroySwapChain();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -755,7 +756,8 @@ bool SwapChain::RecreateSwapChain()
|
|||
|
||||
if (!CreateSwapChain() || !SetupSwapChainImages())
|
||||
{
|
||||
Panic("Failed to re-configure swap chain images, this is fatal (for now)");
|
||||
DestroySwapChainImages();
|
||||
DestroySwapChain();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -576,7 +576,7 @@ bool VulkanHostDisplay::DoneRenderContextCurrent()
|
|||
|
||||
bool VulkanHostDisplay::Render()
|
||||
{
|
||||
if (ShouldSkipDisplayingFrame())
|
||||
if (ShouldSkipDisplayingFrame() || !m_swap_chain)
|
||||
{
|
||||
if (ImGui::GetCurrentContext())
|
||||
ImGui::Render();
|
||||
|
@ -602,6 +602,7 @@ bool VulkanHostDisplay::Render()
|
|||
{
|
||||
Log_ErrorPrint("Failed to recreate surface after loss");
|
||||
g_vulkan_context->ExecuteCommandBuffer(false);
|
||||
m_swap_chain.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue