From efdfa31eda0bc0ba7bcb0449cf8ff2097ce16998 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sat, 18 Oct 2014 22:38:32 +0700 Subject: [PATCH] Make FrameBuffer_CopyDepthBuffer() return bool. --- FrameBuffer.cpp | 21 +++++++++++++-------- FrameBuffer.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 988613a4..90968656 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -56,7 +56,7 @@ class DepthBufferToRDRAM { public: DepthBufferToRDRAM() : - m_FBO(0), m_pTexture(NULL), m_curIndex(0) + m_FBO(0), m_pTexture(NULL), m_curIndex(0), m_lastDList(0) { m_aPBO[0] = m_aPBO[1] = 0; m_aAddress[0] = m_aAddress[1] = 0; @@ -65,13 +65,14 @@ public: void Init(); void Destroy(); - void CopyToRDRAM( u32 address ); + bool CopyToRDRAM( u32 address ); private: GLuint m_FBO; CachedTexture * m_pTexture; u32 m_aAddress[2]; u32 m_curIndex; + u32 m_lastDList; GLuint m_aPBO[2]; }; #endif // GLES2 @@ -721,13 +722,16 @@ void DepthBufferToRDRAM::Destroy() { m_aAddress[0] = m_aAddress[1] = 0; } -void DepthBufferToRDRAM::CopyToRDRAM( u32 address) { +bool DepthBufferToRDRAM::CopyToRDRAM( u32 address) { if (VI.width == 0) // H width is zero. Don't copy - return; + return false; + if (m_lastDList == RSP.DList) // Already read; + return false; FrameBuffer *pBuffer = frameBufferList().findBuffer(address); if (pBuffer == NULL || pBuffer->m_pDepthBuffer == NULL) - return; + return false; + m_lastDList = RSP.DList; glDisable(GL_SCISSOR_TEST); DepthBuffer * pDepthBuffer = pBuffer->m_pDepthBuffer; address = pDepthBuffer->m_address; @@ -755,7 +759,7 @@ void DepthBufferToRDRAM::CopyToRDRAM( u32 address) { GLubyte* pixelData = (GLubyte*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); if(pixelData == NULL) { glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); - return; + return false; } u16 * ptr_src = (u16*)pixelData; @@ -773,12 +777,13 @@ void DepthBufferToRDRAM::CopyToRDRAM( u32 address) { glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glEnable(GL_SCISSOR_TEST); + return true; } #endif // GLES2 -void FrameBuffer_CopyDepthBuffer( u32 address ) { +bool FrameBuffer_CopyDepthBuffer( u32 address ) { #ifndef GLES2 - g_dbToRDRAM.CopyToRDRAM(address); + return g_dbToRDRAM.CopyToRDRAM(address); #endif } diff --git a/FrameBuffer.h b/FrameBuffer.h index 6568a9c3..f9207337 100644 --- a/FrameBuffer.h +++ b/FrameBuffer.h @@ -66,7 +66,7 @@ void FrameBuffer_Init(); void FrameBuffer_Destroy(); void FrameBuffer_CopyToRDRAM( u32 address, bool bSync ); void FrameBuffer_CopyFromRDRAM( u32 address, bool bUseAlpha ); -void FrameBuffer_CopyDepthBuffer( u32 address ); +bool FrameBuffer_CopyDepthBuffer( u32 address ); void FrameBuffer_ActivateBufferTexture(s16 t, FrameBuffer *pBuffer); void FrameBuffer_ActivateBufferTextureBG(s16 t, FrameBuffer *pBuffer);