Henri Verbeet : dxgi: Implement dxgi_device_SetPrivateData().

Alexandre Julliard julliard at wine.codeweavers.com
Thu Feb 12 10:13:40 CST 2015


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Feb 12 09:34:57 2015 +0100

dxgi: Implement dxgi_device_SetPrivateData().

---

 dlls/dxgi/device.c       | 13 +++++++++++--
 dlls/dxgi/dxgi_private.h |  3 +++
 dlls/dxgi/tests/device.c | 10 +++++-----
 dlls/dxgi/utils.c        | 28 ++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index a6f72ca..f0c38a0 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -84,6 +84,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
         wined3d_device_decref(This->wined3d_device);
         LeaveCriticalSection(&dxgi_cs);
         IDXGIFactory1_Release(This->factory);
+        wined3d_private_store_cleanup(&This->private_store);
         HeapFree(GetProcessHeap(), 0, This);
     }
 
@@ -95,9 +96,11 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
 static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IWineDXGIDevice *iface,
         REFGUID guid, UINT data_size, const void *data)
 {
-    FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
+    struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
+
+    return dxgi_set_private_data(&device->private_store, guid, data_size, data);
 }
 
 static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDevice *iface,
@@ -357,6 +360,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
 
     device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
     device->refcount = 1;
+    wined3d_private_store_init(&device->private_store);
 
     layer_base = device + 1;
 
@@ -364,6 +368,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
             device, &IID_IUnknown, (void **)&device->child_layer)))
     {
         WARN("Failed to create device, returning %#x.\n", hr);
+        wined3d_private_store_cleanup(&device->private_store);
         return hr;
     }
 
@@ -372,6 +377,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
     {
         ERR("DXGI device should implement IWineD3DDeviceParent.\n");
         IUnknown_Release(device->child_layer);
+        wined3d_private_store_cleanup(&device->private_store);
         return hr;
     }
     wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
@@ -386,6 +392,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
         if (SUCCEEDED(hr))
             hr = E_FAIL;
         IUnknown_Release(device->child_layer);
+        wined3d_private_store_cleanup(&device->private_store);
         return hr;
     }
 
@@ -397,6 +404,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
     {
         WARN("Failed to create a wined3d device, returning %#x.\n", hr);
         IUnknown_Release(device->child_layer);
+        wined3d_private_store_cleanup(&device->private_store);
         return hr;
     }
 
@@ -409,6 +417,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
         ERR("Failed to initialize 3D, hr %#x.\n", hr);
         wined3d_device_decref(device->wined3d_device);
         IUnknown_Release(device->child_layer);
+        wined3d_private_store_cleanup(&device->private_store);
         return hr;
     }
 
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 278137d..a22916d 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -76,6 +76,8 @@ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
 
 DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
 enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
+HRESULT dxgi_set_private_data(struct wined3d_private_store *store,
+        REFGUID guid, UINT data_size, const void *data) DECLSPEC_HIDDEN;
 
 /* IDXGIFactory */
 struct dxgi_factory
@@ -99,6 +101,7 @@ struct dxgi_device
     IWineDXGIDevice IWineDXGIDevice_iface;
     IUnknown *child_layer;
     LONG refcount;
+    struct wined3d_private_store private_store;
     struct wined3d_device *wined3d_device;
     IDXGIFactory1 *factory;
 };
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c
index 70cf3be..be571a4 100644
--- a/dlls/dxgi/tests/device.c
+++ b/dlls/dxgi/tests/device.c
@@ -621,13 +621,13 @@ static void test_private_data(void)
      * NULL interface is not considered a clear but as setting an interface pointer that
      * happens to be NULL. */
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 0, NULL);
-    todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
     hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
     todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
     todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
-    todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
 
     hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
     todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -662,13 +662,13 @@ static void test_private_data(void)
     todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     size = sizeof(data);
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, size, data);
-    todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     refcount = get_refcount((IUnknown *)test_object);
     ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
-    todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
-    todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
 
     hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
             (IUnknown *)test_object);
diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c
index 979c972..1a8db7e 100644
--- a/dlls/dxgi/utils.c
+++ b/dlls/dxgi/utils.c
@@ -324,3 +324,31 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format)
             return WINED3DFMT_UNKNOWN;
     }
 }
+
+HRESULT dxgi_set_private_data(struct wined3d_private_store *store,
+        REFGUID guid, UINT data_size, const void *data)
+{
+    struct wined3d_private_data *entry;
+    HRESULT hr;
+
+    if (!data)
+    {
+        EnterCriticalSection(&dxgi_cs);
+        if (!(entry = wined3d_private_store_get_private_data(store, guid)))
+        {
+            LeaveCriticalSection(&dxgi_cs);
+            return S_FALSE;
+        }
+
+        wined3d_private_store_free_private_data(store, entry);
+        LeaveCriticalSection(&dxgi_cs);
+
+        return S_OK;
+    }
+
+    EnterCriticalSection(&dxgi_cs);
+    hr = wined3d_private_store_set_private_data(store, guid, data, data_size, 0);
+    LeaveCriticalSection(&dxgi_cs);
+
+    return hr;
+}




More information about the wine-cvs mailing list