From 35bf7c0ee6590296d18f628651cfe9a891b9b0aa Mon Sep 17 00:00:00 2001 From: megai2 Date: Tue, 28 Jul 2020 22:51:33 +0300 Subject: [PATCH] crashfix for GW2 28.07 patch game sets render target to depth stencil, dx9 ignores this with errored out call we just ignore it for now instead of crashing --- d912pxy/d912pxy_device_surface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/d912pxy/d912pxy_device_surface.cpp b/d912pxy/d912pxy_device_surface.cpp index f68c0b6d..c1940343 100644 --- a/d912pxy/d912pxy_device_surface.cpp +++ b/d912pxy/d912pxy_device_surface.cpp @@ -73,7 +73,16 @@ HRESULT d912pxy_device::GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurfac HRESULT d912pxy_device::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) { - d912pxy_s.render.iframe.BindSurface(0, PXY_COM_LOOKUP(pNewZStencil, surface)); + d912pxy_surface* newDS = PXY_COM_LOOKUP(pNewZStencil, surface); + + //megai2: remove this filter when GW2 is fixed + if (newDS) + { + if (newDS->GetDX9DescAtLevel(0).Usage != D3DUSAGE_DEPTHSTENCIL) + newDS = nullptr; + } + + d912pxy_s.render.iframe.BindSurface(0, newDS); return D3D_OK; } @@ -146,7 +155,6 @@ HRESULT d912pxy_device::Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D DWORD cvtCf = ((D3D12_CLEAR_FLAG_DEPTH * ((Flags & D3DCLEAR_ZBUFFER) != 0)) | (D3D12_CLEAR_FLAG_STENCIL * ((Flags & D3DCLEAR_STENCIL) != 0))); d912pxy_surface* surf = d912pxy_s.render.iframe.GetBindedSurface(0); - if (surf) d912pxy_s.render.replay.DoDSClear(surf, Z, Stencil & 0xFF, (D3D12_CLEAR_FLAGS)cvtCf, d912pxy_s.render.iframe.GetViewport()); }