kernel32/tests: Add a test to check some fields in fake dlls.
[wine.git] / dlls / dxgi / device.c
blobc7d663f953bf9ffbcd3e99a37396f750adbb010a
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 static inline struct dxgi_device *impl_from_IWineDXGIDevice(IWineDXGIDevice *iface)
29 return CONTAINING_RECORD(iface, struct dxgi_device, IWineDXGIDevice_iface);
32 /* IUnknown methods */
34 static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IWineDXGIDevice *iface, REFIID riid, void **object)
36 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
38 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDXGIObject)
42 || IsEqualGUID(riid, &IID_IDXGIDevice)
43 || IsEqualGUID(riid, &IID_IDXGIDevice1)
44 || IsEqualGUID(riid, &IID_IDXGIDevice2)
45 || IsEqualGUID(riid, &IID_IWineDXGIDevice))
47 IUnknown_AddRef(iface);
48 *object = iface;
49 return S_OK;
52 if (IsEqualGUID(riid, &IID_IWineDXGISwapChainFactory))
54 IUnknown_AddRef(iface);
55 *object = &device->IWineDXGISwapChainFactory_iface;
56 return S_OK;
59 if (device->child_layer)
61 TRACE("Forwarding to child layer %p.\n", device->child_layer);
62 return IUnknown_QueryInterface(device->child_layer, riid, object);
65 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
67 *object = NULL;
68 return E_NOINTERFACE;
71 static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
73 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
74 ULONG refcount = InterlockedIncrement(&device->refcount);
76 TRACE("%p increasing refcount to %u\n", device, refcount);
78 return refcount;
81 static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
83 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
84 ULONG refcount = InterlockedDecrement(&device->refcount);
86 TRACE("%p decreasing refcount to %u.\n", device, refcount);
88 if (!refcount)
90 if (device->child_layer)
91 IUnknown_Release(device->child_layer);
92 wined3d_mutex_lock();
93 wined3d_device_uninit_3d(device->wined3d_device);
94 wined3d_device_decref(device->wined3d_device);
95 wined3d_mutex_unlock();
96 IWineDXGIAdapter_Release(device->adapter);
97 wined3d_private_store_cleanup(&device->private_store);
98 heap_free(device);
101 return refcount;
104 /* IDXGIObject methods */
106 static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IWineDXGIDevice *iface,
107 REFGUID guid, UINT data_size, const void *data)
109 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
111 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
113 return dxgi_set_private_data(&device->private_store, guid, data_size, data);
116 static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDevice *iface,
117 REFGUID guid, const IUnknown *object)
119 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
121 TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
123 return dxgi_set_private_data_interface(&device->private_store, guid, object);
126 static HRESULT STDMETHODCALLTYPE dxgi_device_GetPrivateData(IWineDXGIDevice *iface,
127 REFGUID guid, UINT *data_size, void *data)
129 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
131 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
133 return dxgi_get_private_data(&device->private_store, guid, data_size, data);
136 static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, REFIID riid, void **parent)
138 IDXGIAdapter *adapter;
139 HRESULT hr;
141 TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
143 hr = IWineDXGIDevice_GetAdapter(iface, &adapter);
144 if (FAILED(hr))
146 ERR("Failed to get adapter, hr %#x.\n", hr);
147 return hr;
150 hr = IDXGIAdapter_QueryInterface(adapter, riid, parent);
151 IDXGIAdapter_Release(adapter);
153 return hr;
156 /* IDXGIDevice methods */
158 static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter)
160 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
162 TRACE("iface %p, adapter %p.\n", iface, adapter);
164 *adapter = (IDXGIAdapter *)device->adapter;
165 IDXGIAdapter_AddRef(*adapter);
166 return S_OK;
169 static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface,
170 const DXGI_SURFACE_DESC *desc, UINT surface_count, DXGI_USAGE usage,
171 const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
173 struct wined3d_device_parent *device_parent;
174 struct wined3d_resource_desc surface_desc;
175 IWineDXGIDeviceParent *dxgi_device_parent;
176 HRESULT hr;
177 UINT i;
178 UINT j;
180 TRACE("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p.\n",
181 iface, desc, surface_count, usage, shared_resource, surface);
183 hr = IWineDXGIDevice_QueryInterface(iface, &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent);
184 if (FAILED(hr))
186 ERR("Device should implement IWineDXGIDeviceParent.\n");
187 return E_FAIL;
190 device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
192 surface_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
193 surface_desc.format = wined3dformat_from_dxgi_format(desc->Format);
194 wined3d_sample_desc_from_dxgi(&surface_desc.multisample_type,
195 &surface_desc.multisample_quality, &desc->SampleDesc);
196 surface_desc.bind_flags = wined3d_bind_flags_from_dxgi_usage(usage);
197 surface_desc.usage = 0;
198 surface_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
199 surface_desc.width = desc->Width;
200 surface_desc.height = desc->Height;
201 surface_desc.depth = 1;
202 surface_desc.size = 0;
204 wined3d_mutex_lock();
205 memset(surface, 0, surface_count * sizeof(*surface));
206 for (i = 0; i < surface_count; ++i)
208 struct wined3d_texture *wined3d_texture;
209 IUnknown *parent;
211 if (FAILED(hr = device_parent->ops->create_swapchain_texture(device_parent,
212 NULL, &surface_desc, 0, &wined3d_texture)))
214 ERR("Failed to create surface, hr %#x.\n", hr);
215 goto fail;
218 parent = wined3d_texture_get_parent(wined3d_texture);
219 hr = IUnknown_QueryInterface(parent, &IID_IDXGISurface, (void **)&surface[i]);
220 wined3d_texture_decref(wined3d_texture);
221 if (FAILED(hr))
223 ERR("Surface should implement IDXGISurface.\n");
224 goto fail;
227 TRACE("Created IDXGISurface %p (%u/%u).\n", surface[i], i + 1, surface_count);
229 wined3d_mutex_unlock();
230 IWineDXGIDeviceParent_Release(dxgi_device_parent);
232 return S_OK;
234 fail:
235 wined3d_mutex_unlock();
236 for (j = 0; j < i; ++j)
238 IDXGISurface_Release(surface[i]);
240 IWineDXGIDeviceParent_Release(dxgi_device_parent);
241 return hr;
244 static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IWineDXGIDevice *iface,
245 IUnknown *const *resources, DXGI_RESIDENCY *residency, UINT resource_count)
247 FIXME("iface %p, resources %p, residency %p, resource_count %u stub!\n",
248 iface, resources, residency, resource_count);
250 return E_NOTIMPL;
253 static HRESULT STDMETHODCALLTYPE dxgi_device_SetGPUThreadPriority(IWineDXGIDevice *iface, INT priority)
255 FIXME("iface %p, priority %d stub!\n", iface, priority);
257 return E_NOTIMPL;
260 static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevice *iface, INT *priority)
262 FIXME("iface %p, priority %p stub!\n", iface, priority);
264 return E_NOTIMPL;
267 static HRESULT STDMETHODCALLTYPE dxgi_device_SetMaximumFrameLatency(IWineDXGIDevice *iface, UINT max_latency)
269 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
271 TRACE("iface %p, max_latency %u.\n", iface, max_latency);
273 if (max_latency > DXGI_FRAME_LATENCY_MAX)
274 return DXGI_ERROR_INVALID_CALL;
276 wined3d_mutex_lock();
277 wined3d_device_set_max_frame_latency(device->wined3d_device, max_latency);
278 wined3d_mutex_unlock();
280 return S_OK;
283 static HRESULT STDMETHODCALLTYPE dxgi_device_GetMaximumFrameLatency(IWineDXGIDevice *iface, UINT *max_latency)
285 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
287 TRACE("iface %p, max_latency %p.\n", iface, max_latency);
289 if (!max_latency)
290 return DXGI_ERROR_INVALID_CALL;
292 wined3d_mutex_lock();
293 *max_latency = wined3d_device_get_max_frame_latency(device->wined3d_device);
294 wined3d_mutex_unlock();
296 return S_OK;
299 static HRESULT STDMETHODCALLTYPE dxgi_device_OfferResources(IWineDXGIDevice *iface, UINT resource_count,
300 IDXGIResource * const *resources, DXGI_OFFER_RESOURCE_PRIORITY priority)
302 FIXME("iface %p, resource_count %u, resources %p, priority %u stub!\n", iface, resource_count,
303 resources, priority);
305 return E_NOTIMPL;
308 static HRESULT STDMETHODCALLTYPE dxgi_device_ReclaimResources(IWineDXGIDevice *iface, UINT resource_count,
309 IDXGIResource * const *resources, BOOL *discarded)
311 FIXME("iface %p, resource_count %u, resources %p, discarded %p stub!\n", iface, resource_count,
312 resources, discarded);
314 return E_NOTIMPL;
317 static HRESULT STDMETHODCALLTYPE dxgi_device_EnqueueSetEvent(IWineDXGIDevice *iface, HANDLE event)
319 FIXME("iface %p, event %p stub!\n", iface, event);
321 return E_NOTIMPL;
324 /* IWineDXGIDevice methods */
326 static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *iface,
327 struct wined3d_texture *wined3d_texture, DXGI_USAGE usage,
328 const DXGI_SHARED_RESOURCE *shared_resource, IUnknown *outer, void **surface)
330 struct dxgi_surface *object;
331 HRESULT hr;
333 TRACE("iface %p, wined3d_texture %p, usage %#x, shared_resource %p, outer %p, surface %p.\n",
334 iface, wined3d_texture, usage, shared_resource, outer, surface);
336 if (!(object = heap_alloc_zero(sizeof(*object))))
338 ERR("Failed to allocate DXGI surface object memory.\n");
339 return E_OUTOFMEMORY;
342 if (FAILED(hr = dxgi_surface_init(object, (IDXGIDevice *)iface, outer, wined3d_texture)))
344 WARN("Failed to initialize surface, hr %#x.\n", hr);
345 heap_free(object);
346 return hr;
349 TRACE("Created IDXGISurface %p.\n", object);
350 *surface = outer ? &object->IUnknown_iface : (IUnknown *)&object->IDXGISurface1_iface;
352 return S_OK;
355 static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *iface,
356 struct wined3d_swapchain_desc *desc, BOOL implicit, struct wined3d_swapchain **wined3d_swapchain)
358 struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
359 struct d3d11_swapchain *object;
360 HRESULT hr;
362 TRACE("iface %p, desc %p, wined3d_swapchain %p.\n",
363 iface, desc, wined3d_swapchain);
365 if (!(object = heap_alloc_zero(sizeof(*object))))
367 ERR("Failed to allocate DXGI swapchain object memory\n");
368 return E_OUTOFMEMORY;
371 if (FAILED(hr = d3d11_swapchain_init(object, device, desc, implicit)))
373 WARN("Failed to initialize swapchain, hr %#x.\n", hr);
374 heap_free(object);
375 return hr;
378 TRACE("Created IDXGISwapChain %p.\n", object);
379 *wined3d_swapchain = object->wined3d_swapchain;
381 return S_OK;
384 static const struct IWineDXGIDeviceVtbl dxgi_device_vtbl =
386 /* IUnknown methods */
387 dxgi_device_QueryInterface,
388 dxgi_device_AddRef,
389 dxgi_device_Release,
390 /* IDXGIObject methods */
391 dxgi_device_SetPrivateData,
392 dxgi_device_SetPrivateDataInterface,
393 dxgi_device_GetPrivateData,
394 dxgi_device_GetParent,
395 /* IDXGIDevice methods */
396 dxgi_device_GetAdapter,
397 dxgi_device_CreateSurface,
398 dxgi_device_QueryResourceResidency,
399 dxgi_device_SetGPUThreadPriority,
400 dxgi_device_GetGPUThreadPriority,
401 /* IDXGIDevice1 methods */
402 dxgi_device_SetMaximumFrameLatency,
403 dxgi_device_GetMaximumFrameLatency,
404 /* IDXGIDevice2 methods */
405 dxgi_device_OfferResources,
406 dxgi_device_ReclaimResources,
407 dxgi_device_EnqueueSetEvent,
408 /* IWineDXGIDevice methods */
409 dxgi_device_create_surface,
410 dxgi_device_create_swapchain,
413 static inline struct dxgi_device *impl_from_IWineDXGISwapChainFactory(IWineDXGISwapChainFactory *iface)
415 return CONTAINING_RECORD(iface, struct dxgi_device, IWineDXGISwapChainFactory_iface);
418 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_factory_QueryInterface(IWineDXGISwapChainFactory *iface,
419 REFIID iid, void **out)
421 struct dxgi_device *device = impl_from_IWineDXGISwapChainFactory(iface);
423 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
425 return dxgi_device_QueryInterface(&device->IWineDXGIDevice_iface, iid, out);
428 static ULONG STDMETHODCALLTYPE dxgi_swapchain_factory_AddRef(IWineDXGISwapChainFactory *iface)
430 struct dxgi_device *device = impl_from_IWineDXGISwapChainFactory(iface);
432 TRACE("iface %p.\n", iface);
434 return dxgi_device_AddRef(&device->IWineDXGIDevice_iface);
437 static ULONG STDMETHODCALLTYPE dxgi_swapchain_factory_Release(IWineDXGISwapChainFactory *iface)
439 struct dxgi_device *device = impl_from_IWineDXGISwapChainFactory(iface);
441 TRACE("iface %p.\n", iface);
443 return dxgi_device_Release(&device->IWineDXGIDevice_iface);
446 static HRESULT STDMETHODCALLTYPE dxgi_swapchain_factory_create_swapchain(IWineDXGISwapChainFactory *iface,
447 IDXGIFactory *factory, HWND window, const DXGI_SWAP_CHAIN_DESC1 *desc,
448 const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain)
450 struct dxgi_device *device = impl_from_IWineDXGISwapChainFactory(iface);
451 struct wined3d_swapchain *wined3d_swapchain;
452 struct wined3d_swapchain_desc wined3d_desc;
453 HRESULT hr;
455 TRACE("iface %p, factory %p, window %p, desc %p, fullscreen_desc %p, output %p, swapchain %p.\n",
456 iface, factory, window, desc, fullscreen_desc, output, swapchain);
458 if (desc->Scaling != DXGI_SCALING_STRETCH)
459 FIXME("Ignoring scaling %#x.\n", desc->Scaling);
460 if (desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE)
461 FIXME("Ignoring alpha mode %#x.\n", desc->AlphaMode);
462 if (fullscreen_desc && fullscreen_desc->ScanlineOrdering)
463 FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering);
464 if (fullscreen_desc && fullscreen_desc->Scaling)
465 FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling);
467 switch (desc->SwapEffect)
469 case DXGI_SWAP_EFFECT_DISCARD:
470 wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
471 break;
472 case DXGI_SWAP_EFFECT_SEQUENTIAL:
473 wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL;
474 break;
475 case DXGI_SWAP_EFFECT_FLIP_DISCARD:
476 wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD;
477 break;
478 case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
479 wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL;
480 break;
481 default:
482 WARN("Invalid swap effect %#x.\n", desc->SwapEffect);
483 return DXGI_ERROR_INVALID_CALL;
486 wined3d_desc.backbuffer_width = desc->Width;
487 wined3d_desc.backbuffer_height = desc->Height;
488 wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(desc->Format);
489 wined3d_desc.backbuffer_count = desc->BufferCount;
490 wined3d_desc.backbuffer_bind_flags = wined3d_bind_flags_from_dxgi_usage(desc->BufferUsage);
491 wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type,
492 &wined3d_desc.multisample_quality, &desc->SampleDesc);
493 wined3d_desc.device_window = window;
494 wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE;
495 wined3d_desc.enable_auto_depth_stencil = FALSE;
496 wined3d_desc.auto_depth_stencil_format = 0;
497 wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(desc->Flags);
498 wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0;
499 wined3d_desc.auto_restore_display_mode = TRUE;
501 if (FAILED(hr = dxgi_device_create_swapchain(&device->IWineDXGIDevice_iface,
502 &wined3d_desc, FALSE, &wined3d_swapchain)))
504 WARN("Failed to create swapchain, hr %#x.\n", hr);
505 return hr;
508 wined3d_mutex_lock();
509 *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
510 wined3d_mutex_unlock();
512 return S_OK;
515 static const struct IWineDXGISwapChainFactoryVtbl dxgi_swapchain_factory_vtbl =
517 dxgi_swapchain_factory_QueryInterface,
518 dxgi_swapchain_factory_AddRef,
519 dxgi_swapchain_factory_Release,
520 dxgi_swapchain_factory_create_swapchain,
523 HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer,
524 IDXGIFactory *factory, IDXGIAdapter *adapter,
525 const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count)
527 struct wined3d_device_parent *wined3d_device_parent;
528 struct wined3d_swapchain_desc swapchain_desc;
529 IWineDXGIDeviceParent *dxgi_device_parent;
530 struct dxgi_adapter *dxgi_adapter;
531 struct dxgi_factory *dxgi_factory;
532 void *layer_base;
533 HRESULT hr;
535 if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory(factory)))
537 WARN("This is not the factory we're looking for.\n");
538 return E_FAIL;
541 if (!(dxgi_adapter = unsafe_impl_from_IDXGIAdapter(adapter)))
543 WARN("This is not the adapter we're looking for.\n");
544 return E_FAIL;
547 device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
548 device->IWineDXGISwapChainFactory_iface.lpVtbl = &dxgi_swapchain_factory_vtbl;
549 device->refcount = 1;
550 wined3d_mutex_lock();
551 wined3d_private_store_init(&device->private_store);
553 layer_base = device + 1;
555 if (FAILED(hr = layer->create(layer->id, &layer_base, 0,
556 device, &IID_IUnknown, (void **)&device->child_layer)))
558 WARN("Failed to create device, returning %#x.\n", hr);
559 wined3d_private_store_cleanup(&device->private_store);
560 wined3d_mutex_unlock();
561 return hr;
564 if (FAILED(hr = IWineDXGIDevice_QueryInterface(&device->IWineDXGIDevice_iface,
565 &IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent)))
567 ERR("DXGI device should implement IWineDXGIDeviceParent.\n");
568 IUnknown_Release(device->child_layer);
569 wined3d_private_store_cleanup(&device->private_store);
570 wined3d_mutex_unlock();
571 return hr;
573 wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
574 IWineDXGIDeviceParent_Release(dxgi_device_parent);
576 if (FAILED(hr = wined3d_device_create(dxgi_factory->wined3d,
577 dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4,
578 (const enum wined3d_feature_level *)feature_levels, level_count,
579 wined3d_device_parent, &device->wined3d_device)))
581 WARN("Failed to create a wined3d device, returning %#x.\n", hr);
582 IUnknown_Release(device->child_layer);
583 wined3d_private_store_cleanup(&device->private_store);
584 wined3d_mutex_unlock();
585 return hr;
588 memset(&swapchain_desc, 0, sizeof(swapchain_desc));
589 swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
590 swapchain_desc.device_window = dxgi_factory_get_device_window(dxgi_factory);
591 swapchain_desc.windowed = TRUE;
592 if (FAILED(hr = wined3d_device_init_3d(device->wined3d_device, &swapchain_desc)))
594 ERR("Failed to initialize 3D, hr %#x.\n", hr);
595 wined3d_device_decref(device->wined3d_device);
596 IUnknown_Release(device->child_layer);
597 wined3d_private_store_cleanup(&device->private_store);
598 wined3d_mutex_unlock();
599 return hr;
601 wined3d_mutex_unlock();
603 device->adapter = &dxgi_adapter->IWineDXGIAdapter_iface;
604 IWineDXGIAdapter_AddRef(device->adapter);
606 return S_OK;