mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Limit depth buffer copy to RDRAM with top and bottom bounds of fillrect command.
Fixed regression issues #436 and #437 Issue #330 with Roadsters is fixed too.
This commit is contained in:
parent
b205529aec
commit
0c886e26c3
|
@ -16,13 +16,15 @@ const GLuint ZlutImageUnit = 0;
|
|||
const GLuint TlutImageUnit = 1;
|
||||
const GLuint depthImageUnit = 2;
|
||||
|
||||
DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_FBO(0), m_pDepthImageTexture(NULL), m_pDepthBufferTexture(NULL), m_cleared(false), m_pResolveDepthBufferTexture(NULL), m_resolved(false)
|
||||
DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_uly(0), m_lry(0),
|
||||
m_FBO(0), m_pDepthImageTexture(NULL), m_pDepthBufferTexture(NULL),
|
||||
m_cleared(false), m_pResolveDepthBufferTexture(NULL), m_resolved(false)
|
||||
{
|
||||
glGenFramebuffers(1, &m_FBO);
|
||||
}
|
||||
|
||||
DepthBuffer::DepthBuffer(DepthBuffer && _other) :
|
||||
m_address(_other.m_address), m_width(_other.m_width),
|
||||
m_address(_other.m_address), m_width(_other.m_width), m_uly(_other.m_uly), m_lry(_other.m_lry),
|
||||
m_FBO(_other.m_FBO), m_pDepthImageTexture(_other.m_pDepthImageTexture), m_pDepthBufferTexture(_other.m_pDepthBufferTexture),
|
||||
m_pResolveDepthBufferTexture(_other.m_pResolveDepthBufferTexture), m_resolved(_other.m_resolved)
|
||||
{
|
||||
|
@ -84,7 +86,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
|||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
|
||||
|
||||
depthBufferList().clearBuffer();
|
||||
depthBufferList().clearBuffer(0, VI.height);
|
||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||
}
|
||||
|
||||
|
@ -306,11 +308,13 @@ void DepthBufferList::saveBuffer(u32 _address)
|
|||
|
||||
}
|
||||
|
||||
void DepthBufferList::clearBuffer()
|
||||
void DepthBufferList::clearBuffer(u32 _uly, u32 _lry)
|
||||
{
|
||||
if (m_pCurrent == NULL)
|
||||
return;
|
||||
m_pCurrent->m_cleared = true;
|
||||
m_pCurrent->m_uly = _uly;
|
||||
m_pCurrent->m_lry = _lry;
|
||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||
if (m_pCurrent->m_FBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@ struct DepthBuffer
|
|||
void bindDepthImageTexture();
|
||||
|
||||
u32 m_address, m_width;
|
||||
u32 m_uly, m_lry; // Top and bottom bounds of fillrect command.
|
||||
GLuint m_FBO;
|
||||
CachedTexture *m_pDepthImageTexture;
|
||||
CachedTexture *m_pDepthBufferTexture;
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
void destroy();
|
||||
void saveBuffer(u32 _address);
|
||||
void removeBuffer(u32 _address);
|
||||
void clearBuffer();
|
||||
void clearBuffer(u32 _uly, u32 _lry);
|
||||
void setNotCleared();
|
||||
DepthBuffer *findBuffer(u32 _address);
|
||||
DepthBuffer * getCurrent() const {return m_pCurrent;}
|
||||
|
|
|
@ -1106,9 +1106,9 @@ bool DepthBufferToRDRAM::CopyToRDRAM( u32 _address) {
|
|||
f32 * ptr_src = (f32*)pixelData;
|
||||
u16 *ptr_dst = (u16*)(RDRAM + address);
|
||||
const u16 * const zLUT = depthBufferList().getZLUT();
|
||||
const u32 height = _cutHeight(address, VI.height, pBuffer->m_width * 2);
|
||||
const u32 height = _cutHeight(address, min(VI.height, pDepthBuffer->m_lry), pBuffer->m_width * 2);
|
||||
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
for (u32 y = pDepthBuffer->m_uly; y < height; ++y) {
|
||||
for (u32 x = 0; x < VI.width; ++x) {
|
||||
f32 z = ptr_src[x + (height - y - 1)*VI.width];
|
||||
u32 idx = 0x3FFFF;
|
||||
|
|
|
@ -1144,12 +1144,12 @@ void OGLRender::drawText(const char *_pText, float x, float y)
|
|||
TextDrawer::get().renderText(_pText, x, y);
|
||||
}
|
||||
|
||||
void OGLRender::clearDepthBuffer()
|
||||
void OGLRender::clearDepthBuffer(u32 _uly, u32 _lry)
|
||||
{
|
||||
if (config.frameBufferEmulation.enable && frameBufferList().getCurrent() == NULL)
|
||||
return;
|
||||
|
||||
depthBufferList().clearBuffer();
|
||||
depthBufferList().clearBuffer(_uly, _lry);
|
||||
|
||||
glDisable( GL_SCISSOR_TEST );
|
||||
glDepthMask( TRUE );
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
};
|
||||
void drawTexturedRect(const TexturedRectParams & _params);
|
||||
void drawText(const char *_pText, float x, float y);
|
||||
void clearDepthBuffer();
|
||||
void clearDepthBuffer(u32 _uly, u32 _lry);
|
||||
void clearColorBuffer( float * _pColor );
|
||||
|
||||
int getTrianglesCount() const {return triangles.num;}
|
||||
|
|
|
@ -757,13 +757,13 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
// If color is not depth clear color, that is most likely the case
|
||||
if (gDP.fillColor.color == DepthClearColor) {
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
render.clearDepthBuffer();
|
||||
render.clearDepthBuffer(uly, lry);
|
||||
return;
|
||||
}
|
||||
} else if (gDP.fillColor.color == DepthClearColor && gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
depthBufferList().saveBuffer(gDP.colorImage.address);
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
render.clearDepthBuffer();
|
||||
render.clearDepthBuffer(uly, lry);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user