From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/dxcore/Makefile.in | 2 +- dlls/dxcore/dxcore.c | 146 +++++++++++++++++++++++++++++++++++++ dlls/dxcore/main.c | 28 ------- dlls/dxcore/tests/dxcore.c | 4 - 4 files changed, 147 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..a07fe0c49e8 --- /dev/null +++ b/dlls/dxcore/dxcore.c @@ -0,0 +1,146 @@ +/* + * 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_statics +{ + IDXCoreAdapterFactory IDXCoreAdapterFactory_iface; + LONG ref; +}; + +static inline struct dxcore_adapter_factory_statics *impl_from_IDXCoreAdapterFactory( IDXCoreAdapterFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct dxcore_adapter_factory_statics, IDXCoreAdapterFactory_iface ); +} + +static HRESULT WINAPI dxcore_adapter_factory_statics_QueryInterface( IDXCoreAdapterFactory *iface, REFIID iid, void **out ) +{ + struct dxcore_adapter_factory_statics *impl = impl_from_IDXCoreAdapterFactory( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IDXCoreAdapterFactory )) + { + *out = &impl->IDXCoreAdapterFactory_iface; + IUnknown_AddRef( (IUnknown *)*out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI dxcore_adapter_factory_statics_AddRef( IDXCoreAdapterFactory *iface ) +{ + struct dxcore_adapter_factory_statics *impl = impl_from_IDXCoreAdapterFactory( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI dxcore_adapter_factory_statics_Release( IDXCoreAdapterFactory *iface ) +{ + struct dxcore_adapter_factory_statics *impl = impl_from_IDXCoreAdapterFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI dxcore_adapter_factory_statics_CreateAdapterList( IDXCoreAdapterFactory *iface, uint32_t num_attributes, + const GUID *filter_attributes, REFIID riid, void **ppv ) +{ + FIXME( "iface %p, num_attributes %u, filter_attributes %p, riid %s, ppv %p stub!\n", iface, num_attributes, filter_attributes, debugstr_guid( riid ), ppv ); + return E_NOTIMPL; +} + +static HRESULT WINAPI dxcore_adapter_factory_statics_GetAdapterByLuid( IDXCoreAdapterFactory *iface, REFLUID adapter_luid, REFIID riid, void **ppv ) +{ + FIXME( "iface %p, adapter_luid %p, riid %s, ppv %p stub!\n", iface, adapter_luid, debugstr_guid( riid ), ppv ); + return E_NOTIMPL; +} + +static BOOL WINAPI dxcore_adapter_factory_statics_IsNotificationTypeSupported( IDXCoreAdapterFactory *iface, DXCoreNotificationType type ) +{ + FIXME( "iface %p, type %u stub!\n", iface, type ); + return FALSE; +} + +static HRESULT WINAPI dxcore_adapter_factory_statics_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 WINAPI dxcore_adapter_factory_statics_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_statics_vtbl = +{ + /* IUnknown methods */ + dxcore_adapter_factory_statics_QueryInterface, + dxcore_adapter_factory_statics_AddRef, + dxcore_adapter_factory_statics_Release, + /* IDXCoreAdapterFactory methods */ + dxcore_adapter_factory_statics_CreateAdapterList, + dxcore_adapter_factory_statics_GetAdapterByLuid, + dxcore_adapter_factory_statics_IsNotificationTypeSupported, + dxcore_adapter_factory_statics_RegisterEventNotification, + dxcore_adapter_factory_statics_UnregisterEventNotification, +}; + +HRESULT WINAPI DXCoreCreateAdapterFactory( REFIID riid, void **ppv ) +{ + static struct dxcore_adapter_factory_statics *impl = NULL; + + TRACE( "riid %s, ppv %p\n", debugstr_guid( riid ), ppv ); + + if (!ppv) return E_POINTER; + if (!impl) + { + if (!(impl = calloc( 1, sizeof( *impl ) ))) + { + *ppv = NULL; + return E_OUTOFMEMORY; + } + + impl->IDXCoreAdapterFactory_iface.lpVtbl = &dxcore_adapter_factory_statics_vtbl; + impl->ref = 0; + } + + TRACE( "created IDXCoreAdapterFactory %p.\n", *ppv ); + return IDXCoreAdapterFactory_QueryInterface( &impl->IDXCoreAdapterFactory_iface, riid, ppv ); +} 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 266a53f8f89..58424ee8b56 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 **)&adapter_factory ); ok( hr == E_NOINTERFACE, "got hr %#lx.\n", hr ); - todo_wine ok( adapter_factory == NULL || broken(adapter_factory == (void *)0xdeadbeef) /* w1064v1909 */, "got adapter_factory %p.\n", adapter_factory );
hr = pDXCoreCreateAdapterFactory( &IID_IDXCoreAdapterFactory, (void **)&adapter_factory ); - todo_wine ok( hr == S_OK || broken(hr == E_NOINTERFACE) /* w1064v1909 */, "got hr %#lx.\n", hr ); if (FAILED(hr)) return;