diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 00ad9ec3..4af272a5 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -47,7 +47,7 @@ class DepthBufferToRDRAM { public: DepthBufferToRDRAM() : - m_FBO(0), m_PBO(0), m_pColorTexture(NULL), m_pDepthTexture(NULL), m_lastDList(0) + m_FBO(0), m_PBO(0), m_pColorTexture(NULL), m_pDepthTexture(NULL) {} void Init(); @@ -60,7 +60,6 @@ private: GLuint m_PBO; CachedTexture * m_pColorTexture; CachedTexture * m_pDepthTexture; - u32 m_lastDList; }; #endif // GLES2 @@ -1096,13 +1095,10 @@ void DepthBufferToRDRAM::Destroy() { bool DepthBufferToRDRAM::CopyToRDRAM( u32 _address) { if (VI.width == 0) // H width is zero. Don't copy return false; - if (m_lastDList == RSP.DList) // Already read; - return true; FrameBuffer *pBuffer = frameBufferList().findBuffer(_address); if (pBuffer == NULL || pBuffer->m_width < VI.width || pBuffer->m_pDepthBuffer == NULL || !pBuffer->m_pDepthBuffer->m_cleared) return false; - m_lastDList = RSP.DList; DepthBuffer * pDepthBuffer = pBuffer->m_pDepthBuffer; const u32 address = pDepthBuffer->m_address; if (address + VI.width*VI.height*2 > RDRAMSize) diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index d8444938..012c9996 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -876,16 +876,21 @@ bool texturedRectDepthBufferCopy(const OGLRender::TexturedRectParams & _params) // Data from depth buffer loaded into TMEM and then rendered to RDRAM by texrect. // Works only with depth buffer emulation enabled. // Load of arbitrary data to that area causes weird camera rotation in CBFD. + static u32 lastDList = 0xFFFFFFFF; const gDPTile * pTile = gSP.textureTile[0]; if (pTile->loadType == LOADTYPE_BLOCK && gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) { + if (config.frameBufferEmulation.copyDepthToRDRAM == 0) + return true; FrameBuffer * pBuffer = frameBufferList().getCurrent(); if (pBuffer == NULL) return true; pBuffer->m_cleared = true; - if (config.frameBufferEmulation.copyDepthToRDRAM == 0) - return true; - if (FrameBuffer_CopyDepthBuffer(gDP.colorImage.address)) - RDP_RepeatLastLoadBlock(); + if (lastDList != RSP.DList) { + lastDList = RSP.DList; + if (!FrameBuffer_CopyDepthBuffer(gDP.colorImage.address)) + return true; + } + RDP_RepeatLastLoadBlock(); const u32 width = (u32)(_params.lrx - _params.ulx); const u32 ulx = (u32)_params.ulx;