2008-10-21 13:06:58 +00: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 "wine/port.h"
|
|
|
|
|
|
|
|
#include "dxgi_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static inline struct dxgi_factory *impl_from_IWineDXGIFactory(IWineDXGIFactory *iface)
|
2011-06-07 07:56:55 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_factory, IWineDXGIFactory_iface);
|
2011-06-07 07:56:55 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IWineDXGIFactory *iface, REFIID iid, void **out)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-02-11 10:42:20 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2018-01-26 21:09:05 +00:00
|
|
|
if (IsEqualGUID(iid, &IID_IWineDXGIFactory)
|
2018-02-14 11:35:49 +00:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory5)
|
2018-01-26 21:09:05 +00:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory4)
|
2018-01-19 12:30:16 +00:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory3)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory2)
|
2018-01-19 12:30:13 +00:00
|
|
|
|| (factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1))
|
2014-09-15 09:03:35 +00:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIFactory)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIObject)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
2014-09-15 09:03:35 +00:00
|
|
|
*out = iface;
|
2008-10-21 13:06:58 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
*out = NULL;
|
2008-10-21 13:06:58 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IWineDXGIFactory *iface)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-09-15 09:03:35 +00:00
|
|
|
ULONG refcount = InterlockedIncrement(&factory->refcount);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IWineDXGIFactory *iface)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2014-09-15 09:03:35 +00:00
|
|
|
ULONG refcount = InterlockedDecrement(&factory->refcount);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2014-09-15 09:03:36 +00:00
|
|
|
if (factory->device_window)
|
|
|
|
DestroyWindow(factory->device_window);
|
2008-11-18 08:27:58 +00:00
|
|
|
|
2015-09-16 23:10:13 +00:00
|
|
|
wined3d_mutex_lock();
|
2014-09-15 09:03:35 +00:00
|
|
|
wined3d_decref(factory->wined3d);
|
2015-09-16 23:10:13 +00:00
|
|
|
wined3d_mutex_unlock();
|
2015-02-13 09:40:52 +00:00
|
|
|
wined3d_private_store_cleanup(&factory->private_store);
|
2018-02-05 23:34:19 +00:00
|
|
|
heap_free(factory);
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IWineDXGIFactory *iface,
|
2008-10-21 13:06:58 +00:00
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2015-02-13 09:40:52 +00: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 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IWineDXGIFactory *iface,
|
2008-10-21 13:06:58 +00:00
|
|
|
REFGUID guid, const IUnknown *object)
|
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2015-02-16 11:25:50 +00: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 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IWineDXGIFactory *iface,
|
2008-10-21 13:06:58 +00:00
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2015-02-16 11:25:51 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2015-02-16 11:25:51 +00:00
|
|
|
return dxgi_get_private_data(&factory->private_store, guid, data_size, data);
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IWineDXGIFactory *iface, REFIID iid, void **parent)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2014-09-15 09:03:35 +00:00
|
|
|
WARN("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2009-12-03 10:38:21 +00:00
|
|
|
*parent = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IWineDXGIFactory *iface,
|
2014-01-28 09:09:26 +00:00
|
|
|
UINT adapter_idx, IDXGIAdapter1 **adapter)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2016-04-14 10:20:23 +00:00
|
|
|
struct dxgi_adapter *adapter_object;
|
|
|
|
UINT adapter_count;
|
|
|
|
HRESULT hr;
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter);
|
2008-11-18 08:27:58 +00:00
|
|
|
|
2014-01-28 09:09:26 +00:00
|
|
|
if (!adapter)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2008-11-18 08:27:58 +00:00
|
|
|
|
2016-04-14 10:20:23 +00:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
adapter_count = wined3d_get_adapter_count(factory->wined3d);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (adapter_idx >= adapter_count)
|
2008-11-18 08:27:58 +00:00
|
|
|
{
|
|
|
|
*adapter = NULL;
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2016-04-14 10:20:23 +00:00
|
|
|
if (FAILED(hr = dxgi_adapter_create(factory, adapter_idx, &adapter_object)))
|
|
|
|
{
|
|
|
|
*adapter = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-01-30 14:54:56 +00:00
|
|
|
*adapter = (IDXGIAdapter1 *)&adapter_object->IWineDXGIAdapter_iface;
|
2008-11-18 08:27:58 +00:00
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("Returning adapter %p.\n", *adapter);
|
2008-11-18 08:27:58 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IWineDXGIFactory *iface,
|
2014-01-28 09:09:26 +00:00
|
|
|
UINT adapter_idx, IDXGIAdapter **adapter)
|
|
|
|
{
|
2014-09-15 09:03:35 +00:00
|
|
|
TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter);
|
2014-01-28 09:09:26 +00:00
|
|
|
|
|
|
|
return dxgi_factory_EnumAdapters1(iface, adapter_idx, (IDXGIAdapter1 **)adapter);
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IWineDXGIFactory *iface,
|
|
|
|
HWND window, UINT flags)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2014-07-22 06:44:23 +00:00
|
|
|
FIXME("iface %p, window %p, flags %#x stub!\n", iface, window, flags);
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2016-02-12 00:27:42 +00:00
|
|
|
return S_OK;
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IWineDXGIFactory *iface, HWND *window)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
|
|
|
FIXME("iface %p, window %p stub!\n", iface, window);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *iface,
|
2008-10-21 13:06:58 +00:00
|
|
|
IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain)
|
2018-01-19 12:30:15 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *factory = impl_from_IWineDXGIFactory(iface);
|
2018-01-19 12:30:15 +00: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 11:35:49 +00:00
|
|
|
return IWineDXGIFactory_CreateSwapChainForHwnd(&factory->IWineDXGIFactory_iface,
|
2018-01-19 12:30:15 +00:00
|
|
|
device, desc->OutputWindow, &swapchain_desc, &fullscreen_desc, NULL,
|
|
|
|
(IDXGISwapChain1 **)swapchain);
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IWineDXGIFactory *iface,
|
2018-01-19 12:30:15 +00:00
|
|
|
HMODULE swrast, IDXGIAdapter **adapter)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IWineDXGIFactory *iface)
|
2018-01-19 12:30:15 +00:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IWineDXGIFactory *iface)
|
2018-01-19 12:30:15 +00:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFactory *iface,
|
2018-01-19 12:30:15 +00:00
|
|
|
IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc,
|
|
|
|
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
|
|
|
|
IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
2008-10-21 13:06:58 +00:00
|
|
|
{
|
2011-04-13 17:14:31 +00:00
|
|
|
struct wined3d_swapchain *wined3d_swapchain;
|
2011-12-02 07:15:52 +00:00
|
|
|
struct wined3d_swapchain_desc wined3d_desc;
|
2016-08-03 07:41:38 +00:00
|
|
|
unsigned int min_buffer_count;
|
2009-02-24 06:43:02 +00:00
|
|
|
IWineDXGIDevice *dxgi_device;
|
|
|
|
HRESULT hr;
|
2008-10-21 13:06:58 +00:00
|
|
|
|
2018-01-30 14:54:54 +00:00
|
|
|
TRACE("iface %p, device %p, window %p, swapchain_desc %p, fullscreen_desc %p, "
|
|
|
|
"output %p, swapchain %p.\n",
|
2018-01-19 12:30:15 +00:00
|
|
|
iface, device, window, swapchain_desc, fullscreen_desc, output, swapchain);
|
|
|
|
|
2018-01-30 14:54:55 +00:00
|
|
|
if (!device || !window || !swapchain_desc || !swapchain)
|
2018-01-19 12:30:15 +00:00
|
|
|
{
|
|
|
|
WARN("Invalid pointer.\n");
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (swapchain_desc->Stereo)
|
|
|
|
{
|
|
|
|
FIXME("Stereo swapchains are not supported.\n");
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
2008-10-29 08:00:26 +00:00
|
|
|
|
2018-01-19 12:30:15 +00:00
|
|
|
switch (swapchain_desc->SwapEffect)
|
2008-10-29 08:00:26 +00:00
|
|
|
{
|
2015-08-27 21:05:03 +00:00
|
|
|
case DXGI_SWAP_EFFECT_DISCARD:
|
2018-02-15 06:05:18 +00:00
|
|
|
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
|
|
|
|
min_buffer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-08-27 21:05:03 +00:00
|
|
|
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
2018-02-15 06:05:18 +00:00
|
|
|
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL;
|
2015-08-27 21:05:03 +00:00
|
|
|
min_buffer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-11-24 21:18:45 +00:00
|
|
|
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
2018-02-15 06:05:18 +00:00
|
|
|
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD;
|
|
|
|
min_buffer_count = 2;
|
|
|
|
break;
|
|
|
|
|
2015-08-27 21:05:03 +00:00
|
|
|
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
2018-02-15 06:05:18 +00:00
|
|
|
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
2015-08-27 21:05:03 +00:00
|
|
|
min_buffer_count = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-01-19 12:30:15 +00:00
|
|
|
WARN("Invalid swap effect %u used.\n", swapchain_desc->SwapEffect);
|
2015-08-27 21:05:03 +00:00
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2008-10-29 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 12:30:15 +00:00
|
|
|
if (swapchain_desc->BufferCount < min_buffer_count || swapchain_desc->BufferCount > 16)
|
2015-08-27 21:05:03 +00:00
|
|
|
{
|
2018-01-19 12:30:15 +00:00
|
|
|
WARN("BufferCount is %u.\n", swapchain_desc->BufferCount);
|
2015-08-27 21:05:03 +00:00
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
2009-02-24 06:43:02 +00:00
|
|
|
|
2018-01-19 12:30:15 +00:00
|
|
|
if (FAILED(hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device)))
|
2015-08-27 21:05:03 +00:00
|
|
|
{
|
|
|
|
ERR("This is not the device we're looking for\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-01-19 12:30:15 +00:00
|
|
|
if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH)
|
|
|
|
FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling);
|
|
|
|
if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE)
|
|
|
|
FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode);
|
2018-01-30 14:54:54 +00:00
|
|
|
if (fullscreen_desc && fullscreen_desc->ScanlineOrdering)
|
|
|
|
FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering);
|
|
|
|
if (fullscreen_desc && fullscreen_desc->Scaling)
|
|
|
|
FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling);
|
2018-01-19 12:30:15 +00:00
|
|
|
|
|
|
|
wined3d_desc.backbuffer_width = swapchain_desc->Width;
|
|
|
|
wined3d_desc.backbuffer_height = swapchain_desc->Height;
|
|
|
|
wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format);
|
|
|
|
wined3d_desc.backbuffer_count = swapchain_desc->BufferCount;
|
2018-01-25 09:56:29 +00:00
|
|
|
wined3d_desc.backbuffer_usage = wined3d_usage_from_dxgi_usage(swapchain_desc->BufferUsage);
|
2015-08-05 22:21:55 +00:00
|
|
|
wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type,
|
2018-01-19 12:30:15 +00:00
|
|
|
&wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc);
|
|
|
|
wined3d_desc.device_window = window;
|
|
|
|
wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE;
|
2011-12-02 07:15:52 +00:00
|
|
|
wined3d_desc.enable_auto_depth_stencil = FALSE;
|
|
|
|
wined3d_desc.auto_depth_stencil_format = 0;
|
2018-01-19 12:30:15 +00:00
|
|
|
wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags);
|
|
|
|
wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0;
|
2015-04-29 15:27:33 +00:00
|
|
|
wined3d_desc.auto_restore_display_mode = TRUE;
|
2011-12-02 07:15:52 +00:00
|
|
|
|
2016-04-12 10:29:38 +00:00
|
|
|
hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, FALSE, &wined3d_swapchain);
|
2014-09-15 09:03:36 +00:00
|
|
|
IWineDXGIDevice_Release(dxgi_device);
|
2009-02-24 06:43:02 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2014-09-15 09:03:36 +00:00
|
|
|
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
2009-02-24 06:43:02 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-09-16 23:10:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-04-13 17:14:31 +00:00
|
|
|
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
|
2015-09-16 23:10:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-24 06:43:02 +00:00
|
|
|
|
2008-10-29 08:00:26 +00:00
|
|
|
return S_OK;
|
2008-10-21 13:06:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00: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 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00:00
|
|
|
HANDLE resource, LUID *luid)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, resource %p, luid %p stub!\n", iface, resource, luid);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00: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 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00:00
|
|
|
HANDLE event, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static void STDMETHODCALLTYPE dxgi_factory_UnregisterStereoStatus(IWineDXGIFactory *iface, DWORD cookie)
|
2018-01-19 12:30:13 +00:00
|
|
|
{
|
2018-01-31 02:41:20 +00:00
|
|
|
FIXME("iface %p, cookie %#x stub!\n", iface, cookie);
|
2018-01-19 12:30:13 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00: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 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00:00
|
|
|
HANDLE event, DWORD *cookie)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static void STDMETHODCALLTYPE dxgi_factory_UnregisterOcclusionStatus(IWineDXGIFactory *iface, DWORD cookie)
|
2018-01-19 12:30:13 +00:00
|
|
|
{
|
|
|
|
FIXME("iface %p, cookie %#x stub!\n", iface, cookie);
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IWineDXGIFactory *iface,
|
2018-01-19 12:30:13 +00: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 11:35:49 +00:00
|
|
|
static UINT STDMETHODCALLTYPE dxgi_factory_GetCreationFlags(IWineDXGIFactory *iface)
|
2018-01-19 12:30:16 +00:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapterByLuid(IWineDXGIFactory *iface,
|
2018-01-19 12:30:16 +00:00
|
|
|
LUID luid, REFIID iid, void **adapter)
|
|
|
|
{
|
2018-01-23 17:15:16 +00: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 12:30:16 +00:00
|
|
|
iface, luid.HighPart, luid.LowPart, debugstr_guid(iid), adapter);
|
|
|
|
|
2018-01-23 17:15:16 +00: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 12:30:16 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumWarpAdapter(IWineDXGIFactory *iface,
|
2018-01-19 12:30:16 +00: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 11:35:49 +00:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CheckFeatureSupport(IWineDXGIFactory *iface,
|
|
|
|
DXGI_FEATURE feature, void *feature_data, UINT data_size)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, feature %#x, feature_data %p, data_size %u stub!\n",
|
|
|
|
iface, feature, feature_data, data_size);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IWineDXGIFactoryVtbl dxgi_factory_vtbl =
|
2008-10-21 13:06:58 +00: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 12:30:13 +00:00
|
|
|
/* IDXGIFactory1 methods */
|
2014-01-28 09:09:26 +00:00
|
|
|
dxgi_factory_EnumAdapters1,
|
|
|
|
dxgi_factory_IsCurrent,
|
2018-01-19 12:30:13 +00:00
|
|
|
/* IDXGIFactory2 methods */
|
|
|
|
dxgi_factory_IsWindowedStereoEnabled,
|
|
|
|
dxgi_factory_CreateSwapChainForHwnd,
|
|
|
|
dxgi_factory_CreateSwapChainForCoreWindow,
|
|
|
|
dxgi_factory_GetSharedResourceAdapterLuid,
|
|
|
|
dxgi_factory_RegisterOcclusionStatusWindow,
|
|
|
|
dxgi_factory_RegisterStereoStatusEvent,
|
|
|
|
dxgi_factory_UnregisterStereoStatus,
|
|
|
|
dxgi_factory_RegisterStereoStatusWindow,
|
|
|
|
dxgi_factory_RegisterOcclusionStatusEvent,
|
|
|
|
dxgi_factory_UnregisterOcclusionStatus,
|
|
|
|
dxgi_factory_CreateSwapChainForComposition,
|
2018-01-19 12:30:16 +00:00
|
|
|
/* IDXGIFactory3 methods */
|
|
|
|
dxgi_factory_GetCreationFlags,
|
|
|
|
/* IDXGIFactory4 methods */
|
|
|
|
dxgi_factory_EnumAdapterByLuid,
|
|
|
|
dxgi_factory_EnumWarpAdapter,
|
2018-02-14 11:35:49 +00:00
|
|
|
/* IDXIGFactory5 methods */
|
|
|
|
dxgi_factory_CheckFeatureSupport,
|
2008-10-21 13:06:58 +00:00
|
|
|
};
|
2009-12-29 16:10:23 +00:00
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
struct dxgi_factory *unsafe_impl_from_IDXGIFactory(IDXGIFactory *iface)
|
2014-09-15 09:03:35 +00:00
|
|
|
{
|
2018-01-26 21:09:05 +00:00
|
|
|
IWineDXGIFactory *wine_factory;
|
|
|
|
struct dxgi_factory *factory;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-09-15 09:03:35 +00:00
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
2018-02-14 11:35:49 +00:00
|
|
|
if (FAILED(hr = IDXGIFactory_QueryInterface(iface, &IID_IWineDXGIFactory, (void **)&wine_factory)))
|
2018-01-26 21:09:05 +00:00
|
|
|
{
|
|
|
|
ERR("Failed to get IWineDXGIFactory interface, hr %#x.\n", hr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-02-14 11:35:49 +00:00
|
|
|
assert(wine_factory->lpVtbl == &dxgi_factory_vtbl);
|
|
|
|
factory = CONTAINING_RECORD(wine_factory, struct dxgi_factory, IWineDXGIFactory_iface);
|
2018-01-26 21:09:05 +00:00
|
|
|
IWineDXGIFactory_Release(wine_factory);
|
|
|
|
return factory;
|
2014-09-15 09:03:35 +00:00
|
|
|
}
|
|
|
|
|
2014-02-11 10:42:20 +00:00
|
|
|
static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
|
2009-12-29 16:10:23 +00:00
|
|
|
{
|
2018-02-14 11:35:49 +00:00
|
|
|
factory->IWineDXGIFactory_iface.lpVtbl = &dxgi_factory_vtbl;
|
2009-12-29 16:10:23 +00:00
|
|
|
factory->refcount = 1;
|
2015-02-13 09:40:52 +00:00
|
|
|
wined3d_private_store_init(&factory->private_store);
|
2009-12-29 16:10:23 +00:00
|
|
|
|
2015-09-16 23:10:13 +00:00
|
|
|
wined3d_mutex_lock();
|
2014-03-20 14:51:45 +00:00
|
|
|
factory->wined3d = wined3d_create(0);
|
2016-04-14 10:20:23 +00:00
|
|
|
wined3d_mutex_unlock();
|
2009-12-29 16:10:23 +00:00
|
|
|
if (!factory->wined3d)
|
|
|
|
{
|
2015-02-13 09:40:52 +00:00
|
|
|
wined3d_private_store_cleanup(&factory->private_store);
|
2009-12-29 16:10:23 +00:00
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2014-02-11 10:42:20 +00:00
|
|
|
factory->extended = extended;
|
|
|
|
|
2009-12-29 16:10:23 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2014-02-11 10:42:20 +00:00
|
|
|
|
|
|
|
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
|
|
|
|
{
|
|
|
|
struct dxgi_factory *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-02-05 23:34:19 +00:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2014-02-11 10:42:20 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = dxgi_factory_init(object, extended)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize factory, hr %#x.\n", hr);
|
2018-02-05 23:34:19 +00:00
|
|
|
heap_free(object);
|
2014-02-11 10:42:20 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created factory %p.\n", object);
|
|
|
|
|
2018-02-14 11:35:49 +00:00
|
|
|
hr = IWineDXGIFactory_QueryInterface(&object->IWineDXGIFactory_iface, riid, factory);
|
|
|
|
IWineDXGIFactory_Release(&object->IWineDXGIFactory_iface);
|
2014-02-11 10:42:20 +00:00
|
|
|
return hr;
|
|
|
|
}
|
2014-09-15 09:03:36 +00:00
|
|
|
|
|
|
|
HWND dxgi_factory_get_device_window(struct dxgi_factory *factory)
|
|
|
|
{
|
2015-09-16 23:10:13 +00:00
|
|
|
wined3d_mutex_lock();
|
2014-09-15 09:03:36 +00: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-16 23:10:13 +00:00
|
|
|
wined3d_mutex_unlock();
|
2014-09-15 09:03:36 +00: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-16 23:10:13 +00:00
|
|
|
wined3d_mutex_unlock();
|
2014-09-15 09:03:36 +00:00
|
|
|
|
|
|
|
return factory->device_window;
|
|
|
|
}
|