2008-10-22 17:41:16 +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);
|
|
|
|
|
2011-06-07 10:00:30 +02:00
|
|
|
static inline struct dxgi_device *impl_from_IWineDXGIDevice(IWineDXGIDevice *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_device, IWineDXGIDevice_iface);
|
|
|
|
}
|
|
|
|
|
2008-10-22 17:41:16 +02:00
|
|
|
/* IUnknown methods */
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IWineDXGIDevice *iface, REFIID riid, void **object)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2008-11-14 13:57:06 +01:00
|
|
|
|
2008-10-22 17:41:16 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDXGIObject)
|
2009-01-19 10:39:05 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IDXGIDevice)
|
|
|
|
|| IsEqualGUID(riid, &IID_IWineDXGIDevice))
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-14 13:57:06 +01:00
|
|
|
if (This->child_layer)
|
|
|
|
{
|
|
|
|
TRACE("forwarding to child layer %p\n", This->child_layer);
|
|
|
|
return IUnknown_QueryInterface(This->child_layer, riid, object);
|
|
|
|
}
|
|
|
|
|
2008-10-22 17:41:16 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2008-10-22 17:41:16 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2008-10-22 17:41:16 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2008-11-14 13:57:06 +01:00
|
|
|
if (This->child_layer) IUnknown_Release(This->child_layer);
|
2008-11-17 12:16:04 +01:00
|
|
|
EnterCriticalSection(&dxgi_cs);
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_decref(This->wined3d_device);
|
2008-11-17 12:16:04 +01:00
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
IWineDXGIFactory_Release(This->factory);
|
2008-10-22 17:41:16 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIObject methods */
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IWineDXGIDevice *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDevice *iface,
|
|
|
|
REFGUID guid, const IUnknown *object)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_GetPrivateData(IWineDXGIDevice *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, REFIID riid, void **parent)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
2009-12-03 11:38:20 +01:00
|
|
|
IDXGIAdapter *adapter;
|
|
|
|
HRESULT hr;
|
2008-10-22 17:41:16 +02:00
|
|
|
|
2009-12-03 11:38:20 +01:00
|
|
|
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
|
|
|
|
|
|
|
|
hr = IDXGIDevice_GetAdapter(iface, &adapter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to get adapter, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDXGIAdapter_QueryInterface(adapter, riid, parent);
|
|
|
|
IDXGIAdapter_Release(adapter);
|
|
|
|
|
|
|
|
return hr;
|
2008-10-22 17:41:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIDevice methods */
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2011-11-27 21:34:48 +01:00
|
|
|
struct wined3d_device_creation_parameters create_parameters;
|
2008-11-20 13:32:00 +01:00
|
|
|
HRESULT hr;
|
2008-10-22 17:41:16 +02:00
|
|
|
|
2008-11-20 13:32:00 +01:00
|
|
|
TRACE("iface %p, adapter %p\n", iface, adapter);
|
|
|
|
|
|
|
|
EnterCriticalSection(&dxgi_cs);
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
hr = wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters);
|
2008-11-20 13:32:00 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
|
2011-11-27 21:34:48 +01:00
|
|
|
return IWineDXGIFactory_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter);
|
2008-10-22 17:41:16 +02:00
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface,
|
2008-10-22 17:41:16 +02:00
|
|
|
const DXGI_SURFACE_DESC *desc, UINT surface_count, DXGI_USAGE usage,
|
|
|
|
const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
|
|
|
|
{
|
2011-05-18 22:30:13 +02:00
|
|
|
struct wined3d_device_parent *device_parent;
|
|
|
|
IWineDXGIDeviceParent *dxgi_device_parent;
|
2009-01-15 09:58:44 +01:00
|
|
|
HRESULT hr;
|
|
|
|
UINT i;
|
2009-01-19 10:39:06 +01:00
|
|
|
UINT j;
|
2009-01-15 09:58:44 +01:00
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
TRACE("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p\n",
|
2008-10-22 17:41:16 +02:00
|
|
|
iface, desc, surface_count, usage, shared_resource, surface);
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
hr = IWineDXGIDevice_QueryInterface(iface, &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent);
|
2009-01-19 10:39:06 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Device should implement IWineD3DDeviceParent\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
|
|
|
|
|
2009-02-19 16:59:42 +01:00
|
|
|
FIXME("Implement DXGI<->wined3d usage conversion\n");
|
2009-01-19 10:39:06 +01:00
|
|
|
|
2009-01-15 09:58:44 +01:00
|
|
|
memset(surface, 0, surface_count * sizeof(*surface));
|
|
|
|
for (i = 0; i < surface_count; ++i)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
struct wined3d_surface *wined3d_surface;
|
2009-01-19 10:39:06 +01:00
|
|
|
IUnknown *parent;
|
|
|
|
|
2012-07-11 12:19:03 +02:00
|
|
|
hr = device_parent->ops->create_texture_surface(device_parent, NULL, desc->Width, desc->Height,
|
2012-01-17 21:13:37 +01:00
|
|
|
wined3dformat_from_dxgi_format(desc->Format), usage, WINED3D_POOL_DEFAULT, 0,
|
2012-01-12 21:43:11 +01:00
|
|
|
WINED3D_CUBEMAP_FACE_POSITIVE_X, &wined3d_surface);
|
2009-01-19 10:39:06 +01:00
|
|
|
if (FAILED(hr))
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
2009-01-19 10:39:06 +01:00
|
|
|
ERR("CreateSurface failed, returning %#x\n", hr);
|
2009-01-15 09:58:44 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
parent = wined3d_surface_get_parent(wined3d_surface);
|
2009-01-19 10:39:06 +01:00
|
|
|
hr = IUnknown_QueryInterface(parent, &IID_IDXGISurface, (void **)&surface[i]);
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_decref(wined3d_surface);
|
2009-01-19 10:39:06 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Surface should implement IDXGISurface\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2009-01-15 09:58:44 +01:00
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
TRACE("Created IDXGISurface %p (%u/%u)\n", surface[i], i + 1, surface_count);
|
2009-01-15 09:58:44 +01:00
|
|
|
}
|
2011-05-18 22:30:13 +02:00
|
|
|
IWineDXGIDeviceParent_Release(dxgi_device_parent);
|
2009-01-15 09:58:44 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
fail:
|
2009-01-19 10:39:06 +01:00
|
|
|
for (j = 0; j < i; ++j)
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
2009-01-19 10:39:06 +01:00
|
|
|
IDXGISurface_Release(surface[i]);
|
2009-01-15 09:58:44 +01:00
|
|
|
}
|
2011-05-18 22:30:13 +02:00
|
|
|
IWineDXGIDeviceParent_Release(dxgi_device_parent);
|
2009-01-15 09:58:44 +01:00
|
|
|
return hr;
|
2008-10-22 17:41:16 +02:00
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IWineDXGIDevice *iface,
|
2008-10-22 17:41:16 +02:00
|
|
|
IUnknown *const *resources, DXGI_RESIDENCY *residency, UINT resource_count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, resources %p, residency %p, resource_count %u stub!\n",
|
|
|
|
iface, resources, residency, resource_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_SetGPUThreadPriority(IWineDXGIDevice *iface, INT priority)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, priority %d stub!\n", iface, priority);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevice *iface, INT *priority)
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, priority %p stub!\n", iface, priority);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:05 +01:00
|
|
|
/* IWineDXGIDevice methods */
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
static struct wined3d_device * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
|
2009-01-19 10:39:05 +01:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2009-01-19 10:39:05 +01:00
|
|
|
|
|
|
|
TRACE("iface %p\n", iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&dxgi_cs);
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_incref(This->wined3d_device);
|
2009-01-19 10:39:05 +01:00
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
return This->wined3d_device;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *iface, const DXGI_SURFACE_DESC *desc,
|
|
|
|
DXGI_USAGE usage, const DXGI_SHARED_RESOURCE *shared_resource, IUnknown *outer, void **surface)
|
|
|
|
{
|
|
|
|
struct dxgi_surface *object;
|
2009-12-07 11:08:38 +01:00
|
|
|
HRESULT hr;
|
2009-01-19 10:39:06 +01:00
|
|
|
|
|
|
|
FIXME("iface %p, desc %p, usage %#x, shared_resource %p, outer %p, surface %p partial stub!\n",
|
|
|
|
iface, desc, usage, shared_resource, outer, surface);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate DXGI surface object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2009-12-07 11:08:39 +01:00
|
|
|
hr = dxgi_surface_init(object, (IDXGIDevice *)iface, outer);
|
2009-12-07 11:08:38 +01:00
|
|
|
if (FAILED(hr))
|
2009-01-19 10:39:06 +01:00
|
|
|
{
|
2009-12-07 11:08:38 +01:00
|
|
|
WARN("Failed to initialize surface, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
2009-01-19 10:39:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created IDXGISurface %p\n", object);
|
2012-04-19 20:44:59 +02:00
|
|
|
*surface = outer ? &object->IUnknown_iface : (IUnknown *)&object->IDXGISurface_iface;
|
2009-01-19 10:39:06 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-02-24 07:43:02 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
|
2011-12-02 08:15:52 +01:00
|
|
|
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **wined3d_swapchain)
|
2009-02-24 07:43:02 +01:00
|
|
|
{
|
2011-06-07 10:00:30 +02:00
|
|
|
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface);
|
2009-02-24 07:43:02 +01:00
|
|
|
struct dxgi_swapchain *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
TRACE("iface %p, desc %p, wined3d_swapchain %p.\n",
|
|
|
|
iface, desc, wined3d_swapchain);
|
2009-12-28 17:38:05 +01:00
|
|
|
|
2009-02-24 07:43:02 +01:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate DXGI swapchain object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-12-02 08:15:52 +01:00
|
|
|
hr = dxgi_swapchain_init(object, This, desc);
|
2009-02-24 07:43:02 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2009-12-28 17:38:05 +01:00
|
|
|
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
|
2009-02-24 07:43:02 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created IDXGISwapChain %p\n", object);
|
2009-12-28 17:38:05 +01:00
|
|
|
*wined3d_swapchain = object->wined3d_swapchain;
|
2009-02-24 07:43:02 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-19 11:41:25 +01:00
|
|
|
static const struct IWineDXGIDeviceVtbl dxgi_device_vtbl =
|
2008-10-22 17:41:16 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
dxgi_device_QueryInterface,
|
|
|
|
dxgi_device_AddRef,
|
|
|
|
dxgi_device_Release,
|
|
|
|
/* IDXGIObject methods */
|
|
|
|
dxgi_device_SetPrivateData,
|
|
|
|
dxgi_device_SetPrivateDataInterface,
|
|
|
|
dxgi_device_GetPrivateData,
|
|
|
|
dxgi_device_GetParent,
|
|
|
|
/* IDXGIDevice methods */
|
|
|
|
dxgi_device_GetAdapter,
|
|
|
|
dxgi_device_CreateSurface,
|
|
|
|
dxgi_device_QueryResourceResidency,
|
|
|
|
dxgi_device_SetGPUThreadPriority,
|
|
|
|
dxgi_device_GetGPUThreadPriority,
|
2009-01-19 10:39:05 +01:00
|
|
|
/* IWineDXGIAdapter methods */
|
|
|
|
dxgi_device_get_wined3d_device,
|
2009-01-19 10:39:06 +01:00
|
|
|
dxgi_device_create_surface,
|
2009-02-24 07:43:02 +01:00
|
|
|
dxgi_device_create_swapchain,
|
2008-10-22 17:41:16 +02:00
|
|
|
};
|
2009-11-19 11:41:25 +01:00
|
|
|
|
|
|
|
HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer,
|
|
|
|
IDXGIFactory *factory, IDXGIAdapter *adapter)
|
|
|
|
{
|
2011-05-18 22:30:13 +02:00
|
|
|
struct wined3d_device_parent *wined3d_device_parent;
|
|
|
|
IWineDXGIDeviceParent *dxgi_device_parent;
|
2009-11-19 11:41:25 +01:00
|
|
|
IWineDXGIAdapter *wine_adapter;
|
|
|
|
UINT adapter_ordinal;
|
2011-02-01 19:39:53 +01:00
|
|
|
struct wined3d *wined3d;
|
2009-11-19 11:41:25 +01:00
|
|
|
void *layer_base;
|
|
|
|
HRESULT hr;
|
2011-10-25 16:58:46 +02:00
|
|
|
WINED3DCAPS caps;
|
2009-11-19 11:41:25 +01:00
|
|
|
|
2011-06-07 10:00:30 +02:00
|
|
|
device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
|
2009-11-19 11:41:25 +01:00
|
|
|
device->refcount = 1;
|
|
|
|
|
|
|
|
layer_base = device + 1;
|
|
|
|
|
|
|
|
hr = layer->create(layer->id, &layer_base, 0,
|
|
|
|
device, &IID_IUnknown, (void **)&device->child_layer);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create device, returning %#x.\n", hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDXGIFactory_QueryInterface(factory, &IID_IWineDXGIFactory, (void **)&device->factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("This is not the factory we're looking for, returning %#x.\n", hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
wined3d = IWineDXGIFactory_get_wined3d(device->factory);
|
|
|
|
|
|
|
|
hr = IDXGIAdapter_QueryInterface(adapter, &IID_IWineDXGIAdapter, (void **)&wine_adapter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("This is not the adapter we're looking for, returning %#x.\n", hr);
|
|
|
|
EnterCriticalSection(&dxgi_cs);
|
2011-02-01 19:39:53 +01:00
|
|
|
wined3d_decref(wined3d);
|
2009-11-19 11:41:25 +01:00
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
adapter_ordinal = IWineDXGIAdapter_get_ordinal(wine_adapter);
|
|
|
|
IWineDXGIAdapter_Release(wine_adapter);
|
|
|
|
|
2011-06-07 10:00:30 +02:00
|
|
|
hr = IWineDXGIDevice_QueryInterface(&device->IWineDXGIDevice_iface, &IID_IWineDXGIDeviceParent,
|
|
|
|
(void **)&dxgi_device_parent);
|
2009-11-19 11:41:25 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("DXGI device should implement IWineD3DDeviceParent.\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2011-05-18 22:30:13 +02:00
|
|
|
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
|
|
|
|
|
2009-11-19 11:41:25 +01:00
|
|
|
FIXME("Ignoring adapter type.\n");
|
2011-10-25 16:58:46 +02:00
|
|
|
|
2011-12-12 20:53:59 +01:00
|
|
|
hr = wined3d_get_device_caps(wined3d, adapter_ordinal, WINED3D_DEVICE_TYPE_HAL, &caps);
|
2011-10-25 16:58:46 +02:00
|
|
|
if (FAILED(hr) || caps.VertexShaderVersion < 4 || caps.PixelShaderVersion < 4)
|
|
|
|
{
|
|
|
|
WARN("Direct3D 10 is not supported on this GPU with the current shader backend.\n");
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2009-11-19 11:41:25 +01:00
|
|
|
EnterCriticalSection(&dxgi_cs);
|
2011-12-12 20:53:59 +01:00
|
|
|
hr = wined3d_device_create(wined3d, adapter_ordinal, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4,
|
2010-08-31 18:41:37 +02:00
|
|
|
wined3d_device_parent, &device->wined3d_device);
|
2011-05-18 22:30:13 +02:00
|
|
|
IWineDXGIDeviceParent_Release(dxgi_device_parent);
|
2011-02-01 19:39:53 +01:00
|
|
|
wined3d_decref(wined3d);
|
2009-11-19 11:41:25 +01:00
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create a wined3d device, returning %#x.\n", hr);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (device->wined3d_device)
|
|
|
|
{
|
|
|
|
EnterCriticalSection(&dxgi_cs);
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_decref(device->wined3d_device);
|
2009-11-19 11:41:25 +01:00
|
|
|
LeaveCriticalSection(&dxgi_cs);
|
|
|
|
}
|
|
|
|
if (device->factory) IWineDXGIFactory_Release(device->factory);
|
|
|
|
if (device->child_layer) IUnknown_Release(device->child_layer);
|
|
|
|
return hr;
|
|
|
|
}
|