=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Implement private data for resources.

Alexandre Julliard julliard at winehq.org
Fri Jan 4 11:47:20 CST 2019


Module: vkd3d
Branch: master
Commit: 781d856ce364afc2ff823de18b8dd39fbc7782c5
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=781d856ce364afc2ff823de18b8dd39fbc7782c5

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Fri Jan  4 14:34:16 2019 +0100

vkd3d: Implement private data for resources.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/resource.c      | 22 ++++++++++++++++------
 libs/vkd3d/vkd3d_private.h |  2 ++
 tests/d3d12.c              |  6 ++++++
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 3fb3c1e..8b628a6 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -706,6 +706,7 @@ static ULONG d3d12_resource_decref(struct d3d12_resource *resource)
 
     if (!refcount)
     {
+        vkd3d_private_store_destroy(&resource->private_store);
         d3d12_resource_destroy(resource, resource->device);
         vkd3d_free(resource);
     }
@@ -781,25 +782,31 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource *iface)
 static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource *iface,
         REFGUID guid, UINT *data_size, void *data)
 {
-    FIXME("iface %p, guid %s, data_size %p, data %p stub!", iface, debugstr_guid(guid), data_size, data);
+    struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
+
+    return vkd3d_get_private_data(&resource->private_store, guid, data_size, data);
 }
 
 static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource *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 d3d12_resource *resource = impl_from_ID3D12Resource(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
+
+    return vkd3d_set_private_data(&resource->private_store, guid, data_size, data);
 }
 
 static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource *iface,
         REFGUID guid, const IUnknown *data)
 {
-    FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
+    struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
+
+    return vkd3d_set_private_data_interface(&resource->private_store, guid, data);
 }
 
 static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, const WCHAR *name)
@@ -1172,6 +1179,8 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12
     resource->heap = NULL;
     resource->heap_offset = 0;
 
+    vkd3d_private_store_init(&resource->private_store);
+
     resource->device = device;
     ID3D12Device_AddRef(&device->ID3D12Device_iface);
 
@@ -1350,6 +1359,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
         object->present_state = D3D12_RESOURCE_STATE_COMMON;
     object->device = d3d12_device;
     ID3D12Device_AddRef(&d3d12_device->ID3D12Device_iface);
+    vkd3d_private_store_init(&object->private_store);
 
     TRACE("Created resource %p.\n", object);
 
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index a7c23f9..76a7a36 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -295,6 +295,8 @@ struct d3d12_resource
     D3D12_RESOURCE_STATES present_state;
 
     struct d3d12_device *device;
+
+    struct vkd3d_private_store private_store;
 };
 
 static inline bool d3d12_resource_is_buffer(const struct d3d12_resource *resource)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index a8cad28..8dd25aa 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -2590,6 +2590,7 @@ static void test_private_data(void)
         &IID_ID3D12Fence,
         &IID_ID3D12Heap,
         &IID_ID3D12PipelineState,
+        &IID_ID3D12Resource,
         &IID_ID3D12RootSignature,
     };
 
@@ -2673,6 +2674,11 @@ static void test_private_data(void)
                     root_signature, DXGI_FORMAT_R8G8B8A8_UNORM, NULL, NULL, NULL);
             ID3D12RootSignature_Release(root_signature);
         }
+        else if (IsEqualGUID(tests[i], &IID_ID3D12Resource))
+        {
+            vkd3d_test_set_context("resource");
+            unknown = (IUnknown *)create_readback_buffer(device, 512);
+        }
         else if (IsEqualGUID(tests[i], &IID_ID3D12RootSignature))
         {
             vkd3d_test_set_context("root signature");




More information about the wine-cvs mailing list