From 178a659a98535a4453ef004645f548c695fc8c18 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 30 Jan 2023 22:58:21 +1000 Subject: [PATCH] GPU: Move graphics API reset state to System Stops us trying to reset state on objects which don't exist if initialization failed (apparently some Android devices.. of course). --- src/core/gpu_hw_d3d11.cpp | 1 - src/core/gpu_hw_d3d12.cpp | 1 - src/core/gpu_hw_opengl.cpp | 1 - src/core/gpu_hw_vulkan.cpp | 1 - src/core/system.cpp | 2 ++ 5 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index 55eaa753f..fa7a17ccc 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -19,7 +19,6 @@ GPU_HW_D3D11::GPU_HW_D3D11(ID3D11Device* device, ID3D11DeviceContext* context) : GPU_HW_D3D11::~GPU_HW_D3D11() { g_host_display->ClearDisplayTexture(); - GPU_HW_D3D11::ResetGraphicsAPIState(); DestroyShaders(); DestroyStateObjects(); diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index b1544a276..533d674e9 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -22,7 +22,6 @@ GPU_HW_D3D12::GPU_HW_D3D12() = default; GPU_HW_D3D12::~GPU_HW_D3D12() { g_host_display->ClearDisplayTexture(); - GPU_HW_D3D12::ResetGraphicsAPIState(); DestroyResources(); } diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index a208f1017..72de52f6d 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -29,7 +29,6 @@ GPU_HW_OpenGL::~GPU_HW_OpenGL() glDeleteTextures(1, &m_texture_buffer_r16ui_texture); g_host_display->ClearDisplayTexture(); - GPU_HW_OpenGL::ResetGraphicsAPIState(); // One of our programs might've been bound. GL::Program::ResetLastProgram(); diff --git a/src/core/gpu_hw_vulkan.cpp b/src/core/gpu_hw_vulkan.cpp index 4e614809b..8a2137f01 100644 --- a/src/core/gpu_hw_vulkan.cpp +++ b/src/core/gpu_hw_vulkan.cpp @@ -21,7 +21,6 @@ GPU_HW_Vulkan::GPU_HW_Vulkan() = default; GPU_HW_Vulkan::~GPU_HW_Vulkan() { g_host_display->ClearDisplayTexture(); - GPU_HW_Vulkan::ResetGraphicsAPIState(); DestroyResources(); } diff --git a/src/core/system.cpp b/src/core/system.cpp index 4fa5f1a54..cf2adef70 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1477,6 +1477,8 @@ void System::DestroySystem() Timers::Shutdown(); Pad::Shutdown(); CDROM::Shutdown(); + if (g_gpu) + g_gpu->ResetGraphicsAPIState(); g_gpu.reset(); InterruptController::Shutdown(); DMA::Shutdown();