mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Avoid Host in Windows graphics init
This commit is contained in:
parent
e7f1716c4f
commit
2786786c9f
5 changed files with 43 additions and 52 deletions
|
@ -30,7 +30,7 @@ public:
|
|||
virtual bool InitGraphics(std::string *error_string, GraphicsContext **ctx) = 0;
|
||||
virtual void ShutdownGraphics() = 0;
|
||||
|
||||
virtual void UpdateSound() {}
|
||||
virtual void UpdateSound() {} // still needed for libretro, will need a proper effort.
|
||||
virtual void PollControllers() {}
|
||||
virtual void ToggleDebugConsoleVisibility() {}
|
||||
|
||||
|
|
|
@ -1426,12 +1426,6 @@ void NativeShutdown() {
|
|||
screenManager = nullptr;
|
||||
}
|
||||
|
||||
if (host) {
|
||||
host->ShutdownGraphics();
|
||||
delete host;
|
||||
host = nullptr;
|
||||
}
|
||||
|
||||
#if !PPSSPP_PLATFORM(UWP)
|
||||
#endif
|
||||
g_Config.Save("NativeShutdown");
|
||||
|
|
|
@ -26,6 +26,13 @@
|
|||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
#include "Windows/GPU/WindowsGLContext.h"
|
||||
#endif
|
||||
#include "Windows/GPU/WindowsVulkanContext.h"
|
||||
#include "Windows/GPU/D3D9Context.h"
|
||||
#include "Windows/GPU/D3D11Context.h"
|
||||
|
||||
enum class EmuThreadState {
|
||||
DISABLED,
|
||||
START_REQUESTED,
|
||||
|
@ -112,6 +119,37 @@ static void EmuThreadJoin() {
|
|||
INFO_LOG(SYSTEM, "EmuThreadJoin - joined");
|
||||
}
|
||||
|
||||
bool CreateGraphicsBackend(std::string *error_message, GraphicsContext **ctx) {
|
||||
WindowsGraphicsContext *graphicsContext = nullptr;
|
||||
switch (g_Config.iGPUBackend) {
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
case (int)GPUBackend::OPENGL:
|
||||
graphicsContext = new WindowsGLContext();
|
||||
break;
|
||||
#endif
|
||||
case (int)GPUBackend::DIRECT3D9:
|
||||
graphicsContext = new D3D9Context();
|
||||
break;
|
||||
case (int)GPUBackend::DIRECT3D11:
|
||||
graphicsContext = new D3D11Context();
|
||||
break;
|
||||
case (int)GPUBackend::VULKAN:
|
||||
graphicsContext = new WindowsVulkanContext();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (graphicsContext->Init(MainWindow::GetHInstance(), MainWindow::GetDisplayHWND(), error_message)) {
|
||||
*ctx = graphicsContext;
|
||||
return true;
|
||||
} else {
|
||||
delete graphicsContext;
|
||||
*ctx = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MainThreadFunc() {
|
||||
if (useEmuThread) {
|
||||
// We'll start up a separate thread we'll call Emu
|
||||
|
@ -164,7 +202,7 @@ void MainThreadFunc() {
|
|||
System_Notify(SystemNotification::UI);
|
||||
|
||||
std::string error_string;
|
||||
bool success = host->InitGraphics(&error_string, &g_graphicsContext);
|
||||
bool success = CreateGraphicsBackend(&error_string, &g_graphicsContext);
|
||||
|
||||
if (success) {
|
||||
// Main thread is the render thread.
|
||||
|
@ -299,7 +337,8 @@ shutdown:
|
|||
g_graphicsContext->ThreadEnd();
|
||||
g_graphicsContext->ShutdownFromRenderThread();
|
||||
|
||||
// NativeShutdown deletes the graphics context through host->ShutdownGraphics().
|
||||
g_graphicsContext->Shutdown();
|
||||
|
||||
NativeShutdown();
|
||||
|
||||
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
|
||||
|
|
|
@ -53,13 +53,6 @@
|
|||
#include "Windows/WindowsHost.h"
|
||||
#include "Windows/MainWindow.h"
|
||||
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
#include "Windows/GPU/WindowsGLContext.h"
|
||||
#endif
|
||||
#include "Windows/GPU/WindowsVulkanContext.h"
|
||||
#include "Windows/GPU/D3D9Context.h"
|
||||
#include "Windows/GPU/D3D11Context.h"
|
||||
|
||||
#include "Windows/Debugger/DebuggerShared.h"
|
||||
#include "Windows/Debugger/Debugger_Disasm.h"
|
||||
#include "Windows/Debugger/Debugger_MemoryDlg.h"
|
||||
|
@ -117,42 +110,10 @@ void WindowsHost::UpdateConsolePosition() {
|
|||
}
|
||||
|
||||
bool WindowsHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
|
||||
WindowsGraphicsContext *graphicsContext = nullptr;
|
||||
switch (g_Config.iGPUBackend) {
|
||||
#if PPSSPP_API(ANY_GL)
|
||||
case (int)GPUBackend::OPENGL:
|
||||
graphicsContext = new WindowsGLContext();
|
||||
break;
|
||||
#endif
|
||||
case (int)GPUBackend::DIRECT3D9:
|
||||
graphicsContext = new D3D9Context();
|
||||
break;
|
||||
case (int)GPUBackend::DIRECT3D11:
|
||||
graphicsContext = new D3D11Context();
|
||||
break;
|
||||
case (int)GPUBackend::VULKAN:
|
||||
graphicsContext = new WindowsVulkanContext();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (graphicsContext->Init(hInstance_, displayWindow_, error_message)) {
|
||||
*ctx = graphicsContext;
|
||||
gfx_ = graphicsContext;
|
||||
return true;
|
||||
} else {
|
||||
delete graphicsContext;
|
||||
*ctx = nullptr;
|
||||
gfx_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowsHost::ShutdownGraphics() {
|
||||
gfx_->Shutdown();
|
||||
delete gfx_;
|
||||
gfx_ = nullptr;
|
||||
}
|
||||
|
||||
void WindowsHost::SetWindowTitle(const char *message) {
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
extern float g_mouseDeltaX;
|
||||
extern float g_mouseDeltaY;
|
||||
|
||||
class GraphicsContext;
|
||||
|
||||
class WindowsHost : public Host {
|
||||
public:
|
||||
WindowsHost(HINSTANCE hInstance, HWND mainWindow, HWND displayWindow);
|
||||
|
@ -61,7 +59,6 @@ private:
|
|||
HINSTANCE hInstance_;
|
||||
HWND displayWindow_;
|
||||
HWND mainWindow_;
|
||||
GraphicsContext *gfx_ = nullptr;
|
||||
size_t numDinputDevices_ = 0;
|
||||
std::wstring lastTitle_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue