Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58133
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58192
-- v6: dxcore: Implement IDXCoreAdapter::GetProperty(HardwareID). dxcore/tests: Add IDXCoreAdapter::GetProperty() tests. dxcore: Implement IDXCoreAdapterList::GetAdapter(). dxcore/tests: Add IDXCoreAdapterList::GetAdapter() tests. dxcore: Implement IDXCoreAdapterList::GetAdapterCount(). dxcore: Partially implement IDXCoreAdapterFactory::CreateAdapterList(). dxcore/tests: Add IDXCoreAdapterFactory::CreateAdapterList() tests. dxcore: Implement DXCoreCreateAdapterFactory().
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/dxcore_interface.h | 84 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
diff --git a/include/dxcore_interface.h b/include/dxcore_interface.h index 635a7f047a5..ba81f827fd6 100644 --- a/include/dxcore_interface.h +++ b/include/dxcore_interface.h @@ -170,6 +170,40 @@ DECLARE_INTERFACE_IID_(IDXCoreAdapter, IUnknown, "f0db4c7f-fe5a-42a2-bd62-f2a6cf #endif };
+#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IDXCoreAdapter_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDXCoreAdapter_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDXCoreAdapter_Release(p) (p)->lpVtbl->Release(p) +/*** IDXCoreAdapter methods ***/ +#define IDXCoreAdapter_IsValid(p) (p)->lpVtbl->IsValid(p) +#define IDXCoreAdapter_IsAttributeSupported(p,a) (p)->lpVtbl->IsAttributeSupported(p,a) +#define IDXCoreAdapter_IsPropertySupported(p,a) (p)->lpVtbl->IsPropertySupported(p,a) +#define IDXCoreAdapter_GetProperty(p,a,b,c) (p)->lpVtbl->GetProperty(p,a,b,c) +#define IDXCoreAdapter_GetPropertySize(p,a,b) (p)->lpVtbl->GetPropertySize(p,a,b) +#define IDXCoreAdapter_IsQueryStateSupported(p,a) (p)->lpVtbl->IsQueryStateSupported(p,a) +#define IDXCoreAdapter_QueryState(p,a,b,c,d,e) (p)->lpVtbl->QueryState(p,a,b,c,d,e) +#define IDXCoreAdapter_IsSetStateSupported(p,a) (p)->lpVtbl->IsSetStateSupported(p,a) +#define IDXCoreAdapter_SetState(p,a,b,c,d,e) (p)->lpVtbl->SetState(p,a,b,c,d,e) +#define IDXCoreAdapter_GetFactory(p,a,b) (p)->lpVtbl->GetFactory(p,a,b) +#else +/*** IUnknown methods ***/ +#define IDXCoreAdapter_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDXCoreAdapter_AddRef(p) (p)->AddRef() +#define IDXCoreAdapter_Release(p) (p)->Release() +/*** IDXCoreAdapter methods ***/ +#define IDXCoreAdapter_IsValid(p) (p)->IsValid() +#define IDXCoreAdapter_IsAttributeSupported(p,a) (p)->IsAttributeSupported(a) +#define IDXCoreAdapter_IsPropertySupported(p,a) (p)->IsPropertySupported(a) +#define IDXCoreAdapter_GetProperty(p,a,b,c) (p)->GetProperty(a,b,c) +#define IDXCoreAdapter_GetPropertySize(p,a,b) (p)->GetPropertySize(a,b) +#define IDXCoreAdapter_IsQueryStateSupported(p,a) (p)->IsQueryStateSupported(a) +#define IDXCoreAdapter_QueryState(p,a,b,c,d,e) (p)->QueryState(a,b,c,d,e) +#define IDXCoreAdapter_IsSetStateSupported(p,a) (p)->IsSetStateSupported(a) +#define IDXCoreAdapter_SetState(p,a,b,c,d,e) (p)->SetState(a,b,c,d,e) +#define IDXCoreAdapter_GetFactory(p,a,b) (p)->GetFactory(a,b) +#endif + #undef INTERFACE #define INTERFACE IDXCoreAdapterList DECLARE_INTERFACE_IID_(IDXCoreAdapterList, IUnknown, "526c7776-40e9-459b-b711-f32ad76dfc28") @@ -201,6 +235,32 @@ DECLARE_INTERFACE_IID_(IDXCoreAdapterList, IUnknown, "526c7776-40e9-459b-b711-f3 #endif };
+#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IDXCoreAdapterList_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDXCoreAdapterList_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDXCoreAdapterList_Release(p) (p)->lpVtbl->Release(p) +/*** IDXCoreAdapterList methods ***/ +#define IDXCoreAdapterList_GetAdapter(p,a,b,c) (p)->lpVtbl->GetAdapter(p,a,b,c) +#define IDXCoreAdapterList_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDXCoreAdapterList_IsStale(p) (p)->lpVtbl->IsStale(p) +#define IDXCoreAdapterList_GetFactory(p,a,b) (p)->lpVtbl->GetFactory(p,a,b) +#define IDXCoreAdapterList_Sort(p,a,b) (p)->lpVtbl->Sort(p,a,b) +#define IDXCoreAdapterList_IsAdapterPreferenceSupported(p,a) (p)->lpVtbl->IsAdapterPreferenceSupported(p,a) +#else +/*** IUnknown methods ***/ +#define IDXCoreAdapterList_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDXCoreAdapterList_AddRef(p) (p)->AddRef() +#define IDXCoreAdapterList_Release(p) (p)->Release() +/*** IDXCoreAdapterList methods ***/ +#define IDXCoreAdapterList_GetAdapter(p,a,b) (p)->GetAdapter(a,b) +#define IDXCoreAdapterList_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDXCoreAdapterList_IsStale(p) (p)->IsStale() +#define IDXCoreAdapterList_GetFactory(p,a,b) (p)->GetFactory(a,b) +#define IDXCoreAdapterList_Sort(p,a,b) (p)->Sort(a,b) +#define IDXCoreAdapterList_IsAdapterPreferenceSupported(p,a) (p)->IsAdapterPreferenceSupported(a) +#endif + #undef INTERFACE #define INTERFACE IDXCoreAdapterFactory DECLARE_INTERFACE_IID_(IDXCoreAdapterFactory, IUnknown, "78ee5945-c36e-4b13-a669-005dd11c0f06") @@ -232,4 +292,28 @@ DECLARE_INTERFACE_IID_(IDXCoreAdapterFactory, IUnknown, "78ee5945-c36e-4b13-a669 #endif };
+#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IDXCoreAdapterFactory_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDXCoreAdapterFactory_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDXCoreAdapterFactory_Release(p) (p)->lpVtbl->Release(p) +/*** IDXCoreAdapterFactory methods ***/ +#define IDXCoreAdapterFactory_CreateAdapterList(p,a,b,c,d) (p)->lpVtbl->CreateAdapterList(p,a,b,c,d) +#define IDXCoreAdapterFactory_GetAdapterByLuid(p,a,b,c) (p)->lpVtbl->GetAdapterByLuid(p,a,b,c) +#define IDXCoreAdapterFactory_IsNotificationTypeSupported(p,a) (p)->lpVtbl->IsNotificationTypeSupported(p,a) +#define IDXCoreAdapterFactory_RegisterEventNotification(p,a,b,c,d,e) (p)->lpVtbl->RegisterEventNotification(p,a,b,c,d,e) +#define IDXCoreAdapterFactory_UnregisterEventNotification(p,a) (p)->lpVtbl->UnregisterEventNotification(p,a) +#else +/*** IUnknown methods ***/ +#define IDXCoreAdapterFactory_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDXCoreAdapterFactory_AddRef(p) (p)->AddRef() +#define IDXCoreAdapterFactory_Release(p) (p)->Release() +/*** IDXCoreAdapterFactory methods ***/ +#define IDXCoreAdapterFactory_CreateAdapterList(p,a,b,c,d) (p)->CreateAdapterList(a,b,c,d) +#define IDXCoreAdapterFactory_GetAdapterByLuid(p,a,b,c) (p)->GetAdapterByLuid(a,b,c) +#define IDXCoreAdapterFactory_IsNotificationTypeSupported(p,a) (p)->IsNotificationTypeSupported(a) +#define IDXCoreAdapterFactory_RegisterEventNotification(p,a,b,c,d,e) (p)->RegisterEventNotification(a,b,c,d,e) +#define IDXCoreAdapterFactory_UnregisterEventNotification(p,a) (p)->UnregisterEventNotification(a) +#endif + #endif /* __DXCORE_INTERFACE__ */
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 1 + dlls/dxcore/tests/Makefile.in | 5 ++ dlls/dxcore/tests/dxcore.c | 103 ++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 dlls/dxcore/tests/Makefile.in create mode 100644 dlls/dxcore/tests/dxcore.c
diff --git a/configure.ac b/configure.ac index 06da342bd4f..af37f5b75e0 100644 --- a/configure.ac +++ b/configure.ac @@ -2687,6 +2687,7 @@ WINE_CONFIG_MAKEFILE(dlls/dwrite) WINE_CONFIG_MAKEFILE(dlls/dwrite/tests) WINE_CONFIG_MAKEFILE(dlls/dx8vb) WINE_CONFIG_MAKEFILE(dlls/dxcore) +WINE_CONFIG_MAKEFILE(dlls/dxcore/tests) WINE_CONFIG_MAKEFILE(dlls/dxdiagn) WINE_CONFIG_MAKEFILE(dlls/dxdiagn/tests) WINE_CONFIG_MAKEFILE(dlls/dxgi) diff --git a/dlls/dxcore/tests/Makefile.in b/dlls/dxcore/tests/Makefile.in new file mode 100644 index 00000000000..841f1c9d14f --- /dev/null +++ b/dlls/dxcore/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = dxcore.dll +IMPORTS = uuid + +SOURCES = \ + dxcore.c diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c new file mode 100644 index 00000000000..fc6cec083da --- /dev/null +++ b/dlls/dxcore/tests/dxcore.c @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#define COBJMACROS +#include "initguid.h" +#include "dxcore.h" + +#include "wine/test.h" + +static HRESULT (WINAPI *pDXCoreCreateAdapterFactory)(REFIID riid, void **out); + +#define check_interface(iface, riid, supported) check_interface_(__LINE__, iface, riid, supported) +static void check_interface_(unsigned int line, void *iface, REFIID riid, BOOL supported) +{ + IUnknown *unknown = iface, *out; + HRESULT hr, expected_hr; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(unknown, riid, (void **)&out); + ok_(__FILE__, line)(hr == expected_hr, "got hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + IUnknown_Release(out); +} + +static void test_DXCoreCreateAdapterFactory(void) +{ + IDXCoreAdapterFactory *factory2 = (void *)0xdeadbeef; + IDXCoreAdapterFactory *factory = (void *)0xdeadbeef; + LONG refcount; + HRESULT hr; + + if (0) /* Crashes on w1064v1909 */ + { + todo_wine + hr = pDXCoreCreateAdapterFactory(NULL, NULL); + ok(hr == E_POINTER, "got hr %#lx.\n", hr); + } + hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, NULL); + todo_wine + ok(hr == E_POINTER || broken(hr == E_NOINTERFACE) /* w1064v1909 */, "got hr %#lx.\n", hr); + hr = pDXCoreCreateAdapterFactory(&DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, (void **)&factory); + ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); + todo_wine + ok(factory == NULL || broken(factory == (void *)0xdeadbeef) /* w1064v1909 */, "got factory %p.\n", factory); + + hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory); + todo_wine + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* w1064v1909 */, "got hr %#lx.\n", hr); + if (FAILED(hr)) + return; + + hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory2); + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(factory == factory2, "got factory %p, factory2 %p.\n", factory, factory2); + refcount = IDXCoreAdapterFactory_Release(factory2); + ok(refcount == 1, "got refcount %ld.\n", refcount); + + check_interface(factory, &IID_IAgileObject, FALSE); + check_interface(factory, &IID_IDXCoreAdapter, FALSE); + check_interface(factory, &IID_IDXCoreAdapterList, FALSE); + + refcount = IDXCoreAdapterFactory_Release(factory); + ok(refcount == 0, "got refcount %ld.\n", refcount); +} + +START_TEST(dxcore) +{ + HMODULE dxcore_handle = LoadLibraryA("dxcore.dll"); + if (!dxcore_handle) + { + win_skip("Could not load dxcore.dll\n"); + return; + } + pDXCoreCreateAdapterFactory = (void *)GetProcAddress(dxcore_handle, "DXCoreCreateAdapterFactory"); + if (!pDXCoreCreateAdapterFactory) + { + win_skip("Failed to get DXCoreCreateAdapterFactory address, skipping dxcore tests\n"); + FreeLibrary(dxcore_handle); + return; + } + + test_DXCoreCreateAdapterFactory(); + + FreeLibrary(dxcore_handle); +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/Makefile.in | 2 +- dlls/dxcore/dxcore.c | 154 +++++++++++++++++++++++++++++++++++++ dlls/dxcore/main.c | 28 ------- dlls/dxcore/tests/dxcore.c | 4 - 4 files changed, 155 insertions(+), 33 deletions(-) create mode 100644 dlls/dxcore/dxcore.c delete mode 100644 dlls/dxcore/main.c
diff --git a/dlls/dxcore/Makefile.in b/dlls/dxcore/Makefile.in index efee290e914..579cceded7e 100644 --- a/dlls/dxcore/Makefile.in +++ b/dlls/dxcore/Makefile.in @@ -3,4 +3,4 @@ MODULE = dxcore.dll EXTRADLLFLAGS = -Wb,--prefer-native
SOURCES = \ - main.c + dxcore.c diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c new file mode 100644 index 00000000000..69e58f0dce9 --- /dev/null +++ b/dlls/dxcore/dxcore.c @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#define COBJMACROS +#include "initguid.h" +#include "dxcore.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dxcore); + +struct dxcore_adapter_factory +{ + IDXCoreAdapterFactory IDXCoreAdapterFactory_iface; + LONG refcount; +}; + +static inline struct dxcore_adapter_factory *impl_from_IDXCoreAdapterFactory(IDXCoreAdapterFactory *iface) +{ + return CONTAINING_RECORD(iface, struct dxcore_adapter_factory, IDXCoreAdapterFactory_iface); +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_QueryInterface(IDXCoreAdapterFactory *iface, REFIID riid, void **out) +{ + struct dxcore_adapter_factory *factory = impl_from_IDXCoreAdapterFactory(iface); + + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_IDXCoreAdapterFactory) + || IsEqualGUID(riid, &IID_IUnknown)) + { + *out = &factory->IDXCoreAdapterFactory_iface; + IUnknown_AddRef((IUnknown *)*out); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_AddRef(IDXCoreAdapterFactory *iface) +{ + struct dxcore_adapter_factory *factory = impl_from_IDXCoreAdapterFactory(iface); + ULONG refcount = InterlockedIncrement(&factory->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_Release(IDXCoreAdapterFactory *iface) +{ + struct dxcore_adapter_factory *factory = impl_from_IDXCoreAdapterFactory(iface); + ULONG refcount = InterlockedDecrement(&factory->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(factory); + + return refcount; +} + +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 stub!\n", iface, num_attributes, filter_attributes, + debugstr_guid(riid), out); + return E_NOTIMPL; +} + +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; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_factory_IsNotificationTypeSupported(IDXCoreAdapterFactory *iface, DXCoreNotificationType type) +{ + FIXME("iface %p, type %u stub!\n", iface, type); + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_RegisterEventNotification(IDXCoreAdapterFactory *iface, IUnknown *dxcore_object, + DXCoreNotificationType type, PFN_DXCORE_NOTIFICATION_CALLBACK callback, void *callback_context, uint32_t *event_cookie) +{ + FIXME("iface %p, dxcore_object %p, type %u, callback %p, callback_context %p, event_cookie %p stub!\n", iface, dxcore_object, type, callback, + callback_context, event_cookie); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_UnregisterEventNotification(IDXCoreAdapterFactory *iface, uint32_t event_cookie) +{ + FIXME("iface %p, event_cookie %u stub!\n", iface, event_cookie); + return E_NOTIMPL; +} + +static const struct IDXCoreAdapterFactoryVtbl dxcore_adapter_factory_vtbl = +{ + /* IUnknown methods */ + dxcore_adapter_factory_QueryInterface, + dxcore_adapter_factory_AddRef, + dxcore_adapter_factory_Release, + /* IDXCoreAdapterFactory methods */ + dxcore_adapter_factory_CreateAdapterList, + dxcore_adapter_factory_GetAdapterByLuid, + dxcore_adapter_factory_IsNotificationTypeSupported, + dxcore_adapter_factory_RegisterEventNotification, + dxcore_adapter_factory_UnregisterEventNotification, +}; + +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 (!(factory = calloc(1, sizeof(*factory)))) + { + *out = NULL; + return E_OUTOFMEMORY; + } + + factory->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_vtbl; + factory->refcount = 0; + } + + TRACE("created IDXCoreAdapterFactory %p.\n", *out); + return IDXCoreAdapterFactory_QueryInterface(&factory->IDXCoreAdapterFactory_iface, riid, out); +} diff --git a/dlls/dxcore/main.c b/dlls/dxcore/main.c deleted file mode 100644 index dcc294d04fa..00000000000 --- a/dlls/dxcore/main.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2023 Mohamad Al-Jaf - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "dxcore.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(dxcore); - -HRESULT WINAPI DXCoreCreateAdapterFactory( REFIID riid, void **ppv ) -{ - FIXME( "riid %s, ppv %p stub!\n", debugstr_guid(riid), ppv ); - return E_NOINTERFACE; -} diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index fc6cec083da..95396b0ad37 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -49,20 +49,16 @@ static void test_DXCoreCreateAdapterFactory(void)
if (0) /* Crashes on w1064v1909 */ { - todo_wine hr = pDXCoreCreateAdapterFactory(NULL, NULL); ok(hr == E_POINTER, "got hr %#lx.\n", hr); } hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, NULL); - todo_wine ok(hr == E_POINTER || broken(hr == E_NOINTERFACE) /* w1064v1909 */, "got hr %#lx.\n", hr); hr = pDXCoreCreateAdapterFactory(&DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, (void **)&factory); ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); - todo_wine ok(factory == NULL || broken(factory == (void *)0xdeadbeef) /* w1064v1909 */, "got factory %p.\n", factory);
hr = pDXCoreCreateAdapterFactory(&IID_IDXCoreAdapterFactory, (void **)&factory); - todo_wine ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* w1064v1909 */, "got hr %#lx.\n", hr); if (FAILED(hr)) return;
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/tests/dxcore.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 95396b0ad37..56ba85e2832 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -44,6 +44,8 @@ static void test_DXCoreCreateAdapterFactory(void) { IDXCoreAdapterFactory *factory2 = (void *)0xdeadbeef; IDXCoreAdapterFactory *factory = (void *)0xdeadbeef; + IDXCoreAdapterList *list2 = (void *)0xdeadbeef; + IDXCoreAdapterList *list = (void *)0xdeadbeef; LONG refcount; HRESULT hr;
@@ -73,6 +75,41 @@ 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); + todo_wine + ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); + todo_wine + ok(list == NULL, "got list %p.\n", list); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterFactory, (void **)&list); + todo_wine + ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, NULL, &IID_IDXCoreAdapterFactory, (void **)&list); + todo_wine + ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterFactory, NULL); + todo_wine + ok(hr == E_POINTER, "got hr %#lx.\n", hr); + + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); + todo_wine + ok(hr == S_OK, "got hr %#lx.\n", hr); + hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list2); + todo_wine + ok(hr == S_OK, "got hr %#lx.\n", hr); + todo_wine + ok(list != list2, "got same list %p, list2 %p.\n", list, list); + if (SUCCEEDED(hr)) + { + 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); + + refcount = IDXCoreAdapterList_Release(list); + ok(refcount == 0, "got refcount %ld.\n", refcount); + } refcount = IDXCoreAdapterFactory_Release(factory); ok(refcount == 0, "got refcount %ld.\n", refcount); }
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/Makefile.in | 3 +- dlls/dxcore/dxcore.c | 133 ++++++++++++++++++++++++++++++++++++- dlls/dxcore/tests/dxcore.c | 11 --- 3 files changed, 133 insertions(+), 14 deletions(-)
diff --git a/dlls/dxcore/Makefile.in b/dlls/dxcore/Makefile.in index 579cceded7e..147216555e9 100644 --- a/dlls/dxcore/Makefile.in +++ b/dlls/dxcore/Makefile.in @@ -1,4 +1,5 @@ -MODULE = dxcore.dll +MODULE = dxcore.dll +IMPORTS = wined3d
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 69e58f0dce9..4f47eb0b30c 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -21,11 +21,119 @@ #define COBJMACROS #include "initguid.h" #include "dxcore.h" +#include "wine/wined3d.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dxcore);
+struct dxcore_adapter_list +{ + IDXCoreAdapterList IDXCoreAdapterList_iface; + LONG refcount; +}; + +static inline struct dxcore_adapter_list *impl_from_IDXCoreAdapterList(IDXCoreAdapterList *iface) +{ + return CONTAINING_RECORD(iface, struct dxcore_adapter_list, IDXCoreAdapterList_iface); +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_QueryInterface(IDXCoreAdapterList *iface, REFIID riid, void **out) +{ + struct dxcore_adapter_list *list = impl_from_IDXCoreAdapterList(iface); + + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_IDXCoreAdapterList) + || IsEqualGUID(riid, &IID_IUnknown)) + { + *out = &list->IDXCoreAdapterList_iface; + IUnknown_AddRef((IUnknown *)*out); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_list_AddRef(IDXCoreAdapterList *iface) +{ + struct dxcore_adapter_list *list = impl_from_IDXCoreAdapterList(iface); + ULONG refcount = InterlockedIncrement(&list->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_list_Release(IDXCoreAdapterList *iface) +{ + struct dxcore_adapter_list *list = impl_from_IDXCoreAdapterList(iface); + ULONG refcount = InterlockedDecrement(&list->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(list); + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_GetAdapter(IDXCoreAdapterList *iface, uint32_t index, + REFIID riid, void **out) +{ + FIXME("iface %p, index %u, riid %s, out %p stub!\n", iface, index, debugstr_guid(riid), out); + return E_NOTIMPL; +} + +static uint32_t STDMETHODCALLTYPE dxcore_adapter_list_GetAdapterCount(IDXCoreAdapterList *iface) +{ + FIXME("iface %p stub!\n", iface); + return 0; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_list_IsStale(IDXCoreAdapterList *iface) +{ + FIXME("iface %p stub!\n", iface); + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_GetFactory(IDXCoreAdapterList *iface, REFIID riid, void **out) +{ + FIXME("iface %p, riid %s, out %p stub!\n", iface, debugstr_guid(riid), out); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_Sort(IDXCoreAdapterList *iface, uint32_t num_preferences, + const DXCoreAdapterPreference *preferences) +{ + FIXME("iface %p, num_preferences %u, preferences %p stub!\n", iface, num_preferences, preferences); + return E_NOTIMPL; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_list_IsAdapterPreferenceSupported(IDXCoreAdapterList *iface, + DXCoreAdapterPreference preference) +{ + FIXME("iface %p, preference %u stub!\n", iface, preference); + return FALSE; +} + +static const struct IDXCoreAdapterListVtbl dxcore_adapter_list_vtbl = +{ + /* IUnknown methods */ + dxcore_adapter_list_QueryInterface, + dxcore_adapter_list_AddRef, + dxcore_adapter_list_Release, + /* IDXCoreAdapterList methods */ + dxcore_adapter_list_GetAdapter, + dxcore_adapter_list_GetAdapterCount, + dxcore_adapter_list_IsStale, + dxcore_adapter_list_GetFactory, + dxcore_adapter_list_Sort, + dxcore_adapter_list_IsAdapterPreferenceSupported, +}; + struct dxcore_adapter_factory { IDXCoreAdapterFactory IDXCoreAdapterFactory_iface; @@ -82,9 +190,30 @@ static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_Release(IDXCoreAdapterFact 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 stub!\n", iface, num_attributes, filter_attributes, + 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); - return E_NOTIMPL; + + if (!out) + return E_POINTER; + + *out = NULL; + + if (!num_attributes || !filter_attributes) + return E_INVALIDARG; + + if (!(list = calloc(1, sizeof(*list)))) + return E_OUTOFMEMORY; + + list->IDXCoreAdapterList_iface.lpVtbl = &dxcore_adapter_list_vtbl; + list->refcount = 1; + + 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_GetAdapterByLuid(IDXCoreAdapterFactory *iface, REFLUID adapter_luid, diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 56ba85e2832..bff14524ae4 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -76,30 +76,20 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(factory, &IID_IDXCoreAdapterList, FALSE);
hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 0, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); - todo_wine ok(list == NULL, "got list %p.\n", list); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterFactory, (void **)&list); - todo_wine ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, NULL, &IID_IDXCoreAdapterFactory, (void **)&list); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterFactory, NULL); - todo_wine ok(hr == E_POINTER, "got hr %#lx.\n", hr);
hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); hr = IDXCoreAdapterFactory_CreateAdapterList(factory, 1, &DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, &IID_IDXCoreAdapterList, (void **)&list2); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); - todo_wine ok(list != list2, "got same list %p, list2 %p.\n", list, list); - if (SUCCEEDED(hr)) - { refcount = IDXCoreAdapterList_Release(list2); ok(refcount == 0, "got refcount %ld.\n", refcount);
@@ -109,7 +99,6 @@ static void test_DXCoreCreateAdapterFactory(void)
refcount = IDXCoreAdapterList_Release(list); ok(refcount == 0, "got refcount %ld.\n", refcount); - } refcount = IDXCoreAdapterFactory_Release(factory); ok(refcount == 0, "got refcount %ld.\n", refcount); }
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58133 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58192 --- dlls/dxcore/dxcore.c | 28 ++++++++++++++++++++++++++-- dlls/dxcore/tests/dxcore.c | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 4f47eb0b30c..50ec065d239 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -31,6 +31,8 @@ struct dxcore_adapter_list { IDXCoreAdapterList IDXCoreAdapterList_iface; LONG refcount; + + uint32_t adapter_count; };
static inline struct dxcore_adapter_list *impl_from_IDXCoreAdapterList(IDXCoreAdapterList *iface) @@ -89,8 +91,11 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_GetAdapter(IDXCoreAdapterLi
static uint32_t STDMETHODCALLTYPE dxcore_adapter_list_GetAdapterCount(IDXCoreAdapterList *iface) { - FIXME("iface %p stub!\n", iface); - return 0; + struct dxcore_adapter_list *list = impl_from_IDXCoreAdapterList(iface); + + TRACE("iface %p\n", iface); + + return list->adapter_count; }
static BOOL STDMETHODCALLTYPE dxcore_adapter_list_IsStale(IDXCoreAdapterList *iface) @@ -187,6 +192,20 @@ static ULONG STDMETHODCALLTYPE dxcore_adapter_factory_Release(IDXCoreAdapterFact return refcount; }
+static HRESULT get_adapters(struct dxcore_adapter_list *list) +{ + struct wined3d *wined3d = wined3d_create(0); + HRESULT hr = S_OK; + + if (!wined3d) + return E_FAIL; + + list->adapter_count = wined3d_get_adapter_count(wined3d); + + wined3d_decref(wined3d); + return hr; +} + static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCoreAdapterFactory *iface, uint32_t num_attributes, const GUID *filter_attributes, REFIID riid, void **out) { @@ -209,6 +228,11 @@ static HRESULT STDMETHODCALLTYPE dxcore_adapter_factory_CreateAdapterList(IDXCor
list->IDXCoreAdapterList_iface.lpVtbl = &dxcore_adapter_list_vtbl; list->refcount = 1; + if (FAILED(hr = get_adapters(list))) + { + IDXCoreAdapterList_Release(&list->IDXCoreAdapterList_iface); + return hr; + }
hr = IDXCoreAdapterList_QueryInterface(&list->IDXCoreAdapterList_iface, riid, out); IDXCoreAdapterList_Release(&list->IDXCoreAdapterList_iface); diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index bff14524ae4..0c21952a95d 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -46,6 +46,7 @@ static void test_DXCoreCreateAdapterFactory(void) IDXCoreAdapterFactory *factory = (void *)0xdeadbeef; IDXCoreAdapterList *list2 = (void *)0xdeadbeef; IDXCoreAdapterList *list = (void *)0xdeadbeef; + uint32_t adapter_count = 0; LONG refcount; HRESULT hr;
@@ -97,6 +98,9 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(list, &IID_IDXCoreAdapter, FALSE); check_interface(list, &IID_IDXCoreAdapterFactory, FALSE);
+ adapter_count = IDXCoreAdapterList_GetAdapterCount(list); + ok(adapter_count != 0, "got adapter_count 0.\n"); + refcount = IDXCoreAdapterList_Release(list); ok(refcount == 0, "got refcount %ld.\n", refcount); refcount = IDXCoreAdapterFactory_Release(factory);
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/tests/dxcore.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 0c21952a95d..84a1d49959b 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -46,6 +46,8 @@ static void test_DXCoreCreateAdapterFactory(void) IDXCoreAdapterFactory *factory = (void *)0xdeadbeef; IDXCoreAdapterList *list2 = (void *)0xdeadbeef; IDXCoreAdapterList *list = (void *)0xdeadbeef; + IDXCoreAdapter *adapter2 = (void *)0xdeadbeef; + IDXCoreAdapter *adapter = (void *)0xdeadbeef; uint32_t adapter_count = 0; LONG refcount; HRESULT hr; @@ -101,6 +103,39 @@ static void test_DXCoreCreateAdapterFactory(void) adapter_count = IDXCoreAdapterList_GetAdapterCount(list); ok(adapter_count != 0, "got adapter_count 0.\n");
+ hr = IDXCoreAdapterList_GetAdapter(list, 0xdeadbeef, &IID_IDXCoreAdapter, NULL); + todo_wine + ok(hr == E_POINTER, "got hr %#lx.\n", hr); + hr = IDXCoreAdapterList_GetAdapter(list, adapter_count, &IID_IDXCoreAdapter, (void **)&adapter); + todo_wine + ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); + todo_wine + ok(adapter == NULL, "got adapter %p.\n", adapter); + hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapterList, (void **)&adapter); + todo_wine + ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr); + + hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapter, (void **)&adapter); + todo_wine + ok(hr == S_OK, "got hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapter, (void **)&adapter2); + todo_wine + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(adapter == adapter2, "got adapter %p, adapter2 %p.\n", adapter, adapter2); + refcount = IDXCoreAdapter_Release(adapter2); + 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); + + refcount = IDXCoreAdapter_Release(adapter); + todo_wine + ok(refcount == 2, "got refcount %ld.\n", refcount); + } refcount = IDXCoreAdapterList_Release(list); ok(refcount == 0, "got refcount %ld.\n", refcount); refcount = IDXCoreAdapterFactory_Release(factory);
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/dxcore.c | 193 ++++++++++++++++++++++++++++++++++++- dlls/dxcore/tests/dxcore.c | 9 -- 2 files changed, 189 insertions(+), 13 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 50ec065d239..850fd5fdb65 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -27,11 +27,150 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxcore);
+struct dxcore_adapter +{ + IDXCoreAdapter IDXCoreAdapter_iface; + LONG refcount; +}; + +static inline struct dxcore_adapter *impl_from_IDXCoreAdapter(IDXCoreAdapter *iface) +{ + return CONTAINING_RECORD(iface, struct dxcore_adapter, IDXCoreAdapter_iface); +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_QueryInterface(IDXCoreAdapter *iface, REFIID riid, void **out) +{ + struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_IDXCoreAdapter) + || IsEqualGUID(riid, &IID_IUnknown)) + { + *out = &adapter->IDXCoreAdapter_iface; + IUnknown_AddRef((IUnknown *)*out); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_AddRef(IDXCoreAdapter *iface) +{ + struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + ULONG refcount = InterlockedIncrement(&adapter->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE dxcore_adapter_Release(IDXCoreAdapter *iface) +{ + struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + ULONG refcount = InterlockedDecrement(&adapter->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(adapter); + + return refcount; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_IsValid(IDXCoreAdapter *iface) +{ + FIXME("iface %p stub!\n", iface); + return FALSE; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_IsAttributeSupported(IDXCoreAdapter *iface, REFGUID attribute) +{ + FIXME("iface %p, attribute %s stub!\n", iface, debugstr_guid(attribute)); + return FALSE; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_IsPropertySupported(IDXCoreAdapter *iface, DXCoreAdapterProperty property) +{ + FIXME("iface %p, property %u stub!\n", iface, property); + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *iface, DXCoreAdapterProperty property, + size_t buffer_size, void *buffer) +{ + FIXME("iface %p, property %u, buffer_size %Iu, buffer stub!%p\n", iface, property, buffer_size, buffer); + return E_NOTIMPL; +} + +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; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_IsQueryStateSupported(IDXCoreAdapter *iface, DXCoreAdapterState property) +{ + FIXME("iface %p, property %u stub!\n", iface, property); + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_QueryState(IDXCoreAdapter *iface, DXCoreAdapterState state, size_t state_details_size, + const void *state_details, size_t buffer_size, void *buffer) +{ + FIXME("iface %p, state %u, state_details_size %Iu, state_details %p, buffer_size %Iu, buffer %p stub!\n", + iface, state, state_details_size, state_details, buffer_size, buffer); + return E_NOTIMPL; +} + +static BOOL STDMETHODCALLTYPE dxcore_adapter_IsSetStateSupported(IDXCoreAdapter *iface, DXCoreAdapterState property) +{ + FIXME("iface %p, property %u stub!\n", iface, property); + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_SetState(IDXCoreAdapter *iface, DXCoreAdapterState state, size_t state_details_size, + const void *state_details, size_t buffer_size, const void *buffer) +{ + FIXME("iface %p, state %u, state_details_size %Iu, state_details %p, buffer_size %Iu, buffer %p stub!\n", + iface, state, state_details_size, state_details, buffer_size, buffer); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetFactory(IDXCoreAdapter *iface, REFIID riid, void **out) +{ + FIXME("iface %p, riid %s, out %p stub!\n", iface, debugstr_guid(riid), out); + return E_NOTIMPL; +} + +static const struct IDXCoreAdapterVtbl dxcore_adapter_vtbl = +{ + /* IUnknown methods */ + dxcore_adapter_QueryInterface, + dxcore_adapter_AddRef, + dxcore_adapter_Release, + /* IDXCoreAdapter methods */ + dxcore_adapter_IsValid, + dxcore_adapter_IsAttributeSupported, + dxcore_adapter_IsPropertySupported, + dxcore_adapter_GetProperty, + dxcore_adapter_GetPropertySize, + dxcore_adapter_IsQueryStateSupported, + dxcore_adapter_QueryState, + dxcore_adapter_IsSetStateSupported, + dxcore_adapter_SetState, + dxcore_adapter_GetFactory, +}; + struct dxcore_adapter_list { IDXCoreAdapterList IDXCoreAdapterList_iface; LONG refcount;
+ struct dxcore_adapter **adapters; uint32_t adapter_count; };
@@ -77,16 +216,38 @@ static ULONG STDMETHODCALLTYPE dxcore_adapter_list_Release(IDXCoreAdapterList *i TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
if (!refcount) + { + for (UINT i = 0; i < list->adapter_count; i++) + { + if (list->adapters[i]) + IDXCoreAdapter_Release(&list->adapters[i]->IDXCoreAdapter_iface); + } + free(list->adapters); free(list); - + } return refcount; }
static HRESULT STDMETHODCALLTYPE dxcore_adapter_list_GetAdapter(IDXCoreAdapterList *iface, uint32_t index, REFIID riid, void **out) { - FIXME("iface %p, index %u, riid %s, out %p stub!\n", iface, index, debugstr_guid(riid), out); - return E_NOTIMPL; + struct dxcore_adapter_list *list = impl_from_IDXCoreAdapterList(iface); + IDXCoreAdapter *adapter; + + TRACE("iface %p, index %u, riid %s, out %p\n", iface, index, debugstr_guid(riid), out); + + if (!out) + return E_POINTER; + + if (index >= list->adapter_count) + { + *out = NULL; + return E_INVALIDARG; + } + + adapter = &list->adapters[index]->IDXCoreAdapter_iface; + TRACE("returning IDXCoreAdapter %p for index %u.\n", adapter, index); + return IDXCoreAdapter_QueryInterface(adapter, riid, out); }
static uint32_t STDMETHODCALLTYPE dxcore_adapter_list_GetAdapterCount(IDXCoreAdapterList *iface) @@ -200,8 +361,32 @@ static HRESULT get_adapters(struct dxcore_adapter_list *list) if (!wined3d) return E_FAIL;
- list->adapter_count = wined3d_get_adapter_count(wined3d); + if (!(list->adapter_count = wined3d_get_adapter_count(wined3d))) + goto done; + + if (!(list->adapters = calloc(list->adapter_count, sizeof(*list->adapters)))) + { + hr = E_OUTOFMEMORY; + goto done; + } + + for (UINT i = 0; i < list->adapter_count; i++) + { + struct dxcore_adapter *dxcore_adapter = calloc(1, sizeof(*dxcore_adapter)); + + if (!dxcore_adapter) + { + hr = E_OUTOFMEMORY; + goto done; + } + + dxcore_adapter->IDXCoreAdapter_iface.lpVtbl = &dxcore_adapter_vtbl; + dxcore_adapter->refcount = 1; + + list->adapters[i] = dxcore_adapter; + }
+done: wined3d_decref(wined3d); return hr; } diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 84a1d49959b..39440c8ad27 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -104,24 +104,16 @@ static void test_DXCoreCreateAdapterFactory(void) ok(adapter_count != 0, "got adapter_count 0.\n");
hr = IDXCoreAdapterList_GetAdapter(list, 0xdeadbeef, &IID_IDXCoreAdapter, NULL); - todo_wine ok(hr == E_POINTER, "got hr %#lx.\n", hr); hr = IDXCoreAdapterList_GetAdapter(list, adapter_count, &IID_IDXCoreAdapter, (void **)&adapter); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); - todo_wine ok(adapter == NULL, "got adapter %p.\n", adapter); hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapterList, (void **)&adapter); - todo_wine ok(hr == E_NOINTERFACE, "got hr %#lx.\n", hr);
hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapter, (void **)&adapter); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - { hr = IDXCoreAdapterList_GetAdapter(list, 0, &IID_IDXCoreAdapter, (void **)&adapter2); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); ok(adapter == adapter2, "got adapter %p, adapter2 %p.\n", adapter, adapter2); refcount = IDXCoreAdapter_Release(adapter2); @@ -135,7 +127,6 @@ static void test_DXCoreCreateAdapterFactory(void) refcount = IDXCoreAdapter_Release(adapter); todo_wine ok(refcount == 2, "got refcount %ld.\n", refcount); - } refcount = IDXCoreAdapterList_Release(list); ok(refcount == 0, "got refcount %ld.\n", refcount); refcount = IDXCoreAdapterFactory_Release(factory);
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/tests/dxcore.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index 39440c8ad27..f73458b1ae4 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -48,6 +48,8 @@ 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; @@ -124,6 +126,42 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(adapter, &IID_IDXCoreAdapterList, FALSE); check_interface(adapter, &IID_IDXCoreAdapterFactory, FALSE);
+ hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); + todo_wine + ok(hr == E_POINTER, "got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, buffer); + todo_wine + ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); + hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, buffer); + todo_wine + 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); + todo_wine + 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); + todo_wine + 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); + todo_wine + ok(hr == S_OK, "got hr %#lx.\n", hr); + if (SUCCEEDED(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);
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58133 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58192 --- dlls/dxcore/dxcore.c | 42 ++++++++++++++++++++++++++++++++++++-- dlls/dxcore/tests/dxcore.c | 9 -------- 2 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/dlls/dxcore/dxcore.c b/dlls/dxcore/dxcore.c index 850fd5fdb65..9aa28f8a3a0 100644 --- a/dlls/dxcore/dxcore.c +++ b/dlls/dxcore/dxcore.c @@ -31,6 +31,8 @@ struct dxcore_adapter { IDXCoreAdapter IDXCoreAdapter_iface; LONG refcount; + + struct wined3d_adapter_identifier identifier; };
static inline struct dxcore_adapter *impl_from_IDXCoreAdapter(IDXCoreAdapter *iface) @@ -101,8 +103,36 @@ static BOOL STDMETHODCALLTYPE dxcore_adapter_IsPropertySupported(IDXCoreAdapter static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetProperty(IDXCoreAdapter *iface, DXCoreAdapterProperty property, size_t buffer_size, void *buffer) { - FIXME("iface %p, property %u, buffer_size %Iu, buffer stub!%p\n", iface, property, buffer_size, buffer); - return E_NOTIMPL; + struct dxcore_adapter *adapter = impl_from_IDXCoreAdapter(iface); + + TRACE("iface %p, property %u, buffer_size %Iu, buffer %p\n", iface, property, buffer_size, buffer); + + if (!buffer) + return E_POINTER; + + switch (property) + { + 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; + } + } + + return S_OK; }
static HRESULT STDMETHODCALLTYPE dxcore_adapter_GetPropertySize(IDXCoreAdapter *iface, DXCoreAdapterProperty property, @@ -373,6 +403,7 @@ 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;
if (!dxcore_adapter) { @@ -380,6 +411,13 @@ static HRESULT get_adapters(struct dxcore_adapter_list *list) 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); + goto done; + } + dxcore_adapter->IDXCoreAdapter_iface.lpVtbl = &dxcore_adapter_vtbl; dxcore_adapter->refcount = 1;
diff --git a/dlls/dxcore/tests/dxcore.c b/dlls/dxcore/tests/dxcore.c index f73458b1ae4..fe86149c76e 100644 --- a/dlls/dxcore/tests/dxcore.c +++ b/dlls/dxcore/tests/dxcore.c @@ -127,39 +127,30 @@ static void test_DXCoreCreateAdapterFactory(void) check_interface(adapter, &IID_IDXCoreAdapterFactory, FALSE);
hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, NULL); - todo_wine ok(hr == E_POINTER, "got hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, HardwareID, 0, buffer); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx.\n", hr); hr = IDXCoreAdapter_GetProperty(adapter, 0xdeadbeef, 0, buffer); - todo_wine 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); - todo_wine 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); - todo_wine 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); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); - if (SUCCEEDED(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);
- Fixed refcount trace messages - Added another buffer_size 0 test in IDXCoreAdapter_GetProperty
This merge request was approved by Elizabeth Figura.