mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +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_refresh_rate = GetRefreshRate();
|
||||||
wi.surface_scale = GetSurfaceScale(width, height);
|
wi.surface_scale = GetSurfaceScale(width, height);
|
||||||
|
|
||||||
m_display->ChangeRenderWindow(wi);
|
const bool surface_valid = m_display->ChangeRenderWindow(wi) && surface;
|
||||||
if (surface)
|
if (surface_valid)
|
||||||
OnHostDisplayResized();
|
OnHostDisplayResized();
|
||||||
|
|
||||||
if (surface && System::GetState() == System::State::Paused)
|
if (surface_valid && System::GetState() == System::State::Paused)
|
||||||
PauseSystem(false);
|
PauseSystem(false);
|
||||||
else if (!surface && System::IsRunning())
|
else if (!surface_valid && System::IsRunning())
|
||||||
PauseSystem(true);
|
PauseSystem(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,8 @@ bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 *
|
||||||
|
|
||||||
if (!CreateSwapChain() || !SetupSwapChainImages())
|
if (!CreateSwapChain() || !SetupSwapChainImages())
|
||||||
{
|
{
|
||||||
Panic("Failed to re-configure swap chain images, this is fatal (for now)");
|
DestroySwapChainImages();
|
||||||
|
DestroySwapChain();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +756,8 @@ bool SwapChain::RecreateSwapChain()
|
||||||
|
|
||||||
if (!CreateSwapChain() || !SetupSwapChainImages())
|
if (!CreateSwapChain() || !SetupSwapChainImages())
|
||||||
{
|
{
|
||||||
Panic("Failed to re-configure swap chain images, this is fatal (for now)");
|
DestroySwapChainImages();
|
||||||
|
DestroySwapChain();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -576,7 +576,7 @@ bool VulkanHostDisplay::DoneRenderContextCurrent()
|
||||||
|
|
||||||
bool VulkanHostDisplay::Render()
|
bool VulkanHostDisplay::Render()
|
||||||
{
|
{
|
||||||
if (ShouldSkipDisplayingFrame())
|
if (ShouldSkipDisplayingFrame() || !m_swap_chain)
|
||||||
{
|
{
|
||||||
if (ImGui::GetCurrentContext())
|
if (ImGui::GetCurrentContext())
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
@ -602,6 +602,7 @@ bool VulkanHostDisplay::Render()
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to recreate surface after loss");
|
Log_ErrorPrint("Failed to recreate surface after loss");
|
||||||
g_vulkan_context->ExecuteCommandBuffer(false);
|
g_vulkan_context->ExecuteCommandBuffer(false);
|
||||||
|
m_swap_chain.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue