libretro: context cleanup

This commit is contained in:
sonninnos 2024-05-28 08:07:20 +03:00
parent 07db63e9ff
commit a83c95ab9b
5 changed files with 29 additions and 26 deletions

View File

@ -8,7 +8,7 @@
#include "libretro/LibretroGLContext.h"
bool LibretroGLContext::Init() {
if (!LibretroHWRenderContext::Init(true))
if (!LibretroHWRenderContext::Init(false))
return false;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;

View File

@ -8,7 +8,7 @@
#include "libretro/LibretroGLCoreContext.h"
bool LibretroGLCoreContext::Init() {
if (!LibretroHWRenderContext::Init(true))
if (!LibretroHWRenderContext::Init(false))
return false;
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;

View File

@ -2,7 +2,6 @@
#include "libretro/LibretroGraphicsContext.h"
#include "libretro/LibretroGLContext.h"
#include "libretro/LibretroGLCoreContext.h"
#include "libretro/libretro.h"
#include "libretro/LibretroVulkanContext.h"
#ifdef _WIN32
#include "libretro/LibretroD3D11Context.h"
@ -43,10 +42,8 @@ LibretroHWRenderContext::LibretroHWRenderContext(retro_hw_context_type context_t
void LibretroHWRenderContext::ContextReset() {
INFO_LOG(G3D, "Context reset");
// needed to restart the thread
// TODO: find a way to move this to ContextDestroy.
if (!hw_render_.cache_context && Libretro::useEmuThread && draw_ && Libretro::emuThreadState != Libretro::EmuThreadState::PAUSED) {
DestroyDrawContext();
if (gpu) {
gpu->DeviceLost();
}
if (!draw_) {
@ -66,11 +63,15 @@ void LibretroHWRenderContext::ContextDestroy() {
INFO_LOG(G3D, "Context destroy");
if (Libretro::useEmuThread) {
#if 0
Libretro::EmuThreadPause();
#else
Libretro::EmuThreadStop();
#endif
}
if (gpu) {
gpu->DeviceLost();
}
if (!hw_render_.cache_context && Libretro::useEmuThread && draw_ && Libretro::emuThreadState != Libretro::EmuThreadState::PAUSED) {
DestroyDrawContext();
}
if (!hw_render_.cache_context && !Libretro::useEmuThread) {

View File

@ -97,7 +97,7 @@ static const VkApplicationInfo *GetApplicationInfo(void) {
}
bool LibretroVulkanContext::Init() {
if (!LibretroHWRenderContext::Init(false)) {
if (!LibretroHWRenderContext::Init(true)) {
return false;
}
@ -131,6 +131,8 @@ void LibretroVulkanContext::ContextReset() {
void LibretroVulkanContext::ContextDestroy() {
INFO_LOG(G3D, "LibretroVulkanContext::ContextDestroy()");
vk->WaitUntilQueueIdle();
LibretroHWRenderContext::ContextDestroy();
}
void LibretroVulkanContext::CreateDrawContext() {