From 6dcae77cc981226f67de55746bf3a44c90037c4f Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sat, 20 May 2006 10:36:33 -0600 Subject: [PATCH] d3d9: All objects created by device should keep reference to it. --- 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(-) diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c index 93b74cedc67..ab53c2bcc1d 100644 --- a/dlls/d3d9/cubetexture.c +++ b/dlls/d3d9/cubetexture.c @@ -60,6 +60,7 @@ ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) { 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_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, 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 32567160169..ec55ff222f5 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 IDirect3DVolumeTexture9Impl { /* 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 Direct3DStateBlock9_Vtbl; * 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 Direct3DPixelShader9_Vtbl; 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 f2706ddb45d..53d88672582 100644 --- a/dlls/d3d9/indexbuffer.c +++ b/dlls/d3d9/indexbuffer.c @@ -57,6 +57,7 @@ ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) { if (ref == 0) { IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -180,6 +181,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, 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 7fed701169f..3dacc008ef7 100644 --- a/dlls/d3d9/pixelshader.c +++ b/dlls/d3d9/pixelshader.c @@ -56,6 +56,7 @@ ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) { if (ref == 0) { IWineD3DPixelShader_Release(This->wineD3DPixelShader); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -123,6 +124,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, C 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 aa448d209e2..bba6fb11c87 100644 --- a/dlls/d3d9/query.c +++ b/dlls/d3d9/query.c @@ -56,6 +56,7 @@ ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) { 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_CreateQuery(LPDIRECT3DDEVICE9 iface, D3DQUER 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 1e0b624618f..1d6941054b8 100644 --- a/dlls/d3d9/stateblock.c +++ b/dlls/d3d9/stateblock.c @@ -57,6 +57,7 @@ ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface) { if (ref == 0) { IWineD3DStateBlock_Release(This->wineD3DStateBlock); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -116,8 +117,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3 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 4eac38ee3df..12b3a3badd9 100644 --- a/dlls/d3d9/swapchain.c +++ b/dlls/d3d9/swapchain.c @@ -58,6 +58,7 @@ ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface) { if (ref == 0) { IWineD3DSwapChain_Release(This->wineD3DSwapChain); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -192,7 +193,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE 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 47c93241086..1c3549a4263 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -59,6 +59,7 @@ ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) { if (ref == 0) { IWineD3DTexture_Release(This->wineD3DTexture); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -263,7 +264,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UIN 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 032bdf5a099..ee18dc865e8 100644 --- a/dlls/d3d9/volumetexture.c +++ b/dlls/d3d9/volumetexture.c @@ -58,6 +58,7 @@ ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) if (ref == 0) { IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture); + IUnknown_Release(This->parentDevice); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -267,6 +268,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 ifac 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); }