GSdx: Fixed a couple memory leaks.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2000 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-12 19:58:03 +00:00
parent 8b0cbe445a
commit c5c21f06cb
7 changed files with 22 additions and 8 deletions

View File

@ -85,6 +85,8 @@ EXPORT_C_(INT32) GSinit()
#ifdef _WINDOWS #ifdef _WINDOWS
//_CrtSetBreakAlloc( 1273 );
s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
if(!GSUtil::CheckDirectX()) if(!GSUtil::CheckDirectX())

View File

@ -188,6 +188,7 @@ void GSDevice::Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVec
{ {
if(!m_merge || !(m_merge->GetSize() == fs)) if(!m_merge || !(m_merge->GetSize() == fs))
{ {
delete m_merge;
m_merge = CreateRenderTarget(fs.x, fs.y, false); m_merge = CreateRenderTarget(fs.x, fs.y, false);
} }

View File

@ -41,6 +41,10 @@ GSDevice9::GSDevice9()
GSDevice9::~GSDevice9() GSDevice9::~GSDevice9()
{ {
for_each(m_mskfix.begin(), m_mskfix.end(), delete_second()); for_each(m_mskfix.begin(), m_mskfix.end(), delete_second());
for_each(m_om_bs.begin(), m_om_bs.end(), delete_second());
for_each(m_om_dss.begin(), m_om_dss.end(), delete_second());
for_each(m_ps_ss.begin(), m_ps_ss.end(), delete_second());
if(m_state.vs_cb) _aligned_free(m_state.vs_cb); if(m_state.vs_cb) _aligned_free(m_state.vs_cb);
if(m_state.ps_cb) _aligned_free(m_state.ps_cb); if(m_state.ps_cb) _aligned_free(m_state.ps_cb);

View File

@ -24,9 +24,10 @@
GSRenderer::GSRenderer() GSRenderer::GSRenderer()
: GSState() : GSState()
, m_tex_buff( (uint8*)_aligned_malloc(1024 * 1024 * sizeof(uint32), 16) )
, m_vt(this)
, m_dev(NULL) , m_dev(NULL)
, m_shader(0) , m_shader(0)
, m_vt(this)
{ {
m_interlace = theApp.GetConfig("interlace", 0); m_interlace = theApp.GetConfig("interlace", 0);
m_aspectratio = theApp.GetConfig("aspectratio", 1); m_aspectratio = theApp.GetConfig("aspectratio", 1);
@ -52,6 +53,8 @@ GSRenderer::~GSRenderer()
m_dev->Reset(1, 1, GSDevice::Windowed); m_dev->Reset(1, 1, GSDevice::Windowed);
}*/ }*/
_aligned_free( m_tex_buff );
delete m_dev; delete m_dev;
} }

View File

@ -46,6 +46,8 @@ protected:
bool m_aa1; bool m_aa1;
bool m_blur; bool m_blur;
uint8* m_tex_buff;
virtual GSTexture* GetOutput(int i) = 0; virtual GSTexture* GetOutput(int i) = 0;
GSVertexTrace m_vt; GSVertexTrace m_vt;
@ -86,6 +88,10 @@ public:
{ {
return !m_nativeres && m_regs->PMODE.EN != 0; // upscale ratio depends on the display size, with no output it may not be set correctly (ps2 logo to game transition) return !m_nativeres && m_regs->PMODE.EN != 0; // upscale ratio depends on the display size, with no output it may not be set correctly (ps2 logo to game transition)
} }
// TODO : Implement proper locking here *if needed* (not sure yet if it is) --air
uint8* GetTextureBufferLock() { return m_tex_buff; }
void ReleaseTextureBufferLock() { }
}; };
template<class Vertex> class GSRendererT : public GSRenderer template<class Vertex> class GSRendererT : public GSRenderer

View File

@ -93,8 +93,7 @@ GSTexture* GSRendererSW::GetOutput(int i)
if(m_dev->ResizeTexture(&m_texture[i], w, h)) if(m_dev->ResizeTexture(&m_texture[i], w, h))
{ {
// TODO uint8* buff = GetTextureBufferLock();
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
static int pitch = 1024 * 4; static int pitch = 1024 * 4;
GSVector4i r(0, 0, w, h); GSVector4i r(0, 0, w, h);

View File

@ -910,9 +910,6 @@ void GSTextureCache::Source::Flush(uint32 count)
GSVector4i tr(0, 0, tw, th); GSVector4i tr(0, 0, tw, th);
// TODO
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * sizeof(uint32), 16);
int pitch = max(tw, psm.bs.x) * sizeof(uint32); int pitch = max(tw, psm.bs.x) * sizeof(uint32);
GSLocalMemory& mem = m_renderer->m_mem; GSLocalMemory& mem = m_renderer->m_mem;
@ -927,6 +924,8 @@ void GSTextureCache::Source::Flush(uint32 count)
rtx = psm.rtxP; rtx = psm.rtxP;
} }
uint8* buff = m_renderer->GetTextureBufferLock();
for(uint32 i = 0; i < count; i++) for(uint32 i = 0; i < count; i++)
{ {
GSVector4i r = m_write.rect[i]; GSVector4i r = m_write.rect[i];
@ -956,14 +955,14 @@ void GSTextureCache::Source::Flush(uint32 count)
} }
} }
m_renderer->ReleaseTextureBufferLock();
if(count < m_write.count) if(count < m_write.count)
{ {
memcpy(m_write.rect[0], &m_write.rect[count], (m_write.count - count) * sizeof(m_write.rect[0])); memcpy(m_write.rect[0], &m_write.rect[count], (m_write.count - count) * sizeof(m_write.rect[0]));
} }
m_write.count -= count; m_write.count -= count;
//_aligned_free(buff);
} }
// GSTextureCache::Target // GSTextureCache::Target