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
@ -20,7 +20,7 @@
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
#include "GPU3D.h"
|
||||
|
||||
#include "GPU_OpenGL.h"
|
||||
#include "OpenGLSupport.h"
|
||||
|
||||
namespace melonDS
|
||||
@ -30,22 +30,31 @@ class GPU;
|
||||
class GLRenderer : public Renderer3D
|
||||
{
|
||||
public:
|
||||
virtual ~GLRenderer() override;
|
||||
virtual void Reset() override;
|
||||
~GLRenderer() override;
|
||||
void Reset() override;
|
||||
|
||||
virtual void SetRenderSettings(const RenderSettings& settings) noexcept override;
|
||||
void SetRenderSettings(bool betterpolygons, int scale) noexcept;
|
||||
void SetBetterPolygons(bool betterpolygons) noexcept;
|
||||
void SetScaleFactor(int scale) noexcept;
|
||||
[[nodiscard]] bool GetBetterPolygons() const noexcept { return BetterPolygons; }
|
||||
[[nodiscard]] int GetScaleFactor() const noexcept { return ScaleFactor; }
|
||||
|
||||
virtual void VCount144() override {};
|
||||
virtual void RenderFrame() override;
|
||||
virtual u32* GetLine(int line) override;
|
||||
void VCount144() override {};
|
||||
void RenderFrame() override;
|
||||
void Stop() override;
|
||||
u32* GetLine(int line) override;
|
||||
|
||||
void SetupAccelFrame();
|
||||
void PrepareCaptureFrame();
|
||||
void PrepareCaptureFrame() override;
|
||||
void Blit() override;
|
||||
|
||||
[[nodiscard]] const GLCompositor& GetCompositor() const noexcept { return CurGLCompositor; }
|
||||
GLCompositor& GetCompositor() noexcept { return CurGLCompositor; }
|
||||
|
||||
static std::unique_ptr<GLRenderer> New(melonDS::GPU& gpu) noexcept;
|
||||
private:
|
||||
// Used by New()
|
||||
GLRenderer(melonDS::GPU& gpu) noexcept;
|
||||
GLRenderer(GLCompositor&& compositor, GPU& gpu) noexcept;
|
||||
|
||||
// GL version requirements
|
||||
// * texelFetch: 3.0 (GLSL 1.30) (3.2/1.50 for MS)
|
||||
@ -66,6 +75,7 @@ private:
|
||||
};
|
||||
|
||||
melonDS::GPU& GPU;
|
||||
GLCompositor CurGLCompositor;
|
||||
RendererPolygon PolygonList[2048] {};
|
||||
|
||||
bool BuildRenderShader(u32 flags, const char* vs, const char* fs);
|
||||
|
Reference in New Issue
Block a user