diff options
author | Jesse Talavera-Greenberg <jesse@jesse.tg> | 2023-11-09 15:54:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 21:54:51 +0100 |
commit | 4558be0d8eb79d276c89392b9410e6edb649db95 (patch) | |
tree | 3e2b37e31b38337adec64c5391e57ddf45af5d23 /src/GPU3D_Soft.h | |
parent | 88072a02c523e26390af6bd726608b3e567f996f (diff) |
Refactor the GPU to be object-oriented (#1873)
* Refactor GPU3D to be an object
- Who has two thumbs and is the sworn enemy of global state? This guy!
* Refactor GPU itself to be an object
- Wow, it's used in a lot of places
- Also introduce a new `Melon` namespace for a few classes
- I expect other classes will be moved into `Melon` over time
* Change signature of Renderer3D::SetRenderSettings
- Make it noexcept, and its argument const
* Remove some stray whitespace
Diffstat (limited to 'src/GPU3D_Soft.h')
-rw-r--r-- | src/GPU3D_Soft.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index 16257df..b1cfb2f 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -18,6 +18,7 @@ #pragma once +#include "GPU.h" #include "GPU3D.h" #include "Platform.h" #include <thread> @@ -28,11 +29,11 @@ namespace GPU3D class SoftRenderer : public Renderer3D { public: - SoftRenderer() noexcept; + SoftRenderer(Melon::GPU& gpu) noexcept; virtual ~SoftRenderer() override; virtual void Reset() override; - virtual void SetRenderSettings(GPU::RenderSettings& settings) override; + virtual void SetRenderSettings(const Melon::RenderSettings& settings) noexcept override; virtual void VCount144() override; virtual void RenderFrame() override; @@ -429,13 +430,14 @@ private: template <typename T> inline T ReadVRAM_Texture(u32 addr) { - return *(T*)&GPU::VRAMFlat_Texture[addr & 0x7FFFF]; + return *(T*)&GPU.VRAMFlat_Texture[addr & 0x7FFFF]; } template <typename T> inline T ReadVRAM_TexPal(u32 addr) { - return *(T*)&GPU::VRAMFlat_TexPal[addr & 0x1FFFF]; + return *(T*)&GPU.VRAMFlat_TexPal[addr & 0x1FFFF]; } + u32 AlphaBlend(u32 srccolor, u32 dstcolor, u32 alpha) noexcept; struct RendererPolygon { @@ -449,6 +451,7 @@ private: }; + Melon::GPU& GPU; RendererPolygon PolygonList[2048]; void TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha); u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t); |