Module: wine Branch: master Commit: 3fd04308abccc735542218f511e7a12b749b1fae URL: http://source.winehq.org/git/wine.git/?a=commit;h=3fd04308abccc735542218f511...
Author: Markus Amsler markus.amsler@oribi.org Date: Tue Dec 5 00:29:31 2006 +0100
d3d: Callback infrastructure for implicit depth stencil surface destruction in IWineD3DDevice.
---
dlls/d3d8/d3d8_private.h | 2 ++ dlls/d3d8/device.c | 2 +- dlls/d3d8/directx.c | 9 +++++++++ dlls/d3d9/d3d9_private.h | 2 ++ dlls/d3d9/device.c | 2 +- dlls/d3d9/directx.c | 8 ++++++++ dlls/ddraw/ddraw.c | 11 ++++++++++- dlls/ddraw/ddraw_private.h | 3 +++ dlls/ddraw/surface.c | 2 +- dlls/wined3d/device.c | 9 +++------ include/wine/wined3d_interface.h | 4 ++-- 11 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index dab2638..4e8b96b 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -591,4 +591,6 @@ extern HRESULT WINAPI D3D8CB_CreateRende DWORD MultisampleQuality, BOOL Lockable, IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
+extern ULONG WINAPI D3D8CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface); + #endif /* __WINE_D3DX8_PRIVATE_H */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index f2b58af..565f4af 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -95,7 +95,7 @@ static ULONG WINAPI IDirect3DDevice8Impl
if (ref == 0) { TRACE("Releasing wined3d device %p\n", This->WineD3DDevice); - IWineD3DDevice_Uninit3D(This->WineD3DDevice); + IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroyDepthStencilSurface); IWineD3DDevice_Release(This->WineD3DDevice); HeapFree(GetProcessHeap(), 0, This->shader_handles); HeapFree(GetProcessHeap(), 0, This); diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index c43aa4a..8c22a6e 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -285,6 +285,15 @@ HRESULT WINAPI D3D8CB_CreateDepthStencil return res; }
+ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) { + IDirect3DSurface8Impl* surfaceParent; + TRACE("(%p) call back\n", pSurface); + + IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent); + IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent); + return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent); +} + static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice8** ppReturnedDeviceInterface) { diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 3b16ef2..5aa7ea6 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -541,4 +541,6 @@ extern HRESULT WINAPI D3D9CB_CreateRende DWORD MultisampleQuality, BOOL Lockable, IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
+extern ULONG WINAPI D3D9CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface); + #endif /* __WINE_D3D9_PRIVATE_H */ diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 87a10bb..bd96b10 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -58,7 +58,7 @@ static ULONG WINAPI IDirect3DDevice9Impl TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) { - IWineD3DDevice_Uninit3D(This->WineD3DDevice); + IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroyDepthStencilSurface); IWineD3DDevice_Release(This->WineD3DDevice); HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index c190784..94f0f17 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -269,6 +269,14 @@ HRESULT WINAPI D3D9CB_CreateDepthStencil return res; }
+ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) { + IDirect3DSurface9Impl* surfaceParent; + TRACE("(%p) call back\n", pSurface); + + IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent); + IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent); + return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent); +}
HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 85b040f..b613c46 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -1621,7 +1621,7 @@ IDirectDrawImpl_RecreateAllSurfaces(IDir /* Should happen almost never */ FIXME("(%p) Switching to non-opengl surfaces with d3d started. Is this a bug?\n", This); /* Shutdown d3d */ - IWineD3DDevice_Uninit3D(This->wineD3DDevice); + IWineD3DDevice_Uninit3D(This->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface); } /* Contrary: D3D starting is handled by the caller, because it knows the render target */
@@ -1679,6 +1679,15 @@ D3D7CB_CreateSurface(IUnknown *device, return D3D_OK; }
+ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) { + IUnknown* surfaceParent; + TRACE("(%p) call back\n", pSurface); + + IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent); + IUnknown_Release(surfaceParent); + return IUnknown_Release(surfaceParent); +} + /***************************************************************************** * IDirectDrawImpl_CreateNewSurface * diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index aaa61a9..9e57b2d 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -75,6 +75,9 @@ typedef struct IDirect3DExecuteBufferImp typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl; typedef struct IParentImpl IParentImpl;
+/* Callbacks for implicit object destruction */ +extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface); + /***************************************************************************** * IDirectDraw implementation structure *****************************************************************************/ diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index ab7eda6..cab163b 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -311,7 +311,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDr IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL, 0); IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
- if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice) != D3D_OK) + if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface) != D3D_OK) { /* Not good */ ERR("(%p) Failed to uninit 3D\n", This); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index a12af38..939dfbe 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2148,10 +2148,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl return WINED3D_OK; }
-static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface) { +static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyDepthStencilSurface) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; int sampler; - IUnknown* stencilBufferParent; IUnknown* swapChainParent; uint i; TRACE("(%p)\n", This); @@ -2186,10 +2185,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl This->renderTarget = NULL;
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); + if(D3DCB_DestroyDepthStencilSurface > 0) { + FIXME("(%p) Something's still holding the depthStencilBuffer\n", This); } This->depthStencilBuffer = NULL; } diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 58ab88a..6017818 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -359,7 +359,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction, struct IWineD3DPixelShader** ppShader, IUnknown *pParent) PURE; STDMETHOD_(HRESULT,CreatePalette)(THIS_ DWORD Flags, PALETTEENTRY *PalEnt, struct IWineD3DPalette **Palette, IUnknown *Parent); STDMETHOD(Init3D)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain); - STDMETHOD(Uninit3D)(THIS); + STDMETHOD(Uninit3D)(THIS, D3DCB_DESTROYSURFACEFN pFn); STDMETHOD_(void, SetFullscreen)(THIS_ BOOL fullscreen); STDMETHOD(EnumDisplayModes)(THIS_ DWORD Flags, UINT Width, UINT Height, WINED3DFORMAT Format, void *context, D3DCB_ENUMDISPLAYMODESCALLBACK cb) PURE; STDMETHOD(EvictManagedResources)(THIS) PURE; @@ -499,7 +499,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD #define IWineD3DDevice_CreatePixelShader(p,a,b,c) (p)->lpVtbl->CreatePixelShader(p,a,b,c) #define IWineD3DDevice_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) #define IWineD3DDevice_Init3D(p, a, b) (p)->lpVtbl->Init3D(p, a, b) -#define IWineD3DDevice_Uninit3D(p) (p)->lpVtbl->Uninit3D(p) +#define IWineD3DDevice_Uninit3D(p, a) (p)->lpVtbl->Uninit3D(p, a) #define IWineD3DDevice_SetFullscreen(p, a) (p)->lpVtbl->SetFullscreen(p, a) #define IWineD3DDevice_EnumDisplayModes(p,a,b,c,d,e,f) (p)->lpVtbl->EnumDisplayModes(p,a,b,c,d,e,f) #define IWineD3DDevice_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p)