kernel32: Change all functions to use CDECL.
[wine/wine64.git] / dlls / dxgi / device.c
blob1b82b2ade8884136d230f109e7999bed93204b5a
1 /*
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
20 #include "config.h"
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);
40 *object = iface;
41 return S_OK;
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));
52 *object = NULL;
53 return E_NOINTERFACE;
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);
63 return 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);
73 if (!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);
83 return refcount;
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);
92 return E_NOTIMPL;
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);
99 return E_NOTIMPL;
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);
106 return E_NOTIMPL;
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);
113 return E_NOTIMPL;
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;
122 HRESULT hr;
124 TRACE("iface %p, adapter %p\n", iface, adapter);
126 EnterCriticalSection(&dxgi_cs);
128 hr = IWineD3DDevice_GetCreationParameters(This->wined3d_device, &create_parameters);
129 if (FAILED(hr))
131 LeaveCriticalSection(&dxgi_cs);
132 return hr;
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);
147 return E_NOTIMPL;
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);
156 return E_NOTIMPL;
159 static HRESULT STDMETHODCALLTYPE dxgi_device_SetGPUThreadPriority(IDXGIDevice *iface, INT priority)
161 FIXME("iface %p, priority %d stub!\n", iface, priority);
163 return E_NOTIMPL;
166 static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IDXGIDevice *iface, INT *priority)
168 FIXME("iface %p, priority %p stub!\n", iface, priority);
170 return E_NOTIMPL;
173 const struct IDXGIDeviceVtbl dxgi_device_vtbl =
175 /* IUnknown methods */
176 dxgi_device_QueryInterface,
177 dxgi_device_AddRef,
178 dxgi_device_Release,
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,