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 08b12af4a1c..3592753745c 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("iface %p, refcount %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("iface %p, refcount %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); }