Permalink
Browse files

video-GLideN64: Test fix for crash in zelda subscreen.

  • Loading branch information...
1 parent 51acac4 commit e7a3ecdb526da5bcadd37202cefcfd02640fc22c @fzurita fzurita committed Apr 11, 2016
Showing with 21 additions and 2 deletions.
  1. +21 −2 jni/mupen64plus-video-gliden64/src/FrameBuffer.cpp
@@ -18,6 +18,7 @@
#include "Debug.h"
#include "PostProcessor.h"
#include "FrameBufferInfo.h"
+#include "Log.h"
using namespace std;
@@ -308,6 +309,7 @@ void FrameBuffer::reinit(u16 _height)
if (m_pResolveTexture != NULL)
textureCache().removeFrameBufferTexture(m_pResolveTexture);
m_pTexture = textureCache().addFrameBufferTexture();
+
init(m_startAddress, endAddress, format, m_size, m_width, _height, m_cfb);
}
@@ -438,6 +440,7 @@ void FrameBufferList::init()
}
void FrameBufferList::destroy() {
+
m_list.clear();
m_pCurrent = NULL;
m_pCopy = NULL;
@@ -484,8 +487,13 @@ void FrameBufferList::clearBuffersChanged()
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) // [ { ]
- return &(*iter);
+ {
+ if (iter->m_startAddress <= _startAddress && iter->m_endAddress >= _startAddress) // [ { ]
+ {
+ return &(*iter);
+ }
+ }
+
return NULL;
}
@@ -538,13 +546,22 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
if (m_pCurrent != NULL) {
// Correct buffer's end address
if (!m_pCurrent->isAuxiliary()) {
+
+ if(m_prevColorImageHeight == 0)
+ {
+ m_prevColorImageHeight = VI.height;
+ }
if (gDP.colorImage.height > 200)
m_prevColorImageHeight = gDP.colorImage.height;
else if (gDP.colorImage.height == 0)
gDP.colorImage.height = m_prevColorImageHeight;
+
gDP.colorImage.height = min(gDP.colorImage.height, VI.height);
+
m_pCurrent->m_endAddress = min(RDRAMSize, m_pCurrent->m_startAddress + (((m_pCurrent->m_width * gDP.colorImage.height) << m_pCurrent->m_size >> 1) - 1));
+
} else if (m_pCurrent->m_needHeightCorrection && gDP.colorImage.height != 0) {
+
m_pCurrent->m_endAddress = min(RDRAMSize, m_pCurrent->m_startAddress + (((m_pCurrent->m_width * gDP.colorImage.height) << m_pCurrent->m_size >> 1) - 1));
}
@@ -594,6 +611,7 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
// Wasn't found or removed, create a new one
m_list.emplace_front();
FrameBuffer & buffer = m_list.front();
+
buffer.init(_address, endAddress, _format, _size, _width, _height, _cfb);
m_pCurrent = &buffer;
@@ -662,6 +680,7 @@ void FrameBufferList::removeBuffers(u32 _width)
m_pCurrent = NULL;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
+
iter = m_list.erase(iter);
if (iter == m_list.end())
return;

0 comments on commit e7a3ecd

Please sign in to comment.