mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 06:35:40 +12:00
Move color/depth format and size to Renderer interface
The state of these values are not specific to any rendering backend and can be moved to be part of the interface itself
This commit is contained in:
parent
5b7fa5be7e
commit
666fd96e7f
3 changed files with 24 additions and 32 deletions
|
@ -14,6 +14,15 @@ class Renderer {
|
|||
static constexpr u32 regNum = 0x300; // Number of internal PICA registers
|
||||
const std::array<u32, regNum>& regs;
|
||||
|
||||
std::array<u32, 2> fbSize; // The size of the framebuffer (ie both the colour and depth buffer)'
|
||||
|
||||
u32 colourBufferLoc; // Location in 3DS VRAM for the colour buffer
|
||||
PICA::ColorFmt colourBufferFormat; // Format of the colours stored in the colour buffer
|
||||
|
||||
// Same for the depth/stencil buffer
|
||||
u32 depthBufferLoc;
|
||||
PICA::DepthFmt depthBufferFormat;
|
||||
|
||||
public:
|
||||
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs);
|
||||
virtual ~Renderer();
|
||||
|
@ -29,11 +38,19 @@ class Renderer {
|
|||
|
||||
virtual void screenshot(const std::string& name) = 0;
|
||||
|
||||
virtual void setFBSize(u32 width, u32 height) = 0;
|
||||
void setFBSize(u32 width, u32 height) {
|
||||
fbSize[0] = width;
|
||||
fbSize[1] = height;
|
||||
}
|
||||
|
||||
virtual void setColourFormat(PICA::ColorFmt format) = 0;
|
||||
virtual void setDepthFormat(PICA::DepthFmt format) = 0;
|
||||
void setColourFormat(PICA::ColorFmt format) { colourBufferFormat = format; }
|
||||
void setDepthFormat(PICA::DepthFmt format) {
|
||||
if (format == PICA::DepthFmt::Unknown1) {
|
||||
Helpers::panic("[PICA] Undocumented depth-stencil mode!");
|
||||
}
|
||||
depthBufferFormat = format;
|
||||
}
|
||||
|
||||
virtual void setColourBufferLoc(u32 loc) = 0;
|
||||
virtual void setDepthBufferLoc(u32 loc) = 0;
|
||||
void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; }
|
||||
void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; }
|
||||
};
|
|
@ -49,15 +49,6 @@ class RendererGL final : public Renderer {
|
|||
SurfaceCache<ColourBuffer, 10, true> colourBufferCache;
|
||||
SurfaceCache<Texture, 256, true> textureCache;
|
||||
|
||||
OpenGL::uvec2 fbSize; // The size of the framebuffer (ie both the colour and depth buffer)'
|
||||
|
||||
u32 colourBufferLoc; // Location in 3DS VRAM for the colour buffer
|
||||
PICA::ColorFmt colourBufferFormat; // Format of the colours stored in the colour buffer
|
||||
|
||||
// Same for the depth/stencil buffer
|
||||
u32 depthBufferLoc;
|
||||
PICA::DepthFmt depthBufferFormat;
|
||||
|
||||
// Dummy VAO/VBO for blitting the final output
|
||||
OpenGL::VertexArray dummyVAO;
|
||||
OpenGL::VertexBuffer dummyVBO;
|
||||
|
@ -88,20 +79,4 @@ class RendererGL final : public Renderer {
|
|||
|
||||
// Take a screenshot of the screen and store it in a file
|
||||
void screenshot(const std::string& name);
|
||||
|
||||
void setFBSize(u32 width, u32 height) {
|
||||
fbSize.x() = width;
|
||||
fbSize.y() = height;
|
||||
}
|
||||
|
||||
void setColourFormat(PICA::ColorFmt format) { colourBufferFormat = format; }
|
||||
void setDepthFormat(PICA::DepthFmt format) {
|
||||
if (format == PICA::DepthFmt::Unknown1) {
|
||||
Helpers::panic("[PICA] Undocumented depth-stencil mode!");
|
||||
}
|
||||
depthBufferFormat = format;
|
||||
}
|
||||
|
||||
void setColourBufferLoc(u32 loc) { colourBufferLoc = loc; }
|
||||
void setDepthBufferLoc(u32 loc) { depthBufferLoc = loc; }
|
||||
};
|
|
@ -961,7 +961,7 @@ void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 co
|
|||
OpenGL::Framebuffer RendererGL::getColourFBO() {
|
||||
// We construct a colour buffer object and see if our cache has any matching colour buffers in it
|
||||
// If not, we allocate a texture & FBO for our framebuffer and store it in the cache
|
||||
ColourBuffer sampleBuffer(colourBufferLoc, colourBufferFormat, fbSize.x(), fbSize.y());
|
||||
ColourBuffer sampleBuffer(colourBufferLoc, colourBufferFormat, fbSize[0], fbSize[1]);
|
||||
auto buffer = colourBufferCache.find(sampleBuffer);
|
||||
|
||||
if (buffer.has_value()) {
|
||||
|
@ -973,7 +973,7 @@ OpenGL::Framebuffer RendererGL::getColourFBO() {
|
|||
|
||||
void RendererGL::bindDepthBuffer() {
|
||||
// Similar logic as the getColourFBO function
|
||||
DepthBuffer sampleBuffer(depthBufferLoc, depthBufferFormat, fbSize.x(), fbSize.y());
|
||||
DepthBuffer sampleBuffer(depthBufferLoc, depthBufferFormat, fbSize[0], fbSize[1]);
|
||||
auto buffer = depthBufferCache.find(sampleBuffer);
|
||||
GLuint tex;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue