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 "wine/port.h"
|
|
|
|
|
|
|
|
#include "dxgi_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static inline struct dxgi_factory *impl_from_IDXGIFactory1(IDXGIFactory1 *iface)
|
2011-06-07 09:56:55 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory1_iface);
|
2011-06-07 09:56:55 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory1 *iface, REFIID iid, void **out)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(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
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
if ((factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1))
|
|
|
|
|| 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;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory1 *iface)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface);
|
|
|
|
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
|
|
|
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_lock();
|
2014-09-15 11:03:35 +02:00
|
|
|
wined3d_decref(factory->wined3d);
|
2015-09-17 01:10:13 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-02-13 10:40:52 +01:00
|
|
|
wined3d_private_store_cleanup(&factory->private_store);
|
2014-09-15 11:03:35 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, factory);
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IDXGIFactory1 *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-02-13 10:40:52 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IDXGIFactory1 *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, const IUnknown *object)
|
|
|
|
{
|
2015-02-16 12:25:50 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IDXGIFactory1 *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-02-16 12:25:51 +01:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory1 *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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory1 *iface,
|
2014-01-28 10:09:26 +01:00
|
|
|
UINT adapter_idx, IDXGIAdapter1 **adapter)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
struct dxgi_factory *factory = impl_from_IDXGIFactory1(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
*adapter = &adapter_object->IDXGIAdapter1_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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory1 *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);
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IDXGIFactory1 *iface, HWND window, UINT flags)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
2014-07-22 08:44:23 +02:00
|
|
|
FIXME("iface %p, window %p, flags %#x stub!\n", iface, window, flags);
|
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
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory1 *iface, HWND *window)
|
2008-10-21 15:06:58 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, window %p stub!\n", iface, window);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2012-09-24 20:01:44 +02:00
|
|
|
static UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational)
|
|
|
|
{
|
|
|
|
if (rational->Denominator)
|
|
|
|
return rational->Numerator / rational->Denominator;
|
|
|
|
else
|
|
|
|
return rational->Numerator;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain)
|
|
|
|
{
|
2011-04-13 19:14:31 +02:00
|
|
|
struct wined3d_swapchain *wined3d_swapchain;
|
2011-12-02 08:15:52 +01:00
|
|
|
struct wined3d_swapchain_desc wined3d_desc;
|
2009-02-24 07:43:02 +01:00
|
|
|
IWineDXGIDevice *dxgi_device;
|
|
|
|
HRESULT hr;
|
2015-08-27 23:05:03 +02:00
|
|
|
UINT min_buffer_count;
|
2008-10-21 15:06:58 +02:00
|
|
|
|
2008-10-29 09:00:26 +01:00
|
|
|
FIXME("iface %p, device %p, desc %p, swapchain %p partial stub!\n", iface, device, desc, swapchain);
|
|
|
|
|
2015-08-27 23:05:03 +02:00
|
|
|
switch (desc->SwapEffect)
|
2008-10-29 09:00:26 +01:00
|
|
|
{
|
2015-08-27 23:05:03 +02:00
|
|
|
case DXGI_SWAP_EFFECT_DISCARD:
|
|
|
|
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
|
|
|
min_buffer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-11-24 22:18:45 +01:00
|
|
|
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
2015-08-27 23:05:03 +02:00
|
|
|
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
|
|
|
min_buffer_count = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Invalid swap effect %u used, returning DXGI_ERROR_INVALID_CALL.\n", desc->SwapEffect);
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2008-10-29 09:00:26 +01:00
|
|
|
}
|
|
|
|
|
2015-08-27 23:05:03 +02:00
|
|
|
if (desc->BufferCount < min_buffer_count || desc->BufferCount > 16)
|
|
|
|
{
|
|
|
|
WARN("BufferCount is %u, returning DXGI_ERROR_INVALID_CALL.\n", desc->BufferCount);
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
}
|
2009-02-24 07:43:02 +01:00
|
|
|
if (!desc->OutputWindow)
|
|
|
|
{
|
|
|
|
FIXME("No output window, should use factory output window\n");
|
|
|
|
}
|
|
|
|
|
2015-08-27 23:05:03 +02:00
|
|
|
hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("This is not the device we're looking for\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-02-24 07:43:02 +01:00
|
|
|
FIXME("Ignoring SwapEffect and Flags\n");
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
wined3d_desc.backbuffer_width = desc->BufferDesc.Width;
|
|
|
|
wined3d_desc.backbuffer_height = desc->BufferDesc.Height;
|
|
|
|
wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(desc->BufferDesc.Format);
|
|
|
|
wined3d_desc.backbuffer_count = desc->BufferCount;
|
2015-08-06 00:21:55 +02:00
|
|
|
wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type,
|
|
|
|
&wined3d_desc.multisample_quality, &desc->SampleDesc);
|
2012-01-06 11:20:07 +01:00
|
|
|
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
|
2011-12-02 08:15:52 +01:00
|
|
|
wined3d_desc.device_window = desc->OutputWindow;
|
|
|
|
wined3d_desc.windowed = desc->Windowed;
|
|
|
|
wined3d_desc.enable_auto_depth_stencil = FALSE;
|
|
|
|
wined3d_desc.auto_depth_stencil_format = 0;
|
|
|
|
wined3d_desc.flags = 0; /* WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL? */
|
2012-09-24 20:01:44 +02:00
|
|
|
wined3d_desc.refresh_rate = dxgi_rational_to_uint(&desc->BufferDesc.RefreshRate);
|
2011-12-02 08:15:52 +01:00
|
|
|
wined3d_desc.swap_interval = WINED3DPRESENT_INTERVAL_DEFAULT;
|
2015-04-29 17:27:33 +02:00
|
|
|
wined3d_desc.auto_restore_display_mode = TRUE;
|
2011-12-02 08:15:52 +01:00
|
|
|
|
2016-04-12 12:29:38 +02:00
|
|
|
hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, FALSE, &wined3d_swapchain);
|
2014-09-15 11:03:36 +02:00
|
|
|
IWineDXGIDevice_Release(dxgi_device);
|
2009-02-24 07:43:02 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2014-09-15 11:03:36 +02:00
|
|
|
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
2009-02-24 07:43:02 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:10:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2011-04-13 19:14:31 +02:00
|
|
|
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
|
2015-09-17 01:10:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-24 07:43:02 +01:00
|
|
|
|
2008-10-29 09:00:26 +01:00
|
|
|
return S_OK;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory1 *iface,
|
2008-10-21 15:06:58 +02:00
|
|
|
HMODULE swrast, IDXGIAdapter **adapter)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory1 *iface)
|
2014-01-28 10:09:26 +01:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
static const struct IDXGIFactory1Vtbl 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,
|
2014-01-28 10:09:26 +01:00
|
|
|
dxgi_factory_EnumAdapters1,
|
|
|
|
dxgi_factory_IsCurrent,
|
2008-10-21 15:06:58 +02:00
|
|
|
};
|
2009-12-29 17:10:23 +01:00
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
struct dxgi_factory *unsafe_impl_from_IDXGIFactory1(IDXGIFactory1 *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &dxgi_factory_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory1_iface);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-09-15 11:03:35 +02:00
|
|
|
factory->IDXGIFactory1_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;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = dxgi_factory_init(object, extended)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize factory, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created factory %p.\n", object);
|
|
|
|
|
2014-09-15 11:03:35 +02:00
|
|
|
hr = IDXGIFactory1_QueryInterface(&object->IDXGIFactory1_iface, riid, factory);
|
|
|
|
IDXGIFactory1_Release(&object->IDXGIFactory1_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;
|
|
|
|
}
|