msvcp140: Added _Winerror_message implementation.
[wine.git] / dlls / d3d9 / directx.c
blob49da816564e1f08553883b6421055c2828f631af
1 /*
2 * IDirect3D9 implementation
4 * Copyright 2002 Jason Edmeades
5 * Copyright 2005 Oliver Stieber
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
27 static inline struct d3d9 *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
29 return CONTAINING_RECORD(iface, struct d3d9, IDirect3D9Ex_iface);
32 static HRESULT WINAPI d3d9_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **out)
34 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
36 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
38 if (IsEqualGUID(riid, &IID_IDirect3D9)
39 || IsEqualGUID(riid, &IID_IUnknown))
41 IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
42 *out = &d3d9->IDirect3D9Ex_iface;
43 return S_OK;
46 if (IsEqualGUID(riid, &IID_IDirect3D9Ex))
48 if (!d3d9->extended)
50 WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex.\n");
51 *out = NULL;
52 return E_NOINTERFACE;
55 IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
56 *out = &d3d9->IDirect3D9Ex_iface;
57 return S_OK;
60 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
62 *out = NULL;
63 return E_NOINTERFACE;
66 static ULONG WINAPI d3d9_AddRef(IDirect3D9Ex *iface)
68 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
69 ULONG refcount = InterlockedIncrement(&d3d9->refcount);
71 TRACE("%p increasing refcount to %u.\n", iface, refcount);
73 return refcount;
76 static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
78 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
79 ULONG refcount = InterlockedDecrement(&d3d9->refcount);
81 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
83 if (!refcount)
85 wined3d_mutex_lock();
86 wined3d_decref(d3d9->wined3d);
87 wined3d_mutex_unlock();
89 heap_free(d3d9);
92 return refcount;
95 static HRESULT WINAPI d3d9_RegisterSoftwareDevice(IDirect3D9Ex *iface, void *init_function)
97 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
98 HRESULT hr;
100 TRACE("iface %p, init_function %p.\n", iface, init_function);
102 wined3d_mutex_lock();
103 hr = wined3d_register_software_device(d3d9->wined3d, init_function);
104 wined3d_mutex_unlock();
106 return hr;
109 static UINT WINAPI d3d9_GetAdapterCount(IDirect3D9Ex *iface)
111 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
112 UINT ret;
114 TRACE("iface %p.\n", iface);
116 wined3d_mutex_lock();
117 ret = wined3d_get_adapter_count(d3d9->wined3d);
118 wined3d_mutex_unlock();
120 return ret;
123 static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapter,
124 DWORD flags, D3DADAPTER_IDENTIFIER9 *identifier)
126 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
127 struct wined3d_adapter_identifier adapter_id;
128 HRESULT hr;
130 TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
131 iface, adapter, flags, identifier);
133 adapter_id.driver = identifier->Driver;
134 adapter_id.driver_size = sizeof(identifier->Driver);
135 adapter_id.description = identifier->Description;
136 adapter_id.description_size = sizeof(identifier->Description);
137 adapter_id.device_name = identifier->DeviceName;
138 adapter_id.device_name_size = sizeof(identifier->DeviceName);
140 wined3d_mutex_lock();
141 hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, flags, &adapter_id);
142 wined3d_mutex_unlock();
144 identifier->DriverVersion = adapter_id.driver_version;
145 identifier->VendorId = adapter_id.vendor_id;
146 identifier->DeviceId = adapter_id.device_id;
147 identifier->SubSysId = adapter_id.subsystem_id;
148 identifier->Revision = adapter_id.revision;
149 memcpy(&identifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(identifier->DeviceIdentifier));
150 identifier->WHQLLevel = adapter_id.whql_level;
152 return hr;
155 static UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format)
157 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
158 UINT ret;
160 TRACE("iface %p, adapter %u, format %#x.\n", iface, adapter, format);
162 /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
163 if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
164 return 0;
166 wined3d_mutex_lock();
167 ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
168 wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN);
169 wined3d_mutex_unlock();
171 return ret;
174 static HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter,
175 D3DFORMAT format, UINT mode_idx, D3DDISPLAYMODE *mode)
177 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
178 struct wined3d_display_mode wined3d_mode;
179 HRESULT hr;
181 TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
182 iface, adapter, format, mode_idx, mode);
184 if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
185 return D3DERR_INVALIDCALL;
187 wined3d_mutex_lock();
188 hr = wined3d_enum_adapter_modes(d3d9->wined3d, adapter, wined3dformat_from_d3dformat(format),
189 WINED3D_SCANLINE_ORDERING_UNKNOWN, mode_idx, &wined3d_mode);
190 wined3d_mutex_unlock();
192 if (SUCCEEDED(hr))
194 mode->Width = wined3d_mode.width;
195 mode->Height = wined3d_mode.height;
196 mode->RefreshRate = wined3d_mode.refresh_rate;
197 mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
200 return hr;
203 static HRESULT WINAPI d3d9_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT adapter, D3DDISPLAYMODE *mode)
205 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
206 struct wined3d_display_mode wined3d_mode;
207 HRESULT hr;
209 TRACE("iface %p, adapter %u, mode %p.\n", iface, adapter, mode);
211 wined3d_mutex_lock();
212 hr = wined3d_get_adapter_display_mode(d3d9->wined3d, adapter, &wined3d_mode, NULL);
213 wined3d_mutex_unlock();
215 if (SUCCEEDED(hr))
217 mode->Width = wined3d_mode.width;
218 mode->Height = wined3d_mode.height;
219 mode->RefreshRate = wined3d_mode.refresh_rate;
220 mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
223 return hr;
226 static HRESULT WINAPI d3d9_CheckDeviceType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
227 D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed)
229 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
230 HRESULT hr;
232 TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
233 iface, adapter, device_type, display_format, backbuffer_format, windowed);
235 /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
236 if (!windowed && display_format != D3DFMT_X8R8G8B8 && display_format != D3DFMT_R5G6B5)
237 return WINED3DERR_NOTAVAILABLE;
239 wined3d_mutex_lock();
240 hr = wined3d_check_device_type(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format),
241 wined3dformat_from_d3dformat(backbuffer_format), windowed);
242 wined3d_mutex_unlock();
244 return hr;
247 static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
248 D3DFORMAT adapter_format, DWORD usage, D3DRESOURCETYPE resource_type, D3DFORMAT format)
250 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
251 enum wined3d_resource_type wined3d_rtype;
252 HRESULT hr;
254 TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
255 iface, adapter, device_type, adapter_format, usage, resource_type, format);
257 if (!adapter_format)
259 WARN("Invalid adapter format.\n");
260 return D3DERR_INVALIDCALL;
263 usage = usage & (WINED3DUSAGE_MASK | WINED3DUSAGE_QUERY_MASK);
264 switch (resource_type)
266 case D3DRTYPE_CUBETEXTURE:
267 usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
268 case D3DRTYPE_TEXTURE:
269 usage |= WINED3DUSAGE_TEXTURE;
270 case D3DRTYPE_SURFACE:
271 wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
272 break;
274 case D3DRTYPE_VOLUMETEXTURE:
275 case D3DRTYPE_VOLUME:
276 usage |= WINED3DUSAGE_TEXTURE;
277 wined3d_rtype = WINED3D_RTYPE_TEXTURE_3D;
278 break;
280 case D3DRTYPE_VERTEXBUFFER:
281 case D3DRTYPE_INDEXBUFFER:
282 wined3d_rtype = WINED3D_RTYPE_BUFFER;
283 break;
285 default:
286 FIXME("Unhandled resource type %#x.\n", resource_type);
287 return WINED3DERR_INVALIDCALL;
290 wined3d_mutex_lock();
291 hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
292 usage, wined3d_rtype, wined3dformat_from_d3dformat(format));
293 wined3d_mutex_unlock();
295 return hr;
298 static HRESULT WINAPI d3d9_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
299 D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type, DWORD *levels)
301 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
302 HRESULT hr;
304 TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
305 iface, adapter, device_type, format, windowed, multisample_type, levels);
307 if (multisample_type > D3DMULTISAMPLE_16_SAMPLES)
308 return D3DERR_INVALIDCALL;
310 wined3d_mutex_lock();
311 hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
312 wined3dformat_from_d3dformat(format), windowed, multisample_type, levels);
313 wined3d_mutex_unlock();
314 if (hr == WINED3DERR_NOTAVAILABLE && levels)
315 *levels = 1;
317 return hr;
320 static HRESULT WINAPI d3d9_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
321 D3DFORMAT adapter_format, D3DFORMAT rt_format, D3DFORMAT ds_format)
323 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
324 HRESULT hr;
326 TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
327 iface, adapter, device_type, adapter_format, rt_format, ds_format);
329 wined3d_mutex_lock();
330 hr = wined3d_check_depth_stencil_match(d3d9->wined3d, adapter, device_type,
331 wined3dformat_from_d3dformat(adapter_format), wined3dformat_from_d3dformat(rt_format),
332 wined3dformat_from_d3dformat(ds_format));
333 wined3d_mutex_unlock();
335 return hr;
338 static HRESULT WINAPI d3d9_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT adapter,
339 D3DDEVTYPE device_type, D3DFORMAT src_format, D3DFORMAT dst_format)
341 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
342 HRESULT hr;
344 TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
345 iface, adapter, device_type, src_format, dst_format);
347 wined3d_mutex_lock();
348 hr = wined3d_check_device_format_conversion(d3d9->wined3d, adapter, device_type,
349 wined3dformat_from_d3dformat(src_format), wined3dformat_from_d3dformat(dst_format));
350 wined3d_mutex_unlock();
352 return hr;
355 static HRESULT WINAPI d3d9_GetDeviceCaps(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS9 *caps)
357 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
358 struct wined3d_caps wined3d_caps;
359 HRESULT hr;
361 TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, adapter, device_type, caps);
363 if (!caps)
364 return D3DERR_INVALIDCALL;
366 memset(caps, 0, sizeof(*caps));
368 wined3d_mutex_lock();
369 hr = wined3d_get_device_caps(d3d9->wined3d, adapter, device_type, &wined3d_caps);
370 wined3d_mutex_unlock();
372 d3dcaps_from_wined3dcaps(caps, &wined3d_caps);
374 return hr;
377 static HMONITOR WINAPI d3d9_GetAdapterMonitor(IDirect3D9Ex *iface, UINT adapter)
379 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
380 struct wined3d_output_desc desc;
381 HRESULT hr;
383 TRACE("iface %p, adapter %u.\n", iface, adapter);
385 wined3d_mutex_lock();
386 hr = wined3d_get_output_desc(d3d9->wined3d, adapter, &desc);
387 wined3d_mutex_unlock();
389 if (FAILED(hr))
391 WARN("Failed to get output desc, hr %#x.\n", hr);
392 return NULL;
395 return desc.monitor;
398 static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, UINT adapter,
399 D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
400 IDirect3DDevice9 **device)
402 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
403 struct d3d9_device *object;
404 HRESULT hr;
406 TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
407 iface, adapter, device_type, focus_window, flags, parameters, device);
409 if (!(object = heap_alloc_zero(sizeof(*object))))
410 return E_OUTOFMEMORY;
412 hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL);
413 if (FAILED(hr))
415 WARN("Failed to initialize device, hr %#x.\n", hr);
416 heap_free(object);
417 return hr;
420 TRACE("Created device %p.\n", object);
421 *device = (IDirect3DDevice9 *)&object->IDirect3DDevice9Ex_iface;
423 return D3D_OK;
426 static UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface,
427 UINT adapter, const D3DDISPLAYMODEFILTER *filter)
429 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
430 UINT ret;
432 TRACE("iface %p, adapter %u, filter %p.\n", iface, adapter, filter);
434 if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
435 return 0;
437 wined3d_mutex_lock();
438 ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
439 wined3dformat_from_d3dformat(filter->Format), filter->ScanLineOrdering);
440 wined3d_mutex_unlock();
442 return ret;
445 static HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface,
446 UINT adapter, const D3DDISPLAYMODEFILTER *filter, UINT mode_idx, D3DDISPLAYMODEEX *mode)
448 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
449 struct wined3d_display_mode wined3d_mode;
450 HRESULT hr;
452 TRACE("iface %p, adapter %u, filter %p, mode_idx %u, mode %p.\n",
453 iface, adapter, filter, mode_idx, mode);
455 if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
456 return D3DERR_INVALIDCALL;
458 wined3d_mutex_lock();
459 hr = wined3d_enum_adapter_modes(d3d9->wined3d, adapter, wined3dformat_from_d3dformat(filter->Format),
460 filter->ScanLineOrdering, mode_idx, &wined3d_mode);
461 wined3d_mutex_unlock();
463 if (SUCCEEDED(hr))
465 mode->Width = wined3d_mode.width;
466 mode->Height = wined3d_mode.height;
467 mode->RefreshRate = wined3d_mode.refresh_rate;
468 mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
469 mode->ScanLineOrdering = wined3d_mode.scanline_ordering;
472 return hr;
475 static HRESULT WINAPI d3d9_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
476 UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation)
478 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
479 struct wined3d_display_mode wined3d_mode;
480 HRESULT hr;
482 TRACE("iface %p, adapter %u, mode %p, rotation %p.\n",
483 iface, adapter, mode, rotation);
485 if (mode->Size != sizeof(*mode))
486 return D3DERR_INVALIDCALL;
488 wined3d_mutex_lock();
489 hr = wined3d_get_adapter_display_mode(d3d9->wined3d, adapter, &wined3d_mode,
490 (enum wined3d_display_rotation *)rotation);
491 wined3d_mutex_unlock();
493 if (SUCCEEDED(hr))
495 mode->Width = wined3d_mode.width;
496 mode->Height = wined3d_mode.height;
497 mode->RefreshRate = wined3d_mode.refresh_rate;
498 mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
499 mode->ScanLineOrdering = wined3d_mode.scanline_ordering;
502 return hr;
505 static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
506 UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
507 D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
509 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
510 struct d3d9_device *object;
511 HRESULT hr;
513 TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
514 iface, adapter, device_type, focus_window, flags, parameters, mode, device);
516 if (!(object = heap_alloc_zero(sizeof(*object))))
517 return E_OUTOFMEMORY;
519 hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode);
520 if (FAILED(hr))
522 WARN("Failed to initialize device, hr %#x.\n", hr);
523 heap_free(object);
524 return hr;
527 TRACE("Created device %p.\n", object);
528 *device = &object->IDirect3DDevice9Ex_iface;
530 return D3D_OK;
533 static HRESULT WINAPI d3d9_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
535 struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
536 struct wined3d_adapter_identifier adapter_id;
537 HRESULT hr;
539 TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid);
541 adapter_id.driver_size = 0;
542 adapter_id.description_size = 0;
543 adapter_id.device_name_size = 0;
545 wined3d_mutex_lock();
546 hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, 0, &adapter_id);
547 wined3d_mutex_unlock();
549 memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid));
551 return hr;
554 static const struct IDirect3D9ExVtbl d3d9_vtbl =
556 /* IUnknown */
557 d3d9_QueryInterface,
558 d3d9_AddRef,
559 d3d9_Release,
560 /* IDirect3D9 */
561 d3d9_RegisterSoftwareDevice,
562 d3d9_GetAdapterCount,
563 d3d9_GetAdapterIdentifier,
564 d3d9_GetAdapterModeCount,
565 d3d9_EnumAdapterModes,
566 d3d9_GetAdapterDisplayMode,
567 d3d9_CheckDeviceType,
568 d3d9_CheckDeviceFormat,
569 d3d9_CheckDeviceMultiSampleType,
570 d3d9_CheckDepthStencilMatch,
571 d3d9_CheckDeviceFormatConversion,
572 d3d9_GetDeviceCaps,
573 d3d9_GetAdapterMonitor,
574 d3d9_CreateDevice,
575 /* IDirect3D9Ex */
576 d3d9_GetAdapterModeCountEx,
577 d3d9_EnumAdapterModesEx,
578 d3d9_GetAdapterDisplayModeEx,
579 d3d9_CreateDeviceEx,
580 d3d9_GetAdapterLUID,
583 BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
585 DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
586 | WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
587 | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
588 | WINED3D_NORMALIZED_DEPTH_BIAS;
590 if (!extended)
591 flags |= WINED3D_VIDMEM_ACCOUNTING;
592 else
593 flags |= WINED3D_RESTORE_MODE_ON_ACTIVATE;
595 d3d9->IDirect3D9Ex_iface.lpVtbl = &d3d9_vtbl;
596 d3d9->refcount = 1;
598 wined3d_mutex_lock();
599 d3d9->wined3d = wined3d_create(flags);
600 wined3d_mutex_unlock();
601 if (!d3d9->wined3d)
602 return FALSE;
603 d3d9->extended = extended;
605 return TRUE;