From 1649d2fcae9260b02bace1cbf9e0f9df9697c5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 26 Jul 2026 20:11:12 +0200 Subject: [PATCH] Also merge away the iOS GL graphics context --- Common/GPU/OpenGL/OpenGLGraphicsContext.cpp | 15 +---- Common/GPU/OpenGL/OpenGLGraphicsContext.h | 2 + ios/ViewController.mm | 72 ++------------------- 3 files changed, 9 insertions(+), 80 deletions(-) diff --git a/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp b/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp index 9ae1f1471a..6ae331c739 100644 --- a/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp +++ b/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp @@ -8,7 +8,7 @@ OpenGLGraphicsContext::OpenGLGraphicsContext() { SetGPUBackend(GPUBackend::OPENGL); - + CheckGLExtensions(); // OpenGL handles rotated rendering in the driver. g_display.rotation = DisplayRotation::ROTATE_0; g_display.rot_matrix.setIdentity(); @@ -16,20 +16,11 @@ OpenGLGraphicsContext::OpenGLGraphicsContext() { bool OpenGLGraphicsContext::InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *errorMessage) { INFO_LOG(Log::G3D, "OpenGLGraphicsContext::InitSurface"); - if (!CheckGLExtensions()) { - *errorMessage = "CheckExtensions failed"; - ERROR_LOG(Log::G3D, "CheckGLExtensions failed - not gonna attempt starting up."); - return false; - } draw_ = Draw::T3DCreateGLContext(false); // Can't fail renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); renderManager_->SetInflightFrames(g_Config.iInflightFrames); - - if (!draw_->CreatePresets()) { - // This can't really happen now that compilation is async - they're only really queued for compile here. - _assert_msg_(false, "Failed to compile preset shaders"); - return false; - } + const bool result = draw_->CreatePresets(); + _dbg_assert_(result); return true; } diff --git a/Common/GPU/OpenGL/OpenGLGraphicsContext.h b/Common/GPU/OpenGL/OpenGLGraphicsContext.h index 015514a6eb..972e1a9c0c 100644 --- a/Common/GPU/OpenGL/OpenGLGraphicsContext.h +++ b/Common/GPU/OpenGL/OpenGLGraphicsContext.h @@ -4,6 +4,8 @@ #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/thin3d_create.h" +// This one is mainly useful for the backends that already initialize GL in platform-specific code. +// It doesn't have the real initialization that we need to do on some platforms. class OpenGLGraphicsContext : public GraphicsContext { public: OpenGLGraphicsContext(); diff --git a/ios/ViewController.mm b/ios/ViewController.mm index db9dde0913..488b446a52 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -18,7 +18,7 @@ #include "Common/GPU/thin3d.h" #include "Common/GPU/thin3d_create.h" #include "Common/GPU/OpenGL/GLRenderManager.h" -#include "Common/GPU/OpenGL/GLFeatures.h" +#include "Common/GPU/OpenGL/OpenGLGraphicsContext.h" #include "Common/System/Display.h" #include "Common/System/System.h" #include "Common/System/OSD.h" @@ -42,77 +42,13 @@ #error Must be built with ARC, please revise the flags for ViewController.mm to include -fobjc-arc. #endif -class IOSGLESContext : public GraphicsContext { -public: - IOSGLESContext() { - CheckGLExtensions(); - SetGPUBackend(GPUBackend::OPENGL); - } - ~IOSGLESContext() { - delete draw_; - } - - bool InitAPI(void *wnd, std::string *deviceNameSetting, std::string *error_message) override { - // Nothing to do here, we already initialized in the constructor. - return true; - } - bool InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *error_message) override { - draw_ = Draw::T3DCreateGLContext(false); - renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); - renderManager_->SetInflightFrames(g_Config.iInflightFrames); - bool success = draw_->CreatePresets(); - _assert_msg_(success, "Failed to compile preset shaders"); - return true; - } - - void ShutdownSurface() override { - // Nothing to do here, we already initialized in the constructor. - if (draw_) { - delete draw_; - draw_ = nullptr; - } - renderManager_ = nullptr; - } - void ShutdownAPI() override { - // Nothing to do here. - } - - bool NeedsSeparateEmuThread() const override { return true; } - Draw::DrawContext *GetDrawContext() override { - return draw_; - } - - void Resize() override {} - - void ThreadStart() override { - renderManager_->ThreadStart(draw_); - } - - bool ThreadFrame(bool waitIfEmpty) override { - return renderManager_->ThreadFrame(waitIfEmpty); - } - - void ThreadEnd() override { - renderManager_->ThreadEnd(); - } - -protected: - void BeginShutdown() { - renderManager_->SetSkipGLCalls(); - } - -private: - Draw::DrawContext *draw_; - GLRenderManager *renderManager_; -}; - static std::atomic renderLoopRunning; static std::thread g_emuThread; PPSSPPBaseViewController *sharedViewController; @interface PPSSPPViewControllerGL () { - IOSGLESContext *graphicsContext; + GraphicsContext *graphicsContext; int imageRequestId; NSString *imageFilename; @@ -202,7 +138,7 @@ PPSSPPBaseViewController *sharedViewController; self.view.frame = [screen bounds]; self.view.multipleTouchEnabled = YES; - graphicsContext = new IOSGLESContext(); + graphicsContext = new OpenGLGraphicsContext(); std::string errorMessage; if (!graphicsContext->InitAPI(nullptr, nullptr, &errorMessage)) { @@ -210,7 +146,7 @@ PPSSPPBaseViewController *sharedViewController; } if (!graphicsContext->InitSurface(WINDOWSYSTEM_NONE, nullptr, nullptr, &errorMessage)) { - ERROR_LOG(Log::G3D, "InitAPI failed: %s", errorMessage.c_str()); + ERROR_LOG(Log::G3D, "InitSurface failed: %s", errorMessage.c_str()); } /*self.iCadeView = [[iCadeReaderView alloc] init];