Vulkan: Avoid crash on double DeviceLost.

This caused Android to crash when switching to OpenGL, because the
destructor would try to deinit again.  There weren't any objects, but
draw_ was no longer valid.
This commit is contained in:
Unknown W. Brackets committed 2022-02-06 23:34:44 -08:00
1 parent 9eeea5a366
commit 8418287a87
3 files changed
+6 -4

No files matched your search

+2 -1
View File
@@ -226,7 +226,7 @@ void DrawEngineVulkan::FrameData::Destroy(VulkanContext *vulkan) {
}
void DrawEngineVulkan::DestroyDeviceObjects() {
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
VulkanContext *vulkan = draw_ ? (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT) : nullptr;
delete tessDataTransferVulkan;
tessDataTransfer = nullptr;
@@ -258,6 +258,7 @@ void DrawEngineVulkan::DestroyDeviceObjects() {
void DrawEngineVulkan::DeviceLost() {
DestroyDeviceObjects();
DirtyAllUBOs();
draw_ = nullptr;
}
void DrawEngineVulkan::DeviceRestore(Draw::DrawContext *draw) {
+2 -1
View File
@@ -200,7 +200,7 @@ void TextureCacheVulkan::SetVulkan2D(Vulkan2D *vk2d) {
}
void TextureCacheVulkan::DeviceLost() {
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
VulkanContext *vulkan = draw_ ? (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT) : nullptr;
Clear(true);
@@ -215,6 +215,7 @@ void TextureCacheVulkan::DeviceLost() {
computeShaderManager_.DeviceLost();
nextTexture_ = nullptr;
draw_ = nullptr;
}
void TextureCacheVulkan::DeviceRestore(Draw::DrawContext *draw) {
+2 -2
View File
@@ -1048,13 +1048,13 @@ bool CreateGlobalPipelines() {
}
void NativeShutdownGraphics() {
INFO_LOG(SYSTEM, "NativeShutdownGraphics");
screenManager->deviceLost();
if (gpu)
gpu->DeviceLost();
INFO_LOG(SYSTEM, "NativeShutdownGraphics");
#if PPSSPP_PLATFORM(WINDOWS)
delete winAudioBackend;
winAudioBackend = nullptr;