mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
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
This commit is contained in:

committed by
GitHub

parent
88072a02c5
commit
4558be0d8e
@ -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);
|
||||
|
Reference in New Issue
Block a user