A resend of 8634 with minor modifications.
From: Elizabeth Figura zfigura@codeweavers.com
Fixes: 6bfd4eb5ec48581479235bd99a88adab91a2aee2 --- dlls/dxcore/dxcore.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 9aa28f8a3a0..6d475030258 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -27,6 +27,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxcore);
+static struct dxcore_adapter_factory *dxcore_adapter_factory; + struct dxcore_adapter { IDXCoreAdapter IDXCoreAdapter_iface; @@ -378,7 +380,10 @@ static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_Release(IDXCoreAdapterFact TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
if (!refcount) + { free(factory); + dxcore_adapter_factory = NULL; + }
return refcount; } @@ -506,25 +511,23 @@ static const struct IDXCoreAdapterFactoryVtbl dxcore_adapter_factory_vtbl =
HRESULT STDMETHODCALLTYPE DXCoreCreateAdapterFactory(REFIID riid, void **out) { - static struct dxcore_adapter_factory *factory = NULL; - TRACE("riid %s, out %p\n", debugstr_guid(riid), out);
if (!out) return E_POINTER;
- if (!factory) + if (!dxcore_adapter_factory) { - if (!(factory = calloc(1, sizeof(*factory)))) + if (!(dxcore_adapter_factory = calloc(1, sizeof(*dxcore_adapter_factory)))) { *out = NULL; return E_OUTOFMEMORY; }
- factory->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_vtbl; - factory->refcount = 0; + dxcore_adapter_factory->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_vtbl; + dxcore_adapter_factory->refcount = 0; }
TRACE("created IDXCoreAdapterFactory %p.\n", *out); - return IDXCoreAdapterFactory_QueryInterface(&factory->IDXCoreAdapterFactory_iface, riid, out); + return IDXCoreAdapterFactory_QueryInterface(&dxcore_adapter_factory->IDXCoreAdapterFactory_iface, riid, out); }
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/dxcore/tests/dxcore.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 1748307e730..d2b6ce68a1e 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -83,6 +83,8 @@ static void test_DXCoreCreateAdapterFactory(void) refcount = IDXCoreAdapterFactory_Release(factory2); ok(refcount == 1, "got refcount %ld.\n", refcount);
+ check_interface(factory, &IID_IUnknown, TRUE); + check_interface(factory, &IID_IDXCoreAdapterFactory, TRUE); check_interface(factory, &IID_IAgileObject, FALSE); check_interface(factory, &IID_IDXCoreAdapter, FALSE); check_interface(factory, &IID_IDXCoreAdapterList, FALSE); @@ -105,6 +107,8 @@ static void test_DXCoreCreateAdapterFactory(void) refcount = IDXCoreAdapterList_Release(list2); ok(refcount == 0, "got refcount %ld.\n", refcount);
+ check_interface(list, &IID_IUnknown, TRUE); + check_interface(list, &IID_IDXCoreAdapterList, TRUE); check_interface(list, &IID_IAgileObject, FALSE); check_interface(list, &IID_IDXCoreAdapter, FALSE); check_interface(list, &IID_IDXCoreAdapterFactory, FALSE); @@ -129,6 +133,8 @@ static void test_DXCoreCreateAdapterFactory(void) todo_wine ok(refcount == 3, "got refcount %ld.\n", refcount);
+ check_interface(adapter, &IID_IUnknown, TRUE); + check_interface(adapter, &IID_IDXCoreAdapter, TRUE); check_interface(adapter, &IID_IAgileObject, FALSE); check_interface(adapter, &IID_IDXCoreAdapterList, FALSE); check_interface(adapter, &IID_IDXCoreAdapterFactory, FALSE);
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/dxcore/tests/dxcore.c | 95 ++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 29 deletions(-)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index d2b6ce68a1e..a9e4adcaea6 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -55,8 +55,6 @@ static void test_DXCoreCreateAdapterFactory(void) IDXCoreAdapterList *list = (void *)0xdeadbeef; IDXCoreAdapter *adapter2 = (void *)0xdeadbeef; IDXCoreAdapter *adapter = (void *)0xdeadbeef; - struct DXCoreHardwareID *hardware_id; - void *buffer = (void *)0xdeadbeef; uint32_t adapter_count = 0; LONG refcount; HRESULT hr; @@ -139,33 +137,6 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(adapter, &IID_IDXCoreAdapterList, FALSE); check_interface(adapter, &IID_IDXCoreAdapterFactory, FALSE);
- hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); - ok(hr == E_POINTER, "got hr %#lx.\n", hr); - hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, buffer); - ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); - hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, buffer); - ok(hr == DXGI_ERROR_INVALID_CALL, "got hr %#lx.\n", hr); - - buffer = calloc(1, sizeof(HardwareID)); - ok(buffer != NULL, "failed to allocate memory for buffer.\n"); - hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(HardwareID), buffer); - ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); - free(buffer); - buffer = calloc(1, sizeof(DXCoreHardwareID)); - ok(buffer != NULL, "failed to allocate memory for buffer.\n"); - hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, sizeof(DXCoreHardwareID), buffer); - ok(hr == DXGI_ERROR_INVALID_CALL, "got hr %#lx.\n", hr); - free(buffer); - - buffer = calloc(1, sizeof(DXCoreHardwareID)); - ok(buffer != NULL, "failed to allocate memory for buffer.\n"); - hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(DXCoreHardwareID), buffer); - ok(hr == S_OK, "got hr %#lx.\n", hr); - hardware_id = buffer; - ok(hardware_id->vendorID != 0, "failed to get vendorID\n"); - ok(hardware_id->deviceID != 0, "failed to get deviceID\n"); - free(buffer); - refcount = IDXCoreAdapter_Release(adapter); todo_wine ok(refcount == 2, "got refcount %ld.\n", refcount); @@ -175,6 +146,71 @@ static void test_DXCoreCreateAdapterFactory(void) ok(refcount == 0, "got refcount %ld.\n", refcount); }
+static void test_GetProperty(void) +{ + IDXCoreAdapterFactory *factory; + IDXCoreAdapterList *list; + DXCoreHardwareID hwid[2]; + IDXCoreAdapter *adapter; + uint32_t count; + size_t size; + HRESULT hr; + + if (FAILED(pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory))) + return; + + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, + &IID_IDXCoreAdapterList, (void **)&list); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (uint32_t i = 0; i < count; ++i) + { + hr = IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, hwid); + ok(hr == DXGI_ERROR_INVALID_CALL, "Got hr %#lx.\n", hr); + + /* HardwareID */ + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, hwid); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) - 1, hwid); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, &size); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + if (hr == S_OK) + ok(size == sizeof(*hwid), "Got size %Iu.\n", size); + + memset(hwid, 0, sizeof(hwid)); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]), hwid); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(!!hwid[0].vendorID, "Expected vendorID.\n"); + ok(!!hwid[0].deviceID, "Expected deviceID.\n"); + + memset(hwid, 0, sizeof(hwid)); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) + 1, hwid); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(!!hwid[0].vendorID, "Expected vendorID.\n"); + todo_wine ok(!!hwid[0].deviceID, "Expected deviceID.\n"); + ok(!hwid[1].vendorID, "Expected no vendorID.\n"); + ok(!hwid[1].deviceID, "Expected no deviceID.\n"); + + IDXCoreAdapter_Release(adapter); + } + + IDXCoreAdapterList_Release(list); + + IDXCoreAdapterFactory_Release(factory); +} + START_TEST(dxcore) { HMODULE dxcore_handle = LoadLibraryA("dxcore.dll"); @@ -198,6 +234,7 @@ START_TEST(dxcore) }
test_DXCoreCreateAdapterFactory(); + test_GetProperty();
FreeLibrary(dxcore_handle); }
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/dxcore/tests/dxcore.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index a9e4adcaea6..7677c82eb08 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -153,6 +153,7 @@ static void test_GetProperty(void) DXCoreHardwareID hwid[2]; IDXCoreAdapter *adapter; uint32_t count; + LUID luid[2]; size_t size; HRESULT hr;
@@ -173,6 +174,28 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, hwid); ok(hr == DXGI_ERROR_INVALID_CALL, "Got hr %#lx.\n", hr);
+ /* InstanceLuid */ + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, NULL); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, luid); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) - 1, luid); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, &size); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + if (hr == S_OK) + ok(size == sizeof(*luid), "Got size %Iu.\n", size); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) + 1, luid); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + /* HardwareID */ hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 10 ++++++++++ dlls/dxcore/tests/dxcore.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 6d475030258..e60740cc5eb 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -114,6 +114,16 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac
switch (property) { + case InstanceLuid: + { + LUID *luid = buffer; + + if (buffer_size < sizeof(*luid)) + return E_INVALIDARG; + + *luid = adapter->identifier.adapter_luid; + break; + } case HardwareID: { struct DXCoreHardwareID *hardware_id = buffer; diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 7677c82eb08..36953a757bf 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -178,9 +178,9 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, NULL); ok(hr == E_POINTER, "Got hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, luid); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) - 1, luid); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr); @@ -191,10 +191,10 @@ static void test_GetProperty(void) ok(size == sizeof(*luid), "Got size %Iu.\n", size);
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) + 1, luid); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(hr == S_OK, "Got hr %#lx.\n", hr);
/* HardwareID */ hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 49 ++++++++++++++++++++++++++------------ dlls/dxcore/tests/dxcore.c | 6 ++--- 2 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index e60740cc5eb..e32b79ec2bb 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -102,46 +102,65 @@ static BOOL STDMETHODCALLTYPE dxcore_adapter_IsPropertySupported(IDXCoreAdapter return FALSE; }
+static HRESULT dxcore_adapter_get_property_size(struct dxcore_adapter *adapter, + DXCoreAdapterProperty property, size_t *size) +{ + static const size_t property_sizes[] = + { + [InstanceLuid] = sizeof(LUID), + [HardwareID] = sizeof(DXCoreHardwareID), + }; + + switch (property) + { + case InstanceLuid: + case HardwareID: + *size = property_sizes[property]; + return S_OK; + + default: + FIXME("Property %u not implemented.\n", property); + return DXGI_ERROR_INVALID_CALL; + } +} + static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *iface, DXCoreAdapterProperty property, size_t buffer_size, void *buffer) { struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + size_t size; + HRESULT hr;
TRACE("iface %p, property %u, buffer_size %Iu, buffer %p\n", iface, property, buffer_size, buffer);
if (!buffer) return E_POINTER;
+ if (FAILED(hr = dxcore_adapter_get_property_size(adapter, property, &size))) + return hr; + + if (buffer_size < size) + return E_INVALIDARG; + switch (property) { case InstanceLuid: - { - LUID *luid = buffer; - - if (buffer_size < sizeof(*luid)) - return E_INVALIDARG; - - *luid = adapter->identifier.adapter_luid; + *(LUID *)buffer = adapter->identifier.adapter_luid; break; - } + case HardwareID: { struct DXCoreHardwareID *hardware_id = buffer;
- if (buffer_size != sizeof(DXCoreHardwareID)) - return E_INVALIDARG; - hardware_id->vendorID = adapter->identifier.vendor_id; hardware_id->deviceID = adapter->identifier.device_id; hardware_id->subSysID = adapter->identifier.subsystem_id; hardware_id->revision = adapter->identifier.revision; break; } + default: - { - FIXME("property %u not implemented.\n", property); - return DXGI_ERROR_INVALID_CALL; - } + break; }
return S_OK; diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 36953a757bf..1f5d8c318bd 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -220,9 +220,9 @@ static void test_GetProperty(void)
memset(hwid, 0, sizeof(hwid)); hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) + 1, hwid); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(!!hwid[0].vendorID, "Expected vendorID.\n"); - todo_wine ok(!!hwid[0].deviceID, "Expected deviceID.\n"); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(!!hwid[0].vendorID, "Expected vendorID.\n"); + ok(!!hwid[0].deviceID, "Expected deviceID.\n"); ok(!hwid[1].vendorID, "Expected no vendorID.\n"); ok(!hwid[1].deviceID, "Expected no deviceID.\n");
This merge request was approved by Elizabeth Figura.
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 10 ++++++++-- dlls/dxcore/tests/dxcore.c | 14 ++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index e32b79ec2bb..def592480b4 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -169,8 +169,14 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetPropertySize(IDXCoreAdapter *iface, DXCoreAdapterProperty property, size_t *buffer_size) { - FIXME("iface %p, property %u, buffer_size %p stub!\n", iface, property, buffer_size); - return E_NOTIMPL; + struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + + TRACE("iface %p, property %u, buffer_size %p.\n", iface, property, buffer_size); + + if (!buffer_size) + return E_POINTER; + + return dxcore_adapter_get_property_size(adapter, property, buffer_size); }
static BOOL STDMETHODCALLTYPE dxcore_adapter_IsQueryStateSupported(IDXCoreAdapter *iface, DXCoreAdapterState property) diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 1f5d8c318bd..bd87d5084f4 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -183,12 +183,11 @@ static void test_GetProperty(void) ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); - todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, &size); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - ok(size == sizeof(*luid), "Got size %Iu.\n", size); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(size == sizeof(*luid), "Got size %Iu.\n", size);
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -205,12 +204,11 @@ static void test_GetProperty(void) ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, NULL); - todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, &size); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - ok(size == sizeof(*hwid), "Got size %Iu.\n", size); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(size == sizeof(*hwid), "Got size %Iu.\n", size);
memset(hwid, 0, sizeof(hwid)); hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]), hwid);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/tests/dxcore.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index bd87d5084f4..eb7157249e7 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -152,7 +152,8 @@ static void test_GetProperty(void) IDXCoreAdapterList *list; DXCoreHardwareID hwid[2]; IDXCoreAdapter *adapter; - uint32_t count; + uint32_t count, dummy; + BYTE is_hardware; LUID luid[2]; size_t size; HRESULT hr; @@ -224,6 +225,29 @@ static void test_GetProperty(void) ok(!hwid[1].vendorID, "Expected no vendorID.\n"); ok(!hwid[1].deviceID, "Expected no deviceID.\n");
+ /* IsHardware */ + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, NULL); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, &is_hardware); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, NULL); + ok(hr == E_POINTER, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, &size); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(size == sizeof(is_hardware), "Got property size.\n"); + + is_hardware = 3; + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(is_hardware), &is_hardware); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(is_hardware == 0 || is_hardware == 1, "Got value %d.\n", is_hardware); + + dummy = 0; + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(dummy), &dummy); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + todo_wine ok(dummy == is_hardware, "Got value %#x.\n", dummy); + IDXCoreAdapter_Release(adapter); }
From: Nikolay Sivov nsivov@codeweavers.com
DXGI currently marks all adapters as 'hardware' too.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 7 +++++++ dlls/dxcore/tests/dxcore.c | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index def592480b4..184610b9291 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -109,12 +109,14 @@ static HRESULT dxcore_adapter_get_property_size(struct dxcore_adapter *adapter, { [InstanceLuid] = sizeof(LUID), [HardwareID] = sizeof(DXCoreHardwareID), + [IsHardware] = sizeof(BYTE), };
switch (property) { case InstanceLuid: case HardwareID: + case IsHardware: *size = property_sizes[property]; return S_OK;
@@ -159,6 +161,11 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac break; }
+ case IsHardware: + FIXME("Returning all adapters as Hardware.\n"); + *(BYTE *)buffer = 1; + break; + default: break; } diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index eb7157249e7..108767393bf 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -229,24 +229,24 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, NULL); ok(hr == E_POINTER, "Got hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, &is_hardware); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, NULL); ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, &size); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(size == sizeof(is_hardware), "Got property size.\n"); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(size == sizeof(is_hardware), "Got property size.\n");
is_hardware = 3; hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(is_hardware), &is_hardware); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(is_hardware == 0 || is_hardware == 1, "Got value %d.\n", is_hardware); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(is_hardware == 0 || is_hardware == 1, "Got value %d.\n", is_hardware);
dummy = 0; hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(dummy), &dummy); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(dummy == is_hardware, "Got value %#x.\n", dummy); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(dummy == is_hardware, "Got value %#x.\n", dummy);
IDXCoreAdapter_Release(adapter); }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/tests/dxcore.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 108767393bf..c3cb954b9ad 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -256,6 +256,45 @@ static void test_GetProperty(void) IDXCoreAdapterFactory_Release(factory); }
+static void test_GetAdapterByLuid(void) +{ + IDXCoreAdapter *adapter, *adapter2; + IDXCoreAdapterFactory *factory; + IDXCoreAdapterList *list; + uint32_t count; + HRESULT hr; + LUID luid; + + if (FAILED(pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory))) + return; + + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, + &IID_IDXCoreAdapterList, (void **)&list); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (uint32_t i = 0; i < count; ++i) + { + hr = IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid), &luid); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDXCoreAdapterFactory_GetAdapterByLuid(factory, &luid, &IID_IDXCoreAdapter, (void **)&adapter2); + todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); + if (hr == S_OK) + IDXCoreAdapter_Release(adapter2); + + IDXCoreAdapter_Release(adapter); + } + + IDXCoreAdapterList_Release(list); + + IDXCoreAdapterFactory_Release(factory); +} + START_TEST(dxcore) { HMODULE dxcore_handle = LoadLibraryA("dxcore.dll"); @@ -280,6 +319,7 @@ START_TEST(dxcore)
test_DXCoreCreateAdapterFactory(); test_GetProperty(); + test_GetAdapterByLuid();
FreeLibrary(dxcore_handle); }
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/dxcore/dxcore.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 184610b9291..4cd07069efe 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -430,6 +430,23 @@ static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_Release(IDXCoreAdapterFact return refcount; }
+static HRESULT dxcore_adapter_create(const struct wined3d_adapter_identifier *adapter_id, + struct dxcore_adapter **ret_adapter) +{ + struct dxcore_adapter *adapter; + + if (!(adapter = calloc(1, sizeof(*adapter)))) + return E_OUTOFMEMORY; + + adapter->IDXCoreAdapter_iface.lpVtbl = &dxcore_adapter_vtbl; + adapter->refcount = 1; + adapter->identifier = *adapter_id; + + TRACE("Created adapter %p.\n", adapter); + *ret_adapter = adapter; + return S_OK; +} + static HRESULT get_adapters(struct dxcore_adapter_list *list) { struct wined3d *wined3d = wined3d_create(0); @@ -449,26 +466,13 @@ static HRESULT get_adapters(struct dxcore_adapter_list *list)
for (UINT i = 0; i < list->adapter_count; i++) { - struct dxcore_adapter *dxcore_adapter = calloc(1, sizeof(*dxcore_adapter)); - const struct wined3d_adapter *wined3d_adapter; + struct wined3d_adapter_identifier adapter_id = {0};
- if (!dxcore_adapter) - { - hr = E_OUTOFMEMORY; + if (FAILED(hr = wined3d_adapter_get_identifier(wined3d_get_adapter(wined3d, i), 0, &adapter_id))) goto done; - }
- wined3d_adapter = wined3d_get_adapter(wined3d, i); - if (FAILED(hr = wined3d_adapter_get_identifier(wined3d_adapter, 0, &dxcore_adapter->identifier))) - { - free(dxcore_adapter); + if (FAILED(hr = dxcore_adapter_create(&adapter_id, &list->adapters[i]))) goto done; - } - - dxcore_adapter->IDXCoreAdapter_iface.lpVtbl = &dxcore_adapter_vtbl; - dxcore_adapter->refcount = 1; - - list->adapters[i] = dxcore_adapter; }
done:
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/dxcore/dxcore.c | 34 ++++++++++++++++++++++++++++++++-- dlls/dxcore/tests/dxcore.c | 9 +++++---- 2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 4cd07069efe..83f9f33a5d4 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -517,8 +517,38 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCor static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_GetAdapterByLuid(IDXCoreAdapterFactory *iface, REFLUID adapter_luid, REFIID riid, void **out) { - FIXME("iface %p, adapter_luid %p, riid %s, out %p stub!\n", iface, adapter_luid, debugstr_guid(riid), out); - return E_NOTIMPL; + struct dxcore_adapter *adapter; + struct wined3d *wined3d; + uint32_t count; + HRESULT hr; + + TRACE("iface %p, adapter_luid %p, riid %s, out %p.\n", iface, adapter_luid, debugstr_guid(riid), out); + + if (!(wined3d = wined3d_create(0))) + return E_FAIL; + + count = wined3d_get_adapter_count(wined3d); + for (uint32_t i = 0; i < count; ++i) + { + struct wined3d_adapter_identifier adapter_id = {0}; + + wined3d_adapter_get_identifier(wined3d_get_adapter(wined3d, i), 0, &adapter_id); + + if (!memcmp(adapter_luid, &adapter_id.adapter_luid, sizeof(LUID))) + { + wined3d_decref(wined3d); + + if (FAILED(hr = dxcore_adapter_create(&adapter_id, &adapter))) + return hr; + + hr = IDXCoreAdapter_QueryInterface(&adapter->IDXCoreAdapter_iface, riid, out); + IDXCoreAdapter_Release(&adapter->IDXCoreAdapter_iface); + return hr; + } + } + + wined3d_decref(wined3d); + return E_INVALIDARG; }
static BOOL STDMETHODCALLTYPE dxcore_adapter_factory_IsNotificationTypeSupported(IDXCoreAdapterFactory *iface, DXCoreNotificationType type) diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index c3cb954b9ad..018c86cf3ec 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -87,9 +87,11 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(factory, &IID_IDXCoreAdapter, FALSE); check_interface(factory, &IID_IDXCoreAdapterList, FALSE);
- hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 0, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 0, NULL, &IID_IDXCoreAdapterList, (void **)&list); ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); ok(list == NULL, "got list %p.\n", list); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 0, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); + ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterFactory, (void **)&list); ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, NULL, &IID_IDXCoreAdapterFactory, (void **)&list); @@ -283,9 +285,8 @@ static void test_GetAdapterByLuid(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IDXCoreAdapterFactory_GetAdapterByLuid(factory, &luid, &IID_IDXCoreAdapter, (void **)&adapter2); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - if (hr == S_OK) - IDXCoreAdapter_Release(adapter2); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IDXCoreAdapter_Release(adapter2);
IDXCoreAdapter_Release(adapter); }