aboutsummaryrefslogtreecommitdiff
path: root/src/GPU3D_Soft.h
diff options
context:
space:
mode:
authorJesse Talavera <jesse@jesse.tg>2023-12-15 08:53:31 -0500
committerGitHub <noreply@github.com>2023-12-15 14:53:31 +0100
commitc867a7f1c09b3c5f07e0772fcddabce07bcd7fe7 (patch)
treec8f7fc0b351ff945b4e581c63873dbd460b2aa32 /src/GPU3D_Soft.h
parent6f47c9ed4c0e5b1035089805f272c6965343f113 (diff)
Make the initial 3D renderer configurable via `NDSArgs` (#1913)
* Allow 3D renderers to be created without passing `GPU` to the constructor * Make the initial 3D renderer configurable via `NDSArgs` * Fix a compiler error
Diffstat (limited to 'src/GPU3D_Soft.h')
-rw-r--r--src/GPU3D_Soft.h49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h
index f405b2d..8fb4201 100644
--- a/src/GPU3D_Soft.h
+++ b/src/GPU3D_Soft.h
@@ -29,19 +29,19 @@ namespace melonDS
class SoftRenderer : public Renderer3D
{
public:
- SoftRenderer(melonDS::GPU& gpu, bool threaded = false) noexcept;
+ SoftRenderer(bool threaded = false) noexcept;
~SoftRenderer() override;
- void Reset() override;
+ void Reset(GPU& gpu) override;
- void SetThreaded(bool threaded) noexcept;
+ void SetThreaded(bool threaded, GPU& gpu) noexcept;
[[nodiscard]] bool IsThreaded() const noexcept { return Threaded; }
- void VCount144() override;
- void RenderFrame() override;
- void RestartFrame() override;
+ void VCount144(GPU& gpu) override;
+ void RenderFrame(GPU& gpu) override;
+ void RestartFrame(GPU& gpu) override;
u32* GetLine(int line) override;
- void SetupRenderThread();
+ void SetupRenderThread(GPU& gpu);
void StopRenderThread();
private:
// Notes on the interpolator:
@@ -429,16 +429,16 @@ private:
};
template <typename T>
- inline T ReadVRAM_Texture(u32 addr) const
+ inline T ReadVRAM_Texture(u32 addr, const GPU& gpu) const
{
- return *(T*)&GPU.VRAMFlat_Texture[addr & 0x7FFFF];
+ return *(T*)&gpu.VRAMFlat_Texture[addr & 0x7FFFF];
}
template <typename T>
- inline T ReadVRAM_TexPal(u32 addr) const
+ inline T ReadVRAM_TexPal(u32 addr, const GPU& gpu) const
{
- return *(T*)&GPU.VRAMFlat_TexPal[addr & 0x1FFFF];
+ return *(T*)&gpu.VRAMFlat_TexPal[addr & 0x1FFFF];
}
- u32 AlphaBlend(u32 srccolor, u32 dstcolor, u32 alpha) const noexcept;
+ u32 AlphaBlend(const GPU3D& gpu3d, u32 srccolor, u32 dstcolor, u32 alpha) const noexcept;
struct RendererPolygon
{
@@ -452,23 +452,22 @@ private:
};
- melonDS::GPU& GPU;
RendererPolygon PolygonList[2048];
- void TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const;
- u32 RenderPixel(const Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t) const;
- void PlotTranslucentPixel(u32 pixeladdr, u32 color, u32 z, u32 polyattr, u32 shadow);
+ void TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const;
+ u32 RenderPixel(const GPU& gpu, const Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t) const;
+ void PlotTranslucentPixel(const GPU3D& gpu3d, u32 pixeladdr, u32 color, u32 z, u32 polyattr, u32 shadow);
void SetupPolygonLeftEdge(RendererPolygon* rp, s32 y) const;
void SetupPolygonRightEdge(RendererPolygon* rp, s32 y) const;
void SetupPolygon(RendererPolygon* rp, Polygon* polygon) const;
- void RenderShadowMaskScanline(RendererPolygon* rp, s32 y);
- void RenderPolygonScanline(RendererPolygon* rp, s32 y);
- void RenderScanline(s32 y, int npolys);
- u32 CalculateFogDensity(u32 pixeladdr) const;
- void ScanlineFinalPass(s32 y);
- void ClearBuffers();
- void RenderPolygons(bool threaded, Polygon** polygons, int npolys);
-
- void RenderThreadFunc();
+ void RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* rp, s32 y);
+ void RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s32 y);
+ void RenderScanline(const GPU& gpu, s32 y, int npolys);
+ u32 CalculateFogDensity(const GPU3D& gpu3d, u32 pixeladdr) const;
+ void ScanlineFinalPass(const GPU3D& gpu3d, s32 y);
+ void ClearBuffers(const GPU& gpu);
+ void RenderPolygons(const GPU& gpu, bool threaded, Polygon** polygons, int npolys);
+
+ void RenderThreadFunc(GPU& gpu);
// buffer dimensions are 258x194 to add a offscreen 1px border
// which simplifies edge marking tests