1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Don't copy depth buffer if it was not cleared.

Uncleared depth buffer most likely is used as auxilary color buffer.

Fix pause screen in Mickey USA when copy depth to RDRAM is enabled, issue #85.
This commit is contained in:
Sergey Lipskiy 2015-02-17 22:10:44 +06:00
parent b7460648be
commit 34d638a0a3
4 changed files with 17 additions and 6 deletions

View File

@ -16,7 +16,7 @@ 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_pResolveDepthBufferTexture(NULL), m_resolved(false)
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)
{
glGenFramebuffers(1, &m_FBO);
}
@ -230,6 +230,12 @@ void DepthBufferList::destroy()
m_list.clear();
}
void DepthBufferList::setNotCleared()
{
for (DepthBuffers::iterator iter = m_list.begin(); iter != m_list.end(); ++iter)
iter->m_cleared = false;
}
DepthBuffer * DepthBufferList::findBuffer(u32 _address)
{
for (DepthBuffers::iterator iter = m_list.begin(); iter != m_list.end(); ++iter)
@ -288,10 +294,11 @@ void DepthBufferList::saveBuffer(u32 _address)
void DepthBufferList::clearBuffer()
{
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (!video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
if (m_pCurrent == NULL)
return;
if (m_pCurrent == NULL || m_pCurrent->m_FBO == 0)
m_pCurrent->m_cleared = true;
#ifdef GL_IMAGE_TEXTURES_SUPPORT
if (m_pCurrent->m_FBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
return;
float color[4] = {1.0f, 1.0f, 0.0f, 1.0f};
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RG32F);

View File

@ -22,6 +22,7 @@ struct DepthBuffer
GLuint m_FBO;
CachedTexture *m_pDepthImageTexture;
CachedTexture *m_pDepthBufferTexture;
bool m_cleared;
// multisampling
CachedTexture *m_pResolveDepthBufferTexture;
bool m_resolved;
@ -38,6 +39,7 @@ public:
void saveBuffer(u32 _address);
void removeBuffer(u32 _address);
void clearBuffer();
void setNotCleared();
DepthBuffer *findBuffer(u32 _address);
DepthBuffer * getCurrent() const {return m_pCurrent;}

View File

@ -861,15 +861,15 @@ bool DepthBufferToRDRAM::CopyToRDRAM( u32 _address) {
if (m_lastDList == RSP.DList) // Already read;
return false;
FrameBuffer *pBuffer = frameBufferList().findBuffer(_address);
if (pBuffer == NULL || pBuffer->m_pDepthBuffer == NULL)
if (pBuffer == NULL || pBuffer->m_pDepthBuffer == NULL || !pBuffer->m_pDepthBuffer->m_cleared)
return false;
m_lastDList = RSP.DList;
glDisable(GL_SCISSOR_TEST);
DepthBuffer * pDepthBuffer = pBuffer->m_pDepthBuffer;
const u32 address = pDepthBuffer->m_address;
glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_FBO);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
glDisable(GL_SCISSOR_TEST);
glBlitFramebuffer(
0, 0, video().getWidth(), video().getHeight(),
0, 0, pBuffer->m_width, pBuffer->m_height,

View File

@ -163,6 +163,8 @@ void RSP_ProcessDList()
RSP.uc_dstart = uc_dstart;
}
depthBufferList().setNotCleared();
if (GBI.getMicrocodeType() == Turbo3D)
RunTurbo3D();
else {