mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d: Implement private data for fences.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
d18360a8b7
commit
0ddd6dbbb6
226
tests/d3d12.c
226
tests/d3d12.c
@@ -2565,7 +2565,9 @@ static void test_private_data(void)
|
||||
IUnknown *test_object;
|
||||
ID3D12Device *device;
|
||||
ID3D12Object *object;
|
||||
ID3D12Fence *fence;
|
||||
unsigned int size;
|
||||
unsigned int i;
|
||||
IUnknown *ptr;
|
||||
HRESULT hr;
|
||||
|
||||
@@ -2574,6 +2576,11 @@ static void test_private_data(void)
|
||||
static const GUID test_guid2
|
||||
= {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
|
||||
static const DWORD data[] = {1, 2, 3, 4};
|
||||
static const GUID *tests[] =
|
||||
{
|
||||
&IID_ID3D12CommandQueue,
|
||||
&IID_ID3D12Fence,
|
||||
};
|
||||
|
||||
if (!(device = create_device()))
|
||||
{
|
||||
@@ -2581,114 +2588,139 @@ static void test_private_data(void)
|
||||
return;
|
||||
}
|
||||
|
||||
queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
queue_desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
queue_desc.NodeMask = 0;
|
||||
hr = ID3D12Device_CreateCommandQueue(device, &queue_desc, &IID_ID3D12CommandQueue, (void **)&queue);
|
||||
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);
|
||||
for (i = 0; i < ARRAY_SIZE(tests); ++i)
|
||||
{
|
||||
object = NULL;
|
||||
if (IsEqualGUID(tests[i], &IID_ID3D12CommandQueue))
|
||||
{
|
||||
vkd3d_test_set_context("queue");
|
||||
queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
queue_desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
queue_desc.NodeMask = 0;
|
||||
hr = ID3D12Device_CreateCommandQueue(device, &queue_desc,
|
||||
&IID_ID3D12CommandQueue, (void **)&queue);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, ~0u, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, ~0u, NULL);
|
||||
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
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);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, ~0u, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, ~0u, NULL);
|
||||
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(ptr) * 2;
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!ptr, "Got unexpected pointer %p.\n", ptr);
|
||||
ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(ptr) * 2;
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!ptr, "Got unexpected pointer %p.\n", ptr);
|
||||
ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
|
||||
|
||||
hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE,
|
||||
&IID_ID3D12Fence, (void **)&test_object);
|
||||
ok(hr == S_OK, "Failed to create fence, hr %#x.\n", hr);
|
||||
hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE,
|
||||
&IID_ID3D12Fence, (void **)&test_object);
|
||||
ok(hr == S_OK, "Failed to create fence, hr %#x.\n", hr);
|
||||
|
||||
refcount = get_refcount(test_object);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
expected_refcount = refcount + 1;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
refcount = get_refcount(test_object);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
expected_refcount = refcount + 1;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
--expected_refcount;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
--expected_refcount;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(data);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, size, data);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, 42, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, 42, NULL);
|
||||
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(data);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, size, data);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, 42, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3D12Object_SetPrivateData(object, &test_guid, 42, NULL);
|
||||
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
++expected_refcount;
|
||||
size = 2 * sizeof(ptr);
|
||||
ptr = NULL;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(test_object), "Got unexpected size %u.\n", size);
|
||||
++expected_refcount;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
IUnknown_Release(ptr);
|
||||
--expected_refcount;
|
||||
hr = ID3D12Object_SetPrivateDataInterface(object, &test_guid, (IUnknown *)test_object);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
++expected_refcount;
|
||||
size = 2 * sizeof(ptr);
|
||||
ptr = NULL;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(test_object), "Got unexpected size %u.\n", size);
|
||||
++expected_refcount;
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
IUnknown_Release(ptr);
|
||||
--expected_refcount;
|
||||
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(ptr), "Got unexpected size %u.\n", size);
|
||||
size = 2 * sizeof(ptr);
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(ptr), "Got unexpected size %u.\n", size);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(ptr), "Got unexpected size %u.\n", size);
|
||||
size = 2 * sizeof(ptr);
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(ptr), "Got unexpected size %u.\n", size);
|
||||
refcount = get_refcount(test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||
(unsigned int)refcount, (unsigned int)expected_refcount);
|
||||
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(object), "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid2, &size, &ptr);
|
||||
ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!size, "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid, &size, &ptr);
|
||||
ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr);
|
||||
ok(size == sizeof(object), "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
size = 1;
|
||||
hr = ID3D12Object_GetPrivateData(object, &test_guid2, &size, &ptr);
|
||||
ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
|
||||
ok(!size, "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
|
||||
ID3D12Object_Release(object);
|
||||
ID3D12Object_Release(object);
|
||||
|
||||
refcount = IUnknown_Release(test_object);
|
||||
ok(!refcount, "Test object has %u references left.\n", (unsigned int)refcount);
|
||||
refcount = IUnknown_Release(test_object);
|
||||
ok(!refcount, "Test object has %u references left.\n", (unsigned int)refcount);
|
||||
|
||||
vkd3d_test_set_context(NULL);
|
||||
}
|
||||
|
||||
refcount = ID3D12Device_Release(device);
|
||||
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
|
||||
|
Reference in New Issue
Block a user