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

Add validity check for background fb textures.

Fixed Nushi Zuri 64: fb background doesn't work anymore #1115

Problem: The game normally uses color and depth buffers.
When it needs to show rectangle with text, CPU copies current color buffer
by depth buffer address. This buffer rendered as background, text rendered over.
Plugin detects buffer usage and tries to use depth buffer as background texture.
That buffer in video memory has no color information, because data copied by CPU and contained in RDRAM.

Solution: check that found frame buffer is valid.
In this case validity check will fail because RDRAM content modified by CPU,
and background will be read from RDRAM.
This commit is contained in:
Sergey Lipskiy 2016-09-16 17:09:25 +07:00
parent f7576185cc
commit e28bebd17e
4 changed files with 8 additions and 4 deletions

View File

@ -258,6 +258,7 @@ bool FrameBuffer::isValid() const
{
if (m_validityChecked == video().getBuffersSwapCount())
return true; // Already checked
m_validityChecked = video().getBuffersSwapCount();
const u32 * const pData = (const u32*)RDRAM;

View File

@ -27,7 +27,7 @@ struct FrameBuffer
bool isAuxiliary() const;
u32 m_startAddress, m_endAddress;
u32 m_size, m_width, m_height, m_fillcolor, m_validityChecked;
u32 m_size, m_width, m_height, m_fillcolor;
float m_scaleX, m_scaleY;
bool m_copiedToRdram;
bool m_fingerprint;
@ -64,6 +64,7 @@ private:
void _setAndAttachTexture(u16 _size, CachedTexture *_pTexture);
bool _initSubTexture(u32 _t);
CachedTexture * _getSubTexture(u32 _t);
mutable u32 m_validityChecked;
};
class FrameBufferList

View File

@ -414,9 +414,7 @@ bool CheckForFrameBufferTexture(u32 _address, u32 _bytes)
if (bRes) {
bRes = pBuffer->isValid();
if (bRes)
pBuffer->m_validityChecked = video().getBuffersSwapCount();
else
if (!bRes)
fbList.removeBuffer(pBuffer->m_startAddress);
}

View File

@ -2123,6 +2123,10 @@ void _loadBGImage(const uObjScaleBg * _bgInfo, bool _loadScale)
if (config.frameBufferEmulation.enable) {
FrameBuffer *pBuffer = frameBufferList().findBuffer(gSP.bgImage.address);
if ((pBuffer != nullptr) && pBuffer->m_size == gSP.bgImage.size && (!pBuffer->m_isDepthBuffer || pBuffer->m_changed)) {
if (!pBuffer->isValid()) {
frameBufferList().removeBuffer(pBuffer->m_startAddress);
return;
}
gDP.tiles[0].frameBuffer = pBuffer;
gDP.tiles[0].textureMode = TEXTUREMODE_FRAMEBUFFER_BG;
gDP.tiles[0].loadType = LOADTYPE_TILE;