mirror of
https://github.com/libretro/pcsx2.git
synced 2024-12-28 04:35:08 +00:00
gsdx: throw oom exception + error
Texture can't be NULL anymore, so we can remove a couples of check
This commit is contained in:
parent
d58b71688b
commit
e890ce989c
@ -523,6 +523,9 @@ 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)
|
||||
{
|
||||
|
@ -718,11 +718,17 @@ 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)
|
||||
|
@ -142,6 +142,9 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt
|
||||
// A wrapper to call GSTextureOGL, with the different kind of parameter
|
||||
GSTextureOGL* t = NULL;
|
||||
t = new GSTextureOGL(type, w, h, fmt, m_fbo_read);
|
||||
if (t == NULL) {
|
||||
throw GSDXErrorOOM();
|
||||
}
|
||||
|
||||
// NOTE: I'm not sure RenderTarget always need to be cleared. It could be costly for big upscale.
|
||||
switch(type)
|
||||
|
@ -412,20 +412,22 @@ void GSRendererHW::Draw()
|
||||
TEX0.TBW = context->FRAME.FBW;
|
||||
TEX0.PSM = context->FRAME.PSM;
|
||||
|
||||
GSTextureCache::Target* rt = no_rt ? NULL : m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::RenderTarget, true);
|
||||
GSTexture* rt_tex = rt ? rt->m_texture : NULL;
|
||||
GSTextureCache::Target* rt = NULL;
|
||||
GSTexture* rt_tex = NULL;
|
||||
if (!no_rt) {
|
||||
rt = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::RenderTarget, true);
|
||||
rt_tex = rt->m_texture;
|
||||
}
|
||||
|
||||
TEX0.TBP0 = context->ZBUF.Block();
|
||||
TEX0.TBW = context->FRAME.FBW;
|
||||
TEX0.PSM = context->ZBUF.PSM;
|
||||
|
||||
GSTextureCache::Target* ds = no_ds ? NULL : m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::DepthStencil, context->DepthWrite());
|
||||
GSTexture* ds_tex = ds ? ds->m_texture : NULL;
|
||||
|
||||
if(!(rt || no_rt) || !(ds || no_ds))
|
||||
{
|
||||
ASSERT(0);
|
||||
return;
|
||||
GSTextureCache::Target* ds = NULL;
|
||||
GSTexture* ds_tex = NULL;
|
||||
if (!no_ds) {
|
||||
ds = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::DepthStencil, context->DepthWrite());
|
||||
ds_tex = ds->m_texture;
|
||||
}
|
||||
|
||||
GSTextureCache::Source* tex = NULL;
|
||||
@ -452,10 +454,6 @@ void GSRendererHW::Draw()
|
||||
|
||||
tex = tex_psm.depth ? m_tc->LookupDepthSource(context->TEX0, env.TEXA, r) : m_tc->LookupSource(context->TEX0, env.TEXA, r);
|
||||
|
||||
if(!tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Could be removed on openGL
|
||||
if(tex_psm.pal > 0)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ void GSTextureCache::RemoveAll()
|
||||
|
||||
GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i& r, bool palette)
|
||||
{
|
||||
if (!CanConvertDepth()) return NULL;
|
||||
if (!CanConvertDepth()) throw GSDXRecoverableError();
|
||||
|
||||
const GSLocalMemory::psm_t& psm_s = GSLocalMemory::m_psm[TEX0.PSM];
|
||||
|
||||
@ -332,11 +332,6 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
|
||||
#endif
|
||||
src = CreateSource(TEX0, TEXA, dst, half_right);
|
||||
|
||||
if(src == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} else {
|
||||
GL_CACHE("TC: src hit: %d (0x%x, F:0x%x)",
|
||||
src->m_texture ? src->m_texture->GetID() : 0,
|
||||
@ -432,9 +427,6 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||
|
||||
dst = CreateTarget(TEX0, w, h, type);
|
||||
|
||||
if(dst == NULL)
|
||||
return NULL;
|
||||
|
||||
// In theory new textures contain invalidated data. Still in theory a new target
|
||||
// must contains the content of the GS memory.
|
||||
// In practice, TC will wrongly invalidate some RT. For example due to write on the alpha
|
||||
@ -594,11 +586,6 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||
|
||||
dst = CreateTarget(TEX0, w, h, RenderTarget);
|
||||
|
||||
if(dst == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_renderer->m_dev->ClearRenderTarget(dst->m_texture, 0); // new frame buffers after reset should be cleared, don't display memory garbage
|
||||
|
||||
if (m_preload_frame) {
|
||||
@ -1076,6 +1063,7 @@ 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;
|
||||
@ -1370,9 +1358,8 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
|
||||
|
||||
if(src->m_texture == NULL)
|
||||
{
|
||||
ASSERT(0);
|
||||
delete src;
|
||||
return NULL;
|
||||
throw GSDXErrorOOM();
|
||||
}
|
||||
|
||||
if(psm.pal > 0)
|
||||
@ -1388,6 +1375,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
|
||||
GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int w, int h, int type)
|
||||
{
|
||||
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
|
||||
|
||||
@ -1406,9 +1394,8 @@ GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int
|
||||
|
||||
if(t->m_texture == NULL)
|
||||
{
|
||||
ASSERT(0);
|
||||
delete t;
|
||||
return NULL;
|
||||
throw GSDXErrorOOM();
|
||||
}
|
||||
|
||||
m_dst[type].push_front(t);
|
||||
|
Loading…
Reference in New Issue
Block a user