mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Merge pull request #21983 from hrydgard/merge-gl-contexts
Merge GL contexts
This commit is contained in:
12 files changed
+55
-141
No files matched your search
@@ -909,8 +909,6 @@ endif()
|
||||
if(ANDROID)
|
||||
list(APPEND AndroidJniSource
|
||||
android/jni/app-android.cpp
|
||||
android/jni/AndroidJavaGLContext.cpp
|
||||
android/jni/AndroidJavaGLContext.h
|
||||
android/jni/AndroidAudio.cpp
|
||||
android/jni/AndroidAudio.h
|
||||
android/jni/OpenSLContext.cpp
|
||||
|
||||
@@ -170,6 +170,8 @@ add_library(Common STATIC
|
||||
GPU/OpenGL/GLProfiler.h
|
||||
GPU/OpenGL/DataFormatGL.cpp
|
||||
GPU/OpenGL/DataFormatGL.h
|
||||
GPU/OpenGL/OpenGLGraphicsContext.cpp
|
||||
GPU/OpenGL/OpenGLGraphicsContext.h
|
||||
GPU/Vulkan/VulkanBarrier.cpp
|
||||
GPU/Vulkan/VulkanBarrier.h
|
||||
GPU/Vulkan/VulkanDebug.cpp
|
||||
|
||||
@@ -442,6 +442,7 @@
|
||||
<ClInclude Include="GPU\OpenGL\GLSLProgram.h" />
|
||||
<ClInclude Include="GPU\OpenGL\GLCommon.h" />
|
||||
<ClInclude Include="GPU\OpenGL\GLDebugLog.h" />
|
||||
<ClInclude Include="GPU\OpenGL\OpenGLGraphicsContext.h" />
|
||||
<ClInclude Include="GPU\Shader.h" />
|
||||
<ClInclude Include="GPU\ShaderTranslation.h" />
|
||||
<ClInclude Include="GPU\ShaderWriter.h" />
|
||||
@@ -924,6 +925,7 @@
|
||||
<ClCompile Include="GPU\OpenGL\GLRenderManager.cpp" />
|
||||
<ClCompile Include="GPU\OpenGL\GLSLProgram.cpp" />
|
||||
<ClCompile Include="GPU\OpenGL\GLDebugLog.cpp" />
|
||||
<ClCompile Include="GPU\OpenGL\OpenGLGraphicsContext.cpp" />
|
||||
<ClCompile Include="GPU\OpenGL\thin3d_gl.cpp" />
|
||||
<ClCompile Include="GPU\Shader.cpp" />
|
||||
<ClCompile Include="GPU\ShaderTranslation.cpp" />
|
||||
|
||||
@@ -792,6 +792,9 @@
|
||||
<ClInclude Include="GPU\Vulkan\VulkanGraphicsContext.h">
|
||||
<Filter>GPU\Vulkan</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GPU\OpenGL\OpenGLGraphicsContext.h">
|
||||
<Filter>GPU\OpenGL</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ABI.cpp" />
|
||||
@@ -1463,6 +1466,9 @@
|
||||
<ClCompile Include="GPU\Vulkan\VulkanGraphicsContext.cpp">
|
||||
<Filter>GPU\Vulkan</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GPU\OpenGL\OpenGLGraphicsContext.cpp">
|
||||
<Filter>GPU\OpenGL</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "OpenGLGraphicsContext.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/GPU/OpenGL/GLFeatures.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
OpenGLGraphicsContext::OpenGLGraphicsContext() {
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
CheckGLExtensions();
|
||||
// OpenGL handles rotated rendering in the driver.
|
||||
g_display.rotation = DisplayRotation::ROTATE_0;
|
||||
g_display.rot_matrix.setIdentity();
|
||||
}
|
||||
|
||||
bool OpenGLGraphicsContext::InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *errorMessage) {
|
||||
INFO_LOG(Log::G3D, "OpenGLGraphicsContext::InitSurface");
|
||||
draw_ = Draw::T3DCreateGLContext(false); // Can't fail
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
const bool result = draw_->CreatePresets();
|
||||
_dbg_assert_(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLGraphicsContext::ShutdownSurface() {
|
||||
INFO_LOG(Log::G3D, "OpenGLGraphicsContext::Shutdown");
|
||||
renderManager_ = nullptr; // owned by draw_.
|
||||
delete draw_;
|
||||
draw_ = nullptr;
|
||||
}
|
||||
@@ -4,10 +4,12 @@
|
||||
#include "Common/GPU/OpenGL/GLRenderManager.h"
|
||||
#include "Common/GPU/thin3d_create.h"
|
||||
|
||||
class AndroidJavaEGLGraphicsContext : public GraphicsContext {
|
||||
// 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:
|
||||
AndroidJavaEGLGraphicsContext();
|
||||
~AndroidJavaEGLGraphicsContext() override { delete draw_; }
|
||||
OpenGLGraphicsContext();
|
||||
~OpenGLGraphicsContext() override { delete draw_; }
|
||||
|
||||
bool NeedsSeparateEmuThread() const override { return true; }
|
||||
|
||||
@@ -411,14 +411,6 @@
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\android\jni\AndroidJavaGLContext.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\android\jni\app-android.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -711,14 +703,6 @@
|
||||
<ClCompile Include="XinputDevice.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\android\jni\AndroidJavaGLContext.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\AndroidContentURI.h" />
|
||||
<ClInclude Include="..\android\jni\app-android.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -187,9 +187,6 @@
|
||||
<ClCompile Include="CaptureDevice.cpp">
|
||||
<Filter>Windows\Input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\android\jni\AndroidJavaGLContext.cpp">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\android\jni\app-android.cpp">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClCompile>
|
||||
@@ -397,9 +394,6 @@
|
||||
<ClInclude Include="BufferLock.h">
|
||||
<Filter>Windows\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\AndroidJavaGLContext.h">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\app-android.h">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -127,7 +127,8 @@ NATIVE_FILES :=\
|
||||
$(SRC)/Common/GPU/OpenGL/GLRenderManager.cpp \
|
||||
$(SRC)/Common/GPU/OpenGL/GLQueueRunner.cpp \
|
||||
$(SRC)/Common/GPU/OpenGL/GLProfiler.cpp \
|
||||
$(SRC)/Common/GPU/OpenGL/DataFormatGL.cpp
|
||||
$(SRC)/Common/GPU/OpenGL/DataFormatGL.cpp \
|
||||
$(SRC)/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp
|
||||
|
||||
VULKAN_FILES := \
|
||||
$(SRC)/Common/GPU/Vulkan/thin3d_vulkan.cpp \
|
||||
@@ -916,7 +917,6 @@ LOCAL_STATIC_LIBRARIES += ppsspp_common ppsspp_core libarmips libzstd
|
||||
LOCAL_MODULE := ppsspp_jni
|
||||
LOCAL_SRC_FILES := \
|
||||
$(SRC)/android/jni/app-android.cpp \
|
||||
$(SRC)/android/jni/AndroidJavaGLContext.cpp \
|
||||
$(SRC)/android/jni/AndroidAudio.cpp \
|
||||
$(SRC)/android/jni/OpenSLContext.cpp \
|
||||
$(SRC)/UI/ImDebugger/ImDebugger.cpp \
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#include "AndroidJavaGLContext.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/GPU/OpenGL/GLFeatures.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
AndroidJavaEGLGraphicsContext::AndroidJavaEGLGraphicsContext() {
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
// OpenGL handles rotated rendering in the driver.
|
||||
g_display.rotation = DisplayRotation::ROTATE_0;
|
||||
g_display.rot_matrix.setIdentity();
|
||||
}
|
||||
|
||||
bool AndroidJavaEGLGraphicsContext::InitSurface(WindowSystem winsys, void *data1, void *data2, std::string *errorMessage) {
|
||||
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::InitFromRenderThread");
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidJavaEGLGraphicsContext::ShutdownSurface() {
|
||||
INFO_LOG(Log::G3D, "AndroidJavaEGLGraphicsContext::Shutdown");
|
||||
renderManager_ = nullptr; // owned by draw_.
|
||||
delete draw_;
|
||||
draw_ = nullptr;
|
||||
}
|
||||
@@ -88,11 +88,10 @@ struct JNIEnv {};
|
||||
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
||||
#include "Common/GPU/GraphicsContext.h"
|
||||
#include "Common/GPU/Vulkan/VulkanGraphicsContext.h"
|
||||
#include "Common/GPU/OpenGL/OpenGLGraphicsContext.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
|
||||
#include "AndroidJavaGLContext.h"
|
||||
|
||||
#include "Core/CmdLine.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
@@ -779,7 +778,7 @@ retry:
|
||||
switch (g_Config.iGPUBackend) {
|
||||
case (int)GPUBackend::OPENGL:
|
||||
INFO_LOG(Log::System, "NativeApp.init() -- creating OpenGL context (JavaGL)");
|
||||
graphicsContext = new AndroidJavaEGLGraphicsContext();
|
||||
graphicsContext = new OpenGLGraphicsContext();
|
||||
INFO_LOG(Log::System, "NativeApp.init() - not yet launching emuthread, waiting to displayInit");
|
||||
break;
|
||||
case (int)GPUBackend::VULKAN:
|
||||
|
||||
+4
-68
@@ -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<bool> 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];
|
||||
|
||||
Reference in new issue
Block a user