[WINED3D] Resend, Bugfix: Respect EnableAutoDepthStencil parameter

Ivan Gyurdiev ivg231 at gmail.com
Thu Jul 20 22:06:32 CDT 2006


The present parameters in wined3d are pointers (why, I don't know)... so 
they have to be dereferenced. Otherwise this is always true, and a depth 
stencil buffer is always created (forcing the ZENABLE state to always be 
true, which is how this bug was found). Correct the bug, and change the 
release fn to only free the depth stencil buffer if one was allocated.

Uncovered by stateblock test patch.

-------------- next part --------------
---

 dlls/wined3d/device.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

98970c36592fadaa1af46225e760365a7d6aa927
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index babbb9b..53c4986 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1752,7 +1752,7 @@ #endif
     }
 
     /* Under directX swapchains share the depth stencil, so only create one depth-stencil */
-    if (pPresentationParameters->EnableAutoDepthStencil && hr == WINED3D_OK) {
+    if (*(pPresentationParameters->EnableAutoDepthStencil) && hr == WINED3D_OK) {
         TRACE("Creating depth stencil buffer\n");
         if (This->depthStencilBuffer == NULL ) {
             hr = D3DCB_CreateDepthStencil((IUnknown *) This->parent,
@@ -2127,12 +2127,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl
     TRACE("Setting rendertarget to NULL\n");
     This->renderTarget = NULL;
 
-    IWineD3DSurface_GetParent(This->depthStencilBuffer, &stencilBufferParent);
-    IUnknown_Release(stencilBufferParent);          /* once for the get parent */
-    if(IUnknown_Release(stencilBufferParent)  >0){  /* the second time for when it was created */
-        FIXME("(%p) Something's still holding the depthStencilBuffer\n",This);
+    if (This->depthStencilBuffer) {
+        IWineD3DSurface_GetParent(This->depthStencilBuffer, &stencilBufferParent);
+        IUnknown_Release(stencilBufferParent);          /* once for the get parent */
+        if(IUnknown_Release(stencilBufferParent)  >0){  /* the second time for when it was created */
+            FIXME("(%p) Something's still holding the depthStencilBuffer\n",This);
+        }
+        This->depthStencilBuffer = NULL;
     }
-    This->depthStencilBuffer = NULL;
 
     for(i=0; i < This->NumberOfSwapChains; i++) {
         TRACE("Releasing the implicit swapchain %d\n", i);
-- 
1.3.3



More information about the wine-patches mailing list