mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
libretro: context cleanup
This commit is contained in:
parent
07db63e9ff
commit
a83c95ab9b
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
@ -26,9 +25,9 @@ static void context_destroy() { ((LibretroHWRenderContext *)Libretro::ctx)->Cont
|
||||
bool LibretroHWRenderContext::Init(bool cache_context) {
|
||||
hw_render_.cache_context = cache_context;
|
||||
if (!Libretro::environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render_))
|
||||
return false;
|
||||
libretro_get_proc_address = hw_render_.get_proc_address;
|
||||
return true;
|
||||
return false;
|
||||
libretro_get_proc_address = hw_render_.get_proc_address;
|
||||
return true;
|
||||
}
|
||||
|
||||
LibretroHWRenderContext::LibretroHWRenderContext(retro_hw_context_type context_type, unsigned version_major, unsigned version_minor) {
|
||||
@ -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) {
|
||||
@ -139,6 +140,6 @@ LibretroGraphicsContext *LibretroGraphicsContext::CreateGraphicsContext() {
|
||||
#endif
|
||||
|
||||
ctx = new LibretroSoftwareContext();
|
||||
ctx->Init();
|
||||
return ctx;
|
||||
ctx->Init();
|
||||
return ctx;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static bool create_device(retro_vulkan_context *context, VkInstance instance, Vk
|
||||
|
||||
vk = new VulkanContext();
|
||||
|
||||
vk_libretro_init(instance, gpu, surface, get_instance_proc_addr, required_device_extensions, num_required_device_extensions, required_device_layers, num_required_device_layers, required_features);
|
||||
vk_libretro_init(instance, gpu, surface, get_instance_proc_addr, required_device_extensions, num_required_device_extensions, required_device_layers, num_required_device_layers, required_features);
|
||||
|
||||
// TODO: Here we'll inject the instance and all of the stuff into the VulkanContext.
|
||||
|
||||
@ -97,17 +97,17 @@ static const VkApplicationInfo *GetApplicationInfo(void) {
|
||||
}
|
||||
|
||||
bool LibretroVulkanContext::Init() {
|
||||
if (!LibretroHWRenderContext::Init(false)) {
|
||||
if (!LibretroHWRenderContext::Init(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const struct retro_hw_render_context_negotiation_interface_vulkan iface = {
|
||||
RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN,
|
||||
RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION,
|
||||
GetApplicationInfo,
|
||||
create_device, // Callback above.
|
||||
nullptr,
|
||||
};
|
||||
RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN,
|
||||
RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION,
|
||||
GetApplicationInfo,
|
||||
create_device, // Callback above.
|
||||
nullptr,
|
||||
};
|
||||
Libretro::environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE, (void *)&iface);
|
||||
|
||||
g_Config.iGPUBackend = (int)GPUBackend::VULKAN;
|
||||
@ -131,6 +131,8 @@ void LibretroVulkanContext::ContextReset() {
|
||||
|
||||
void LibretroVulkanContext::ContextDestroy() {
|
||||
INFO_LOG(G3D, "LibretroVulkanContext::ContextDestroy()");
|
||||
vk->WaitUntilQueueIdle();
|
||||
LibretroHWRenderContext::ContextDestroy();
|
||||
}
|
||||
|
||||
void LibretroVulkanContext::CreateDrawContext() {
|
||||
|
@ -13,8 +13,8 @@ public:
|
||||
void *GetAPIContext() override;
|
||||
void CreateDrawContext() override;
|
||||
|
||||
void ContextReset() override;
|
||||
void ContextDestroy() override;
|
||||
void ContextReset() override;
|
||||
void ContextDestroy() override;
|
||||
|
||||
GPUCore GetGPUCore() override { return GPUCORE_VULKAN; }
|
||||
const char *Ident() override { return "Vulkan"; }
|
||||
|
Loading…
Reference in New Issue
Block a user