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

Fix pause screen in Conker BFD.

How it work:
- content of previous main frame buffer is copied into depth buffer area.
- CPU applies blur to th eimage in depth buffer area.
- Depth buffer is used as background texture for pause screen.

Solution:
1. Do not use depth buffer FBO as texture. Image must be load from RDRAM.
2. If current color image is depth image and previous color buffer is used as
texture for it, copy content of color image in RDRAM to depth image area.
This commit is contained in:
Sergey Lipskiy 2015-02-27 19:51:53 +06:00
parent 62aa6495ec
commit bc34838db6
5 changed files with 18 additions and 8 deletions

View File

@ -146,7 +146,7 @@ struct Config
};
#define hack_Ogre64 (1<<0) //Ogre Battle 64 background copy
#define hack_MarioGolf (1<<1) //Mario golf replays
#define hack_noDepthFrameBuffers (1<<1) //Do not use depth buffers as texture
extern Config config;

View File

@ -95,7 +95,7 @@ DepthBufferToRDRAM g_dbToRDRAM;
#endif
RDRAMtoFrameBuffer g_RDRAMtoFB;
FrameBuffer::FrameBuffer() : m_cleared(false), m_pLoadTile(NULL), m_pDepthBuffer(NULL), m_pResolveTexture(NULL), m_resolveFBO(0), m_resolved(false)
FrameBuffer::FrameBuffer() : m_cleared(false), m_isDepthBuffer(false), m_copiedToRDRAM(false), m_pLoadTile(NULL), m_pDepthBuffer(NULL), m_pResolveTexture(NULL), m_resolveFBO(0), m_resolved(false)
{
m_pTexture = textureCache().addFrameBufferTexture();
glGenFramebuffers(1, &m_FBO);
@ -104,7 +104,7 @@ FrameBuffer::FrameBuffer() : m_cleared(false), m_pLoadTile(NULL), m_pDepthBuffer
FrameBuffer::FrameBuffer(FrameBuffer && _other) :
m_startAddress(_other.m_startAddress), m_endAddress(_other.m_endAddress),
m_size(_other.m_size), m_width(_other.m_width), m_height(_other.m_height), m_fillcolor(_other.m_fillcolor),
m_scaleX(_other.m_scaleX), m_scaleY(_other.m_scaleY), m_cleared(_other.m_cleared), m_cfb(_other.m_cfb),
m_scaleX(_other.m_scaleX), m_scaleY(_other.m_scaleY), m_cleared(_other.m_cleared), m_cfb(_other.m_cfb), m_isDepthBuffer(_other.m_isDepthBuffer), m_copiedToRDRAM(_other.m_copiedToRDRAM),
m_FBO(_other.m_FBO), m_pLoadTile(_other.m_pLoadTile), m_pTexture(_other.m_pTexture), m_pDepthBuffer(_other.m_pDepthBuffer),
m_pResolveTexture(_other.m_pResolveTexture), m_resolveFBO(_other.m_resolveFBO), m_resolved(_other.m_resolved)
{
@ -347,6 +347,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
m_pCurrent->m_cleared = false;
m_pCurrent->m_isDepthBuffer = false;
m_pCurrent->m_copiedToRDRAM = false;
gSP.changed |= CHANGED_TEXTURE;
}
@ -756,6 +757,7 @@ void FrameBufferToRDRAM::CopyToRDRAM(u32 _address) {
}
}
}
pBuffer->m_copiedToRDRAM = true;
#ifndef GLES2
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
@ -1013,7 +1015,7 @@ void RDRAMtoFrameBuffer::CopyFromRDRAM( u32 _address, bool _bUseAlpha)
g = ((col >> 6)&31)<<3;
b = ((col >> 1)&31)<<3;
a = (col&1) > 0 ? 0xff : 0;
dst[x + y*width] = (a<<24)|(b<<16)|(g<<8)|r;
dst[x + y*width] = (a << 24) | (b << 16) | (g << 8) | r;
}
}
} else {

View File

@ -23,6 +23,7 @@ struct FrameBuffer
bool m_cleared;
bool m_cfb;
bool m_isDepthBuffer;
bool m_copiedToRDRAM;
GLuint m_FBO;
gDPTile *m_pLoadTile;

View File

@ -306,10 +306,10 @@ void RSP_Init()
TFH.shutdown();
strncpy(RSP.romname, romname, 21);
if (strstr(RSP.romname, (const char *)"OgreBattle64"))
if (strstr(RSP.romname, (const char *)"OgreBattle64") != NULL)
config.generalEmulation.hacks |= hack_Ogre64;
else if (strstr(RSP.romname, (const char *)"MarioGolf64"))
config.generalEmulation.hacks |= hack_MarioGolf;
else if (strstr(RSP.romname, (const char *)"MarioGolf64") != NULL || strstr(RSP.romname, (const char *)"CONKER BFD") != NULL)
config.generalEmulation.hacks |= hack_noDepthFrameBuffers;
api().FindPluginPath(RSP.pluginpath);

View File

@ -512,11 +512,18 @@ bool CheckForFrameBufferTexture(u32 _address, u32 _bytes)
return false;
FrameBuffer *pBuffer = frameBufferList().findBuffer(_address);
bool bRes = pBuffer != NULL && ((config.generalEmulation.hacks & hack_MarioGolf) == 0 || !pBuffer->m_isDepthBuffer);
const bool noDepthBuffers = (config.generalEmulation.hacks & hack_noDepthFrameBuffers) != 0;
bool bRes = pBuffer != NULL && (!noDepthBuffers || !pBuffer->m_isDepthBuffer);
if ((bRes)
//&& ((*(u32*)&RDRAM[pBuffer->startAddress] & 0xFFFEFFFE) == (pBuffer->startAddress & 0xFFFEFFFE)) // Does not work for Jet Force Gemini
)
{
if (noDepthBuffers && gDP.colorImage.address == gDP.depthImageAddress && pBuffer->m_copiedToRDRAM)
{
memcpy(RDRAM + gDP.depthImageAddress, RDRAM + pBuffer->m_startAddress, (pBuffer->m_width*pBuffer->m_height) << pBuffer->m_size >> 1);
pBuffer->m_copiedToRDRAM = false;
}
const u32 texEndAddress = _address + _bytes - 1;
u32 height = (int)gDP.scissor.lry;
if (height % 2 != 0)