From 9314c5fed7c0fd8da77d882be043c3a50562f39e Mon Sep 17 00:00:00 2001 From: avihal Date: Thu, 1 Sep 2011 13:25:08 +0000 Subject: [PATCH] GSdx: bypass (prevent) some crashes. Important: this is not a fix of the cause of the crashes, it just bypasses cases of sure crash. Once that spot is bypassed, things can go wrong elsewhere. Generally, however, things just continue normally. E.g. GT4 (camera changes), Tourist Trophy (camera changes), MGS3 (codec screen when CRC hacks are disabled) and probably more - now don't crash anymore, even at high resolution (but might still get some slowdowns). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4895 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDevice11.cpp | 12 ++++++++++++ plugins/GSdx/GSDevice9.cpp | 12 ++++++++++++ plugins/GSdx/GSRendererHW.h | 6 ++++++ plugins/GSdx/GSTextureCache.cpp | 5 ++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index c51cdc2ace..58190b357a 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -518,6 +518,12 @@ GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, void GSDevice11::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) { + if(!st || !dt) + { + ASSERT(0); + return; + } + D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); @@ -535,6 +541,12 @@ void GSDevice11::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, void GSDevice11::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, ID3D11BlendState* bs, bool linear) { + if(!st || !dt) + { + ASSERT(0); + return; + } + BeginScene(); GSVector2i ds = dt->GetSize(); diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index e5dda141ea..855df86537 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -701,6 +701,12 @@ GSTexture* GSDevice9::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, void GSDevice9::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) { + if(!st || !dt) + { + ASSERT(0); + return; + } + m_dev->StretchRect(*(GSTexture9*)st, r, *(GSTexture9*)dt, r, D3DTEXF_NONE); } @@ -716,6 +722,12 @@ void GSDevice9::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, c void GSDevice9::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len, Direct3DBlendState9* bs, bool linear) { + if(!st || !dt) + { + ASSERT(0); + return; + } + BeginScene(); GSVector2i ds = dt->GetSize(); diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index d6ef16cb18..a78cf8f50e 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -756,6 +756,12 @@ protected: GSTextureCache::Target* ds = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::DepthStencil, m_context->DepthWrite()); + if(!rt || !ds) + { + ASSERT(0); + return; + } + GSTextureCache::Source* tex = NULL; if(PRIM->TME) diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 88a0e8a7c3..0fbbfa4923 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -736,7 +736,10 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con src->m_texture = dt; } - src->m_texture->SetScale(scale); + if( src->m_texture ) + src->m_texture->SetScale(scale); + else + ASSERT(0); switch(TEX0.PSM) {