mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 23:29:55 -06:00
Clean up the 3D renderer for enhanced flexibility (#1895)
* Give `GPU2D::Unit` a virtual destructor - Undefined behavior avoided! * Add an `array2d` alias * Move various parts of `GPU2D::SoftRenderer` to `constexpr` - `SoftRenderer::MosaicTable` is now initialized at compile-time - Most of the `SoftRenderer::Color*` functions are now `constexpr` - The aforementioned functions are used with a constant value in at least one place, so they'll be at least partially computed at compile-time * Generalize `GLRenderer::PrepareCaptureFrame` - Declare it in the base `Renderer3D` class, but make it empty * Remove unneeded `virtual` specifiers * Store `Framebuffer`'s memory in `unique_ptr`s - Reduce the risk of leaks this way * Clean up how `GLCompositor` is initialized - Return it as an `std::optional` instead of a `std::unique_ptr` - Make `GLCompositor` movable - Replace `GLCompositor`'s plain arrays with `std::array` to simplify moving * Pass `GPU` to `GLCompositor`'s important functions instead of passing it to the constructor * Move `GLCompositor` to be a field within `GLRenderer` - Some methods were moved up and made `virtual` * Fix some linker errors * Set the renderer in the frontend * Remove unneeded `virtual` specifiers * Remove `RenderSettings` in favor of just exposing the relevant member variables * Update the frontend to accommodate the core changes * Add `constexpr` and `const` to places in the interpolator * Qualify references to `size_t` * Construct the `optional` directly instead of using `make_optional` - It makes the Linux build choke - I think it's because `GLCompositor`'s constructor is `private`
This commit is contained in:

committed by
GitHub

parent
e973236203
commit
7caddf9615
16
src/GPU3D.h
16
src/GPU3D.h
@ -27,7 +27,7 @@
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
struct RenderSettings;
|
||||
class GPU;
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
@ -86,7 +86,7 @@ class NDS;
|
||||
class GPU3D
|
||||
{
|
||||
public:
|
||||
GPU3D(melonDS::NDS& nds) noexcept;
|
||||
GPU3D(melonDS::NDS& nds, std::unique_ptr<Renderer3D>&& renderer = nullptr) noexcept;
|
||||
~GPU3D() noexcept = default;
|
||||
void Reset() noexcept;
|
||||
|
||||
@ -106,6 +106,7 @@ public:
|
||||
void VCount215() noexcept;
|
||||
|
||||
void RestartFrame() noexcept;
|
||||
void Stop() noexcept;
|
||||
|
||||
void SetRenderXPos(u16 xpos) noexcept;
|
||||
[[nodiscard]] u16 GetRenderXPos() const noexcept { return RenderXPos; }
|
||||
@ -114,8 +115,8 @@ public:
|
||||
void WriteToGXFIFO(u32 val) noexcept;
|
||||
|
||||
[[nodiscard]] bool IsRendererAccelerated() const noexcept;
|
||||
[[nodiscard]] Renderer3D* GetCurrentRenderer() noexcept { return CurrentRenderer.get(); }
|
||||
[[nodiscard]] const Renderer3D* GetCurrentRenderer() const noexcept { return CurrentRenderer.get(); }
|
||||
[[nodiscard]] Renderer3D& GetCurrentRenderer() noexcept { return *CurrentRenderer; }
|
||||
[[nodiscard]] const Renderer3D& GetCurrentRenderer() const noexcept { return *CurrentRenderer; }
|
||||
void SetCurrentRenderer(std::unique_ptr<Renderer3D>&& renderer) noexcept { CurrentRenderer = std::move(renderer); }
|
||||
|
||||
u8 Read8(u32 addr) noexcept;
|
||||
@ -124,6 +125,7 @@ public:
|
||||
void Write8(u32 addr, u8 val) noexcept;
|
||||
void Write16(u32 addr, u16 val) noexcept;
|
||||
void Write32(u32 addr, u32 val) noexcept;
|
||||
void Blit() noexcept;
|
||||
private:
|
||||
melonDS::NDS& NDS;
|
||||
typedef union
|
||||
@ -338,13 +340,13 @@ public:
|
||||
// are more detailed "traits" that we can ask of the Renderer3D type
|
||||
const bool Accelerated;
|
||||
|
||||
virtual void SetRenderSettings(const RenderSettings& settings) noexcept = 0;
|
||||
|
||||
virtual void VCount144() {};
|
||||
|
||||
virtual void Stop() {}
|
||||
virtual void RenderFrame() = 0;
|
||||
virtual void RestartFrame() {};
|
||||
virtual u32* GetLine(int line) = 0;
|
||||
virtual void Blit() {};
|
||||
virtual void PrepareCaptureFrame() {}
|
||||
protected:
|
||||
Renderer3D(bool Accelerated);
|
||||
};
|
||||
|
Reference in New Issue
Block a user