Remove InitGraphics/ShutdownGraphics from Host, except for headless

This commit is contained in:
Henrik Rydgård 2023-03-21 22:19:48 +01:00
parent 2786786c9f
commit 47f063550a
15 changed files with 10 additions and 47 deletions

View file

@ -27,9 +27,6 @@ class Host {
public:
virtual ~Host() {}
virtual bool InitGraphics(std::string *error_string, GraphicsContext **ctx) = 0;
virtual void ShutdownGraphics() = 0;
virtual void UpdateSound() {} // still needed for libretro, will need a proper effort.
virtual void PollControllers() {}
virtual void ToggleDebugConsoleVisibility() {}

View file

@ -31,9 +31,6 @@ public:
mainWindow = mainWindow_;
}
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
void ShutdownGraphics() override {}
void UpdateSound() override {}
bool AttemptLoadSymbolMap() override {

View file

@ -24,9 +24,6 @@ class NativeHost : public Host {
public:
NativeHost() {}
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
void ShutdownGraphics() override {}
void UpdateSound() override {}
bool AttemptLoadSymbolMap() override {return false;}

View file

@ -54,15 +54,6 @@ void UWPHost::SetConsolePosition() {
void UWPHost::UpdateConsolePosition() {
}
bool UWPHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
// Done elsewhere
return true;
}
void UWPHost::ShutdownGraphics() {
// Done elsewhere
}
void UWPHost::SetWindowTitle(const char *message) {
}

View file

@ -12,10 +12,7 @@ public:
UWPHost();
~UWPHost();
// If returns false, will return a null context
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
void PollControllers() override;
void ShutdownGraphics() override;
void UpdateSound() override;

View file

@ -109,13 +109,6 @@ void WindowsHost::UpdateConsolePosition() {
}
}
bool WindowsHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
return true;
}
void WindowsHost::ShutdownGraphics() {
}
void WindowsHost::SetWindowTitle(const char *message) {
#ifdef GOLD
const char *name = "PPSSPP Gold ";

View file

@ -32,10 +32,7 @@ public:
UpdateConsolePosition();
}
// If returns false, will return a null context
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
void PollControllers() override;
void ShutdownGraphics() override;
void UpdateSound() override;
@ -50,8 +47,6 @@ public:
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void SendUIMessage(const std::string &message, const std::string &value) override;
GraphicsContext *GetGraphicsContext() { return gfx_; }
private:
void SetConsolePosition();
void UpdateConsolePosition();

@ -1 +1 @@
Subproject commit b34f619e1c85810dcb3c578107d2e48ba4ee2b37
Subproject commit 77551c429f86c0e077f26552b7c1c0f12a9f235e

View file

@ -409,12 +409,11 @@ int main(int argc, const char* argv[])
g_threadManager.Init(cpu_info.num_cores, cpu_info.logical_cpu_count);
HeadlessHost *headlessHost = getHost(gpuCore);
headlessHost->SetGraphicsCore(gpuCore);
host = headlessHost;
std::string error_string;
GraphicsContext *graphicsContext = nullptr;
bool glWorking = host->InitGraphics(&error_string, &graphicsContext);
bool glWorking = ((HeadlessHost *)host)->InitGraphics(&error_string, &graphicsContext, gpuCore);
CoreParameter coreParameter;
coreParameter.cpuCore = cpuCore;
@ -578,7 +577,7 @@ int main(int argc, const char* argv[])
ShutdownWebServer();
}
host->ShutdownGraphics();
((HeadlessHost *)host)->ShutdownGraphics();
delete host;
host = nullptr;
headlessHost = nullptr;

View file

@ -165,7 +165,7 @@ bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) {
return success;
}
bool SDLHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
bool SDLHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {
GraphicsContext *graphicsContext = new GLDummyGraphicsContext();
*ctx = graphicsContext;
gfx_ = graphicsContext;

View file

@ -30,7 +30,7 @@ typedef void *SDL_GLContext;
class SDLHeadlessHost : public HeadlessHost
{
public:
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) override;
void ShutdownGraphics() override;
void SwapBuffers() override;

View file

@ -23,12 +23,10 @@
#include "Core/Host.h"
#include "Core/Debugger/SymbolMap.h"
// TODO: Get rid of this junk
class HeadlessHost : public Host {
public:
void SetGraphicsCore(GPUCore core) { gpuCore_ = core; }
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override {return false;}
void ShutdownGraphics() override {}
virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {return false;}
virtual void ShutdownGraphics() {}
void UpdateSound() override {}

View file

@ -72,8 +72,9 @@ void WindowsHeadlessHost::SendDebugOutput(const std::string &output)
OutputDebugStringUTF8(output.c_str());
}
bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {
hWnd = CreateHiddenWindow();
gpuCore_ = core;
if (WINDOW_VISIBLE) {
ShowWindow(hWnd, TRUE);

View file

@ -29,7 +29,7 @@
class WindowsHeadlessHost : public HeadlessHost
{
public:
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) override;
void ShutdownGraphics() override;
void SwapBuffers() override;

View file

@ -386,8 +386,6 @@ class LibretroHost : public Host
{
public:
LibretroHost() {}
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
void ShutdownGraphics() override {}
void UpdateSound() override
{
int hostAttemptBlockSize = __AudioGetHostAttemptBlockSize();