mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-06 13:38:56 +00:00
Fixes to vulkan restart logic on Android. Should help #10696
This commit is contained in:
parent
0ed3deabe6
commit
9f9903c02e
@ -922,13 +922,16 @@ VkFence VulkanContext::CreateFence(bool presignalled) {
|
||||
return fence;
|
||||
}
|
||||
|
||||
void VulkanContext::DestroyDevice() {
|
||||
ILOG("VulkanContext::DestroyDevice (performing deletes)");
|
||||
// If there happen to be any pending deletes, now is a good time.
|
||||
void VulkanContext::PerformPendingDeletes() {
|
||||
for (int i = 0; i < ARRAY_SIZE(frame_); i++) {
|
||||
frame_[i].deleteList.PerformDeletes(device_);
|
||||
}
|
||||
Delete().PerformDeletes(device_);
|
||||
}
|
||||
|
||||
void VulkanContext::DestroyDevice() {
|
||||
ILOG("VulkanContext::DestroyDevice (performing deletes)");
|
||||
PerformPendingDeletes();
|
||||
|
||||
vkDestroyDevice(device_, nullptr);
|
||||
device_ = nullptr;
|
||||
|
@ -148,9 +148,9 @@ public:
|
||||
|
||||
// Also destroys the surface.
|
||||
void DestroyObjects();
|
||||
|
||||
void DestroyDevice();
|
||||
|
||||
void PerformPendingDeletes();
|
||||
void WaitUntilQueueIdle();
|
||||
|
||||
// Utility functions for shorter code
|
||||
|
@ -169,22 +169,24 @@ bool AndroidVulkanContext::InitFromRenderThread(ANativeWindow *wnd, int desiredB
|
||||
return success;
|
||||
}
|
||||
|
||||
void AndroidVulkanContext::Shutdown() {
|
||||
void AndroidVulkanContext::ShutdownFromRenderThread() {
|
||||
ILOG("AndroidVulkanContext::Shutdown");
|
||||
draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
|
||||
ILOG("Calling NativeShutdownGraphics");
|
||||
NativeShutdownGraphics();
|
||||
delete draw_;
|
||||
draw_ = nullptr;
|
||||
g_Vulkan->WaitUntilQueueIdle();
|
||||
g_Vulkan->DestroyObjects();
|
||||
g_Vulkan->PerformPendingDeletes();
|
||||
g_Vulkan->DestroyObjects(); // Also destroys the surface, a bit asymmetric
|
||||
ILOG("Done with ShutdownFromRenderThread");
|
||||
}
|
||||
|
||||
void AndroidVulkanContext::Shutdown() {
|
||||
ILOG("Calling NativeShutdownGraphics");
|
||||
g_Vulkan->DestroyDevice();
|
||||
g_Vulkan->DestroyDebugMsgCallback();
|
||||
|
||||
g_Vulkan->DestroyInstance();
|
||||
|
||||
// We keep the g_Vulkan context around to avoid invalidating a ton of pointers around the app.
|
||||
|
||||
finalize_glslang();
|
||||
ILOG("AndroidVulkanContext::Shutdown completed");
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ public:
|
||||
bool InitAPI();
|
||||
|
||||
bool InitFromRenderThread(ANativeWindow *wnd, int desiredBackbufferSizeX, int desiredBackbufferSizeY, int backbufferFormat, int androidVersion) override;
|
||||
void ShutdownFromRenderThread() override; // Inverses InitFromRenderThread.
|
||||
|
||||
void Shutdown() override;
|
||||
void SwapInterval(int interval) override;
|
||||
void SwapBuffers() override;
|
||||
|
@ -983,10 +983,9 @@ retry:
|
||||
NativeShutdownGraphics();
|
||||
renderer_inited = false;
|
||||
|
||||
ILOG("Shutting down graphics context.");
|
||||
graphicsContext->Shutdown();
|
||||
delete graphicsContext;
|
||||
graphicsContext = nullptr;
|
||||
// Shut the graphics context down to the same state it was in when we entered the render thread.
|
||||
ILOG("Shutting down graphics context from render thread...");
|
||||
graphicsContext->ShutdownFromRenderThread();
|
||||
renderLoopRunning = false;
|
||||
WLOG("Render loop function exited.");
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user