Merge pull request #120 from Wunkolo/renderer-null

Add a `null` rendering backend
This commit is contained in:
wheremyfoodat 2023-07-18 23:26:52 +03:00 committed by GitHub
commit 5b4f6ef46c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 143 additions and 30 deletions

View file

@ -1,10 +1,14 @@
#pragma once
#include <filesystem>
#include "renderer.hpp"
// Remember to initialize every field here to its default value otherwise bad things will happen
struct EmulatorConfig {
bool shaderJitEnabled = false;
RendererType rendererType = RendererType::OpenGL;
EmulatorConfig(const std::filesystem::path& path);
void load(const std::filesystem::path& path);
void save(const std::filesystem::path& path);
};

View file

@ -25,13 +25,13 @@ enum class ROMType {
};
class Emulator {
EmulatorConfig config;
CPU cpu;
GPU gpu;
Memory memory;
Kernel kernel;
Crypto::AESEngine aesEngine;
EmulatorConfig config;
SDL_Window* window;
#ifdef PANDA3DS_ENABLE_OPENGL
@ -70,8 +70,8 @@ class Emulator {
public:
// Decides whether to reload or not reload the ROM when resetting. We use enum class over a plain bool for clarity.
// If NoReload is selected, the emulator will not reload its selected ROM. This is useful for things like booting up the emulator, or resetting to
// change ROMs. If Reload is selected, the emulator will reload its selected ROM. This is useful for eg a "reset" button that keeps the current ROM
// and just resets the emu
// change ROMs. If Reload is selected, the emulator will reload its selected ROM. This is useful for eg a "reset" button that keeps the current
// ROM and just resets the emu
enum class ReloadOption { NoReload, Reload };
Emulator();

View file

@ -1,11 +1,19 @@
#pragma once
#include <array>
#include <span>
#include <optional>
#include "PICA/pica_vertex.hpp"
#include "PICA/regs.hpp"
#include "helpers.hpp"
enum class RendererType : s8 {
// Todo: Auto = -1,
Null = 0,
OpenGL = 1,
Vulkan = 2,
};
class GPU;
class Renderer {
@ -28,6 +36,8 @@ class Renderer {
virtual ~Renderer();
static constexpr u32 vertexBufferSize = 0x10000;
static std::optional<RendererType> typeFromString(std::string inString);
static const char* typeToString(RendererType rendererType);
virtual void reset() = 0;
virtual void display() = 0; // Display the 3DS screen contents to the window

View file

@ -68,6 +68,7 @@ class RendererGL final : public Renderer {
public:
RendererGL(GPU& gpu, const std::array<u32, regNum>& internalRegs) : Renderer(gpu, internalRegs) {}
~RendererGL() override;
void reset() override;
void display() override; // Display the 3DS screen contents to the window

View file

@ -0,0 +1,17 @@
#include "renderer.hpp"
class GPU;
class RendererNull final : public Renderer {
public:
RendererNull(GPU& gpu, const std::array<u32, regNum>& internalRegs);
~RendererNull() override;
void reset() override;
void display() override;
void initGraphicsContext() override;
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) override;
void displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32 outputSize, u32 flags) override;
void drawVertices(PICA::PrimType primType, std::span<const PICA::Vertex> vertices) override;
void screenshot(const std::string& name) override;
};