From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/command.c | 22 ++++++++++++++++------ libs/vkd3d/vkd3d_private.h | 2 ++ tests/d3d12.c | 35 +++++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index b947ad2f00db..8708aaf98285 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -1610,6 +1610,8 @@ static ULONG STDMETHODCALLTYPE d3d12_command_list_Release(ID3D12GraphicsCommandL { struct d3d12_device *device = list->device;
+ vkd3d_private_store_destroy(&list->private_store); + /* When command pool is destroyed, all command buffers are implicitly freed. */ if (list->allocator) d3d12_command_allocator_free_command_buffer(list->allocator, list); @@ -1625,25 +1627,31 @@ static ULONG STDMETHODCALLTYPE d3d12_command_list_Release(ID3D12GraphicsCommandL static HRESULT STDMETHODCALLTYPE d3d12_command_list_GetPrivateData(ID3D12GraphicsCommandList *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_command_list *list = impl_from_ID3D12GraphicsCommandList(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(&list->private_store, guid, data_size, data); }
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateData(ID3D12GraphicsCommandList *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_command_list *list = impl_from_ID3D12GraphicsCommandList(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(&list->private_store, guid, data_size, data); }
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateDataInterface(ID3D12GraphicsCommandList *iface, REFGUID guid, const IUnknown *data) { - FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data); + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
- return E_NOTIMPL; + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + return vkd3d_set_private_data_interface(&list->private_store, guid, data); }
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetName(ID3D12GraphicsCommandList *iface, const WCHAR *name) @@ -4282,6 +4290,8 @@ static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d list->device = device; ID3D12Device_AddRef(&device->ID3D12Device_iface);
+ vkd3d_private_store_init(&list->private_store); + list->allocator = allocator;
if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator, list))) diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 24d41e84fa45..74e34329a849 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -765,6 +765,8 @@ struct d3d12_command_list
struct d3d12_command_allocator *allocator; struct d3d12_device *device; + + struct vkd3d_private_store private_store; };
HRESULT d3d12_command_list_create(struct d3d12_device *device, diff --git a/tests/d3d12.c b/tests/d3d12.c index 70ee83ef3428..38e66735f4e9 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2562,11 +2562,10 @@ static void test_private_data(void) D3D12_COMMAND_QUEUE_DESC queue_desc; ULONG refcount, expected_refcount; ID3D12CommandAllocator *allocator; - ID3D12CommandQueue *queue; IUnknown *test_object; ID3D12Device *device; ID3D12Object *object; - ID3D12Fence *fence; + IUnknown *unknown; unsigned int size; unsigned int i; IUnknown *ptr; @@ -2580,6 +2579,7 @@ static void test_private_data(void) static const GUID *tests[] = { &IID_ID3D12CommandAllocator, + &IID_ID3D12CommandList, &IID_ID3D12CommandQueue, &IID_ID3D12Fence, }; @@ -2592,15 +2592,22 @@ static void test_private_data(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i) { - object = NULL; if (IsEqualGUID(tests[i], &IID_ID3D12CommandAllocator)) { vkd3d_test_set_context("allocator"); + hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, + &IID_IUnknown, (void **)&unknown); + ok(hr == S_OK, "Failed to create command allocator, hr %#x.\n", hr); + } + else if (IsEqualGUID(tests[i], &IID_ID3D12CommandList)) + { + vkd3d_test_set_context("list"); hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, &IID_ID3D12CommandAllocator, (void **)&allocator); ok(hr == S_OK, "Failed to create command allocator, hr %#x.\n", hr); - hr = ID3D12CommandAllocator_QueryInterface(allocator, &IID_ID3D12Object, (void **)&object); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, + allocator, NULL, &IID_IUnknown, (void **)&unknown); + ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); ID3D12CommandAllocator_Release(allocator); } else if (IsEqualGUID(tests[i], &IID_ID3D12CommandQueue)) @@ -2611,27 +2618,27 @@ static void test_private_data(void) queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queue_desc.NodeMask = 0; hr = ID3D12Device_CreateCommandQueue(device, &queue_desc, - &IID_ID3D12CommandQueue, (void **)&queue); + &IID_IUnknown, (void **)&unknown); ok(hr == S_OK, "Failed to create command queue, hr %#x.\n", hr); - hr = ID3D12CommandQueue_QueryInterface(queue, &IID_ID3D12Object, (void **)&object); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - ID3D12CommandQueue_Release(queue); } else if (IsEqualGUID(tests[i], &IID_ID3D12Fence)) { vkd3d_test_set_context("fence"); hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, - &IID_ID3D12Fence, (void **)&fence); + &IID_IUnknown, (void **)&unknown); ok(hr == S_OK, "Failed to create fence, hr %#x.\n", hr); - hr = ID3D12Fence_QueryInterface(fence, &IID_ID3D12Object, (void **)&object); - ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - ID3D12Fence_Release(fence); } else { - ok(false, "Unhandled object type %u.\n", i); + unknown = NULL; }
+ ok(unknown, "Unhandled object type %u.\n", i); + object = NULL; + hr = IUnknown_QueryInterface(unknown, &IID_ID3D12Object, (void **)&object); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + IUnknown_Release(unknown); + hr = ID3D12Object_SetPrivateData(object, &test_guid, 0, NULL); ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr); hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, NULL);