1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

New fix for issue #563. It does not break CBFD work.

This commit is contained in:
Sergey Lipskiy 2015-06-14 23:29:33 +06:00
parent 48959f0702
commit eb23f38934
2 changed files with 10 additions and 9 deletions

View File

@ -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)

View File

@ -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;