mirror of https://github.com/PCSX2/pcsx2.git
GSDx: Free textures that have been in the unused texture pool for a few frames.
GSDx: Reset device on save state load. GSDx: Made GSRenderer::ResetDevice() actually do the main function in its name and implemented InvalidateTextureCache(). If anything breaks, it's because of this change. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3067 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
d8ba646de2
commit
ab77eb4646
|
@ -368,6 +368,7 @@ EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data)
|
|||
}
|
||||
else if(mode == FREEZE_LOAD)
|
||||
{
|
||||
s_gs->ResetDevice();
|
||||
return s_gs->Defrost(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ GSDevice::GSDevice()
|
|||
, m_weavebob(NULL)
|
||||
, m_blend(NULL)
|
||||
, m_1x1(NULL)
|
||||
, m_frame(0)
|
||||
{
|
||||
memset(&m_vertices, 0, sizeof(m_vertices));
|
||||
|
||||
|
@ -143,6 +144,7 @@ void GSDevice::Recycle(GSTexture* t)
|
|||
{
|
||||
if(t)
|
||||
{
|
||||
t->last_frame_used = m_frame;
|
||||
m_pool.push_front(t);
|
||||
//printf("%d\n",m_pool.size());
|
||||
while(m_pool.size() > 300)
|
||||
|
@ -154,6 +156,16 @@ void GSDevice::Recycle(GSTexture* t)
|
|||
}
|
||||
}
|
||||
|
||||
void GSDevice::AgePool()
|
||||
{
|
||||
m_frame++;
|
||||
while (m_pool.size() > 20 && m_frame - m_pool.back()->last_frame_used > 10)
|
||||
{
|
||||
delete m_pool.back();
|
||||
m_pool.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
GSTexture* GSDevice::CreateRenderTarget(int w, int h, bool msaa, int format)
|
||||
{
|
||||
return Fetch(GSTexture::RenderTarget, w, h, msaa, format);
|
||||
|
|
|
@ -66,6 +66,7 @@ protected:
|
|||
struct {size_t stride, start, count, limit;} m_vertices;
|
||||
uint32 m_msaa;
|
||||
DXGI_SAMPLE_DESC m_msaa_desc;
|
||||
unsigned m_frame; // for ageing the pool
|
||||
|
||||
virtual GSTexture* Create(int type, int w, int h, bool msaa, int format) = 0;
|
||||
|
||||
|
@ -146,4 +147,6 @@ public:
|
|||
}
|
||||
|
||||
bool SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode); // TODO: GSDeviceDX
|
||||
|
||||
void AgePool();
|
||||
};
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
{
|
||||
InvalidateTextureCache();
|
||||
ResetPrim();
|
||||
m_dev->Reset(1, 1);
|
||||
}
|
||||
virtual void VSync(int field);
|
||||
virtual bool MakeSnapshot(const string& path);
|
||||
|
|
|
@ -467,6 +467,7 @@ protected:
|
|||
__super::VSync(field);
|
||||
|
||||
m_tc->IncAge();
|
||||
m_dev->AgePool();
|
||||
|
||||
m_skip = 0;
|
||||
|
||||
|
@ -478,10 +479,14 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
void InvalidateTextureCache()
|
||||
{
|
||||
m_tc->RemoveAll();
|
||||
}
|
||||
|
||||
void ResetDevice()
|
||||
{
|
||||
__super::ResetDevice();
|
||||
m_tc->RemoveAll();
|
||||
}
|
||||
|
||||
GSTexture* GetOutput(int i)
|
||||
|
|
|
@ -49,4 +49,9 @@ public:
|
|||
|
||||
template<uint32 prim, uint32 tme, uint32 fst>
|
||||
void VertexKick(bool skip);
|
||||
|
||||
void InvalidateTextureCache()
|
||||
{
|
||||
m_tc->RemoveAll();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -59,7 +59,11 @@ public:
|
|||
int GetFormat() const {return m_format;}
|
||||
|
||||
bool IsMSAA() const {return m_msaa;}
|
||||
|
||||
|
||||
// frame number (arbitrary base) the texture was recycled on
|
||||
// different purpose than texture cache ages, do not attempt to merge
|
||||
unsigned last_frame_used;
|
||||
|
||||
bool LikelyOffset;
|
||||
float OffsetHack_modx;
|
||||
float OffsetHack_mody;
|
||||
|
|
Loading…
Reference in New Issue