From 2578f34a7ceedc4306fb3dacb53d7f53c7df816f Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 5 Nov 2019 19:51:08 +1000 Subject: [PATCH] GPU/HW: Reset state when shutting down --- src/core/gpu_hw_d3d11.cpp | 6 +++++- src/core/gpu_hw_opengl.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index 5d978553f..137fbd662 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -13,7 +13,11 @@ GPU_HW_D3D11::GPU_HW_D3D11() = default; GPU_HW_D3D11::~GPU_HW_D3D11() { - m_host_display->SetDisplayTexture(nullptr, 0, 0, 0, 0, 0, 0, 1.0f); + if (m_host_display) + { + m_host_display->SetDisplayTexture(nullptr, 0, 0, 0, 0, 0, 0, 1.0f); + ResetGraphicsAPIState(); + } } bool GPU_HW_D3D11::Initialize(HostDisplay* host_display, System* system, DMA* dma, diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 204ad5415..19aa5c681 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -11,8 +11,11 @@ GPU_HW_OpenGL::GPU_HW_OpenGL() : GPU_HW() {} GPU_HW_OpenGL::~GPU_HW_OpenGL() { - m_host_display->SetDisplayTexture(nullptr, 0, 0, 0, 0, 0, 0, 1.0f); - DestroyFramebuffer(); + if (m_host_display) + { + m_host_display->SetDisplayTexture(nullptr, 0, 0, 0, 0, 0, 0, 1.0f); + ResetGraphicsAPIState(); + } } bool GPU_HW_OpenGL::Initialize(HostDisplay* host_display, System* system, DMA* dma,