2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
23 #include "dxgi_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi
);
27 /* IUnknown methods */
29 static HRESULT STDMETHODCALLTYPE
dxgi_device_QueryInterface(IDXGIDevice
*iface
, REFIID riid
, void **object
)
31 struct dxgi_device
*This
= (struct dxgi_device
*)iface
;
33 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
35 if (IsEqualGUID(riid
, &IID_IUnknown
)
36 || IsEqualGUID(riid
, &IID_IDXGIObject
)
37 || IsEqualGUID(riid
, &IID_IDXGIDevice
))
39 IUnknown_AddRef(iface
);
44 if (This
->child_layer
)
46 TRACE("forwarding to child layer %p\n", This
->child_layer
);
47 return IUnknown_QueryInterface(This
->child_layer
, riid
, object
);
50 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
56 static ULONG STDMETHODCALLTYPE
dxgi_device_AddRef(IDXGIDevice
*iface
)
58 struct dxgi_device
*This
= (struct dxgi_device
*)iface
;
59 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
61 TRACE("%p increasing refcount to %u\n", This
, refcount
);
66 static ULONG STDMETHODCALLTYPE
dxgi_device_Release(IDXGIDevice
*iface
)
68 struct dxgi_device
*This
= (struct dxgi_device
*)iface
;
69 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
71 TRACE("%p decreasing refcount to %u\n", This
, refcount
);
75 if (This
->child_layer
) IUnknown_Release(This
->child_layer
);
76 EnterCriticalSection(&dxgi_cs
);
77 IWineD3DDevice_Release(This
->wined3d_device
);
78 LeaveCriticalSection(&dxgi_cs
);
79 IWineDXGIFactory_Release(This
->factory
);
80 HeapFree(GetProcessHeap(), 0, This
);
86 /* IDXGIObject methods */
88 static HRESULT STDMETHODCALLTYPE
dxgi_device_SetPrivateData(IDXGIDevice
*iface
, REFGUID guid
, UINT data_size
, const void *data
)
90 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
95 static HRESULT STDMETHODCALLTYPE
dxgi_device_SetPrivateDataInterface(IDXGIDevice
*iface
, REFGUID guid
, const IUnknown
*object
)
97 FIXME("iface %p, guid %s, object %p stub!\n", iface
, debugstr_guid(guid
), object
);
102 static HRESULT STDMETHODCALLTYPE
dxgi_device_GetPrivateData(IDXGIDevice
*iface
, REFGUID guid
, UINT
*data_size
, void *data
)
104 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface
, debugstr_guid(guid
), data_size
, data
);
109 static HRESULT STDMETHODCALLTYPE
dxgi_device_GetParent(IDXGIDevice
*iface
, REFIID riid
, void **parent
)
111 FIXME("iface %p, riid %s, parent %p stub!\n", iface
, debugstr_guid(riid
), parent
);
116 /* IDXGIDevice methods */
118 static HRESULT STDMETHODCALLTYPE
dxgi_device_GetAdapter(IDXGIDevice
*iface
, IDXGIAdapter
**adapter
)
120 struct dxgi_device
*This
= (struct dxgi_device
*)iface
;
121 WINED3DDEVICE_CREATION_PARAMETERS create_parameters
;
124 TRACE("iface %p, adapter %p\n", iface
, adapter
);
126 EnterCriticalSection(&dxgi_cs
);
128 hr
= IWineD3DDevice_GetCreationParameters(This
->wined3d_device
, &create_parameters
);
131 LeaveCriticalSection(&dxgi_cs
);
135 LeaveCriticalSection(&dxgi_cs
);
137 return IWineDXGIFactory_EnumAdapters(This
->factory
, create_parameters
.AdapterOrdinal
, adapter
);
140 static HRESULT STDMETHODCALLTYPE
dxgi_device_CreateSurface(IDXGIDevice
*iface
,
141 const DXGI_SURFACE_DESC
*desc
, UINT surface_count
, DXGI_USAGE usage
,
142 const DXGI_SHARED_RESOURCE
*shared_resource
, IDXGISurface
**surface
)
144 FIXME("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p stub!\n",
145 iface
, desc
, surface_count
, usage
, shared_resource
, surface
);
150 static HRESULT STDMETHODCALLTYPE
dxgi_device_QueryResourceResidency(IDXGIDevice
*iface
,
151 IUnknown
*const *resources
, DXGI_RESIDENCY
*residency
, UINT resource_count
)
153 FIXME("iface %p, resources %p, residency %p, resource_count %u stub!\n",
154 iface
, resources
, residency
, resource_count
);
159 static HRESULT STDMETHODCALLTYPE
dxgi_device_SetGPUThreadPriority(IDXGIDevice
*iface
, INT priority
)
161 FIXME("iface %p, priority %d stub!\n", iface
, priority
);
166 static HRESULT STDMETHODCALLTYPE
dxgi_device_GetGPUThreadPriority(IDXGIDevice
*iface
, INT
*priority
)
168 FIXME("iface %p, priority %p stub!\n", iface
, priority
);
173 const struct IDXGIDeviceVtbl dxgi_device_vtbl
=
175 /* IUnknown methods */
176 dxgi_device_QueryInterface
,
179 /* IDXGIObject methods */
180 dxgi_device_SetPrivateData
,
181 dxgi_device_SetPrivateDataInterface
,
182 dxgi_device_GetPrivateData
,
183 dxgi_device_GetParent
,
184 /* IDXGIDevice methods */
185 dxgi_device_GetAdapter
,
186 dxgi_device_CreateSurface
,
187 dxgi_device_QueryResourceResidency
,
188 dxgi_device_SetGPUThreadPriority
,
189 dxgi_device_GetGPUThreadPriority
,