Henri Verbeet : d3d8: Fix IDirect3DDevice8::SetRenderTarget().

Alexandre Julliard julliard at winehq.org
Wed Sep 10 06:01:49 CDT 2008


Module: wine
Branch: master
Commit: 43f5d8e5ad634795bd236c8adc907fb01269a9e4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=43f5d8e5ad634795bd236c8adc907fb01269a9e4

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Sep 10 11:08:58 2008 +0200

d3d8: Fix IDirect3DDevice8::SetRenderTarget().

The render target should be left alone if the render target argument is
NULL. WineD3D calls should be done inside the critical section.

---

 dlls/d3d8/device.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index e877456..976d7dd 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -805,13 +805,22 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 ifa
     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
     IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
     IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
+    IWineD3DSurface *original_ds = NULL;
     HRESULT hr;
     TRACE("(%p) Relay\n" , This);
 
-    IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL == pZSurface ? NULL : pZSurface->wineD3DSurface);
-
     EnterCriticalSection(&d3d8_cs);
-    hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface ? pSurface->wineD3DSurface : NULL);
+
+    hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &original_ds);
+    if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
+    {
+        hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, pZSurface ? pZSurface->wineD3DSurface : NULL);
+        if (SUCCEEDED(hr) && pSurface)
+            hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface->wineD3DSurface);
+        if (FAILED(hr)) IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, original_ds);
+    }
+    if (original_ds) IWineD3DSurface_Release(original_ds);
+
     LeaveCriticalSection(&d3d8_cs);
     return hr;
 }




More information about the wine-cvs mailing list