mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-18 11:41:31 +12:00
renderer_gl: Proper viewport rendering
* I've also corrected a mistake made in the displayTransfer/textureCopy rectangles.
This commit is contained in:
parent
1544710e36
commit
d6e5f658d6
2 changed files with 15 additions and 8 deletions
|
@ -22,6 +22,7 @@ namespace PICA {
|
||||||
ShaderOutputCount = 0x4F,
|
ShaderOutputCount = 0x4F,
|
||||||
ShaderOutmap0 = 0x50,
|
ShaderOutmap0 = 0x50,
|
||||||
|
|
||||||
|
ViewportXY = 0x68,
|
||||||
DepthmapEnable = 0x6D,
|
DepthmapEnable = 0x6D,
|
||||||
|
|
||||||
// Texture registers
|
// Texture registers
|
||||||
|
|
|
@ -369,8 +369,8 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBlending();
|
setupBlending();
|
||||||
OpenGL::Framebuffer poop = getColourFBO();
|
auto poop = getColourBuffer(colourBufferLoc, colourBufferFormat, fbSize[0], fbSize[1]);
|
||||||
poop.bind(OpenGL::DrawAndReadFramebuffer);
|
poop->fbo.bind(OpenGL::DrawAndReadFramebuffer);
|
||||||
|
|
||||||
const u32 depthControl = regs[PICA::InternalRegs::DepthAndColorMask];
|
const u32 depthControl = regs[PICA::InternalRegs::DepthAndColorMask];
|
||||||
const bool depthWrite = regs[PICA::InternalRegs::DepthBufferWrite];
|
const bool depthWrite = regs[PICA::InternalRegs::DepthBufferWrite];
|
||||||
|
@ -413,10 +413,12 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
updateLightingLUT();
|
updateLightingLUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Actually use this
|
const GLsizei viewportX = regs[PICA::InternalRegs::ViewportXY] & 0x3ff;
|
||||||
GLsizei viewportWidth = GLsizei(f24::fromRaw(regs[PICA::InternalRegs::ViewportWidth] & 0xffffff).toFloat32() * 2.0f);
|
const GLsizei viewportY = (regs[PICA::InternalRegs::ViewportXY] >> 16) & 0x3ff;
|
||||||
GLsizei viewportHeight = GLsizei(f24::fromRaw(regs[PICA::InternalRegs::ViewportHeight] & 0xffffff).toFloat32() * 2.0f);
|
const GLsizei viewportWidth = GLsizei(f24::fromRaw(regs[PICA::InternalRegs::ViewportWidth] & 0xffffff).toFloat32() * 2.0f);
|
||||||
OpenGL::setViewport(viewportWidth, viewportHeight);
|
const GLsizei viewportHeight = GLsizei(f24::fromRaw(regs[PICA::InternalRegs::ViewportHeight] & 0xffffff).toFloat32() * 2.0f);
|
||||||
|
const auto rect = poop->getSubRect(colourBufferLoc, fbSize[0], fbSize[1]);
|
||||||
|
OpenGL::setViewport(rect.left + viewportX, rect.bottom + viewportY, viewportWidth, viewportHeight);
|
||||||
|
|
||||||
const u32 stencilConfig = regs[PICA::InternalRegs::StencilTest];
|
const u32 stencilConfig = regs[PICA::InternalRegs::StencilTest];
|
||||||
const bool stencilEnable = getBit<0>(stencilConfig);
|
const bool stencilEnable = getBit<0>(stencilConfig);
|
||||||
|
@ -628,8 +630,10 @@ void RendererGL::displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u
|
||||||
// Blit the framebuffers
|
// Blit the framebuffers
|
||||||
srcFramebuffer->fbo.bind(OpenGL::ReadFramebuffer);
|
srcFramebuffer->fbo.bind(OpenGL::ReadFramebuffer);
|
||||||
destFramebuffer->fbo.bind(OpenGL::DrawFramebuffer);
|
destFramebuffer->fbo.bind(OpenGL::DrawFramebuffer);
|
||||||
|
gl.disableScissor();
|
||||||
|
|
||||||
glBlitFramebuffer(
|
glBlitFramebuffer(
|
||||||
srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, destRect.left, destRect.top, destRect.right, destRect.bottom, GL_COLOR_BUFFER_BIT,
|
srcRect.left, srcRect.bottom, srcRect.right, srcRect.top, destRect.left, destRect.bottom, destRect.right, destRect.top, GL_COLOR_BUFFER_BIT,
|
||||||
GL_LINEAR
|
GL_LINEAR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -694,8 +698,10 @@ void RendererGL::textureCopy(u32 inputAddr, u32 outputAddr, u32 totalBytes, u32
|
||||||
// Blit the framebuffers
|
// Blit the framebuffers
|
||||||
srcFramebuffer->fbo.bind(OpenGL::ReadFramebuffer);
|
srcFramebuffer->fbo.bind(OpenGL::ReadFramebuffer);
|
||||||
destFramebuffer->fbo.bind(OpenGL::DrawFramebuffer);
|
destFramebuffer->fbo.bind(OpenGL::DrawFramebuffer);
|
||||||
|
gl.disableScissor();
|
||||||
|
|
||||||
glBlitFramebuffer(
|
glBlitFramebuffer(
|
||||||
srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, destRect.left, destRect.top, destRect.right, destRect.bottom, GL_COLOR_BUFFER_BIT,
|
srcRect.left, srcRect.bottom, srcRect.right, srcRect.top, destRect.left, destRect.bottom, destRect.right, destRect.top, GL_COLOR_BUFFER_BIT,
|
||||||
GL_LINEAR
|
GL_LINEAR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue