From: Nikolay Sivov nsivov@codeweavers.com
Current logic is broken and does not allow releasing a factory, and creating another one. There is no reason at the moment not to have multiple factory instances.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 25 ++++++++++++------------- dlls/dxcore/tests/dxcore.c | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 9aa28f8a3a0..9095430aafd 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -506,25 +506,24 @@ static const struct IDXCoreAdapterFactoryVtbl dxcore_adapter_factory_vtbl =
HRESULT STDMETHODCALLTYPE DXCoreCreateAdapterFactory(REFIID riid, void **out) { - static struct dxcore_adapter_factory *factory = NULL; + struct dxcore_adapter_factory *factory; + HRESULT hr;
TRACE("riid %s, out %p\n", debugstr_guid(riid), out);
if (!out) return E_POINTER;
- if (!factory) - { - if (!(factory = calloc(1, sizeof(*factory)))) - { - *out = NULL; - return E_OUTOFMEMORY; - } + *out = NULL;
- factory->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_vtbl; - factory->refcount = 0; - } + if (!(factory = calloc(1, sizeof(*factory)))) + return E_OUTOFMEMORY; + + factory->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_vtbl; + factory->refcount = 1;
- TRACE("created IDXCoreAdapterFactory %p.\n", *out); - return IDXCoreAdapterFactory_QueryInterface(&factory->IDXCoreAdapterFactory_iface, riid, out); + hr = IDXCoreAdapterFactory_QueryInterface(&factory->IDXCoreAdapterFactory_iface, riid, out); + IDXCoreAdapterFactory_Release(&factory->IDXCoreAdapterFactory_iface); + + return hr; } diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 1748307e730..5da7dc9972d 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -79,9 +79,9 @@ static void test_DXCoreCreateAdapterFactory(void)
hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory2); ok(hr == S_OK, "got hr %#lx.\n", hr); + todo_wine ok(factory == factory2, "got factory %p, factory2 %p.\n", factory, factory2); - refcount = IDXCoreAdapterFactory_Release(factory2); - ok(refcount == 1, "got refcount %ld.\n", refcount); + IDXCoreAdapterFactory_Release(factory2);
check_interface(factory, &IID_IAgileObject, FALSE); check_interface(factory, &IID_IDXCoreAdapter, FALSE);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/tests/dxcore.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 5da7dc9972d..7a51d5fbbda 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -83,9 +83,8 @@ static void test_DXCoreCreateAdapterFactory(void) ok(factory == factory2, "got factory %p, factory2 %p.\n", factory, factory2); IDXCoreAdapterFactory_Release(factory2);
- check_interface(factory, &IID_IAgileObject, FALSE); - check_interface(factory, &IID_IDXCoreAdapter, FALSE); - check_interface(factory, &IID_IDXCoreAdapterList, FALSE); + check_interface(factory, &IID_IUnknown, TRUE); + check_interface(factory, &IID_IDXCoreAdapterFactory, TRUE);
hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 0, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); @@ -105,9 +104,8 @@ static void test_DXCoreCreateAdapterFactory(void) refcount = IDXCoreAdapterList_Release(list2); ok(refcount == 0, "got refcount %ld.\n", refcount);
- check_interface(list, &IID_IAgileObject, FALSE); - check_interface(list, &IID_IDXCoreAdapter, FALSE); - check_interface(list, &IID_IDXCoreAdapterFactory, FALSE); + check_interface(list, &IID_IUnknown, TRUE); + check_interface(list, &IID_IDXCoreAdapterList, TRUE);
adapter_count = IDXCoreAdapterList_GetAdapterCount(list); ok(adapter_count != 0, "got adapter_count 0.\n"); @@ -129,9 +127,8 @@ static void test_DXCoreCreateAdapterFactory(void) todo_wine ok(refcount == 3, "got refcount %ld.\n", refcount);
- check_interface(adapter, &IID_IAgileObject, FALSE); - check_interface(adapter, &IID_IDXCoreAdapterList, FALSE); - check_interface(adapter, &IID_IDXCoreAdapterFactory, FALSE); + check_interface(adapter, &IID_IUnknown, TRUE); + check_interface(adapter, &IID_IDXCoreAdapter, TRUE);
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/tests/dxcore.c | 101 ++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 29 deletions(-)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 7a51d5fbbda..bbe67748182 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; @@ -130,33 +128,6 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(adapter, &IID_IUnknown, TRUE); check_interface(adapter, &IID_IDXCoreAdapter, TRUE);
- 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); @@ -166,6 +137,77 @@ 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, i; + size_t size; + HRESULT hr; + + hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory); + if (FAILED(hr)) + return; + + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, + &IID_IDXCoreAdapterList, (void **)&list); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (i = 0; i < count; ++i) + { + hr = IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, hwid); + ok(hr == DXGI_ERROR_INVALID_CALL, "Unexpected hr %#lx.\n", hr); + + /* HardwareID */ + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, hwid); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) - 1, hwid); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, NULL); + todo_wine + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, &size); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (hr == S_OK) + ok(size == sizeof(*hwid), "Unexpected property size.\n"); + + memset(hwid, 0, sizeof(hwid)); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]), hwid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!hwid[0].vendorID, "Unexpected vendorID.\n"); + ok(!!hwid[0].deviceID, "Unexpected deviceID.\n"); + + memset(hwid, 0, sizeof(hwid)); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, sizeof(hwid[0]) + 1, hwid); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(!!hwid[0].vendorID, "Unexpected vendorID.\n"); + todo_wine + ok(!!hwid[0].deviceID, "Unexpected deviceID.\n"); + ok(!hwid[1].vendorID, "Unexpected vendorID.\n"); + ok(!hwid[1].deviceID, "Unexpected deviceID.\n"); + + IDXCoreAdapter_Release(adapter); + } + + IDXCoreAdapterList_Release(list); + + IDXCoreAdapterFactory_Release(factory); +} + START_TEST(dxcore) { HMODULE dxcore_handle = LoadLibraryA("dxcore.dll"); @@ -189,6 +231,7 @@ START_TEST(dxcore) }
test_DXCoreCreateAdapterFactory(); + test_GetProperty();
FreeLibrary(dxcore_handle); }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/tests/dxcore.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index bbe67748182..38c483312f9 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -144,6 +144,7 @@ static void test_GetProperty(void) DXCoreHardwareID hwid[2]; IDXCoreAdapter *adapter; uint32_t count, i; + LUID luid[2]; size_t size; HRESULT hr;
@@ -165,6 +166,34 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, hwid); ok(hr == DXGI_ERROR_INVALID_CALL, "Unexpected hr %#lx.\n", hr);
+ /* InstanceLuid */ + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, luid); + todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) - 1, luid); + todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); + todo_wine + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, &size); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (hr == S_OK) + ok(size == sizeof(*luid), "Unexpected property size.\n"); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) + 1, luid); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + /* HardwareID */ hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); ok(hr == E_POINTER, "Unexpected 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 | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 9095430aafd..3895302c1d2 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -112,6 +112,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 38c483312f9..c4a036d0f6c 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -170,10 +170,8 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, 0, luid); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) - 1, luid); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); @@ -187,11 +185,9 @@ static void test_GetProperty(void) ok(size == sizeof(*luid), "Unexpected property size.\n");
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]) + 1, luid); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* HardwareID */
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 44 +++++++++++++++++++++++++++----------- dlls/dxcore/tests/dxcore.c | 3 --- 2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 3895302c1d2..d08fd1c772b 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -100,35 +100,56 @@ 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; @@ -136,10 +157,7 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac break; } default: - { - FIXME("property %u not implemented.\n", property); - return DXGI_ERROR_INVALID_CALL; - } + ; }
return S_OK; diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index c4a036d0f6c..7cab5bbc55a 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -216,11 +216,8 @@ 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, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!!hwid[0].vendorID, "Unexpected vendorID.\n"); - todo_wine ok(!!hwid[0].deviceID, "Unexpected deviceID.\n"); ok(!hwid[1].vendorID, "Unexpected vendorID.\n"); ok(!hwid[1].deviceID, "Unexpected deviceID.\n");
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 10 ++++++++-- dlls/dxcore/tests/dxcore.c | 10 ++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index d08fd1c772b..f8a14a82998 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -166,8 +166,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 7cab5bbc55a..2f32179336b 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -175,14 +175,11 @@ static void test_GetProperty(void) ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, InstanceLuid, &size); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - ok(size == sizeof(*luid), "Unexpected property size.\n"); + ok(size == sizeof(*luid), "Unexpected property size.\n");
hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid[0]), luid); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -199,14 +196,11 @@ static void test_GetProperty(void) ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, HardwareID, &size); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - ok(size == sizeof(*hwid), "Unexpected property size.\n"); + ok(size == sizeof(*hwid), "Unexpected property size.\n");
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 | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 2f32179336b..f4ac0cce62d 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -142,8 +142,9 @@ static void test_GetProperty(void) IDXCoreAdapterFactory *factory; IDXCoreAdapterList *list; DXCoreHardwareID hwid[2]; + uint32_t count, i, dummy; IDXCoreAdapter *adapter; - uint32_t count, i; + BYTE is_hardware; LUID luid[2]; size_t size; HRESULT hr; @@ -216,6 +217,36 @@ static void test_GetProperty(void) ok(!hwid[1].vendorID, "Unexpected vendorID.\n"); ok(!hwid[1].deviceID, "Unexpected deviceID.\n");
+ /* IsHardware */ + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, &is_hardware); + todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, &size); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(size == sizeof(is_hardware), "Unexpected property size.\n"); + + is_hardware = 3; + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(is_hardware), &is_hardware); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(is_hardware == 0 || is_hardware == 1, "Unexpected value %d.\n", is_hardware); + + dummy = 0; + hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(dummy), &dummy); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(dummy == is_hardware, "Unexpected 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 | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index f8a14a82998..7b753728dc4 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -107,12 +107,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; default: @@ -156,6 +158,11 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *ifac hardware_id->revision = adapter->identifier.revision; break; } + case IsHardware: + FIXME("Returning all adapters as Hardware.\n"); + + *(BYTE *)buffer = 1; + break; default: ; } diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index f4ac0cce62d..28f928f9a18 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -221,30 +221,23 @@ static void test_GetProperty(void) hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, 0, &is_hardware); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapter_GetPropertySize(adapter, IsHardware, &size); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(size == sizeof(is_hardware), "Unexpected property size.\n");
is_hardware = 3; hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(is_hardware), &is_hardware); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(is_hardware == 0 || is_hardware == 1, "Unexpected value %d.\n", is_hardware);
dummy = 0; hr = IDXCoreAdapter_GetProperty(adapter, IsHardware, sizeof(dummy), &dummy); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(dummy == is_hardware, "Unexpected 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 | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 28f928f9a18..53952a40003 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -248,6 +248,47 @@ static void test_GetProperty(void) IDXCoreAdapterFactory_Release(factory); }
+static void test_GetAdapterByLuid(void) +{ + IDXCoreAdapter *adapter, *adapter2; + IDXCoreAdapterFactory *factory; + IDXCoreAdapterList *list; + uint32_t count, i; + HRESULT hr; + LUID luid; + + hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory); + if (FAILED(hr)) + return; + + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, + &IID_IDXCoreAdapterList, (void **)&list); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (i = 0; i < count; ++i) + { + hr = IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid), &luid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IDXCoreAdapterFactory_GetAdapterByLuid(factory, &luid, &IID_IDXCoreAdapter, (void **)&adapter2); + todo_wine + ok(hr == S_OK, "Unexpected 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"); @@ -272,6 +313,7 @@ START_TEST(dxcore)
test_DXCoreCreateAdapterFactory(); test_GetProperty(); + test_GetAdapterByLuid();
FreeLibrary(dxcore_handle); }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxcore/dxcore.c | 70 +++++++++++++++++++++++++++++--------- dlls/dxcore/tests/dxcore.c | 8 ++--- 2 files changed, 58 insertions(+), 20 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 7b753728dc4..de40f934cf0 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -470,23 +470,11 @@ done: return hr; }
-static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCoreAdapterFactory *iface, uint32_t num_attributes, - const GUID *filter_attributes, REFIID riid, void **out) +static HRESULT dxcore_create_adapter_list(REFIID riid, void **out) { struct dxcore_adapter_list *list; HRESULT hr;
- FIXME("iface %p, num_attributes %u, filter_attributes %p, riid %s, out %p semi-stub!\n", iface, num_attributes, filter_attributes, - debugstr_guid(riid), out); - - if (!out) - return E_POINTER; - - *out = NULL; - - if (!num_attributes || !filter_attributes) - return E_INVALIDARG; - if (!(list = calloc(1, sizeof(*list)))) return E_OUTOFMEMORY;
@@ -500,15 +488,65 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCor
hr = IDXCoreAdapterList_QueryInterface(&list->IDXCoreAdapterList_iface, riid, out); IDXCoreAdapterList_Release(&list->IDXCoreAdapterList_iface); - TRACE("created IDXCoreAdapterList %p.\n", *out); + return hr; }
+static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCoreAdapterFactory *iface, uint32_t num_attributes, + const GUID *filter_attributes, REFIID riid, void **out) +{ + FIXME("iface %p, num_attributes %u, filter_attributes %p, riid %s, out %p semi-stub!\n", iface, num_attributes, filter_attributes, + debugstr_guid(riid), out); + + if (!out) + return E_POINTER; + + *out = NULL; + + if (!num_attributes || !filter_attributes) + return E_INVALIDARG; + + return dxcore_create_adapter_list(riid, out); +} + 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; + IDXCoreAdapterList *list; + IDXCoreAdapter *adapter; + uint32_t count; + HRESULT hr; + LUID luid; + + TRACE("iface %p, adapter_luid %p, riid %s, out %p.\n", iface, adapter_luid, debugstr_guid(riid), out); + + if (FAILED(hr = dxcore_create_adapter_list(&IID_IDXCoreAdapterList, (void **)&list))) + return hr; + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (uint32_t i = 0; i < count; ++i) + { + if (SUCCEEDED(IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter))) + { + if (SUCCEEDED(IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid), &luid))) + { + if (!memcmp(&luid, adapter_luid, sizeof(luid))) + { + hr = IDXCoreAdapter_QueryInterface(adapter, riid, out); + + IDXCoreAdapter_Release(adapter); + IDXCoreAdapterList_Release(list); + return hr; + } + } + IDXCoreAdapter_Release(adapter); + } + } + + IDXCoreAdapterList_Release(list); + + 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 53952a40003..24cbad49b4f 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -84,9 +84,11 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(factory, &IID_IUnknown, TRUE); check_interface(factory, &IID_IDXCoreAdapterFactory, TRUE);
- 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); @@ -276,10 +278,8 @@ static void test_GetAdapterByLuid(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDXCoreAdapterFactory_GetAdapterByLuid(factory, &luid, &IID_IDXCoreAdapter, (void **)&adapter2); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr == S_OK) - IDXCoreAdapter_Release(adapter2); + IDXCoreAdapter_Release(adapter2);
IDXCoreAdapter_Release(adapter); }
We don't have anyone automatically assigned to this new module, pinging @zfigura as this is a natural progression from !8047.
nice to see progress on dxcore implementation..
related to dozen bug I reported: https://bugs.winehq.org/show_bug.cgi?id=58192
I seen progress since originally reported..
now testing dozen fails with:
0124:fixme:dxcore:dxcore_adapter_GetProperty property 7 not implemented.
(tested with wine 10.9)
currently missing in wine dxcore are property types: 7,9,8,0,11,2 seeing from dozen code below:
this MR adds 0 (InstanceLuid)..
``` typedef enum DXCoreAdapterProperty { InstanceLuid = 0, DriverVersion = 1, DriverDescription = 2, HardwareID = 3, KmdModelVersion = 4, ComputePreemptionGranularity = 5, GraphicsPreemptionGranularity = 6, DedicatedAdapterMemory = 7, DedicatedSystemMemory = 8, SharedSystemMemory = 9, AcgCompatible = 10, IsHardware = 11, IsIntegrated = 12, IsDetachable = 13, HardwareIDParts = 14, PhysicalAdapterCount = 15, AdapterEngineCount = 16, AdapterEngineName = 17 } ; ```
``` if (FAILED(adapter->GetProperty(DXCoreAdapterProperty::HardwareID, &hardware_id)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::DedicatedAdapterMemory, &desc.dedicated_video_memory)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::SharedSystemMemory, &desc.shared_system_memory)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::DedicatedSystemMemory, &desc.dedicated_system_memory)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::InstanceLuid, &desc.adapter_luid)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::IsHardware, &is_hardware)) || FAILED(adapter->GetProperty(DXCoreAdapterProperty::DriverDescription, sizeof(desc.description), desc.description))) { mesa_loge("Failed to retrieve DXCore adapter properties\n"); result = VK_ERROR_INITIALIZATION_FAILED; } else { desc.vendor_id = hardware_id.vendorID; desc.device_id = hardware_id.deviceID; desc.subsys_id = hardware_id.subSysID; desc.revision = hardware_id.revision; desc.is_warp = !is_hardware; result = dzn_instance_add_physical_device(instance, adapter, &desc);
```
This merge request was approved by Elizabeth Figura.
``` Current logic is broken and does not allow releasing a factory, and creating another one. There is no reason at the moment not to have multiple factory instances. ```
That seems easy enough to fix, just move that variable into global scope and clear it on destruction. There may not be a known application that relies on it, but no reason to add todo_wine to a test when just fixing the code is easier.
``` dxcore/tests: Remove unrelated interfaces checks. ```
Why spend a patch on this? I don't think they're necessary, but they aren't really hurting anything.
``` + if (FAILED(hr = dxcore_create_adapter_list(&IID_IDXCoreAdapterList, (void **)&list))) + return hr; + + count = IDXCoreAdapterList_GetAdapterCount(list); + + for (uint32_t i = 0; i < count; ++i) + { + if (SUCCEEDED(IDXCoreAdapterList_GetAdapter(list, i, &IID_IDXCoreAdapter, (void **)&adapter))) + { + if (SUCCEEDED(IDXCoreAdapter_GetProperty(adapter, InstanceLuid, sizeof(luid), &luid))) + { + if (!memcmp(&luid, adapter_luid, sizeof(luid))) + { + hr = IDXCoreAdapter_QueryInterface(adapter, riid, out); + + IDXCoreAdapter_Release(adapter); + IDXCoreAdapterList_Release(list); + return hr; + } + } + IDXCoreAdapter_Release(adapter); + } + } ```
I guess. If it were me I'd just avoid the list and use wined3d functions directly.
That seems easy enough to fix, just move that variable into global scope and clear it on destruction. There may not be a known application that relies on it, but no reason to add todo_wine to a test when just fixing the code is easier.
There is no reason to have such test to begin with, same as trying to match refcount values. It's clear and more straightforward to have a new instance every time, or a static factory. Using something global then brings a question about safety, why would we go there if we don't need it.
Why spend a patch on this? I don't think they're necessary, but they aren't really hurting anything.
Because interface checks have to make some sense. What are we testing with IAgileObject for instance?
That seems easy enough to fix, just move that variable into global scope and clear it on destruction. There may not be a known application that relies on it, but no reason to add todo_wine to a test when just fixing the code is easier.
There is no reason to have such test to begin with, same as trying to match refcount values. It's clear and more straightforward to have a new instance every time, or a static factory. Using something global then brings a question about safety, why would we go there if we don't need it.
Maybe it would have been simpler to do it a different way in the first place, but I don't really see the need, at this point, to go out of our way to do it *less* like native, when fixing the tests—which you're not even removing—takes two changed lines.
Why spend a patch on this? I don't think they're necessary, but they aren't really hurting anything.
Because interface checks have to make some sense. What are we testing with IAgileObject for instance?
That it doesn't support IAgileObject? I don't know why Mohamad added those, but I'd guess it's either because he some application query for it, or because all of the dxcore documentation appears to be written in WinRT. Both seem quite plausible and both seem good reasons to check something like this.
I may not test anything this deeply myself, without a preexisting reason, but I really don't think it makes sense to remove tests, or bring our implementation further away from behaviour already tested.
Maybe it would have been simpler to do it a different way in the first place, but I don't really see the need, at this point, to go out of our way to do it _less_ like native, when fixing the tests—which you're not even removing—takes two changed lines.
Making it more straightforward and less broken is the reason for this change. Making it match some implementation details that we for some reason are testing for I don't find productive.
That it doesn't support IAgileObject? I don't know why Mohamad added those, but I'd guess it's either because he some application query for it, or because all of the dxcore documentation appears to be written in WinRT. Both seem quite plausible and both seem good reasons to check something like this.
What else it doesn't support? Other removed lines were checking for unrelated things too. Why would adapter support IDXCoreAdapterList or a factory interface? If application queries something that has no place in implementation, you can verify that of course, but there is no need to have that in tests.
This merge request was closed by Nikolay Sivov.