From 48959f07026f5e6fdc6efa9566a84d19367f5559 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sun, 14 Jun 2015 22:57:53 +0600 Subject: [PATCH] Revert "Correct coronas emulation in Perfect Dark." This reverts commit 36fbcd5eac64ae41a6109ff716d9fb6810abd068. Reverted commits causes issues in CBFD. Need another approach. --- src/DepthBuffer.cpp | 80 --------------------------------------------- src/DepthBuffer.h | 3 -- src/FrameBuffer.cpp | 2 ++ src/OpenGL.cpp | 11 ++++++- src/RDP.cpp | 5 ++- src/RDP.h | 3 +- src/gDP.cpp | 1 - 7 files changed, 15 insertions(+), 90 deletions(-) diff --git a/src/DepthBuffer.cpp b/src/DepthBuffer.cpp index fec8c79e..f035e72f 100644 --- a/src/DepthBuffer.cpp +++ b/src/DepthBuffer.cpp @@ -10,8 +10,6 @@ #include "FrameBuffer.h" #include "DepthBuffer.h" #include "VI.h" -#include "RDP.h" -#include "N64.h" #include "Config.h" #include "Debug.h" @@ -355,81 +353,3 @@ void DepthBuffer_Destroy() { depthBufferList().destroy(); } - -/*------------------------DepthBufferCopyRect---------------------------------*/ -class DepthBufferCopyRect -{ -public: - void addData(const OGLRender::TexturedRectParams & _params) - { - m_vecData.push_back(DepthBufferCopyRectData(_params)); - } - - void flush() - { - if (m_vecData.empty()) - return; - FrameBuffer_CopyDepthBuffer(gDP.colorImage.address); - - for (RectData::iterator it = m_vecData.begin(); it != m_vecData.end(); ++it) { - gDPTile & tile = gDP.tiles[_SHIFTR(it->w1, 24, 3)]; - tile.tmem = it->tmem; - tile.size = it->size; - gDP.textureImage.bpl = it->bpl; - gDP.textureImage.size = it->size; - gDP.textureImage.address = it->texAddress; - RDP_LoadBlock(it->w0, it->w1); - - const u32 width = (u32)(it->lrx - it->ulx); - const u32 ulx = (u32)it->ulx; - u16 * pSrc = ((u16*)TMEM) + (u32)floorf(it->uls + 0.5f); - u16 *pDst = (u16*)(RDRAM + it->address); - for (u32 x = 0; x < width; ++x) - pDst[(ulx + x) ^ 1] = swapword(pSrc[x]); - } - m_vecData.clear(); - } - - static DepthBufferCopyRect & get() - { - static DepthBufferCopyRect dbcr; - return dbcr; - } -private: - DepthBufferCopyRect() {} - ~DepthBufferCopyRect() {} - - struct DepthBufferCopyRectData - { - float ulx, lrx, uls; - u32 w0, w1; - u32 address; - u32 tmem, bpl, size, texAddress; - - DepthBufferCopyRectData(const OGLRender::TexturedRectParams & _params) - { - ulx = _params.ulx; - lrx = _params.lrx; - uls = _params.uls; - RDP_GetLastLoadBlockParams(w0, w1); - address = gDP.colorImage.address; - tmem = gDP.tiles[_SHIFTR(w1, 24, 3)].tmem; - bpl = gDP.textureImage.bpl; - size = gDP.textureImage.size; - texAddress = gDP.textureImage.address; - } - }; - - typedef std::vector RectData; - RectData m_vecData; -}; - -void AddDepthBufferCopyRectData(const OGLRender::TexturedRectParams & _params) -{ - DepthBufferCopyRect::get().addData(_params); -} - -void FlushDepthBufferCopyRects() -{ - DepthBufferCopyRect::get().flush(); -} diff --git a/src/DepthBuffer.h b/src/DepthBuffer.h index 5acb356b..bb8a5eec 100644 --- a/src/DepthBuffer.h +++ b/src/DepthBuffer.h @@ -72,7 +72,4 @@ extern const GLuint depthImageUnit; void DepthBuffer_Init(); void DepthBuffer_Destroy(); -void AddDepthBufferCopyRectData(const OGLRender::TexturedRectParams & _params); -void FlushDepthBufferCopyRects(); - #endif diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index b9df7a58..00ad9ec3 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -1096,6 +1096,8 @@ 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; diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index 30239db2..d8444938 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -884,7 +884,16 @@ bool texturedRectDepthBufferCopy(const OGLRender::TexturedRectParams & _params) pBuffer->m_cleared = true; if (config.frameBufferEmulation.copyDepthToRDRAM == 0) return true; - AddDepthBufferCopyRectData(_params); + if (FrameBuffer_CopyDepthBuffer(gDP.colorImage.address)) + RDP_RepeatLastLoadBlock(); + + const u32 width = (u32)(_params.lrx - _params.ulx); + const u32 ulx = (u32)_params.ulx; + u16 * pSrc = ((u16*)TMEM) + (u32)floorf(_params.uls + 0.5f); + u16 *pDst = (u16*)(RDRAM + gDP.colorImage.address); + for (u32 x = 0; x < width; ++x) + pDst[(ulx + x) ^ 1] = swapword(pSrc[x]); + return true; } return false; diff --git a/src/RDP.cpp b/src/RDP.cpp index 4ee68ef5..d0ccd8e2 100644 --- a/src/RDP.cpp +++ b/src/RDP.cpp @@ -137,10 +137,9 @@ void RDP_LoadBlock( u32 w0, u32 w1 ) _SHIFTR( w1, 0, 12 ) ); // dxt } -void RDP_GetLastLoadBlockParams(u32 & _w0, u32 & _w1) +void RDP_RepeatLastLoadBlock() { - _w0 = lbw0; - _w1 = lbw1; + RDP_LoadBlock(lbw0, lbw1); } void RDP_SetTileSize( u32 w0, u32 w1 ) diff --git a/src/RDP.h b/src/RDP.h index 647e417a..da90f03d 100644 --- a/src/RDP.h +++ b/src/RDP.h @@ -17,8 +17,7 @@ extern RDPInfo RDP; void RDP_Init(); void RDP_Half_1(u32 _c); void RDP_ProcessRDPList(); -void RDP_LoadBlock(u32 w0, u32 w1); -void RDP_GetLastLoadBlockParams(u32 & _w0, u32 & _w1); +void RDP_RepeatLastLoadBlock(); void RDP_SetScissor(u32 w0, u32 w1); #endif diff --git a/src/gDP.cpp b/src/gDP.cpp index 7168d339..5b3a4767 100644 --- a/src/gDP.cpp +++ b/src/gDP.cpp @@ -758,7 +758,6 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry ) // Game may use depth texture as auxilary color texture. Example: Mario Tennis // If color is not depth clear color, that is most likely the case if (gDP.fillColor.color == DepthClearColor) { - FlushDepthBufferCopyRects(); gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color); render.clearDepthBuffer(uly, lry); return;