gsdx: check null pointer when doing a texture clear

This commit is contained in:
Gregory Hainaut 2015-08-04 19:26:17 +02:00
parent 42f51591df
commit 3784ea768f
5 changed files with 23 additions and 5 deletions

View File

@ -444,11 +444,13 @@ void GSDevice11::Dispatch(uint32 x, uint32 y, uint32 z)
void GSDevice11::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
if (!t) return;
m_ctx->ClearRenderTargetView(*(GSTexture11*)t, c.v);
}
void GSDevice11::ClearRenderTarget(GSTexture* t, uint32 c)
{
if (!t) return;
GSVector4 color = GSVector4::rgba32(c) * (1.0f / 255);
m_ctx->ClearRenderTargetView(*(GSTexture11*)t, color.v);
@ -456,11 +458,13 @@ void GSDevice11::ClearRenderTarget(GSTexture* t, uint32 c)
void GSDevice11::ClearDepth(GSTexture* t, float c)
{
if (!t) return;
m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_DEPTH, c, 0);
}
void GSDevice11::ClearStencil(GSTexture* t, uint8 c)
{
if (!t) return;
m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_STENCIL, 0, c);
}

View File

@ -649,11 +649,13 @@ void GSDevice9::EndScene()
void GSDevice9::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
if (!t) return;
ClearRenderTarget(t, (c * 255 + 0.5f).zyxw().rgba32());
}
void GSDevice9::ClearRenderTarget(GSTexture* rt, uint32 c)
{
if (!rt) return;
CComPtr<IDirect3DSurface9> surface;
m_dev->GetRenderTarget(0, &surface);
m_dev->SetRenderTarget(0, *(GSTexture9*)rt);
@ -663,6 +665,7 @@ void GSDevice9::ClearRenderTarget(GSTexture* rt, uint32 c)
void GSDevice9::ClearDepth(GSTexture* t, float c)
{
if (!t) return;
CComPtr<IDirect3DSurface9> dssurface;
m_dev->GetDepthStencilSurface(&dssurface);
m_dev->SetDepthStencilSurface(*(GSTexture9*)t);
@ -672,6 +675,7 @@ void GSDevice9::ClearDepth(GSTexture* t, float c)
void GSDevice9::ClearStencil(GSTexture* t, uint8 c)
{
if (!t) return;
CComPtr<IDirect3DSurface9> dssurface;
m_dev->GetDepthStencilSurface(&dssurface);
m_dev->SetDepthStencilSurface(*(GSTexture9*)t);

View File

@ -444,6 +444,8 @@ void GSDeviceOGL::DrawIndexedPrimitive(int offset, int count)
void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
if (!t) return;
GSTextureOGL* T = static_cast<GSTextureOGL*>(t);
if (T->HasBeenCleaned() && !T->IsBackbuffer())
return;
@ -481,12 +483,16 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c)
void GSDeviceOGL::ClearRenderTarget(GSTexture* t, uint32 c)
{
if (!t) return;
GSVector4 color = GSVector4::rgba32(c) * (1.0f / 255);
ClearRenderTarget(t, color);
}
void GSDeviceOGL::ClearRenderTarget_i(GSTexture* t, int32 c)
{
if (!t) return;
GSTextureOGL* T = static_cast<GSTextureOGL*>(t);
GL_PUSH("Clear RTi %d", T->GetID());
@ -514,6 +520,8 @@ void GSDeviceOGL::ClearRenderTarget_i(GSTexture* t, int32 c)
void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
{
if (!t) return;
GSTextureOGL* T = static_cast<GSTextureOGL*>(t);
GL_PUSH("Clear Depth %d", T->GetID());
@ -537,6 +545,8 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
{
if (!t) return;
GSTextureOGL* T = static_cast<GSTextureOGL*>(t);
GL_PUSH("Clear Stencil %d", T->GetID());

View File

@ -47,8 +47,8 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc
GSDrawingEnvironment& env = m_env;
GSDrawingContext* context = m_context;
const GSVector2i& rtsize = ds->GetSize();
const GSVector2& rtscale = ds->GetScale();
const GSVector2i& rtsize = ds ? ds->GetSize() : rt->GetSize();
const GSVector2& rtscale = ds ? ds->GetScale() : rt->GetScale();
bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24;

View File

@ -547,12 +547,12 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
{
GL_PUSH("GL Draw from %d in %d (Depth %d)",
tex && tex->m_texture ? tex->m_texture->GetID() : 0,
rt ? rt->GetID() : -1, ds->GetID());
rt ? rt->GetID() : -1, ds ? ds->GetID() : -1);
GSTexture* hdr_rt = NULL;
const GSVector2i& rtsize = ds->GetSize();
const GSVector2& rtscale = ds->GetScale();
const GSVector2i& rtsize = ds ? ds->GetSize() : rt->GetSize();
const GSVector2& rtscale = ds ? ds->GetScale() : rt->GetScale();
bool DATE = m_context->TEST.DATE && m_context->FRAME.PSM != PSM_PSMCT24;
bool DATE_GL42 = false;