make OpenGL renderer a build option
mostly meant for the Switch port
This commit is contained in:
parent
4b705556bc
commit
6977302403
|
@ -50,6 +50,12 @@ else()
|
|||
option(ENABLE_LTO "Enable link-time optimization" OFF)
|
||||
endif()
|
||||
|
||||
option(ENABLE_OGLRENDERER "Enable OpenGL renderer" ON)
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
add_definitions(-DOGLRENDERER_ENABLED)
|
||||
endif()
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_compile_options(-Og)
|
||||
endif()
|
||||
|
|
|
@ -26,17 +26,12 @@ add_library(core STATIC
|
|||
FIFO.h
|
||||
GBACart.cpp
|
||||
GPU.cpp
|
||||
GPU_OpenGL.cpp
|
||||
GPU_OpenGL_shaders.h
|
||||
GPU2D.cpp
|
||||
GPU3D.cpp
|
||||
GPU3D_OpenGL.cpp
|
||||
GPU3D_OpenGL_shaders.h
|
||||
GPU3D_Soft.cpp
|
||||
melonDLDI.h
|
||||
NDS.cpp
|
||||
NDSCart.cpp
|
||||
OpenGLSupport.cpp
|
||||
Platform.h
|
||||
ROMList.h
|
||||
RTC.cpp
|
||||
|
@ -52,6 +47,16 @@ add_library(core STATIC
|
|||
xxhash/xxhash.c
|
||||
)
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
target_sources(core PRIVATE
|
||||
GPU_OpenGL.cpp
|
||||
GPU_OpenGL_shaders.h
|
||||
GPU3D_OpenGL.cpp
|
||||
GPU3D_OpenGL_shaders.h
|
||||
OpenGLSupport.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (ENABLE_JIT)
|
||||
enable_language(ASM)
|
||||
|
||||
|
@ -95,8 +100,16 @@ if (ENABLE_JIT)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||
if (ENABLE_OGLRENDERER)
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32 opengl32)
|
||||
else()
|
||||
target_link_libraries(core GL EGL)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(core GL EGL)
|
||||
endif()
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32)
|
||||
else()
|
||||
target_link_libraries(core)
|
||||
endif()
|
||||
endif()
|
13
src/GPU.cpp
13
src/GPU.cpp
|
@ -280,6 +280,7 @@ void AssignFramebuffers()
|
|||
|
||||
void InitRenderer(int renderer)
|
||||
{
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (renderer == 1)
|
||||
{
|
||||
if (!GLCompositor::Init())
|
||||
|
@ -292,8 +293,8 @@ void InitRenderer(int renderer)
|
|||
renderer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (renderer == 0)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
GPU3D::SoftRenderer::Init();
|
||||
}
|
||||
|
@ -308,11 +309,13 @@ void DeInitRenderer()
|
|||
{
|
||||
GPU3D::SoftRenderer::DeInit();
|
||||
}
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
else
|
||||
{
|
||||
GPU3D::GLRenderer::DeInit();
|
||||
GLCompositor::DeInit();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResetRenderer()
|
||||
|
@ -321,11 +324,13 @@ void ResetRenderer()
|
|||
{
|
||||
GPU3D::SoftRenderer::Reset();
|
||||
}
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
else
|
||||
{
|
||||
GLCompositor::Reset();
|
||||
GPU3D::GLRenderer::Reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetRenderSettings(int renderer, RenderSettings& settings)
|
||||
|
@ -364,11 +369,13 @@ void SetRenderSettings(int renderer, RenderSettings& settings)
|
|||
{
|
||||
GPU3D::SoftRenderer::SetRenderSettings(settings);
|
||||
}
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
else
|
||||
{
|
||||
GLCompositor::SetRenderSettings(settings);
|
||||
GPU3D::GLRenderer::SetRenderSettings(settings);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1055,7 +1062,9 @@ void StartScanline(u32 line)
|
|||
GPU2D_B->VBlank();
|
||||
GPU3D::VBlank();
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (Accelerated) GLCompositor::RenderFrame();
|
||||
#endif
|
||||
}
|
||||
else if (VCount == 144)
|
||||
{
|
||||
|
|
|
@ -437,6 +437,7 @@ void SetDispStat(u32 cpu, u16 val);
|
|||
|
||||
void SetVCount(u16 val);
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
namespace GLCompositor
|
||||
{
|
||||
|
||||
|
@ -450,6 +451,7 @@ void RenderFrame();
|
|||
void BindOutputTexture();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -949,6 +949,7 @@ void GPU2D::VBlankEnd()
|
|||
//OBJMosaicY = 0;
|
||||
//OBJMosaicYCount = 0;
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (Accelerated)
|
||||
{
|
||||
if ((Num == 0) && (CaptureCnt & (1<<31)) && (((CaptureCnt >> 29) & 0x3) != 1))
|
||||
|
@ -956,6 +957,7 @@ void GPU2D::VBlankEnd()
|
|||
GPU3D::GLRenderer::PrepareCaptureFrame();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2528,13 +2528,19 @@ void VBlank()
|
|||
void VCount215()
|
||||
{
|
||||
if (GPU::Renderer == 0) SoftRenderer::RenderFrame();
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
else GLRenderer::RenderFrame();
|
||||
#endif
|
||||
}
|
||||
|
||||
u32* GetLine(int line)
|
||||
{
|
||||
if (GPU::Renderer == 0) return SoftRenderer::GetLine(line);
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
else return GLRenderer::GetLine(line);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ u32* GetLine(int line);
|
|||
|
||||
}
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
namespace GLRenderer
|
||||
{
|
||||
|
||||
|
@ -154,6 +155,7 @@ u32* GetLine(int line);
|
|||
void SetupAccelFrame();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ VideoSettingsDialog::VideoSettingsDialog(QWidget* parent) : QDialog(parent), ui(
|
|||
connect(grp3DRenderer, SIGNAL(buttonClicked(int)), this, SLOT(onChange3DRenderer(int)));
|
||||
grp3DRenderer->button(Config::_3DRenderer)->setChecked(true);
|
||||
|
||||
#ifndef OGLRENDERER_ENABLED
|
||||
ui->rb3DOpenGL->setEnabled(false);
|
||||
#endif
|
||||
|
||||
ui->cbGLDisplay->setChecked(Config::ScreenUseGL != 0);
|
||||
|
||||
ui->cbVSync->setChecked(Config::ScreenVSync != 0);
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
|
||||
#include "NDS.h"
|
||||
#include "GBACart.h"
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
#include "OpenGLSupport.h"
|
||||
#endif
|
||||
#include "GPU.h"
|
||||
#include "SPU.h"
|
||||
#include "Wifi.h"
|
||||
|
@ -336,13 +338,17 @@ void EmuThread::run()
|
|||
videoSettings.Soft_Threaded = Config::Threaded3D != 0;
|
||||
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (hasOGL)
|
||||
{
|
||||
oglContext->makeCurrent(oglSurface);
|
||||
videoRenderer = OpenGL::Init() ? Config::_3DRenderer : 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
videoRenderer = 0;
|
||||
}
|
||||
|
||||
GPU::InitRenderer(videoRenderer);
|
||||
GPU::SetRenderSettings(videoRenderer, videoSettings);
|
||||
|
@ -396,13 +402,17 @@ void EmuThread::run()
|
|||
if (hasOGL != mainWindow->hasOGL)
|
||||
{
|
||||
hasOGL = mainWindow->hasOGL;
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (hasOGL)
|
||||
{
|
||||
oglContext->makeCurrent(oglSurface);
|
||||
videoRenderer = OpenGL::Init() ? Config::_3DRenderer : 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
videoRenderer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
videoRenderer = hasOGL ? Config::_3DRenderer : 0;
|
||||
|
@ -923,12 +933,14 @@ void ScreenPanelGL::paintGL()
|
|||
int frontbuf = GPU::FrontBuffer;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (GPU::Renderer != 0)
|
||||
{
|
||||
// hardware-accelerated render
|
||||
GPU::GLCompositor::BindOutputTexture();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// regular render
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
|
Loading…
Reference in New Issue