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

Fix frame buffer allocation again.

Check for all possible intersections of frame buffers address space,
remove all buffers, intersected with the new one.
This commit is contained in:
Sergey Lipskiy 2014-10-22 14:49:55 +07:00
parent fa5d2ce544
commit bc1a5a1f1f
3 changed files with 32 additions and 8 deletions

View File

@ -150,12 +150,33 @@ void FrameBufferList::destroy() {
m_drawBuffer = GL_BACK;
}
FrameBuffer * FrameBufferList::findBuffer(u32 _startAddress, u32 _endAddress)
FrameBuffer * FrameBufferList::findBuffer(u32 _startAddress)
{
for (FrameBuffers::iterator iter = m_list.begin(); iter != m_list.end(); ++iter)
if ((iter->m_startAddress <= _startAddress && iter->m_endAddress >= _startAddress) ||
(_startAddress < iter->m_startAddress && _endAddress > iter->m_startAddress))
return &(*iter);
if (iter->m_startAddress <= _startAddress && iter->m_endAddress >= _startAddress) // [ { ]
return &(*iter);
return NULL;
}
FrameBuffer * FrameBufferList::_findBuffer(u32 _startAddress, u32 _endAddress, u32 _width)
{
if (m_list.empty())
return NULL;
FrameBuffers::iterator iter = m_list.end();
do {
--iter;
if ((iter->m_startAddress <= _startAddress && iter->m_endAddress >= _startAddress) || // [ { ]
(_startAddress <= iter->m_startAddress && _endAddress >= iter->m_startAddress)) { // { [ }
if (_startAddress != iter->m_startAddress || _width != iter->m_width) {
m_list.erase(iter);
return _findBuffer(_startAddress, _endAddress, _width);
}
return &(*iter);
}
} while (iter != m_list.begin());
return NULL;
}
@ -180,8 +201,8 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
}
const u32 endAddress = _address + ((_width * _height << _size >> 1) - 1);
if (m_pCurrent == NULL || m_pCurrent->m_startAddress != _address)
m_pCurrent = findBuffer(_address, endAddress);
if (m_pCurrent == NULL || m_pCurrent->m_startAddress != _address || m_pCurrent->m_width != _width)
m_pCurrent = _findBuffer(_address, endAddress, _width);
if (m_pCurrent != NULL) {
if ((m_pCurrent->m_startAddress != _address) ||
(m_pCurrent->m_width != _width) ||
@ -334,7 +355,7 @@ void FrameBufferList::renderBuffer(u32 _address)
if (VI.width == 0) // H width is zero. Don't draw
return;
FrameBuffer *pBuffer = findBuffer(_address, 0);
FrameBuffer *pBuffer = findBuffer(_address);
if (pBuffer == NULL)
return;

View File

@ -34,7 +34,7 @@ public:
void saveBuffer(u32 _address, u16 _format, u16 _size, u16 _width, u16 _height, bool _cfb);
void removeBuffer(u32 _address);
void attachDepthBuffer();
FrameBuffer * findBuffer(u32 _startAddress, u32 _endAddress = 0);
FrameBuffer * findBuffer(u32 _startAddress);
FrameBuffer * findTmpBuffer(u32 _address);
FrameBuffer * getCurrent() const {return m_pCurrent;}
void renderBuffer(u32 _address);
@ -50,6 +50,8 @@ private:
FrameBufferList() : m_pCurrent(NULL), m_drawBuffer(GL_BACK) {}
FrameBufferList(const FrameBufferList &);
FrameBuffer * _findBuffer(u32 _startAddress, u32 _endAddress, u32 _width);
typedef std::list<FrameBuffer> FrameBuffers;
FrameBuffers m_list;
FrameBuffer * m_pCurrent;

View File

@ -686,6 +686,7 @@ void gDPLoadBlock( u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt )
} else
UnswapCopy( src, dest, bytes );
//gDP.textureImage.address += bytes;
#ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadBlock( %i, %i, %i, %i, %i );\n",
tile, uls, ult, lrs, dxt );