Skip to content

Commit

Permalink
Unset current render target reference in "Direct3DDevice8::Reset" sin…
Browse files Browse the repository at this point in the history
…ce that likely invalidates it

See #84
  • Loading branch information
crosire committed Jul 15, 2018
1 parent 00023b3 commit 9d8651c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::Reset(D3DPRESENT_PARAMETERS8 *pPresen
return D3DERR_INVALIDCALL;
}

pCurrentRenderTarget = nullptr;

D3DPRESENT_PARAMETERS PresentParams;
ConvertPresentParameters(*pPresentationParameters, PresentParams);

Expand Down Expand Up @@ -410,8 +412,6 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateRenderTarget(UINT Width, UINT H
return hr;
}

pCurrentRenderTarget = SurfaceInterface;

*ppSurface = new Direct3DSurface8(this, SurfaceInterface);

return D3D_OK;
Expand Down Expand Up @@ -623,10 +623,10 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetRenderTarget(Direct3DSurface8 *pRe
{
return hr;
}

pCurrentRenderTarget = pRenderTarget->GetProxyInterface();
}

pCurrentRenderTarget = pRenderTarget->GetProxyInterface();

if (pNewZStencil != nullptr)
{
hr = ProxyInterface->SetDepthStencilSurface(pNewZStencil->GetProxyInterface());
Expand Down Expand Up @@ -713,9 +713,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetViewport(const D3DVIEWPORT8 *pView
{
if (pCurrentRenderTarget != nullptr)
{
D3DSURFACE_DESC Desc;
HRESULT hr = pCurrentRenderTarget->GetDesc(&Desc);
if (SUCCEEDED(hr) && (pViewport->Height > Desc.Height || pViewport->Width > Desc.Width))
D3DSURFACE_DESC Desc = {};

if (SUCCEEDED(pCurrentRenderTarget->GetDesc(&Desc)) && (pViewport->Height > Desc.Height || pViewport->Width > Desc.Width))
{
return D3DERR_INVALIDCALL;
}
Expand Down

0 comments on commit 9d8651c

Please sign in to comment.