d3d9: All objects created by device should keep reference to it.

Vitaliy Margolen wine-patch at kievinfo.com
Sat May 6 16:44:00 CDT 2006


ChangeLog:
d3d9: All objects created by device should keep reference to it.

The only object left to fix is surface. But it's a special case and needs
more work.

 dlls/d3d9/cubetexture.c   |    3 +++
 dlls/d3d9/d3d9_private.h  |   44 ++++++++++++++++++++++++++++++--------------
 dlls/d3d9/indexbuffer.c   |    3 +++
 dlls/d3d9/pixelshader.c   |    3 +++
 dlls/d3d9/query.c         |    3 +++
 dlls/d3d9/stateblock.c    |    7 +++++--
 dlls/d3d9/swapchain.c     |    5 ++++-
 dlls/d3d9/texture.c       |    4 +++-
 dlls/d3d9/volumetexture.c |    3 +++
 9 files changed, 57 insertions(+), 18 deletions(-)
-------------- next part --------------
0e8f0a312b05c8eb283708283392f5941fe5ae22
diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c
index 93b74ce..ab53c2b 100644
--- a/dlls/d3d9/cubetexture.c
+++ b/dlls/d3d9/cubetexture.c
@@ -60,6 +60,7 @@ ULONG WINAPI IDirect3DCubeTexture9Impl_R
     if (ref == 0) {
         TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
         IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -270,6 +271,8 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_Cr
         FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
     } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object;
         TRACE("(%p) : Created cube texture %p\n", This, object);
     }
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 3256716..ec55ff2 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -270,6 +270,8 @@ typedef struct IDirect3DSwapChain9Impl
     /* IDirect3DSwapChain9 fields */
     IWineD3DSwapChain      *wineD3DSwapChain;
 
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DSwapChain9Impl;
 
 /* ------------------ */
@@ -379,6 +381,8 @@ typedef struct IDirect3DIndexBuffer9Impl
     /* IDirect3DResource9 fields */
     IWineD3DIndexBuffer    *wineD3DIndexBuffer;
 
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DIndexBuffer9Impl;
 
 /* --------------------- */
@@ -444,11 +448,13 @@ typedef struct IDirect3DCubeTexture9Impl
 {
     /* IUnknown fields */
     const IDirect3DCubeTexture9Vtbl *lpVtbl;
-    LONG                      ref;
+    LONG                    ref;
 
     /* IDirect3DResource9 fields */
-    IWineD3DCubeTexture      *wineD3DCubeTexture;
-    
+    IWineD3DCubeTexture    *wineD3DCubeTexture;
+
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 }  IDirect3DCubeTexture9Impl;
 
 
@@ -473,6 +479,8 @@ typedef struct IDirect3DTexture9Impl
     /* IDirect3DResource9 fields */
     IWineD3DTexture        *wineD3DTexture;
 
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DTexture9Impl;
 
 /* ----------------------- */
@@ -491,11 +499,13 @@ typedef struct IDirect3DVolumeTexture9Im
 {
     /* IUnknown fields */
     const IDirect3DVolumeTexture9Vtbl *lpVtbl;
-    LONG                        ref;
+    LONG                    ref;
 
     /* IDirect3DResource9 fields */
-    IWineD3DVolumeTexture      *wineD3DVolumeTexture;
-    
+    IWineD3DVolumeTexture  *wineD3DVolumeTexture;
+
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DVolumeTexture9Impl;
 
 /* ----------------------- */
@@ -511,13 +521,15 @@ extern const IDirect3DStateBlock9Vtbl Di
  * IDirect3DStateBlock9 implementation structure
  */
 typedef struct  IDirect3DStateBlock9Impl {
-  /* IUnknown fields */
-  const IDirect3DStateBlock9Vtbl *lpVtbl;
-  LONG                      ref;
+    /* IUnknown fields */
+    const IDirect3DStateBlock9Vtbl *lpVtbl;
+    LONG                    ref;
 
-  /* IDirect3DStateBlock9 fields */
-  IWineD3DStateBlock       *wineD3DStateBlock;
+    /* IDirect3DStateBlock9 fields */
+    IWineD3DStateBlock     *wineD3DStateBlock;
 
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DStateBlock9Impl;
 
 
@@ -584,11 +596,13 @@ extern const IDirect3DPixelShader9Vtbl D
 typedef struct IDirect3DPixelShader9Impl {
   /* IUnknown fields */
     const IDirect3DPixelShader9Vtbl *lpVtbl;
-    LONG  ref;
+    LONG                    ref;
 
     /* IDirect3DPixelShader9 fields */
-    IWineD3DPixelShader       *wineD3DPixelShader;
+    IWineD3DPixelShader    *wineD3DPixelShader;
 
+    /* Parent reference */
+    LPDIRECT3DDEVICE9       parentDevice;
 } IDirect3DPixelShader9Impl;
 
 /* --------------- */
@@ -610,7 +624,9 @@ typedef struct IDirect3DQuery9Impl {
 
     /* IDirect3DQuery9 fields */
     IWineD3DQuery       *wineD3DQuery;
-    
+
+    /* Parent reference */
+    LPDIRECT3DDEVICE9    parentDevice;
 } IDirect3DQuery9Impl;
 
 
diff --git a/dlls/d3d9/indexbuffer.c b/dlls/d3d9/indexbuffer.c
index f2706dd..53d8867 100644
--- a/dlls/d3d9/indexbuffer.c
+++ b/dlls/d3d9/indexbuffer.c
@@ -57,6 +57,7 @@ ULONG WINAPI IDirect3DIndexBuffer9Impl_R
 
     if (ref == 0) {
         IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -180,6 +181,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_Crea
         FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
     } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object;
         TRACE("(%p) : Created index buffer %p\n", This, object);
     }
diff --git a/dlls/d3d9/pixelshader.c b/dlls/d3d9/pixelshader.c
index 6c9b75c..a70e0f5 100644
--- a/dlls/d3d9/pixelshader.c
+++ b/dlls/d3d9/pixelshader.c
@@ -56,6 +56,7 @@ ULONG WINAPI IDirect3DPixelShader9Impl_R
 
     if (ref == 0) {
         IWineD3DPixelShader_Release(This->wineD3DPixelShader);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -123,6 +124,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_Crea
         FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
         HeapFree(GetProcessHeap(), 0 , object);
     } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppShader = (IDirect3DPixelShader9*) object;
         TRACE("(%p) : Created pixel shader %p\n", This, object);
     }
diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c
index aa448d2..bba6fb1 100644
--- a/dlls/d3d9/query.c
+++ b/dlls/d3d9/query.c
@@ -56,6 +56,7 @@ ULONG WINAPI IDirect3DQuery9Impl_Release
     TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
 
     if (ref == 0) {
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -145,6 +146,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_Crea
         FIXME("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
     } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppQuery = (LPDIRECT3DQUERY9) object;
         TRACE("(%p) : Created query %p\n", This , object);
     }
diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c
index 1e0b624..1d69410 100644
--- a/dlls/d3d9/stateblock.c
+++ b/dlls/d3d9/stateblock.c
@@ -57,6 +57,7 @@ ULONG WINAPI IDirect3DStateBlock9Impl_Re
 
     if (ref == 0) {
         IWineD3DStateBlock_Release(This->wineD3DStateBlock);    
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -116,8 +117,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_Crea
        FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
        HeapFree(GetProcessHeap(), 0, object);
    } else {
-       *ppStateBlock = (IDirect3DStateBlock9*)object;
-       TRACE("(%p) : Created stateblock %p\n", This, object);
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
+        *ppStateBlock = (IDirect3DStateBlock9*)object;
+        TRACE("(%p) : Created stateblock %p\n", This, object);
    }
    TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
    return hrc;
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index 4eac38e..12b3a3b 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -58,6 +58,7 @@ ULONG WINAPI IDirect3DSwapChain9Impl_Rel
 
     if (ref == 0) {
         IWineD3DSwapChain_Release(This->wineD3DSwapChain);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -192,7 +193,9 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_Cr
     if (hrc != D3D_OK) {
         FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
         HeapFree(GetProcessHeap(), 0 , object);
-    }else{
+    } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *pSwapChain = (IDirect3DSwapChain9 *)object;
         TRACE("(%p) : Created swapchain %p\n", This, *pSwapChain);
     }
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index 47c9324..1c3549a 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -59,6 +59,7 @@ ULONG WINAPI IDirect3DTexture9Impl_Relea
 
     if (ref == 0) {
         IWineD3DTexture_Release(This->wineD3DTexture);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -263,7 +264,8 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_Cr
         FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
    } else {
-
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppTexture= (LPDIRECT3DTEXTURE9) object;
         TRACE("(%p) Created Texture %p, %p\n", This, object, object->wineD3DTexture);
    }
diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c
index 032bdf5..ee18dc8 100644
--- a/dlls/d3d9/volumetexture.c
+++ b/dlls/d3d9/volumetexture.c
@@ -58,6 +58,7 @@ ULONG WINAPI IDirect3DVolumeTexture9Impl
 
     if (ref == 0) {
         IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
+        IUnknown_Release(This->parentDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -267,6 +268,8 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_Cr
         FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
     } else {
+        IUnknown_AddRef(iface);
+        object->parentDevice = iface;
         *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object;
         TRACE("(%p) : Created volume texture %p\n", This, object);
     }


More information about the wine-patches mailing list