Henri Verbeet : d3d10core: Keep a reference to the wined3d device in the d3d10 device.

Alexandre Julliard julliard at winehq.org
Mon Feb 23 10:00:23 CST 2009


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Feb 23 09:16:01 2009 +0100

d3d10core: Keep a reference to the wined3d device in the d3d10 device.

---

 dlls/d3d10core/d3d10core_private.h |    2 ++
 dlls/d3d10core/device.c            |   23 ++++++++++++++++-------
 dlls/d3d8/device.c                 |    6 ++++++
 dlls/d3d9/device.c                 |    6 ++++++
 dlls/ddraw/ddraw.c                 |    6 ++++++
 dlls/wined3d/directx.c             |    3 +++
 include/wine/wined3d.idl           |    4 ++++
 7 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index c48a72c..263c22d 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -52,6 +52,8 @@ struct d3d10_device
     const struct IWineD3DDeviceParentVtbl *device_parent_vtbl;
     IUnknown *outer_unknown;
     LONG refcount;
+
+    IWineD3DDevice *wined3d_device;
 };
 
 /* ID3D10Texture2D */
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 7eaa659..46e57b2 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -75,6 +75,8 @@ static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
 
     TRACE("%p decreasing refcount to %u\n", This, refcount);
 
+    if (This->wined3d_device) IWineD3DDevice_Release(This->wined3d_device);
+
     return refcount;
 }
 
@@ -590,6 +592,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device *ifac
 static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *iface,
         const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture2D **texture)
 {
+    struct d3d10_device *This = (struct d3d10_device *)iface;
     struct d3d10_texture2d *object;
     HRESULT hr;
 
@@ -608,7 +611,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
 
     if (desc->MipLevels == 1 && desc->ArraySize == 1)
     {
-        IWineD3DDevice *wined3d_device;
         IWineDXGIDevice *wine_device;
 
         hr = ID3D10Device_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
@@ -621,24 +623,20 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
 
         hr = IWineDXGIDevice_create_surface(wine_device, NULL, 0, NULL,
                 (IUnknown *)object, (void **)&object->dxgi_surface);
+        IWineDXGIDevice_Release(wine_device);
         if (FAILED(hr))
         {
             ERR("Failed to create DXGI surface, returning %#x\n", hr);
             HeapFree(GetProcessHeap(), 0, object);
-            IWineDXGIDevice_Release(wine_device);
             return hr;
         }
 
-        wined3d_device = IWineDXGIDevice_get_wined3d_device(wine_device);
-        IWineDXGIDevice_Release(wine_device);
-
         FIXME("Implement DXGI<->wined3d usage conversion\n");
 
-        hr = IWineD3DDevice_CreateSurface(wined3d_device, desc->Width, desc->Height,
+        hr = IWineD3DDevice_CreateSurface(This->wined3d_device, desc->Width, desc->Height,
                 wined3dformat_from_dxgi_format(desc->Format), FALSE, FALSE, 0,
                 &object->wined3d_surface, WINED3DRTYPE_SURFACE, desc->Usage, WINED3DPOOL_DEFAULT,
                 desc->SampleDesc.Count, desc->SampleDesc.Quality, NULL, SURFACE_OPENGL, (IUnknown *)object);
-        IWineD3DDevice_Release(wined3d_device);
         if (FAILED(hr))
         {
             ERR("CreateSurface failed, returning %#x\n", hr);
@@ -1144,6 +1142,16 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+{
+    struct d3d10_device *This = device_from_device_parent(iface);
+
+    TRACE("iface %p, device %p\n", iface, device);
+
+    IWineD3DDevice_AddRef(device);
+    This->wined3d_device = device;
+}
+
 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@@ -1287,6 +1295,7 @@ const struct IWineD3DDeviceParentVtbl d3d10_wined3d_device_parent_vtbl =
     device_parent_AddRef,
     device_parent_Release,
     /* IWineD3DDeviceParent methods */
+    device_parent_WineD3DDeviceCreated,
     device_parent_CreateSurface,
     device_parent_CreateRenderTarget,
     device_parent_CreateDepthStencilSurface,
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 908a1a8..643cdbc 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2394,6 +2394,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+{
+    TRACE("iface %p, device %p\n", iface, device);
+}
+
 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@@ -2591,6 +2596,7 @@ const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
     device_parent_AddRef,
     device_parent_Release,
     /* IWineD3DDeviceParent methods */
+    device_parent_WineD3DDeviceCreated,
     device_parent_CreateSurface,
     device_parent_CreateRenderTarget,
     device_parent_CreateDepthStencilSurface,
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index c273d70..d551ff6 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1929,6 +1929,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+{
+    TRACE("iface %p, device %p\n", iface, device);
+}
+
 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@@ -2130,6 +2135,7 @@ const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl =
     device_parent_AddRef,
     device_parent_Release,
     /* IWineD3DDeviceParent methods */
+    device_parent_WineD3DDeviceCreated,
     device_parent_CreateSurface,
     device_parent_CreateRenderTarget,
     device_parent_CreateDepthStencilSurface,
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index a4d2705..3e5b1fa 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -3409,6 +3409,11 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+{
+    TRACE("iface %p, device %p\n", iface, device);
+}
+
 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
         IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
         WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
@@ -3624,6 +3629,7 @@ const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl =
     device_parent_AddRef,
     device_parent_Release,
     /* IWineD3DDeviceParent methods */
+    device_parent_WineD3DDeviceCreated,
     device_parent_CreateSurface,
     device_parent_CreateRenderTarget,
     device_parent_CreateDepthStencilSurface,
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index f6af28c..66eec6b 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -3722,6 +3722,9 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
     for(i = 0; i < PATCHMAP_SIZE; i++) {
         list_init(&object->patches[i]);
     }
+
+    IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent, *ppReturnedDeviceInterface);
+
     return WINED3D_OK;
 }
 #undef GLINFO_LOCATION
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 05e55a7..d53aa24 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -2188,6 +2188,10 @@ interface IWineD3DDevice;
 ]
 interface IWineD3DDeviceParent : IUnknown
 {
+    void WineD3DDeviceCreated(
+        [in] IWineD3DDevice *device
+    );
+
     HRESULT CreateSurface(
         [in] IUnknown *superior,
         [in] UINT width,




More information about the wine-cvs mailing list