diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 001bb3043f..459c4cc474 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -526,9 +526,6 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, bool msaa, int form if(SUCCEEDED(hr)) { t = new GSTexture11(texture); - if (t == NULL) { - throw GSDXErrorOOM(); - } switch(type) { @@ -540,6 +537,10 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, bool msaa, int form break; } } + else + { + throw std::bad_alloc(); + } return t; } diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 81df6537fb..7d2c1181d1 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -718,17 +718,11 @@ GSTexture* GSDevice9::CreateSurface(int type, int w, int h, bool msaa, int forma if(surface) { t = new GSTexture9(surface); - if (t == NULL) { - throw GSDXErrorOOM(); - } } if(texture) { t = new GSTexture9(texture); - if (t == NULL) { - throw GSDXErrorOOM(); - } } if(t) @@ -743,6 +737,10 @@ GSTexture* GSDevice9::CreateSurface(int type, int w, int h, bool msaa, int forma break; } } + else + { + throw std::bad_alloc(); + } return t; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 1b47fc8c3a..58080d1edc 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -229,11 +229,7 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt GL_PUSH("Create surface"); // A wrapper to call GSTextureOGL, with the different kind of parameter - GSTextureOGL* t = NULL; - t = new GSTextureOGL(type, w, h, fmt, m_fbo_read, m_mipmap > 1 || m_filter > 2); - if (t == NULL) { - throw GSDXErrorOOM(); - } + GSTextureOGL* t = new GSTextureOGL(type, w, h, fmt, m_fbo_read, m_mipmap > 1 || m_filter > 2); // NOTE: I'm not sure RenderTarget always need to be cleared. It could be costly for big upscale. // FIXME: it will be more logical to do it in FetchSurface. This code is only called at first creation diff --git a/plugins/GSdx/GSDeviceSW.cpp b/plugins/GSdx/GSDeviceSW.cpp index a2bf63d923..948b57ee87 100644 --- a/plugins/GSdx/GSDeviceSW.cpp +++ b/plugins/GSdx/GSDeviceSW.cpp @@ -50,7 +50,7 @@ bool GSDeviceSW::Reset(int w, int h) GSTexture* GSDeviceSW::CreateSurface(int type, int w, int h, bool msaa, int format) { - if(format != 0) return NULL; // there is only one format + ASSERT(format == 0); return new GSTextureSW(type, w, h); } diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 380b543224..4c6fa6b3b8 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -1590,7 +1590,7 @@ void GSState::FlushPrim() Draw(); } catch (GSDXRecoverableError&) { // could be an unsupported draw call - } catch (GSDXErrorOOM&) { + } catch (const std::bad_alloc& e) { // Texture Out Of Memory PurgePool(); fprintf(stderr, "GSDX OUT OF MEMORY\n"); diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index dd95a3d54c..aa6db5d75f 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -1110,7 +1110,6 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con { const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM]; Source* src = new Source(m_renderer, TEX0, TEXA, m_temp); - if (src == NULL) throw GSDXErrorOOM(); int tw = 1 << TEX0.TW; int th = 1 << TEX0.TH; @@ -1431,11 +1430,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con src->m_texture = m_renderer->m_dev->CreateTexture(tw, th); } - if(src->m_texture == NULL) - { - delete src; - throw GSDXErrorOOM(); - } + ASSERT(src->m_texture); if(psm.pal > 0) { @@ -1449,8 +1444,9 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int w, int h, int type) { + ASSERT(type == RenderTarget || type == DepthStencil); + Target* t = new Target(m_renderer, TEX0, m_temp, CanConvertDepth()); - if (t == NULL) throw GSDXErrorOOM(); // FIXME: initial data should be unswizzled from local mem in Update() if dirty @@ -1467,12 +1463,6 @@ GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int t->m_texture = m_renderer->m_dev->CreateDepthStencil(w, h, true); } - if(t->m_texture == NULL) - { - delete t; - throw GSDXErrorOOM(); - } - m_dst[type].push_front(t); return t; @@ -1880,7 +1870,6 @@ void GSTextureCache::Target::Update() TEXA.TA1 = 0x80; GSTexture* t = m_renderer->m_dev->CreateTexture(w, h); - if (t == NULL) return; const GSOffset* off = m_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 55970991c1..352fe1f0f2 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -246,7 +246,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, fprintf(stderr, "Available VRAM is very low (%lld), a crash is expected ! Disable Larger framebuffer or reduce upscaling!\n", GLState::available_vram); every_512++; // Pull emergency break - throw GSDXErrorOOM(); + throw std::bad_alloc(); } // Only 32 bits input texture will be supported for mipmap diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h index 91f900e208..1272227c35 100644 --- a/plugins/GSdx/GSdx.h +++ b/plugins/GSdx/GSdx.h @@ -84,6 +84,5 @@ public: struct GSDXError {}; struct GSDXRecoverableError : GSDXError {}; -struct GSDXErrorOOM : GSDXError {}; extern GSdxApp theApp;