From 4cd36fc5539f686c07f89dcd7aca25e4de955c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 23 Jan 2018 13:30:16 +0100 Subject: [PATCH] libs/vkd3d: Implement d3d12_device_GetAdapterLuid(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/vkd3d.h | 2 ++ libs/vkd3d/device.c | 16 +++++++++++----- libs/vkd3d/vkd3d_main.c | 8 ++++---- libs/vkd3d/vkd3d_private.h | 4 +++- tests/vkd3d_api.c | 23 +++++++++++++++++++++++ 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/include/vkd3d.h b/include/vkd3d.h index 0eb85ea2..033017e7 100644 --- a/include/vkd3d.h +++ b/include/vkd3d.h @@ -65,6 +65,8 @@ struct vkd3d_device_create_info const struct vkd3d_instance_create_info *instance_create_info; VkPhysicalDevice vk_physical_device; + + LUID adapter_luid; }; /* resource flags */ diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 21e09f10..e6210fc4 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2052,7 +2052,11 @@ static void STDMETHODCALLTYPE d3d12_device_GetResourceTiling(ID3D12Device *iface static LUID * STDMETHODCALLTYPE d3d12_device_GetAdapterLuid(ID3D12Device *iface, LUID *luid) { - FIXME("iface %p, luid %p stub!\n", iface, luid); + struct d3d12_device *device = impl_from_ID3D12Device(iface); + + TRACE("iface %p, luid %p.\n", iface, luid); + + *luid = device->adapter_luid; return luid; } @@ -2117,7 +2121,7 @@ struct d3d12_device *unsafe_impl_from_ID3D12Device(ID3D12Device *iface) } static HRESULT d3d12_device_init(struct d3d12_device *device, - struct vkd3d_instance *instance, VkPhysicalDevice vk_physical_device) + struct vkd3d_instance *instance, const struct vkd3d_device_create_info *create_info) { HRESULT hr; @@ -2131,7 +2135,9 @@ static HRESULT d3d12_device_init(struct d3d12_device *device, device->join_thread = instance->join_thread; device->wchar_size = instance->wchar_size; - if (FAILED(hr = vkd3d_create_vk_device(device, vk_physical_device))) + device->adapter_luid = create_info->adapter_luid; + + if (FAILED(hr = vkd3d_create_vk_device(device, create_info->vk_physical_device))) { vkd3d_instance_decref(device->vkd3d_instance); return hr; @@ -2163,7 +2169,7 @@ static HRESULT d3d12_device_init(struct d3d12_device *device, } HRESULT d3d12_device_create(struct vkd3d_instance *instance, - VkPhysicalDevice vk_physical_device, struct d3d12_device **device) + const struct vkd3d_device_create_info *create_info, struct d3d12_device **device) { struct d3d12_device *object; HRESULT hr; @@ -2171,7 +2177,7 @@ HRESULT d3d12_device_create(struct vkd3d_instance *instance, if (!(object = vkd3d_malloc(sizeof(*object)))) return E_OUTOFMEMORY; - if (FAILED(hr = d3d12_device_init(object, instance, vk_physical_device))) + if (FAILED(hr = d3d12_device_init(object, instance, create_info))) { vkd3d_free(object); return hr; diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index d3b0bf4f..7dd7a1d9 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -20,13 +20,13 @@ #include "vkd3d_private.h" HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info, - REFIID riid, void **device) + REFIID iid, void **device) { struct vkd3d_instance *instance; struct d3d12_device *object; HRESULT hr; - TRACE("create_info %p, riid %s, device %p.\n", create_info, debugstr_guid(riid), device); + TRACE("create_info %p, iid %s, device %p.\n", create_info, debugstr_guid(iid), device); if (!create_info || !device) return E_INVALIDARG; @@ -64,13 +64,13 @@ HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info, return E_FAIL; } - hr = d3d12_device_create(instance, create_info->vk_physical_device, &object); + hr = d3d12_device_create(instance, create_info, &object); vkd3d_instance_decref(instance); if (FAILED(hr)) return hr; return return_interface((IUnknown *)&object->ID3D12Device_iface, &IID_ID3D12Device, - riid, device); + iid, device); } /* ID3D12RootSignatureDeserializer */ diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index f4bae9d4..b3607853 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -665,10 +665,12 @@ struct d3d12_device vkd3d_create_thread_pfn create_thread; vkd3d_join_thread_pfn join_thread; + + LUID adapter_luid; }; HRESULT d3d12_device_create(struct vkd3d_instance *instance, - VkPhysicalDevice vk_physical_device, struct d3d12_device **device) DECLSPEC_HIDDEN; + const struct vkd3d_device_create_info *create_info, struct d3d12_device **device) DECLSPEC_HIDDEN; struct d3d12_device *unsafe_impl_from_ID3D12Device(ID3D12Device *iface) DECLSPEC_HIDDEN; HRESULT vkd3d_create_buffer(struct d3d12_device *device, diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index 8dd7c78f..375bd6d4 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -299,6 +299,28 @@ static void test_physical_device(void) ok(!refcount, "Instance has %u references left.\n", refcount); } +static void test_adapter_luid(void) +{ + struct vkd3d_device_create_info create_info; + ID3D12Device *device; + ULONG refcount; + HRESULT hr; + LUID luid; + + create_info = device_default_create_info; + create_info.adapter_luid.HighPart = 0xdeadc0de; + create_info.adapter_luid.LowPart = 0xdeadbeef; + hr = vkd3d_create_device(&create_info, &IID_ID3D12Device, (void **)&device); + ok(hr == S_OK, "Failed to create device, hr %#x.\n", hr); + + luid = ID3D12Device_GetAdapterLuid(device); + ok(luid.HighPart == 0xdeadc0de && luid.LowPart == 0xdeadbeef, + "Got unexpected LUID %08x:%08x.\n", luid.HighPart, luid.LowPart); + + refcount = ID3D12Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + static void test_vkd3d_queue(void) { ID3D12CommandQueue *direct_queue, *compute_queue, *copy_queue; @@ -362,5 +384,6 @@ START_TEST(vkd3d_api) run_test(test_create_device); run_test(test_required_device_extensions); run_test(test_physical_device); + run_test(test_adapter_luid); run_test(test_vkd3d_queue); }