Add configurable Renderer backend

There are still some initialization errors to work through, such as
config not being initialized properly by the time GPU tries to utilize
it too. Also some life-time issues. But manually forcing it to use the
Null backnd successfully works and allows games to be "played"
headlessly.
This commit is contained in:
Wunkolo 2023-07-17 10:12:38 -07:00
parent 1becbef811
commit ceff20f57f
7 changed files with 48 additions and 24 deletions

View file

@ -7,7 +7,7 @@
#include "PICA/float_types.hpp"
#include "PICA/regs.hpp"
#include "renderer_null/renderer_null.hpp"
#ifdef PANDA3DS_ENABLE_OPENGL
#include "renderer_gl/renderer_gl.hpp"
#endif
@ -20,10 +20,22 @@ GPU::GPU(Memory& mem, EmulatorConfig& config) : mem(mem), config(config) {
vram = new u8[vramSize];
mem.setVRAM(vram); // Give the bus a pointer to our VRAM
// TODO: Configurable backend
switch (config.rendererType) {
case RendererType::Null: {
renderer.reset(new RendererNull(*this, regs));
break;
}
#ifdef PANDA3DS_ENABLE_OPENGL
renderer.reset(new RendererGL(*this, regs));
case RendererType::OpenGL: {
renderer.reset(new RendererGL(*this, regs));
break;
}
#endif
default: {
Helpers::panic("Invalid rendering backend index: %d", static_cast<s8>(config.rendererType));
break;
}
}
}
void GPU::reset() {