diff --git a/Source/Core/Common/Src/VideoBackendBase.h b/Source/Core/Common/Src/VideoBackendBase.h index 311fa66104..4454bde8a7 100644 --- a/Source/Core/Common/Src/VideoBackendBase.h +++ b/Source/Core/Common/Src/VideoBackendBase.h @@ -102,6 +102,7 @@ public: virtual void Video_Prepare() = 0; virtual void Video_EnterLoop() = 0; virtual void Video_ExitLoop() = 0; + virtual void Video_Cleanup() = 0; // called from gl/d3d thread virtual void Video_BeginField(u32, FieldType, u32, u32) = 0; virtual void Video_EndField() = 0; diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index a6c07eeaaa..87348e5a74 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -323,6 +323,9 @@ void CpuThread() CCPU::Run(); g_bStarted = false; + + if (!_CoreParameter.bCPUThread) + g_video_backend->Video_Cleanup(); return; } @@ -351,6 +354,9 @@ void FifoPlayerThread() } g_bStarted = false; + + if(!_CoreParameter.bCPUThread) + g_video_backend->Video_Cleanup(); return; } @@ -477,6 +483,9 @@ void EmuThread() g_cpu_thread.join(); INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str()); + + if(_CoreParameter.bCPUThread) + g_video_backend->Video_Cleanup(); VolumeHandler::EjectVolume(); FileMon::Close(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h index 4c6de67ab1..a76935da72 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h @@ -15,6 +15,7 @@ class VideoBackend : public VideoBackendHardware std::string GetName(); void Video_Prepare(); + void Video_Cleanup(); void ShowConfig(void* parent); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index cb348b8684..37b2e24fea 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -207,6 +207,7 @@ void VideoBackend::Shutdown() { s_BackendInitialized = false; + // TODO: should be in Video_Cleanup if (g_renderer) { s_efbAccessRequested = FALSE; @@ -234,4 +235,7 @@ void VideoBackend::Shutdown() } } +void VideoBackend::Video_Cleanup() { +} + } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h index 77cbd14dae..ef3a9f5a51 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h @@ -15,6 +15,7 @@ class VideoBackend : public VideoBackendHardware std::string GetName(); void Video_Prepare(); + void Video_Cleanup(); void ShowConfig(void* parent); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index 5a80100a08..d488747a5a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -190,6 +190,7 @@ void VideoBackend::Shutdown() { s_BackendInitialized = false; + // TODO: should be in Video_Cleanup if (g_renderer) { s_efbAccessRequested = FALSE; @@ -217,4 +218,7 @@ void VideoBackend::Shutdown() D3D::Shutdown(); } +void VideoBackend::Video_Cleanup() { +} + } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h index 4c7414794d..2520c72763 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h @@ -15,6 +15,7 @@ class VideoBackend : public VideoBackendHardware std::string GetName(); void Video_Prepare(); + void Video_Cleanup(); void ShowConfig(void* parent); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index efa13eff76..c100721e6e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -210,7 +210,11 @@ void VideoBackend::Video_Prepare() void VideoBackend::Shutdown() { s_BackendInitialized = false; + GLInterface->Shutdown(); +} +void VideoBackend::Video_Cleanup() { + if (g_renderer) { s_efbAccessRequested = false; @@ -236,7 +240,6 @@ void VideoBackend::Shutdown() delete g_renderer; g_renderer = NULL; } - GLInterface->Shutdown(); } } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index 7d823eff42..5899d82c39 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -132,11 +132,17 @@ void VideoSoftware::EmuStateChange(EMUSTATE_CHANGE newState) void VideoSoftware::Shutdown() { + // TODO: should be in Video_Cleanup HwRasterizer::Shutdown(); SWRenderer::Shutdown(); + GLInterface->Shutdown(); } +void VideoSoftware::Video_Cleanup() +{ +} + // This is called after Video_Initialize() from the Core void VideoSoftware::Video_Prepare() { diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h index 3e1490031f..a0826862ce 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h @@ -21,6 +21,7 @@ class VideoSoftware : public VideoBackend void ShowConfig(void* parent); void Video_Prepare(); + void Video_Cleanup(); void Video_EnterLoop(); void Video_ExitLoop();