2008-10-21 15:06:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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 "config.h"
|
|
|
|
|
|
|
|
#include "dxgi_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static inline struct dxgi_factory *impl_from_IWineDXGIFactory(IWineDXGIFactory *iface)
|
2011-06-07 09:56:55 +02:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_factory, IWineDXGIFactory_iface);
|
2011-06-07 09:56:55 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IWineDXGIFactory *iface, REFIID iid, void **out)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-02-11 11:42:20 +01:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2018-01-26 22:09:05 +01:00
|
|
|
if (IsEqualGUID(iid, &IID_IWineDXGIFactory)
|
2020-05-13 16:46:57 +02:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory7)
|
2020-05-13 16:46:55 +02:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory6)
|
2018-02-14 12:35:49 +01:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory5)
|
2018-01-26 22:09:05 +01:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory4)
|
2018-01-19 13:30:16 +01:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory3)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory2)
|
2018-01-19 13:30:13 +01:00
|
|
|
|| (factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1))
|
2014-09-15 11:03:35 +02:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIObject)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
2014-09-15 11:03:35 +02:00
|
|
|
*out = iface;
|
2008-10-21 15:06:58 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
*out = NULL;
|
2008-10-21 15:06:58 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IWineDXGIFactory *iface)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-09-15 11:03:35 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&factory->refcount);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IWineDXGIFactory *iface)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-09-15 11:03:35 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&factory->refcount);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2014-09-15 11:03:36 +02:00
|
|
|
if (factory->device_window)
|
|
|
|
DestroyWindow(factory->device_window);
|
2008-11-18 09:27:58 +01:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
wined3d_decref(factory->wined3d);
|
2015-02-13 10:40:52 +01:00
|
|
|
wined3d_private_store_cleanup(&factory->private_store);
|
2018-02-06 00:34:19 +01:00
|
|
|
heap_free(factory);
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IWineDXGIFactory *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2015-02-13 10:40:52 +01:00
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return dxgi_set_private_data(&factory->private_store, guid, data_size, data);
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IWineDXGIFactory *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, const IUnknown *object)
|
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2015-02-16 12:25:50 +01:00
|
|
|
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
|
|
|
|
|
|
|
|
return dxgi_set_private_data_interface(&factory->private_store, guid, object);
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IWineDXGIFactory *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2015-02-16 12:25:51 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2015-02-16 12:25:51 +01:00
|
|
|
return dxgi_get_private_data(&factory->private_store, guid, data_size, data);
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IWineDXGIFactory *iface, REFIID iid, void **parent)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
WARN("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2009-12-03 11:38:21 +01:00
|
|
|
*parent = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IWineDXGIFactory *iface,
|
2014-01-28 10:09:26 +01:00
|
|
|
UINT adapter_idx, IDXGIAdapter1 **adapter)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2016-04-14 12:20:23 +02:00
|
|
|
struct dxgi_adapter *adapter_object;
|
|
|
|
UINT adapter_count;
|
|
|
|
HRESULT hr;
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter);
|
2008-11-18 09:27:58 +01:00
|
|
|
|
2014-01-28 10:09:26 +01:00
|
|
|
if (!adapter)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2008-11-18 09:27:58 +01:00
|
|
|
|
2016-04-14 12:20:23 +02:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
adapter_count = wined3d_get_adapter_count(factory->wined3d);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (adapter_idx >= adapter_count)
|
2008-11-18 09:27:58 +01:00
|
|
|
{
|
|
|
|
*adapter = NULL;
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:20:23 +02:00
|
|
|
if (FAILED(hr = dxgi_adapter_create(factory, adapter_idx, &adapter_object)))
|
|
|
|
{
|
|
|
|
*adapter = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-01-30 15:54:56 +01:00
|
|
|
*adapter = (IDXGIAdapter1 *)&adapter_object->IWineDXGIAdapter_iface;
|
2008-11-18 09:27:58 +01:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("Returning adapter %p.\n", *adapter);
|
2008-11-18 09:27:58 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IWineDXGIFactory *iface,
|
2014-01-28 10:09:26 +01:00
|
|
|
UINT adapter_idx, IDXGIAdapter **adapter)
|
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter);
|
2014-01-28 10:09:26 +01:00
|
|
|
|
|
|
|
return dxgi_factory_EnumAdapters1(iface, adapter_idx, (IDXGIAdapter1 **)adapter);
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IWineDXGIFactory *iface,
|
|
|
|
HWND window, UINT flags)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2019-06-19 12:11:04 +02:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
|
|
|
|
|
|
|
|
if (flags > DXGI_MWA_VALID)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
wined3d_unregister_windows(factory->wined3d);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wined3d_register_window(factory->wined3d, window, NULL, flags))
|
|
|
|
return E_FAIL;
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2016-02-12 01:27:42 +01:00
|
|
|
return S_OK;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IWineDXGIFactory *iface, HWND *window)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2019-06-19 12:11:01 +02:00
|
|
|
TRACE("iface %p, window %p.\n", iface, window);
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2019-06-19 12:11:01 +02:00
|
|
|
if (!window)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
/* The tests show that this always returns NULL for some unknown reason. */
|
|
|
|
*window = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain)
|
2018-01-19 13:30:15 +01:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2018-01-19 13:30:15 +01:00
|
|
|
DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc;
|
|
|
|
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p, desc %p, swapchain %p.\n", iface, device, desc, swapchain);
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
WARN("Invalid pointer.\n");
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
swapchain_desc.Width = desc->BufferDesc.Width;
|
|
|
|
swapchain_desc.Height = desc->BufferDesc.Height;
|
|
|
|
swapchain_desc.Format = desc->BufferDesc.Format;
|
|
|
|
swapchain_desc.Stereo = FALSE;
|
|
|
|
swapchain_desc.SampleDesc = desc->SampleDesc;
|
|
|
|
swapchain_desc.BufferUsage = desc->BufferUsage;
|
|
|
|
swapchain_desc.BufferCount = desc->BufferCount;
|
|
|
|
swapchain_desc.Scaling = DXGI_SCALING_STRETCH;
|
|
|
|
swapchain_desc.SwapEffect = desc->SwapEffect;
|
|
|
|
swapchain_desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
|
|
|
|
swapchain_desc.Flags = desc->Flags;
|
|
|
|
|
|
|
|
fullscreen_desc.RefreshRate = desc->BufferDesc.RefreshRate;
|
|
|
|
fullscreen_desc.ScanlineOrdering = desc->BufferDesc.ScanlineOrdering;
|
|
|
|
fullscreen_desc.Scaling = desc->BufferDesc.Scaling;
|
|
|
|
fullscreen_desc.Windowed = desc->Windowed;
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
return IWineDXGIFactory_CreateSwapChainForHwnd(&factory->IWineDXGIFactory_iface,
|
2018-01-19 13:30:15 +01:00
|
|
|
device, desc->OutputWindow, &swapchain_desc, &fullscreen_desc, NULL,
|
|
|
|
(IDXGISwapChain1 **)swapchain);
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IWineDXGIFactory *iface,
|
2018-01-19 13:30:15 +01:00
|
|
|
HMODULE swrast, IDXGIAdapter **adapter)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IWineDXGIFactory *iface)
|
2018-01-19 13:30:15 +01:00
|
|
|
{
|
2021-11-29 22:05:01 +01:00
|
|
|
static BOOL once = FALSE;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
else
|
|
|
|
WARN("iface %p stub!\n", iface);
|
2018-01-19 13:30:15 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IWineDXGIFactory *iface)
|
2018-01-19 13:30:15 +01:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFactory *iface,
|
2018-05-30 12:18:34 +02:00
|
|
|
IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *desc,
|
2018-01-19 13:30:15 +01:00
|
|
|
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
|
|
|
|
IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2018-12-04 15:22:00 +01:00
|
|
|
IWineDXGISwapChainFactory *swapchain_factory;
|
2018-05-28 14:40:27 +02:00
|
|
|
ID3D12CommandQueue *command_queue;
|
2009-02-24 07:43:02 +01:00
|
|
|
HRESULT hr;
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2018-05-30 12:18:34 +02:00
|
|
|
TRACE("iface %p, device %p, window %p, desc %p, fullscreen_desc %p, output %p, swapchain %p.\n",
|
|
|
|
iface, device, window, desc, fullscreen_desc, output, swapchain);
|
2018-01-19 13:30:15 +01:00
|
|
|
|
2018-05-30 12:18:34 +02:00
|
|
|
if (!device || !window || !desc || !swapchain)
|
2018-01-19 13:30:15 +01:00
|
|
|
{
|
|
|
|
WARN("Invalid pointer.\n");
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
|
|
|
|
2018-05-30 12:18:34 +02:00
|
|
|
if (desc->Stereo)
|
2018-01-19 13:30:15 +01:00
|
|
|
{
|
|
|
|
FIXME("Stereo swapchains are not supported.\n");
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
2008-10-29 09:00:26 +01:00
|
|
|
|
2018-09-18 16:06:00 +02:00
|
|
|
if (!dxgi_validate_swapchain_desc(desc))
|
2015-08-27 23:05:03 +02:00
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2018-05-30 12:18:32 +02:00
|
|
|
if (output)
|
|
|
|
FIXME("Ignoring output %p.\n", output);
|
|
|
|
|
2018-12-04 15:22:00 +01:00
|
|
|
if (SUCCEEDED(IUnknown_QueryInterface(device, &IID_IWineDXGISwapChainFactory, (void **)&swapchain_factory)))
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2018-12-04 15:22:00 +01:00
|
|
|
hr = IWineDXGISwapChainFactory_create_swapchain(swapchain_factory,
|
|
|
|
(IDXGIFactory *)iface, window, desc, fullscreen_desc, output, swapchain);
|
|
|
|
IWineDXGISwapChainFactory_Release(swapchain_factory);
|
2009-02-24 07:43:02 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-05-28 14:40:27 +02:00
|
|
|
if (SUCCEEDED(IUnknown_QueryInterface(device, &IID_ID3D12CommandQueue, (void **)&command_queue)))
|
|
|
|
{
|
2018-05-30 12:18:34 +02:00
|
|
|
hr = d3d12_swapchain_create(iface, command_queue, window, desc, fullscreen_desc, swapchain);
|
2018-05-28 14:40:27 +02:00
|
|
|
ID3D12CommandQueue_Release(command_queue);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-05-28 14:40:26 +02:00
|
|
|
ERR("This is not the device we're looking for.\n");
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
IUnknown *device, IUnknown *window, const DXGI_SWAP_CHAIN_DESC1 *desc,
|
|
|
|
IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, device %p, window %p, desc %p, output %p, swapchain %p stub!\n",
|
|
|
|
iface, device, window, desc, output, swapchain);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
HANDLE resource, LUID *luid)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, resource %p, luid %p stub!\n", iface, resource, luid);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
HWND window, UINT message, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, window %p, message %#x, cookie %p stub!\n",
|
|
|
|
iface, window, message, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
HANDLE event, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static void STDMETHODCALLTYPE dxgi_factory_UnregisterStereoStatus(IWineDXGIFactory *iface, DWORD cookie)
|
2018-01-19 13:30:13 +01:00
|
|
|
{
|
2018-01-31 03:41:20 +01:00
|
|
|
FIXME("iface %p, cookie %#x stub!\n", iface, cookie);
|
2018-01-19 13:30:13 +01:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
HWND window, UINT message, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, window %p, message %#x, cookie %p stub!\n",
|
|
|
|
iface, window, message, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
HANDLE event, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static void STDMETHODCALLTYPE dxgi_factory_UnregisterOcclusionStatus(IWineDXGIFactory *iface, DWORD cookie)
|
2018-01-19 13:30:13 +01:00
|
|
|
{
|
|
|
|
FIXME("iface %p, cookie %#x stub!\n", iface, cookie);
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IWineDXGIFactory *iface,
|
2018-01-19 13:30:13 +01:00
|
|
|
IUnknown *device, const DXGI_SWAP_CHAIN_DESC1 *desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, device %p, desc %p, output %p, swapchain %p stub!\n",
|
|
|
|
iface, device, desc, output, swapchain);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static UINT STDMETHODCALLTYPE dxgi_factory_GetCreationFlags(IWineDXGIFactory *iface)
|
2018-01-19 13:30:16 +01:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapterByLuid(IWineDXGIFactory *iface,
|
2018-01-19 13:30:16 +01:00
|
|
|
LUID luid, REFIID iid, void **adapter)
|
|
|
|
{
|
2018-01-23 18:15:16 +01:00
|
|
|
unsigned int adapter_index;
|
|
|
|
DXGI_ADAPTER_DESC1 desc;
|
|
|
|
IDXGIAdapter1 *adapter1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, luid %08x:%08x, iid %s, adapter %p.\n",
|
2018-01-19 13:30:16 +01:00
|
|
|
iface, luid.HighPart, luid.LowPart, debugstr_guid(iid), adapter);
|
|
|
|
|
2020-02-20 13:48:04 +01:00
|
|
|
if (!adapter)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-01-23 18:15:16 +01:00
|
|
|
adapter_index = 0;
|
|
|
|
while ((hr = dxgi_factory_EnumAdapters1(iface, adapter_index, &adapter1)) == S_OK)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = IDXGIAdapter1_GetDesc1(adapter1, &desc)))
|
|
|
|
{
|
|
|
|
WARN("Failed to get adapter %u desc, hr %#x.\n", adapter_index, hr);
|
|
|
|
++adapter_index;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc.AdapterLuid.LowPart == luid.LowPart
|
|
|
|
&& desc.AdapterLuid.HighPart == luid.HighPart)
|
|
|
|
{
|
|
|
|
hr = IDXGIAdapter1_QueryInterface(adapter1, iid, adapter);
|
|
|
|
IDXGIAdapter1_Release(adapter1);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDXGIAdapter1_Release(adapter1);
|
|
|
|
++adapter_index;
|
|
|
|
}
|
|
|
|
if (hr != DXGI_ERROR_NOT_FOUND)
|
|
|
|
WARN("Failed to enumerate adapters, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
WARN("Adapter could not be found.\n");
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
2018-01-19 13:30:16 +01:00
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumWarpAdapter(IWineDXGIFactory *iface,
|
2018-01-19 13:30:16 +01:00
|
|
|
REFIID iid, void **adapter)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, iid %s, adapter %p stub!\n", iface, debugstr_guid(iid), adapter);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CheckFeatureSupport(IWineDXGIFactory *iface,
|
|
|
|
DXGI_FEATURE feature, void *feature_data, UINT data_size)
|
|
|
|
{
|
2020-04-10 19:03:52 +02:00
|
|
|
TRACE("iface %p, feature %#x, feature_data %p, data_size %u.\n",
|
2018-02-14 12:35:49 +01:00
|
|
|
iface, feature, feature_data, data_size);
|
|
|
|
|
2020-04-10 19:03:52 +02:00
|
|
|
switch (feature)
|
|
|
|
{
|
|
|
|
case DXGI_FEATURE_PRESENT_ALLOW_TEARING:
|
|
|
|
if (data_size != sizeof(BOOL))
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
*(BOOL *)feature_data = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Unsupported feature %#x.\n", feature);
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
2018-02-14 12:35:49 +01:00
|
|
|
}
|
|
|
|
|
2020-05-13 16:46:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapterByGpuPreference(IWineDXGIFactory *iface,
|
|
|
|
UINT adapter_idx, DXGI_GPU_PREFERENCE gpu_preference, REFIID iid, void **adapter)
|
|
|
|
{
|
|
|
|
IDXGIAdapter1 *adapter_object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, adapter_idx %u, gpu_preference %#x, iid %s, adapter %p.\n",
|
|
|
|
iface, adapter_idx, gpu_preference, debugstr_guid(iid), adapter);
|
|
|
|
|
|
|
|
if (gpu_preference != DXGI_GPU_PREFERENCE_UNSPECIFIED)
|
|
|
|
FIXME("Ignoring GPU preference %#x.\n", gpu_preference);
|
|
|
|
|
|
|
|
if (FAILED(hr = dxgi_factory_EnumAdapters1(iface, adapter_idx, &adapter_object)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDXGIAdapter1_QueryInterface(adapter_object, iid, adapter);
|
|
|
|
IDXGIAdapter1_Release(adapter_object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2020-05-13 16:46:57 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterAdaptersChangedEvent(IWineDXGIFactory *iface,
|
|
|
|
HANDLE event, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_UnregisterAdaptersChangedEvent(IWineDXGIFactory *iface,
|
|
|
|
DWORD cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, cookie %#x stub!\n", iface, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
static const struct IWineDXGIFactoryVtbl dxgi_factory_vtbl =
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
|
|
|
dxgi_factory_QueryInterface,
|
|
|
|
dxgi_factory_AddRef,
|
|
|
|
dxgi_factory_Release,
|
|
|
|
dxgi_factory_SetPrivateData,
|
|
|
|
dxgi_factory_SetPrivateDataInterface,
|
|
|
|
dxgi_factory_GetPrivateData,
|
|
|
|
dxgi_factory_GetParent,
|
|
|
|
dxgi_factory_EnumAdapters,
|
|
|
|
dxgi_factory_MakeWindowAssociation,
|
|
|
|
dxgi_factory_GetWindowAssociation,
|
|
|
|
dxgi_factory_CreateSwapChain,
|
|
|
|
dxgi_factory_CreateSoftwareAdapter,
|
2018-01-19 13:30:13 +01:00
|
|
|
/* IDXGIFactory1 methods */
|
2014-01-28 10:09:26 +01:00
|
|
|
dxgi_factory_EnumAdapters1,
|
|
|
|
dxgi_factory_IsCurrent,
|
2018-01-19 13:30:13 +01:00
|
|
|
/* IDXGIFactory2 methods */
|
|
|
|
dxgi_factory_IsWindowedStereoEnabled,
|
|
|
|
dxgi_factory_CreateSwapChainForHwnd,
|
|
|
|
dxgi_factory_CreateSwapChainForCoreWindow,
|
|
|
|
dxgi_factory_GetSharedResourceAdapterLuid,
|
2020-08-14 07:18:43 +02:00
|
|
|
dxgi_factory_RegisterStereoStatusWindow,
|
2018-01-19 13:30:13 +01:00
|
|
|
dxgi_factory_RegisterStereoStatusEvent,
|
|
|
|
dxgi_factory_UnregisterStereoStatus,
|
2020-08-14 07:18:43 +02:00
|
|
|
dxgi_factory_RegisterOcclusionStatusWindow,
|
2018-01-19 13:30:13 +01:00
|
|
|
dxgi_factory_RegisterOcclusionStatusEvent,
|
|
|
|
dxgi_factory_UnregisterOcclusionStatus,
|
|
|
|
dxgi_factory_CreateSwapChainForComposition,
|
2018-01-19 13:30:16 +01:00
|
|
|
/* IDXGIFactory3 methods */
|
|
|
|
dxgi_factory_GetCreationFlags,
|
|
|
|
/* IDXGIFactory4 methods */
|
|
|
|
dxgi_factory_EnumAdapterByLuid,
|
|
|
|
dxgi_factory_EnumWarpAdapter,
|
2018-02-14 12:35:49 +01:00
|
|
|
/* IDXIGFactory5 methods */
|
|
|
|
dxgi_factory_CheckFeatureSupport,
|
2020-05-13 16:46:55 +02:00
|
|
|
/* IDXGIFactory6 methods */
|
|
|
|
dxgi_factory_EnumAdapterByGpuPreference,
|
2020-05-13 16:46:57 +02:00
|
|
|
/* IDXGIFactory7 methods */
|
|
|
|
dxgi_factory_RegisterAdaptersChangedEvent,
|
|
|
|
dxgi_factory_UnregisterAdaptersChangedEvent,
|
2008-10-21 15:06:58 +02:00
|
|
|
};
|
2009-12-29 17:10:23 +01:00
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
struct dxgi_factory *unsafe_impl_from_IDXGIFactory(IDXGIFactory *iface)
|
2014-09-15 11:03:35 +02:00
|
|
|
{
|
2018-01-26 22:09:05 +01:00
|
|
|
IWineDXGIFactory *wine_factory;
|
|
|
|
struct dxgi_factory *factory;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
2018-02-14 12:35:49 +01:00
|
|
|
if (FAILED(hr = IDXGIFactory_QueryInterface(iface, &IID_IWineDXGIFactory, (void **)&wine_factory)))
|
2018-01-26 22:09:05 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to get IWineDXGIFactory interface, hr %#x.\n", hr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-02-14 12:35:49 +01:00
|
|
|
assert(wine_factory->lpVtbl == &dxgi_factory_vtbl);
|
|
|
|
factory = CONTAINING_RECORD(wine_factory, struct dxgi_factory, IWineDXGIFactory_iface);
|
2018-01-26 22:09:05 +01:00
|
|
|
IWineDXGIFactory_Release(wine_factory);
|
|
|
|
return factory;
|
2014-09-15 11:03:35 +02:00
|
|
|
}
|
|
|
|
|
2014-02-11 11:42:20 +01:00
|
|
|
static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
|
2009-12-29 17:10:23 +01:00
|
|
|
{
|
2018-02-14 12:35:49 +01:00
|
|
|
factory->IWineDXGIFactory_iface.lpVtbl = &dxgi_factory_vtbl;
|
2009-12-29 17:10:23 +01:00
|
|
|
factory->refcount = 1;
|
2015-02-13 10:40:52 +01:00
|
|
|
wined3d_private_store_init(&factory->private_store);
|
2009-12-29 17:10:23 +01:00
|
|
|
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_lock();
|
2014-03-20 15:51:45 +01:00
|
|
|
factory->wined3d = wined3d_create(0);
|
2016-04-14 12:20:23 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-12-29 17:10:23 +01:00
|
|
|
if (!factory->wined3d)
|
|
|
|
{
|
2015-02-13 10:40:52 +01:00
|
|
|
wined3d_private_store_cleanup(&factory->private_store);
|
2009-12-29 17:10:23 +01:00
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2014-02-11 11:42:20 +01:00
|
|
|
factory->extended = extended;
|
|
|
|
|
2009-12-29 17:10:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2014-02-11 11:42:20 +01:00
|
|
|
|
|
|
|
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
|
|
|
|
{
|
|
|
|
struct dxgi_factory *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-02-06 00:34:19 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2014-02-11 11:42:20 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = dxgi_factory_init(object, extended)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize factory, hr %#x.\n", hr);
|
2018-02-06 00:34:19 +01:00
|
|
|
heap_free(object);
|
2014-02-11 11:42:20 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created factory %p.\n", object);
|
|
|
|
|
2018-02-14 12:35:49 +01:00
|
|
|
hr = IWineDXGIFactory_QueryInterface(&object->IWineDXGIFactory_iface, riid, factory);
|
|
|
|
IWineDXGIFactory_Release(&object->IWineDXGIFactory_iface);
|
2014-02-11 11:42:20 +01:00
|
|
|
return hr;
|
|
|
|
}
|
2014-09-15 11:03:36 +02:00
|
|
|
|
|
|
|
HWND dxgi_factory_get_device_window(struct dxgi_factory *factory)
|
|
|
|
{
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_lock();
|
2014-09-15 11:03:36 +02:00
|
|
|
|
|
|
|
if (!factory->device_window)
|
|
|
|
{
|
|
|
|
if (!(factory->device_window = CreateWindowA("static", "DXGI device window",
|
|
|
|
WS_DISABLED, 0, 0, 0, 0, NULL, NULL, NULL, NULL)))
|
|
|
|
{
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-09-15 11:03:36 +02:00
|
|
|
ERR("Failed to create a window.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
TRACE("Created device window %p for factory %p.\n", factory->device_window, factory);
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-09-15 11:03:36 +02:00
|
|
|
|
|
|
|
return factory->device_window;
|
|
|
|
}
|