diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 6851851e1..53075ab62 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -85,6 +85,8 @@ EXPORT_C_(INT32) GSinit() #ifdef _WINDOWS + //_CrtSetBreakAlloc( 1273 ); + s_hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); if(!GSUtil::CheckDirectX()) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index e44a22da1..723a36531 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -188,6 +188,7 @@ void GSDevice::Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVec { if(!m_merge || !(m_merge->GetSize() == fs)) { + delete m_merge; m_merge = CreateRenderTarget(fs.x, fs.y, false); } diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 6052fe129..059e231e4 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -41,6 +41,10 @@ GSDevice9::GSDevice9() GSDevice9::~GSDevice9() { 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.ps_cb) _aligned_free(m_state.ps_cb); diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index f2c484ea3..b42676f86 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -24,9 +24,10 @@ GSRenderer::GSRenderer() : GSState() + , m_tex_buff( (uint8*)_aligned_malloc(1024 * 1024 * sizeof(uint32), 16) ) + , m_vt(this) , m_dev(NULL) , m_shader(0) - , m_vt(this) { m_interlace = theApp.GetConfig("interlace", 0); m_aspectratio = theApp.GetConfig("aspectratio", 1); @@ -52,6 +53,8 @@ GSRenderer::~GSRenderer() m_dev->Reset(1, 1, GSDevice::Windowed); }*/ + _aligned_free( m_tex_buff ); + delete m_dev; } diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index 6b441368d..40ba69ed7 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -46,6 +46,8 @@ protected: bool m_aa1; bool m_blur; + uint8* m_tex_buff; + virtual GSTexture* GetOutput(int i) = 0; 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) } + + // TODO : Implement proper locking here *if needed* (not sure yet if it is) --air + uint8* GetTextureBufferLock() { return m_tex_buff; } + void ReleaseTextureBufferLock() { } }; template class GSRendererT : public GSRenderer diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 10cc08b78..601ae1cc9 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -93,8 +93,7 @@ GSTexture* GSRendererSW::GetOutput(int i) if(m_dev->ResizeTexture(&m_texture[i], w, h)) { - // TODO - static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16); + uint8* buff = GetTextureBufferLock(); static int pitch = 1024 * 4; GSVector4i r(0, 0, w, h); diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 2d690bd4c..e70af2760 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -910,9 +910,6 @@ void GSTextureCache::Source::Flush(uint32 count) 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); GSLocalMemory& mem = m_renderer->m_mem; @@ -927,6 +924,8 @@ void GSTextureCache::Source::Flush(uint32 count) rtx = psm.rtxP; } + uint8* buff = m_renderer->GetTextureBufferLock(); + for(uint32 i = 0; i < count; 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) { memcpy(m_write.rect[0], &m_write.rect[count], (m_write.count - count) * sizeof(m_write.rect[0])); } m_write.count -= count; - - //_aligned_free(buff); } // GSTextureCache::Target