gsdx: add draw exception (OOM and Recoverable)

The exception will free the unused (but allocated) texture aka the emergency break ;)

Recoverable could be useful for unsupported draw call
This commit is contained in:
Gregory Hainaut 2016-05-05 16:43:02 +02:00
parent c8dddfed06
commit 37c7fa7663
7 changed files with 30 additions and 1 deletions

View File

@ -202,6 +202,17 @@ void GSDevice::AgePool()
}
}
void GSDevice::PurgePool()
{
// OOM emergency. Let's free this useless pool
while(m_pool.size() > 0)
{
delete m_pool.back();
m_pool.pop_back();
}
}
GSTexture* GSDevice::CreateRenderTarget(int w, int h, bool msaa, int format)
{
return FetchSurface(GSTexture::RenderTarget, w, h, msaa, format);

View File

@ -194,6 +194,7 @@ public:
bool IsRBSwapped() {return m_rbswapped;}
void AgePool();
void PurgePool();
virtual void PrintMemoryUsage();
};

View File

@ -645,3 +645,8 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
}
#endif
}
void GSRenderer::PurgePool()
{
m_dev->PurgePool();
}

View File

@ -79,6 +79,8 @@ public:
virtual bool BeginCapture();
virtual void EndCapture();
void PurgePool();
public:
std::mutex m_pGSsetTitle_Crit;

View File

@ -1475,7 +1475,15 @@ void GSState::FlushPrim()
m_vt.Update(m_vertex.buff, m_index.buff, m_index.tail, GSUtil::GetPrimClass(PRIM->PRIM));
Draw();
try {
Draw();
} catch (GSDXRecoverableError&) {
// could be an unsupported draw call
} catch (GSDXErrorOOM&) {
// Texture Out Of Memory
PurgePool();
fprintf(stderr, "GSDX OUT OF MEMORY\n");
}
m_perfmon.Put(GSPerfMon::Draw, 1);
m_perfmon.Put(GSPerfMon::Prim, m_index.tail / GSUtil::GetVertexCount(PRIM->PRIM));

View File

@ -249,6 +249,7 @@ public:
virtual void FlushPrim();
virtual void FlushWrite();
virtual void Draw() = 0;
virtual void PurgePool() = 0;
virtual void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}
virtual void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false) {}

View File

@ -79,5 +79,6 @@ public:
struct GSDXError {};
struct GSDXRecoverableError : GSDXError {};
struct GSDXErrorOOM : GSDXError {};
extern GSdxApp theApp;