Allow for a more modular renderer backends (#990)

* Draft GPU3D renderer modularization

* Update sources C++ standard to C++17

The top-level `CMakeLists.txt` is already using the C++17 standard.

* Move GLCompositor into class type

Some other misc fixes to push towards better modularity

* Make renderer-implementation types move-only

These types are going to be holding onto handles
of GPU-side resources and shouldn't ever be copied around.

* Fix OSX: Remove 'register' storage class specifier

`register` has been removed in C++17...
But this keyword hasn't done anything in years anyways.

OSX builds consider this "warning" an error and it
stops the whole build.

* Add RestartFrame to Renderer3D interface

* Move Accelerated property to Renderer3D interface

There are points in the code base where we do:
`renderer != 0` to know if we are feeding
an openGL renderer. Rather than that we can instead just have this be
a property of the renderer itself.
With this pattern a renderer can just say how it wants its data to come
in rather than have everyone know that they're talking to an OpenGL
renderer.

* Remove Accelerated flag from GPU

* Move 2D_Soft interface in separate header

Also make the current 2D engine an "owned" unique_ptr.

* Update alignment attribute to standard alignas

Uses standardized `alignas` rather than compiler-specific
attributes.

https://en.cppreference.com/w/cpp/language/alignas

* Fix Clang: alignas specifier

Alignment must be specified before the array to align the entire array.

https://en.cppreference.com/w/cpp/language/alignas

* Converted Renderer3D Accelerated to variable

This flag is checked a lot during scanline rasterization. So rather
than having an expensive vtable-lookup call during mainline rendering
code, it is now a public constant bool type that is written to only once
during Renderer3D initialization.
This commit is contained in:
Wunk
2021-02-09 14:38:51 -08:00
committed by GitHub
parent 891427c75c
commit a7029aebae
16 changed files with 1039 additions and 836 deletions

View File

@ -273,7 +273,7 @@ u32 RenderNumPolygons;
u32 FlushRequest;
u32 FlushAttributes;
std::unique_ptr<GPU3D::Renderer3D> CurrentRenderer = {};
bool Init()
{
@ -2497,12 +2497,12 @@ void CheckFIFODMA()
void VCount144()
{
if (GPU::Renderer == 0) SoftRenderer::VCount144();
CurrentRenderer->VCount144();
}
void RestartFrame()
{
if (GPU::Renderer == 0) SoftRenderer::SetupRenderThread();
CurrentRenderer->RestartFrame();
}
@ -2597,10 +2597,7 @@ void VBlank()
void VCount215()
{
if (GPU::Renderer == 0) SoftRenderer::RenderFrame();
#ifdef OGLRENDERER_ENABLED
else GLRenderer::RenderFrame();
#endif
CurrentRenderer->RenderFrame();
}
void SetRenderXPos(u16 xpos)
@ -2614,12 +2611,7 @@ u32 ScrolledLine[256];
u32* GetLine(int line)
{
u32* rawline = NULL;
if (GPU::Renderer == 0) rawline = SoftRenderer::GetLine(line);
#ifdef OGLRENDERER_ENABLED
else rawline = GLRenderer::GetLine(line);
#endif
u32* rawline = CurrentRenderer->GetLine(line);
if (RenderXPos == 0) return rawline;
@ -3055,5 +3047,9 @@ void Write32(u32 addr, u32 val)
printf("unknown GPU3D write32 %08X %08X\n", addr, val);
}
Renderer3D::Renderer3D(bool Accelerated)
: Accelerated(Accelerated)
{ }
}