ws2_32: Add support for hints in GetAddrInfoExW.
[wine.git] / dlls / wined3d / directx.c
blob9883017f932af0dc46324bffa192c8bdd67f9860
1 /*
2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include "wined3d_private.h"
28 #include "winternl.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
31 WINE_DECLARE_DEBUG_CHANNEL(winediag);
33 #define DEFAULT_REFRESH_RATE 0
35 enum wined3d_driver_model
37 DRIVER_MODEL_GENERIC,
38 DRIVER_MODEL_WIN9X,
39 DRIVER_MODEL_NT40,
40 DRIVER_MODEL_NT5X,
41 DRIVER_MODEL_NT6X
44 /* The d3d device ID */
45 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
47 /**********************************************************
48 * Utility functions follow
49 **********************************************************/
51 const struct min_lookup minMipLookup[] =
53 /* NONE POINT LINEAR */
54 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
55 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
56 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
59 const GLenum magLookup[] =
61 /* NONE POINT LINEAR */
62 GL_NEAREST, GL_NEAREST, GL_LINEAR,
65 void CDECL wined3d_output_release_ownership(const struct wined3d_output *output)
67 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc = {0};
69 TRACE("output %p.\n", output);
71 set_owner_desc.hDevice = output->kmt_device;
72 D3DKMTSetVidPnSourceOwner(&set_owner_desc);
75 HRESULT CDECL wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive)
77 D3DKMT_SETVIDPNSOURCEOWNER set_owner_desc;
78 D3DKMT_VIDPNSOURCEOWNER_TYPE owner_type;
79 NTSTATUS status;
81 TRACE("output %p, exclusive %#x.\n", output, exclusive);
83 owner_type = exclusive ? D3DKMT_VIDPNSOURCEOWNER_EXCLUSIVE : D3DKMT_VIDPNSOURCEOWNER_SHARED;
84 set_owner_desc.pType = &owner_type;
85 set_owner_desc.pVidPnSourceId = &output->vidpn_source_id;
86 set_owner_desc.VidPnSourceCount = 1;
87 set_owner_desc.hDevice = output->kmt_device;
88 status = D3DKMTSetVidPnSourceOwner(&set_owner_desc);
90 switch (status)
92 case STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE:
93 return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
94 case STATUS_INVALID_PARAMETER:
95 return E_INVALIDARG;
96 case STATUS_PROCEDURE_NOT_FOUND:
97 return E_NOINTERFACE;
98 case STATUS_SUCCESS:
99 return S_OK;
100 default:
101 FIXME("Unhandled error %#x.\n", status);
102 return E_FAIL;
106 static void wined3d_output_cleanup(const struct wined3d_output *output)
108 D3DKMT_DESTROYDEVICE destroy_device_desc;
109 D3DKMT_CLOSEADAPTER close_adapter_desc;
111 TRACE("output %p.\n", output);
113 destroy_device_desc.hDevice = output->kmt_device;
114 D3DKMTDestroyDevice(&destroy_device_desc);
115 close_adapter_desc.hAdapter = output->kmt_adapter;
116 D3DKMTCloseAdapter(&close_adapter_desc);
119 static HRESULT wined3d_output_init(struct wined3d_output *output, unsigned int ordinal,
120 struct wined3d_adapter *adapter, const WCHAR *device_name)
122 D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME open_adapter_desc;
123 D3DKMT_CREATEDEVICE create_device_desc = {{0}};
124 D3DKMT_CLOSEADAPTER close_adapter_desc;
126 TRACE("output %p, device_name %s.\n", output, wine_dbgstr_w(device_name));
128 lstrcpyW(open_adapter_desc.DeviceName, device_name);
129 if (D3DKMTOpenAdapterFromGdiDisplayName(&open_adapter_desc))
130 return E_INVALIDARG;
132 create_device_desc.u.hAdapter = open_adapter_desc.hAdapter;
133 if (D3DKMTCreateDevice(&create_device_desc))
135 close_adapter_desc.hAdapter = open_adapter_desc.hAdapter;
136 D3DKMTCloseAdapter(&close_adapter_desc);
137 return E_FAIL;
140 output->ordinal = ordinal;
141 lstrcpyW(output->device_name, device_name);
142 output->adapter = adapter;
143 output->screen_format = WINED3DFMT_UNKNOWN;
144 output->kmt_adapter = open_adapter_desc.hAdapter;
145 output->kmt_device = create_device_desc.hDevice;
146 output->vidpn_source_id = open_adapter_desc.VidPnSourceId;
148 return WINED3D_OK;
151 /* Adjust the amount of used texture memory */
152 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
154 adapter->vram_bytes_used += amount;
155 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
156 wine_dbgstr_longlong(amount),
157 wine_dbgstr_longlong(adapter->vram_bytes_used));
158 return adapter->vram_bytes_used;
161 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
163 unsigned int output_idx;
165 for (output_idx = 0; output_idx < adapter->output_count; ++output_idx)
166 wined3d_output_cleanup(&adapter->outputs[output_idx]);
167 heap_free(adapter->outputs);
168 heap_free(adapter->formats);
171 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
173 ULONG refcount = InterlockedIncrement(&wined3d->ref);
175 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
177 return refcount;
180 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
182 ULONG refcount = InterlockedDecrement(&wined3d->ref);
184 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
186 if (!refcount)
188 unsigned int i;
190 for (i = 0; i < wined3d->adapter_count; ++i)
192 struct wined3d_adapter *adapter = wined3d->adapters[i];
194 adapter->adapter_ops->adapter_destroy(adapter);
196 heap_free(wined3d);
199 return refcount;
202 /* Certain applications (e.g. Steam) complain if we report an outdated driver
203 * version.
205 * The driver version has the form "x.y.z.w".
207 * "x" is the Windows version / driver model the driver is meant for:
208 * 4 -> 95/98/NT4
209 * 5 -> 2000
210 * 6 -> XP
211 * 7 -> Vista - WDDM 1.0
212 * 8 -> Windows 7 - WDDM 1.1
213 * 9 -> Windows 8 - WDDM 1.2
214 * 10 -> Windows 8.1 - WDDM 1.3
215 * 20 -> Windows 10 - WDDM 2.0
216 * 21 -> Windows 10 Anniversary Update - WDDM 2.1
217 * 22 -> Windows 10 Creators Update - WDDM 2.2
218 * 23 -> Windows 10 Fall Creators Update - WDDM 2.3
219 * 24 -> Windows 10 April 2018 Update - WDDM 2.4
220 * 25 -> Windows 10 October 2018 Update - WDDM 2.5
221 * 26 -> Windows 10 May 2019 Update - WDDM 2.6
223 * "y" is the maximum Direct3D version / feature level the driver supports.
224 * 11 -> 6
225 * 12 -> 7
226 * 13 -> 8
227 * 14 -> 9
228 * 15 -> 10_0
229 * 16 -> 10_1
230 * 17 -> 11_0
231 * 18 -> 11_1
232 * 19 -> 12_0
233 * 20 -> 12_1
234 * 21 -> 12_x
236 * "z" is the subversion number.
238 * "w" is the vendor specific driver build number.
240 * In practice the reported version is tied to the driver, not the actual
241 * Windows version or feature level. E.g. NVIDIA driver 445.87 advertises the
242 * exact same version 26.21.14.4587 on Windows 7 as it does on Windows 10
243 * (it's in fact the same driver). Similarly for driver 310.90 that advertises
244 * itself as 9.18.13.1090 on Windows Vista with a GeForce 9600M. */
246 struct driver_version_information
248 enum wined3d_display_driver driver;
249 enum wined3d_driver_model driver_model;
250 const char *driver_name; /* name of Windows driver */
251 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
252 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
255 /* The driver version table contains driver information for different devices on several OS versions. */
256 static const struct driver_version_information driver_version_table[] =
258 /* AMD
259 * - Radeon HD2x00 (R600) and up supported by current drivers.
260 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
261 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
262 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
263 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 3279, 0},
264 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 10, 6614},
265 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 10, 6764},
266 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 10, 1280},
267 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 10, 741 },
268 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 10, 1280},
269 {DRIVER_AMD_RX, DRIVER_MODEL_NT6X, "aticfx32.dll", 15002, 61},
271 /* Intel
272 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
273 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
274 * igxprd32.dll but the GMA800 driver was never updated. */
275 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 10, 3889},
276 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 10, 4764},
277 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 10, 4926},
278 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 10, 5218},
279 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 10, 1504},
280 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 10, 1666},
281 {DRIVER_INTEL_HD4000, DRIVER_MODEL_NT6X, "igdumdim32.dll", 15, 4352},
283 /* Nvidia
284 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
285 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
286 * - GeforceFX support is up to 173.x on <= XP
287 * - Geforce2MX/3/4 up to 96.x on <= XP
288 * - TNT/Geforce1/2 up to 71.x on <= XP
289 * All version numbers used below are from the Linux nvidia drivers. */
290 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 10, 7186},
291 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 10, 9371},
292 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 11, 7516},
293 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 13, 783},
294 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT5X, "nv4_disp.dll", 13, 4052},
295 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 13, 783},
296 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT6X, "nvd3dum.dll", 13, 4052},
297 {DRIVER_NVIDIA_FERMI, DRIVER_MODEL_NT6X, "nvd3dum.dll", 13, 9135},
298 {DRIVER_NVIDIA_KEPLER, DRIVER_MODEL_NT6X, "nvd3dum.dll", 14, 4587},
300 /* Red Hat */
301 {DRIVER_REDHAT_VIRGL, DRIVER_MODEL_GENERIC, "virgl.dll", 0, 0},
303 /* VMware */
304 {DRIVER_VMWARE, DRIVER_MODEL_NT5X, "vm3dum.dll", 1, 1134},
306 /* Wine */
307 {DRIVER_WINE, DRIVER_MODEL_GENERIC, "wined3d.dll", 0, 0},
310 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
311 * found on a board containing a specific GPU. */
312 static const struct wined3d_gpu_description gpu_description_table[] =
314 /* Nvidia cards */
315 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT, 4 },
316 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
317 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
318 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
319 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
320 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
321 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
322 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
323 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
324 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
325 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
326 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
327 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
328 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
329 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
330 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
331 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
332 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
333 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
334 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8200, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8, 512 },
335 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
336 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
337 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8500GT, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
338 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
339 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
340 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8, 320 },
341 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8, 768 },
342 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8, 256 },
343 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8, 256 },
344 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8, 256 },
345 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
346 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
347 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
348 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9700MGT, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
349 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
350 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8, 512 },
351 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8, 512 },
352 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8, 512 },
353 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS250, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8, 1024},
354 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8, 1024},
355 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8, 896 },
356 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8, 1024},
357 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8, 512 },
358 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8, 256},
359 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8, 1024},
360 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8, 1024},
361 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8, 1024},
362 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8, 1024},
363 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_FERMI, 512},
364 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_FERMI, 2048},
365 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT425M, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_FERMI, 1024},
366 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_FERMI, 1024},
367 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_FERMI, 1024},
368 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_FERMI, 1024},
369 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_FERMI, 768 },
370 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_FERMI, 1536},
371 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_FERMI, 1024},
372 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_FERMI, 1280},
373 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_FERMI, 1536},
374 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_FERMI, 1024},
375 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT525M, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_FERMI, 1024},
376 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_FERMI, 1024},
377 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_FERMI, 1024},
378 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_FERMI, 1024},
379 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_FERMI, 1024},
380 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560M, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_FERMI, 3072},
381 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_FERMI, 1024},
382 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_FERMI, 1280},
383 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_FERMI, 1536},
384 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_FERMI, 1024},
385 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_KEPLER, 1024},
386 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_FERMI, 1024},
387 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640, "NVIDIA GeForce GT 640", DRIVER_NVIDIA_KEPLER, 1024},
388 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_KEPLER, 1024},
389 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_KEPLER, 2048},
390 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_KEPLER, 1024},
391 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_KEPLER, 1024},
392 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_KEPLER, 2048},
393 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660M, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_KEPLER, 2048},
394 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_KEPLER, 2048},
395 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_KEPLER, 2048},
396 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_KEPLER, 3072},
397 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX_1, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_KEPLER, 4096},
398 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX_2, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_KEPLER, 2048},
399 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_KEPLER, 2048},
400 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX690, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_KEPLER, 2048},
401 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT720, "NVIDIA GeForce GT 720", DRIVER_NVIDIA_KEPLER, 2048},
402 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_KEPLER, 2048},
403 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730M, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_KEPLER, 1024},
404 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT740M, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_KEPLER, 2048},
405 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_KEPLER, 1024},
406 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT755M, "NVIDIA GeForce GT 755M", DRIVER_NVIDIA_KEPLER, 1024},
407 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_KEPLER, 1024},
408 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_KEPLER, 2048},
409 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_KEPLER, 2048},
410 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760TI, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_KEPLER, 2048},
411 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_KEPLER, 2048},
412 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_KEPLER, 3072},
413 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_KEPLER, 2048},
414 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX775M, "NVIDIA GeForce GTX 775M", DRIVER_NVIDIA_KEPLER, 3072},
415 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_KEPLER, 3072},
416 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780M, "NVIDIA GeForce GTX 780M", DRIVER_NVIDIA_KEPLER, 4096},
417 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_KEPLER, 3072},
418 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITAN, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_KEPLER, 6144},
419 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANB, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_KEPLER, 6144},
420 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANX, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_KEPLER, 12288},
421 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANZ, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_KEPLER, 12288},
422 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_820M, "NVIDIA GeForce 820M", DRIVER_NVIDIA_FERMI, 2048},
423 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_830M, "NVIDIA GeForce 830M", DRIVER_NVIDIA_KEPLER, 2048},
424 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_840M, "NVIDIA GeForce 840M", DRIVER_NVIDIA_KEPLER, 2048},
425 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_845M, "NVIDIA GeForce 845M", DRIVER_NVIDIA_KEPLER, 2048},
426 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX850M, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_KEPLER, 2048},
427 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX860M, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_KEPLER, 2048},
428 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX870M, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_KEPLER, 3072},
429 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX880M, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_KEPLER, 4096},
430 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_940M, "NVIDIA GeForce 940M", DRIVER_NVIDIA_KEPLER, 4096},
431 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_KEPLER, 2048},
432 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950M, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_KEPLER, 4096},
433 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_KEPLER, 4096},
434 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960M, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_KEPLER, 2048},
435 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_KEPLER, 4096},
436 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970M, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_KEPLER, 3072},
437 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_KEPLER, 4096},
438 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980TI, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_KEPLER, 6144},
439 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_KEPLER, 2048},
440 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050TI, "NVIDIA GeForce GTX 1050 Ti", DRIVER_NVIDIA_KEPLER, 4096},
441 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060_3GB,"NVIDIA GeForce GTX 1060 3GB", DRIVER_NVIDIA_KEPLER, 3072},
442 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_KEPLER, 6144},
443 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060M, "NVIDIA GeForce GTX 1060M", DRIVER_NVIDIA_KEPLER, 6144},
444 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1070, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_KEPLER, 8192},
445 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_KEPLER, 8192},
446 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080M, "NVIDIA GeForce GTX 1080M", DRIVER_NVIDIA_KEPLER, 8192},
447 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080TI, "NVIDIA GeForce GTX 1080 Ti", DRIVER_NVIDIA_KEPLER, 11264},
448 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANX_PASCAL, "NVIDIA TITAN X (Pascal)", DRIVER_NVIDIA_KEPLER, 12288},
449 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANV, "NVIDIA TITAN V", DRIVER_NVIDIA_KEPLER, 12288},
450 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1650SUPER,"NVIDIA GeForce GTX 1650 SUPER", DRIVER_NVIDIA_KEPLER, 4096},
451 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1660SUPER,"NVIDIA GeForce GTX 1660 SUPER", DRIVER_NVIDIA_KEPLER, 6144},
452 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1660TI, "NVIDIA GeForce GTX 1660 Ti", DRIVER_NVIDIA_KEPLER, 6144},
453 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_RTX2060, "NVIDIA GeForce RTX 2060", DRIVER_NVIDIA_KEPLER, 6144},
454 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_RTX2070, "NVIDIA GeForce RTX 2070", DRIVER_NVIDIA_KEPLER, 8192},
455 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_RTX2080, "NVIDIA GeForce RTX 2080", DRIVER_NVIDIA_KEPLER, 8192},
456 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_RTX2080TI, "NVIDIA GeForce RTX 2080 Ti", DRIVER_NVIDIA_KEPLER, 11264},
458 /* AMD cards */
459 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
460 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
461 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
462 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
463 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
464 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
465 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
466 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
467 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
468 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
469 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
470 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3850, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600, 512 },
471 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
472 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
473 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
474 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
475 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
476 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
477 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
478 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
479 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
480 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
481 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
482 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
483 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
484 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6480G, "AMD Radeon HD 6480G", DRIVER_AMD_R600, 512 },
485 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6490M, "AMD Radeon HD 6490M", DRIVER_AMD_R600, 1024},
486 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
487 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
488 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
489 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
490 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
491 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
492 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048},
493 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
494 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
495 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7870, "AMD Radeon HD 7870 Series", DRIVER_AMD_R600, 2048},
496 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
497 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024},
498 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048},
499 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048},
500 {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048},
501 {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048},
502 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_285, "AMD Radeon R9 285", DRIVER_AMD_RX, 2048},
503 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290, "AMD Radeon R9 290", DRIVER_AMD_RX, 4096},
504 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290X, "AMD Radeon R9 290X", DRIVER_AMD_RX, 4096},
505 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_FURY, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX, 4096},
506 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_M370X, "AMD Radeon R9 M370X", DRIVER_AMD_RX, 2048},
507 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_M380, "AMD Radeon R9 M380", DRIVER_AMD_RX, 2048},
508 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_M395X, "AMD Radeon R9 M395X", DRIVER_AMD_RX, 4096},
509 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_460, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX, 4096},
510 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_480, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX, 4096},
511 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_VEGA_10, "Radeon RX Vega", DRIVER_AMD_RX, 8192},
512 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_VEGA_12, "Radeon Pro Vega 20", DRIVER_AMD_RX, 4096},
513 {HW_VENDOR_AMD, CARD_AMD_RADEON_RAVEN, "AMD Radeon(TM) Vega 10 Mobile Graphics", DRIVER_AMD_RX, 1024},
514 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_VEGA_20, "Radeon RX Vega 20", DRIVER_AMD_RX, 4096},
515 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_NAVI_10, "Radeon RX 5700 / 5700 XT", DRIVER_AMD_RX, 8192},
516 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_NAVI_14, "Radeon RX 5500M", DRIVER_AMD_RX, 4096},
517 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_NAVI_21, "Radeon RX 6800/6800 XT / 6900 XT", DRIVER_AMD_RX, 16384},
519 /* Red Hat */
520 {HW_VENDOR_REDHAT, CARD_REDHAT_VIRGL, "Red Hat VirtIO GPU", DRIVER_REDHAT_VIRGL, 1024},
522 /* VMware */
523 {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024},
525 /* Intel cards */
526 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
527 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
528 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
529 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
530 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
531 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
532 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
533 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
534 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
535 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
536 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
537 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
538 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
539 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
540 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
541 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
542 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
543 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
544 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
545 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
546 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
547 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
548 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
549 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
550 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
551 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
552 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
553 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
554 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
555 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
556 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000, 1536},
557 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
558 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
559 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
560 {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
561 {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
562 {HW_VENDOR_INTEL, CARD_INTEL_HD5000_1, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536},
563 {HW_VENDOR_INTEL, CARD_INTEL_HD5000_2, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536},
564 {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
565 {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
566 {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
567 {HW_VENDOR_INTEL, CARD_INTEL_I5100_4, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
568 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_1, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
569 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_2, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
570 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_3, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
571 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_4, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
572 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_5, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
573 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_6, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 2048},
574 {HW_VENDOR_INTEL, CARD_INTEL_HD5300, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000, 2048},
575 {HW_VENDOR_INTEL, CARD_INTEL_HD5500, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000, 2048},
576 {HW_VENDOR_INTEL, CARD_INTEL_HD5600, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000, 2048},
577 {HW_VENDOR_INTEL, CARD_INTEL_HD6000, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000, 2048},
578 {HW_VENDOR_INTEL, CARD_INTEL_I6100, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000, 2048},
579 {HW_VENDOR_INTEL, CARD_INTEL_IP6200, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000, 2048},
580 {HW_VENDOR_INTEL, CARD_INTEL_IPP6300, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000, 2048},
581 {HW_VENDOR_INTEL, CARD_INTEL_HD510_1, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
582 {HW_VENDOR_INTEL, CARD_INTEL_HD510_2, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
583 {HW_VENDOR_INTEL, CARD_INTEL_HD510_3, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
584 {HW_VENDOR_INTEL, CARD_INTEL_HD515, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000, 2048},
585 {HW_VENDOR_INTEL, CARD_INTEL_HD520_1, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
586 {HW_VENDOR_INTEL, CARD_INTEL_HD520_2, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
587 {HW_VENDOR_INTEL, CARD_INTEL_HD530_1, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
588 {HW_VENDOR_INTEL, CARD_INTEL_HD530_2, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
589 {HW_VENDOR_INTEL, CARD_INTEL_HDP530, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000, 2048},
590 {HW_VENDOR_INTEL, CARD_INTEL_I540, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000, 2048},
591 {HW_VENDOR_INTEL, CARD_INTEL_I550, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000, 2048},
592 {HW_VENDOR_INTEL, CARD_INTEL_I555, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000, 2048},
593 {HW_VENDOR_INTEL, CARD_INTEL_IP555, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000, 2048},
594 {HW_VENDOR_INTEL, CARD_INTEL_IP580_1, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
595 {HW_VENDOR_INTEL, CARD_INTEL_IP580_2, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
596 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_1, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
597 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_2, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
598 {HW_VENDOR_INTEL, CARD_INTEL_UHD617, "Intel(R) UHD Graphics 617", DRIVER_INTEL_HD4000, 2048},
599 {HW_VENDOR_INTEL, CARD_INTEL_UHD620, "Intel(R) UHD Graphics 620", DRIVER_INTEL_HD4000, 3072},
600 {HW_VENDOR_INTEL, CARD_INTEL_HD615, "Intel(R) HD Graphics 615", DRIVER_INTEL_HD4000, 2048},
601 {HW_VENDOR_INTEL, CARD_INTEL_HD620, "Intel(R) HD Graphics 620", DRIVER_INTEL_HD4000, 3072},
602 {HW_VENDOR_INTEL, CARD_INTEL_HD630_1, "Intel(R) HD Graphics 630", DRIVER_INTEL_HD4000, 3072},
603 {HW_VENDOR_INTEL, CARD_INTEL_HD630_2, "Intel(R) HD Graphics 630", DRIVER_INTEL_HD4000, 3072},
606 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
607 enum wined3d_driver_model driver_model)
609 unsigned int i;
611 TRACE("Looking up version info for driver %#x, driver_model %#x.\n", driver, driver_model);
613 for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i)
615 const struct driver_version_information *entry = &driver_version_table[i];
617 if (entry->driver == driver && (driver_model == DRIVER_MODEL_GENERIC
618 || entry->driver_model == driver_model))
620 TRACE("Found driver \"%s\", subversion %u, build %u.\n",
621 entry->driver_name, entry->subversion, entry->build);
622 return entry;
625 return NULL;
628 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
629 enum wined3d_pci_device device)
631 unsigned int i;
633 for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i)
635 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].device)
636 return &gpu_description_table[i];
639 return NULL;
642 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
643 enum wined3d_pci_device device)
645 const struct wined3d_gpu_description *gpu_desc;
646 static unsigned int once;
648 if (wined3d_settings.pci_vendor_id == PCI_VENDOR_NONE && wined3d_settings.pci_device_id == PCI_DEVICE_NONE)
649 return NULL;
651 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
653 vendor = wined3d_settings.pci_vendor_id;
654 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor);
656 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
658 device = wined3d_settings.pci_device_id;
659 TRACE("Overriding device PCI ID with 0x%04x.\n", device);
662 if (!(gpu_desc = wined3d_get_gpu_description(vendor, device)) && !once++)
663 ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor, device);
665 return gpu_desc;
668 static void wined3d_copy_name(char *dst, const char *src, unsigned int dst_size)
670 size_t len;
672 if (dst_size)
674 len = min(strlen(src), dst_size - 1);
675 memcpy(dst, src, len);
676 memset(&dst[len], 0, dst_size - len);
680 bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
681 const struct wined3d_gpu_description *gpu_desc, enum wined3d_feature_level feature_level,
682 UINT64 vram_bytes, UINT64 sysmem_bytes)
684 const struct driver_version_information *version_info;
685 WORD driver_os_version, driver_feature_level = 10;
686 enum wined3d_driver_model driver_model;
687 enum wined3d_display_driver driver;
688 MEMORYSTATUSEX memory_status;
689 OSVERSIONINFOW os_version;
691 memset(&os_version, 0, sizeof(os_version));
692 os_version.dwOSVersionInfoSize = sizeof(os_version);
693 if (!GetVersionExW(&os_version))
695 ERR("Failed to get OS version, reporting 2000/XP.\n");
696 driver_os_version = 6;
697 driver_model = DRIVER_MODEL_NT5X;
699 else
701 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
702 switch (os_version.dwMajorVersion)
704 case 2:
705 case 3:
706 case 4:
707 /* If needed we could distinguish between 9x and NT4, but this code won't make
708 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
710 driver_os_version = 4;
711 driver_model = DRIVER_MODEL_WIN9X;
712 break;
714 case 5:
715 driver_os_version = 6;
716 driver_model = DRIVER_MODEL_NT5X;
717 break;
719 case 6:
720 if (os_version.dwMinorVersion == 0)
722 driver_os_version = 7;
723 driver_model = DRIVER_MODEL_NT6X;
725 else if (os_version.dwMinorVersion == 1)
727 driver_os_version = 8;
728 driver_model = DRIVER_MODEL_NT6X;
730 else if (os_version.dwMinorVersion == 2)
732 driver_os_version = 9;
733 driver_model = DRIVER_MODEL_NT6X;
735 else
737 if (os_version.dwMinorVersion > 3)
739 FIXME("Unhandled OS version %u.%u, reporting Windows 8.1.\n",
740 os_version.dwMajorVersion, os_version.dwMinorVersion);
742 driver_os_version = 10;
743 driver_model = DRIVER_MODEL_NT6X;
745 break;
747 case 10:
748 driver_os_version = 26;
749 driver_model = DRIVER_MODEL_NT6X;
750 break;
752 default:
753 FIXME("Unhandled OS version %u.%u, reporting Windows 7.\n",
754 os_version.dwMajorVersion, os_version.dwMinorVersion);
755 driver_os_version = 8;
756 driver_model = DRIVER_MODEL_NT6X;
757 break;
761 TRACE("GPU maximum feature level %#x.\n", feature_level);
762 switch (feature_level)
764 case WINED3D_FEATURE_LEVEL_NONE:
765 case WINED3D_FEATURE_LEVEL_5:
766 if (driver_model == DRIVER_MODEL_WIN9X)
767 driver_feature_level = 5;
768 else
769 driver_feature_level = 10;
770 break;
771 case WINED3D_FEATURE_LEVEL_6:
772 driver_feature_level = 11;
773 break;
774 case WINED3D_FEATURE_LEVEL_7:
775 driver_feature_level = 12;
776 break;
777 case WINED3D_FEATURE_LEVEL_8:
778 driver_feature_level = 13;
779 break;
780 case WINED3D_FEATURE_LEVEL_9_1:
781 case WINED3D_FEATURE_LEVEL_9_2:
782 case WINED3D_FEATURE_LEVEL_9_3:
783 driver_feature_level = 14;
784 break;
785 case WINED3D_FEATURE_LEVEL_10:
786 driver_feature_level = 15;
787 break;
788 case WINED3D_FEATURE_LEVEL_10_1:
789 driver_feature_level = 16;
790 break;
791 case WINED3D_FEATURE_LEVEL_11:
792 driver_feature_level = 17;
793 break;
794 case WINED3D_FEATURE_LEVEL_11_1:
795 /* Advertise support for everything up to FL 12_x. */
796 driver_feature_level = 21;
797 break;
799 if (os_version.dwMajorVersion == 6 && !os_version.dwMinorVersion)
800 driver_feature_level = min(driver_feature_level, 18);
801 else if (os_version.dwMajorVersion < 6)
802 driver_feature_level = min(driver_feature_level, 14);
804 driver_info->vendor = gpu_desc->vendor;
805 driver_info->device = gpu_desc->device;
806 wined3d_copy_name(driver_info->description, gpu_desc->description, ARRAY_SIZE(driver_info->description));
807 driver_info->vram_bytes = vram_bytes ? vram_bytes : (UINT64)gpu_desc->vidmem * 1024 * 1024;
808 driver = gpu_desc->driver;
810 if (wined3d_settings.emulated_textureram)
812 driver_info->vram_bytes = wined3d_settings.emulated_textureram;
813 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
814 wine_dbgstr_longlong(driver_info->vram_bytes));
818 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
819 * In order to avoid this application bug we limit the amount of video memory
820 * to LONG_MAX for older Windows versions.
822 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
824 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
825 driver_info->vram_bytes = LONG_MAX;
828 if (!(driver_info->sysmem_bytes = sysmem_bytes))
830 driver_info->sysmem_bytes = 64 * 1024 * 1024;
831 memory_status.dwLength = sizeof(memory_status);
832 if (GlobalMemoryStatusEx(&memory_status))
833 driver_info->sysmem_bytes = max(memory_status.ullTotalPhys / 2, driver_info->sysmem_bytes);
834 else
835 ERR("Failed to get global memory status.\n");
838 /* Try to obtain driver version information for the current Windows version. This fails in
839 * some cases:
840 * - the gpu is not available on the currently selected OS version:
841 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
842 * version information for the current Windows version is returned instead of faked info.
843 * We do the same and assume the default Windows version to emulate is WinXP.
845 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
846 * For now return the XP driver info. Perhaps later on we should return VESA.
848 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
849 * This could be an indication that our database is not up to date, so this should be fixed.
851 if ((version_info = get_driver_version_info(driver, driver_model))
852 || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))
854 driver_info->name = version_info->driver_name;
855 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, driver_feature_level);
856 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
858 return true;
861 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
862 driver_info->vendor, driver_info->device, driver_model);
863 return false;
866 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
867 enum wined3d_feature_level feature_level)
869 static const struct wined3d_fallback_card
871 enum wined3d_feature_level feature_level;
872 enum wined3d_pci_device device_id;
874 card_fallback_nvidia[] =
876 {WINED3D_FEATURE_LEVEL_5, CARD_NVIDIA_RIVA_128},
877 {WINED3D_FEATURE_LEVEL_6, CARD_NVIDIA_RIVA_TNT},
878 {WINED3D_FEATURE_LEVEL_7, CARD_NVIDIA_GEFORCE},
879 {WINED3D_FEATURE_LEVEL_8, CARD_NVIDIA_GEFORCE3},
880 {WINED3D_FEATURE_LEVEL_9_2, CARD_NVIDIA_GEFORCEFX_5800},
881 {WINED3D_FEATURE_LEVEL_9_3, CARD_NVIDIA_GEFORCE_6800},
882 {WINED3D_FEATURE_LEVEL_10, CARD_NVIDIA_GEFORCE_8800GTX},
883 {WINED3D_FEATURE_LEVEL_11, CARD_NVIDIA_GEFORCE_GTX470},
884 {WINED3D_FEATURE_LEVEL_NONE},
886 card_fallback_amd[] =
888 {WINED3D_FEATURE_LEVEL_5, CARD_AMD_RAGE_128PRO},
889 {WINED3D_FEATURE_LEVEL_7, CARD_AMD_RADEON_7200},
890 {WINED3D_FEATURE_LEVEL_8, CARD_AMD_RADEON_8500},
891 {WINED3D_FEATURE_LEVEL_9_1, CARD_AMD_RADEON_9500},
892 {WINED3D_FEATURE_LEVEL_9_3, CARD_AMD_RADEON_X1600},
893 {WINED3D_FEATURE_LEVEL_10, CARD_AMD_RADEON_HD2900},
894 {WINED3D_FEATURE_LEVEL_11, CARD_AMD_RADEON_HD5600},
895 {WINED3D_FEATURE_LEVEL_NONE},
897 card_fallback_intel[] =
899 {WINED3D_FEATURE_LEVEL_5, CARD_INTEL_845G},
900 {WINED3D_FEATURE_LEVEL_8, CARD_INTEL_915G},
901 {WINED3D_FEATURE_LEVEL_9_3, CARD_INTEL_945G},
902 {WINED3D_FEATURE_LEVEL_10, CARD_INTEL_G45},
903 {WINED3D_FEATURE_LEVEL_11, CARD_INTEL_IVBD},
904 {WINED3D_FEATURE_LEVEL_NONE},
907 static const struct
909 enum wined3d_pci_vendor vendor;
910 const struct wined3d_fallback_card *cards;
912 fallbacks[] =
914 {HW_VENDOR_AMD, card_fallback_amd},
915 {HW_VENDOR_NVIDIA, card_fallback_nvidia},
916 {HW_VENDOR_VMWARE, card_fallback_amd},
917 {HW_VENDOR_INTEL, card_fallback_intel},
920 const struct wined3d_fallback_card *cards;
921 enum wined3d_pci_device device_id;
922 unsigned int i;
924 cards = NULL;
925 for (i = 0; i < ARRAY_SIZE(fallbacks); ++i)
927 if (*vendor == fallbacks[i].vendor)
928 cards = fallbacks[i].cards;
930 if (!cards)
932 *vendor = HW_VENDOR_NVIDIA;
933 cards = card_fallback_nvidia;
936 device_id = cards->device_id;
937 for (i = 0; cards[i].feature_level; ++i)
939 if (feature_level >= cards[i].feature_level)
940 device_id = cards[i].device_id;
942 return device_id;
945 struct wined3d_adapter * CDECL wined3d_get_adapter(const struct wined3d *wined3d, unsigned int idx)
947 TRACE("wined3d %p, idx %u.\n", wined3d, idx);
949 if (idx >= wined3d->adapter_count)
950 return NULL;
952 return wined3d->adapters[idx];
955 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
957 TRACE("wined3d %p, reporting %u adapters.\n",
958 wined3d, wined3d->adapter_count);
960 return wined3d->adapter_count;
963 struct wined3d_output * CDECL wined3d_adapter_get_output(const struct wined3d_adapter *adapter,
964 unsigned int idx)
966 TRACE("adapter %p, idx %u.\n", adapter, idx);
968 if (idx >= adapter->output_count)
969 return NULL;
971 return &adapter->outputs[idx];
974 unsigned int CDECL wined3d_adapter_get_output_count(const struct wined3d_adapter *adapter)
976 TRACE("adapter %p, reporting %u outputs.\n", adapter, adapter->output_count);
978 return adapter->output_count;
981 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
983 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
985 return WINED3D_OK;
988 static BOOL CALLBACK enum_monitor_proc(HMONITOR monitor, HDC hdc, RECT *rect, LPARAM lparam)
990 struct wined3d_output_desc *desc = (struct wined3d_output_desc *)lparam;
991 MONITORINFOEXW monitor_info;
993 monitor_info.cbSize = sizeof(monitor_info);
994 if (GetMonitorInfoW(monitor, (MONITORINFO *)&monitor_info) &&
995 !lstrcmpiW(desc->device_name, monitor_info.szDevice))
997 desc->monitor = monitor;
998 desc->desktop_rect = monitor_info.rcMonitor;
999 desc->attached_to_desktop = TRUE;
1000 return FALSE;
1003 return TRUE;
1006 HRESULT CDECL wined3d_output_get_desc(const struct wined3d_output *output,
1007 struct wined3d_output_desc *desc)
1009 TRACE("output %p, desc %p.\n", output, desc);
1011 memset(desc, 0, sizeof(*desc));
1012 desc->ordinal = output->ordinal;
1013 lstrcpyW(desc->device_name, output->device_name);
1014 EnumDisplayMonitors(NULL, NULL, enum_monitor_proc, (LPARAM)desc);
1015 return WINED3D_OK;
1018 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
1019 of the same bpp but different resolutions */
1021 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
1022 unsigned int CDECL wined3d_output_get_mode_count(const struct wined3d_output *output,
1023 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
1025 const struct wined3d_adapter *adapter;
1026 const struct wined3d_format *format;
1027 unsigned int i = 0;
1028 unsigned int j = 0;
1029 UINT format_bits;
1030 DEVMODEW mode;
1032 TRACE("output %p, format %s, scanline_ordering %#x.\n",
1033 output, debug_d3dformat(format_id), scanline_ordering);
1035 adapter = output->adapter;
1036 format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
1037 format_bits = format->byte_count * CHAR_BIT;
1039 memset(&mode, 0, sizeof(mode));
1040 mode.dmSize = sizeof(mode);
1042 while (EnumDisplaySettingsExW(output->device_name, j++, &mode, 0))
1044 if (mode.dmFields & DM_DISPLAYFLAGS)
1046 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
1047 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
1048 continue;
1050 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
1051 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
1052 continue;
1055 if (format_id == WINED3DFMT_UNKNOWN)
1057 /* This is for d3d8, do not enumerate P8 here. */
1058 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
1060 else if (mode.dmBitsPerPel == format_bits)
1062 ++i;
1066 TRACE("Returning %u matching modes (out of %u total) for output %p.\n", i, j, output);
1068 return i;
1071 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
1072 HRESULT CDECL wined3d_output_get_mode(const struct wined3d_output *output,
1073 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
1074 unsigned int mode_idx, struct wined3d_display_mode *mode)
1076 const struct wined3d_adapter *adapter;
1077 const struct wined3d_format *format;
1078 UINT format_bits;
1079 DEVMODEW m;
1080 UINT i = 0;
1081 int j = 0;
1083 TRACE("output %p, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
1084 output, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
1086 if (!mode)
1087 return WINED3DERR_INVALIDCALL;
1089 adapter = output->adapter;
1090 format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
1091 format_bits = format->byte_count * CHAR_BIT;
1093 memset(&m, 0, sizeof(m));
1094 m.dmSize = sizeof(m);
1096 while (i <= mode_idx)
1098 if (!EnumDisplaySettingsExW(output->device_name, j++, &m, 0))
1100 WARN("Invalid mode_idx %u.\n", mode_idx);
1101 return WINED3DERR_INVALIDCALL;
1104 if (m.dmFields & DM_DISPLAYFLAGS)
1106 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
1107 && (m.u2.dmDisplayFlags & DM_INTERLACED))
1108 continue;
1110 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
1111 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
1112 continue;
1115 if (format_id == WINED3DFMT_UNKNOWN)
1117 /* This is for d3d8, do not enumerate P8 here. */
1118 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
1120 else if (m.dmBitsPerPel == format_bits)
1122 ++i;
1126 mode->width = m.dmPelsWidth;
1127 mode->height = m.dmPelsHeight;
1128 mode->refresh_rate = DEFAULT_REFRESH_RATE;
1129 if (m.dmFields & DM_DISPLAYFREQUENCY)
1130 mode->refresh_rate = m.dmDisplayFrequency;
1132 if (format_id == WINED3DFMT_UNKNOWN)
1133 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
1134 else
1135 mode->format_id = format_id;
1137 if (!(m.dmFields & DM_DISPLAYFLAGS))
1138 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
1139 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
1140 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
1141 else
1142 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
1144 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
1145 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
1147 return WINED3D_OK;
1150 HRESULT CDECL wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
1151 struct wined3d_display_mode *mode)
1153 unsigned int i, j, mode_count, matching_mode_count, closest;
1154 struct wined3d_display_mode **matching_modes;
1155 struct wined3d_display_mode *modes;
1156 HRESULT hr;
1158 TRACE("output %p, mode %p.\n", output, mode);
1160 if (!(mode_count = wined3d_output_get_mode_count(output, mode->format_id,
1161 WINED3D_SCANLINE_ORDERING_UNKNOWN)))
1163 WARN("Output has 0 matching modes.\n");
1164 return E_FAIL;
1167 if (!(modes = heap_calloc(mode_count, sizeof(*modes))))
1168 return E_OUTOFMEMORY;
1169 if (!(matching_modes = heap_calloc(mode_count, sizeof(*matching_modes))))
1171 heap_free(modes);
1172 return E_OUTOFMEMORY;
1175 for (i = 0; i < mode_count; ++i)
1177 if (FAILED(hr = wined3d_output_get_mode(output, mode->format_id,
1178 WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
1180 heap_free(matching_modes);
1181 heap_free(modes);
1182 return hr;
1184 matching_modes[i] = &modes[i];
1187 matching_mode_count = mode_count;
1189 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
1191 for (i = 0, j = 0; i < matching_mode_count; ++i)
1193 if (matching_modes[i]->scanline_ordering == mode->scanline_ordering)
1194 matching_modes[j++] = matching_modes[i];
1196 if (j > 0)
1197 matching_mode_count = j;
1200 if (mode->refresh_rate)
1202 for (i = 0, j = 0; i < matching_mode_count; ++i)
1204 if (matching_modes[i]->refresh_rate == mode->refresh_rate)
1205 matching_modes[j++] = matching_modes[i];
1207 if (j > 0)
1208 matching_mode_count = j;
1211 if (!mode->width || !mode->height)
1213 struct wined3d_display_mode current_mode;
1214 if (FAILED(hr = wined3d_output_get_display_mode(output, &current_mode, NULL)))
1216 heap_free(matching_modes);
1217 heap_free(modes);
1218 return hr;
1220 mode->width = current_mode.width;
1221 mode->height = current_mode.height;
1224 closest = ~0u;
1225 for (i = 0, j = 0; i < matching_mode_count; ++i)
1227 unsigned int d = abs(mode->width - matching_modes[i]->width)
1228 + abs(mode->height - matching_modes[i]->height);
1230 if (closest > d)
1232 closest = d;
1233 j = i;
1237 *mode = *matching_modes[j];
1239 heap_free(matching_modes);
1240 heap_free(modes);
1242 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
1243 mode->refresh_rate, debug_d3dformat(mode->format_id),
1244 mode->scanline_ordering);
1246 return WINED3D_OK;
1249 struct wined3d_adapter * CDECL wined3d_output_get_adapter(const struct wined3d_output *output)
1251 TRACE("output %p.\n", output);
1253 return output->adapter;
1256 HRESULT CDECL wined3d_output_get_display_mode(const struct wined3d_output *output,
1257 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
1259 DEVMODEW m;
1261 TRACE("output %p, display_mode %p, rotation %p.\n", output, mode, rotation);
1263 if (!mode)
1264 return WINED3DERR_INVALIDCALL;
1266 memset(&m, 0, sizeof(m));
1267 m.dmSize = sizeof(m);
1269 EnumDisplaySettingsExW(output->device_name, ENUM_CURRENT_SETTINGS, &m, 0);
1270 mode->width = m.dmPelsWidth;
1271 mode->height = m.dmPelsHeight;
1272 mode->refresh_rate = DEFAULT_REFRESH_RATE;
1273 if (m.dmFields & DM_DISPLAYFREQUENCY)
1274 mode->refresh_rate = m.dmDisplayFrequency;
1275 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
1277 /* Lie about the format. X11 can't change the color depth, and some apps
1278 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
1279 * that GetDisplayMode still returns 24 bpp. This should probably be
1280 * handled in winex11 instead. */
1281 if (output->screen_format && output->screen_format != mode->format_id)
1283 WARN("Overriding format %s with stored format %s.\n",
1284 debug_d3dformat(mode->format_id),
1285 debug_d3dformat(output->screen_format));
1286 mode->format_id = output->screen_format;
1289 if (!(m.dmFields & DM_DISPLAYFLAGS))
1290 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
1291 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
1292 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
1293 else
1294 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
1296 if (rotation)
1298 switch (m.u1.s2.dmDisplayOrientation)
1300 case DMDO_DEFAULT:
1301 *rotation = WINED3D_DISPLAY_ROTATION_0;
1302 break;
1303 case DMDO_90:
1304 *rotation = WINED3D_DISPLAY_ROTATION_90;
1305 break;
1306 case DMDO_180:
1307 *rotation = WINED3D_DISPLAY_ROTATION_180;
1308 break;
1309 case DMDO_270:
1310 *rotation = WINED3D_DISPLAY_ROTATION_270;
1311 break;
1312 default:
1313 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
1314 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
1315 break;
1319 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
1320 mode->refresh_rate, debug_d3dformat(mode->format_id),
1321 mode->scanline_ordering);
1322 return WINED3D_OK;
1325 static BOOL equal_display_mode(const DEVMODEW *mode1, const DEVMODEW *mode2)
1327 if (mode1->dmFields & mode2->dmFields & DM_PELSWIDTH
1328 && mode1->dmPelsWidth != mode2->dmPelsWidth)
1329 return FALSE;
1331 if (mode1->dmFields & mode2->dmFields & DM_PELSHEIGHT
1332 && mode1->dmPelsHeight != mode2->dmPelsHeight)
1333 return FALSE;
1335 if (mode1->dmFields & mode2->dmFields & DM_BITSPERPEL
1336 && mode1->dmBitsPerPel != mode2->dmBitsPerPel)
1337 return FALSE;
1339 if (mode1->dmFields & mode2->dmFields & DM_DISPLAYFLAGS
1340 && mode1->u2.dmDisplayFlags != mode2->u2.dmDisplayFlags)
1341 return FALSE;
1343 if (mode1->dmFields & mode2->dmFields & DM_DISPLAYFREQUENCY
1344 && mode1->dmDisplayFrequency != mode2->dmDisplayFrequency)
1345 return FALSE;
1347 if (mode1->dmFields & mode2->dmFields & DM_DISPLAYORIENTATION
1348 && mode1->u1.s2.dmDisplayOrientation != mode2->u1.s2.dmDisplayOrientation)
1349 return FALSE;
1351 if (mode1->dmFields & mode2->dmFields & DM_POSITION
1352 && (mode1->u1.s2.dmPosition.x != mode2->u1.s2.dmPosition.x
1353 || mode1->u1.s2.dmPosition.y != mode2->u1.s2.dmPosition.y))
1354 return FALSE;
1356 return TRUE;
1359 HRESULT CDECL wined3d_restore_display_modes(struct wined3d *wined3d)
1361 unsigned int adapter_idx, output_idx = 0;
1362 DEVMODEW current_mode, registry_mode;
1363 struct wined3d_adapter *adapter;
1364 DISPLAY_DEVICEW display_device;
1365 struct wined3d_output *output;
1366 BOOL do_mode_change = FALSE;
1367 LONG ret;
1369 TRACE("wined3d %p.\n", wined3d);
1371 memset(&current_mode, 0, sizeof(current_mode));
1372 memset(&registry_mode, 0, sizeof(registry_mode));
1373 current_mode.dmSize = sizeof(current_mode);
1374 registry_mode.dmSize = sizeof(registry_mode);
1375 display_device.cb = sizeof(display_device);
1376 while (EnumDisplayDevicesW(NULL, output_idx++, &display_device, 0))
1378 if (!EnumDisplaySettingsExW(display_device.DeviceName, ENUM_CURRENT_SETTINGS, &current_mode, 0))
1380 ERR("Failed to read the current display mode for %s.\n",
1381 wine_dbgstr_w(display_device.DeviceName));
1382 return WINED3DERR_NOTAVAILABLE;
1385 if (!EnumDisplaySettingsExW(display_device.DeviceName, ENUM_REGISTRY_SETTINGS, &registry_mode, 0))
1387 ERR("Failed to read the registry display mode for %s.\n",
1388 wine_dbgstr_w(display_device.DeviceName));
1389 return WINED3DERR_NOTAVAILABLE;
1392 if (!equal_display_mode(&current_mode, &registry_mode))
1394 do_mode_change = TRUE;
1395 break;
1399 if (do_mode_change)
1401 ret = ChangeDisplaySettingsExW(NULL, NULL, NULL, 0, NULL);
1402 if (ret != DISP_CHANGE_SUCCESSFUL)
1404 ERR("Failed to restore all outputs to their registry display settings, error %d.\n", ret);
1405 return WINED3DERR_NOTAVAILABLE;
1408 else
1410 TRACE("Skipping redundant mode setting call.\n");
1413 for (adapter_idx = 0; adapter_idx < wined3d->adapter_count; ++adapter_idx)
1415 adapter = wined3d->adapters[adapter_idx];
1416 for (output_idx = 0; output_idx < adapter->output_count; ++output_idx)
1418 output = &adapter->outputs[output_idx];
1420 if (!EnumDisplaySettingsExW(output->device_name, ENUM_CURRENT_SETTINGS, &current_mode, 0))
1422 ERR("Failed to read the current display mode for %s.\n",
1423 wine_dbgstr_w(output->device_name));
1424 return WINED3DERR_NOTAVAILABLE;
1427 output->screen_format = pixelformat_for_depth(current_mode.dmBitsPerPel);
1431 return WINED3D_OK;
1434 HRESULT CDECL wined3d_output_set_display_mode(struct wined3d_output *output,
1435 const struct wined3d_display_mode *mode)
1437 enum wined3d_format_id new_format_id;
1438 const struct wined3d_format *format;
1439 DEVMODEW new_mode, current_mode;
1440 LONG ret;
1442 TRACE("output %p, mode %p.\n", output, mode);
1443 TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
1444 debug_d3dformat(mode->format_id), mode->scanline_ordering);
1446 memset(&new_mode, 0, sizeof(new_mode));
1447 new_mode.dmSize = sizeof(new_mode);
1448 memset(&current_mode, 0, sizeof(current_mode));
1449 current_mode.dmSize = sizeof(current_mode);
1451 format = wined3d_get_format(output->adapter, mode->format_id, WINED3D_BIND_RENDER_TARGET);
1453 new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
1454 new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
1455 new_mode.dmPelsWidth = mode->width;
1456 new_mode.dmPelsHeight = mode->height;
1457 new_mode.dmDisplayFrequency = mode->refresh_rate;
1458 if (mode->refresh_rate)
1459 new_mode.dmFields |= DM_DISPLAYFREQUENCY;
1460 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
1462 new_mode.dmFields |= DM_DISPLAYFLAGS;
1463 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
1464 new_mode.u2.dmDisplayFlags |= DM_INTERLACED;
1466 new_format_id = mode->format_id;
1468 /* Only change the mode if necessary. */
1469 if (!EnumDisplaySettingsW(output->device_name, ENUM_CURRENT_SETTINGS, &current_mode))
1471 ERR("Failed to get current display mode.\n");
1473 else if (equal_display_mode(&current_mode, &new_mode))
1475 TRACE("Skipping redundant mode setting call.\n");
1476 output->screen_format = new_format_id;
1477 return WINED3D_OK;
1480 ret = ChangeDisplaySettingsExW(output->device_name, &new_mode, NULL, CDS_FULLSCREEN, NULL);
1481 if (ret != DISP_CHANGE_SUCCESSFUL)
1483 if (new_mode.dmFields & DM_DISPLAYFREQUENCY)
1485 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
1486 new_mode.dmFields &= ~DM_DISPLAYFREQUENCY;
1487 new_mode.dmDisplayFrequency = 0;
1488 ret = ChangeDisplaySettingsExW(output->device_name, &new_mode, NULL, CDS_FULLSCREEN, NULL);
1490 if (ret != DISP_CHANGE_SUCCESSFUL)
1491 return WINED3DERR_NOTAVAILABLE;
1494 /* Store the new values. */
1495 output->screen_format = new_format_id;
1497 return WINED3D_OK;
1500 HRESULT CDECL wined3d_output_set_gamma_ramp(struct wined3d_output *output, const struct wined3d_gamma_ramp *ramp)
1502 HDC dc;
1504 TRACE("output %p, ramp %p.\n", output, ramp);
1506 dc = CreateDCW(output->device_name, NULL, NULL, NULL);
1507 SetDeviceGammaRamp(dc, (void *)ramp);
1508 DeleteDC(dc);
1510 return WINED3D_OK;
1513 HRESULT wined3d_output_get_gamma_ramp(struct wined3d_output *output, struct wined3d_gamma_ramp *ramp)
1515 HDC dc;
1517 TRACE("output %p, ramp %p.\n", output, ramp);
1519 dc = CreateDCW(output->device_name, NULL, NULL, NULL);
1520 GetDeviceGammaRamp(dc, ramp);
1521 DeleteDC(dc);
1523 return WINED3D_OK;
1526 HRESULT CDECL wined3d_adapter_get_identifier(const struct wined3d_adapter *adapter,
1527 DWORD flags, struct wined3d_adapter_identifier *identifier)
1529 TRACE("adapter %p, flags %#x, identifier %p.\n", adapter, flags, identifier);
1531 wined3d_mutex_lock();
1533 wined3d_copy_name(identifier->driver, adapter->driver_info.name, identifier->driver_size);
1534 wined3d_copy_name(identifier->description, adapter->driver_info.description, identifier->description_size);
1536 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
1537 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
1538 identifier->vendor_id = adapter->driver_info.vendor;
1539 identifier->device_id = adapter->driver_info.device;
1540 identifier->subsystem_id = 0;
1541 identifier->revision = 0;
1542 identifier->device_identifier = IID_D3DDEVICE_D3DUID;
1543 identifier->driver_uuid = adapter->driver_uuid;
1544 identifier->device_uuid = adapter->device_uuid;
1545 identifier->whql_level = (flags & WINED3DENUM_WHQL_LEVEL) ? 1 : 0;
1546 identifier->adapter_luid = adapter->luid;
1547 identifier->video_memory = min(~(SIZE_T)0, adapter->driver_info.vram_bytes);
1548 identifier->shared_system_memory = min(~(SIZE_T)0, adapter->driver_info.sysmem_bytes);
1550 wined3d_mutex_unlock();
1552 return WINED3D_OK;
1555 HRESULT CDECL wined3d_output_get_raster_status(const struct wined3d_output *output,
1556 struct wined3d_raster_status *raster_status)
1558 LONGLONG freq_per_frame, freq_per_line;
1559 LARGE_INTEGER counter, freq_per_sec;
1560 struct wined3d_display_mode mode;
1561 static UINT once;
1563 if (!once++)
1564 FIXME("output %p, raster_status %p semi-stub!\n", output, raster_status);
1565 else
1566 WARN("output %p, raster_status %p semi-stub!\n", output, raster_status);
1568 /* Obtaining the raster status is a widely implemented but optional
1569 * feature. When this method returns OK StarCraft 2 expects the
1570 * raster_status->InVBlank value to actually change over time.
1571 * And Endless Alice Crysis doesn't care even if this method fails.
1572 * Thus this method returns OK and fakes raster_status by
1573 * QueryPerformanceCounter. */
1575 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
1576 return WINED3DERR_INVALIDCALL;
1577 if (FAILED(wined3d_output_get_display_mode(output, &mode, NULL)))
1578 return WINED3DERR_INVALIDCALL;
1579 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
1580 mode.refresh_rate = 60;
1582 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
1583 /* Assume 20 scan lines in the vertical blank. */
1584 freq_per_line = freq_per_frame / (mode.height + 20);
1585 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
1586 if (raster_status->scan_line < mode.height)
1587 raster_status->in_vblank = FALSE;
1588 else
1590 raster_status->scan_line = 0;
1591 raster_status->in_vblank = TRUE;
1594 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
1595 raster_status->in_vblank, raster_status->scan_line);
1597 return WINED3D_OK;
1600 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d_adapter *adapter,
1601 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
1602 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
1604 const struct wined3d_format *rt_format;
1605 const struct wined3d_format *ds_format;
1607 TRACE("adapter %p, device_type %s, adapter_format %s, render_target_format %s, "
1608 "depth_stencil_format %s.\n",
1609 adapter, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
1610 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
1612 rt_format = wined3d_get_format(adapter, render_target_format_id, WINED3D_BIND_RENDER_TARGET);
1613 ds_format = wined3d_get_format(adapter, depth_stencil_format_id, WINED3D_BIND_DEPTH_STENCIL);
1615 if (!(rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET))
1617 WARN("Format %s is not render target format.\n", debug_d3dformat(rt_format->id));
1618 return WINED3DERR_NOTAVAILABLE;
1620 if (!(ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_DEPTH_STENCIL))
1622 WARN("Format %s is not depth/stencil format.\n", debug_d3dformat(ds_format->id));
1623 return WINED3DERR_NOTAVAILABLE;
1626 if (adapter->adapter_ops->adapter_check_format(adapter, NULL, rt_format, ds_format))
1628 TRACE("Formats match.\n");
1629 return WINED3D_OK;
1632 TRACE("Unsupported format pair: %s and %s.\n",
1633 debug_d3dformat(render_target_format_id),
1634 debug_d3dformat(depth_stencil_format_id));
1636 return WINED3DERR_NOTAVAILABLE;
1639 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d_adapter *adapter,
1640 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
1641 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
1643 const struct wined3d_format *format;
1644 HRESULT hr = WINED3D_OK;
1646 TRACE("adapter %p, device_type %s, surface_format %s, "
1647 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
1648 adapter, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
1649 windowed, multisample_type, quality_levels);
1651 if (surface_format_id == WINED3DFMT_UNKNOWN)
1652 return WINED3DERR_INVALIDCALL;
1653 if (multisample_type < WINED3D_MULTISAMPLE_NONE)
1654 return WINED3DERR_INVALIDCALL;
1655 if (multisample_type > WINED3D_MULTISAMPLE_16_SAMPLES)
1657 FIXME("multisample_type %u not handled yet.\n", multisample_type);
1658 return WINED3DERR_NOTAVAILABLE;
1661 format = wined3d_get_format(adapter, surface_format_id, 0);
1663 if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
1664 hr = WINED3DERR_NOTAVAILABLE;
1666 if (SUCCEEDED(hr) || (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && format->multisample_types))
1668 if (quality_levels)
1670 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
1671 *quality_levels = wined3d_popcount(format->multisample_types);
1672 else
1673 *quality_levels = 1;
1675 return WINED3D_OK;
1678 TRACE("Returning not supported.\n");
1679 return hr;
1682 static BOOL wined3d_check_depth_stencil_format(const struct wined3d_adapter *adapter,
1683 const struct wined3d_format *adapter_format, const struct wined3d_format *ds_format,
1684 enum wined3d_gl_resource_type gl_type)
1686 if (!ds_format->depth_size && !ds_format->stencil_size)
1687 return FALSE;
1689 return adapter->adapter_ops->adapter_check_format(adapter, adapter_format, NULL, ds_format);
1692 static BOOL wined3d_check_surface_format(const struct wined3d_format *format)
1694 if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] | format->flags[WINED3D_GL_RES_TYPE_RB]) & WINED3DFMT_FLAG_BLIT)
1695 return TRUE;
1697 if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
1698 == (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
1699 return TRUE;
1701 return FALSE;
1704 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
1705 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
1706 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
1707 * show that wrapping is supported. The lack of filtering will sort out the
1708 * mipmapping capability anyway.
1710 * For now lets report this on all formats, but in the future we may want to
1711 * restrict it to some should applications need that. */
1712 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d,
1713 const struct wined3d_adapter *adapter, enum wined3d_device_type device_type,
1714 enum wined3d_format_id adapter_format_id, DWORD usage, unsigned int bind_flags,
1715 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
1717 const struct wined3d_format *adapter_format, *format;
1718 enum wined3d_gl_resource_type gl_type, gl_type_end;
1719 BOOL mipmap_gen_supported = TRUE;
1720 unsigned int allowed_bind_flags;
1721 DWORD format_flags = 0;
1722 DWORD allowed_usage;
1724 TRACE("wined3d %p, adapter %p, device_type %s, adapter_format %s, usage %s, "
1725 "bind_flags %s, resource_type %s, check_format %s.\n",
1726 wined3d, adapter, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
1727 debug_d3dusage(usage), wined3d_debug_bind_flags(bind_flags),
1728 debug_d3dresourcetype(resource_type), debug_d3dformat(check_format_id));
1730 adapter_format = wined3d_get_format(adapter, adapter_format_id, WINED3D_BIND_RENDER_TARGET);
1731 format = wined3d_get_format(adapter, check_format_id, bind_flags);
1733 switch (resource_type)
1735 case WINED3D_RTYPE_NONE:
1736 allowed_usage = 0;
1737 allowed_bind_flags = WINED3D_BIND_RENDER_TARGET
1738 | WINED3D_BIND_DEPTH_STENCIL
1739 | WINED3D_BIND_UNORDERED_ACCESS;
1740 gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
1741 gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
1742 break;
1744 case WINED3D_RTYPE_TEXTURE_1D:
1745 allowed_usage = WINED3DUSAGE_DYNAMIC
1746 | WINED3DUSAGE_SOFTWAREPROCESSING
1747 | WINED3DUSAGE_QUERY_FILTER
1748 | WINED3DUSAGE_QUERY_GENMIPMAP
1749 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
1750 | WINED3DUSAGE_QUERY_SRGBREAD
1751 | WINED3DUSAGE_QUERY_SRGBWRITE
1752 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1753 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1754 allowed_bind_flags = WINED3D_BIND_SHADER_RESOURCE
1755 | WINED3D_BIND_UNORDERED_ACCESS;
1756 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D;
1757 break;
1759 case WINED3D_RTYPE_TEXTURE_2D:
1760 allowed_usage = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
1761 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
1762 allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
1763 allowed_bind_flags = WINED3D_BIND_RENDER_TARGET
1764 | WINED3D_BIND_DEPTH_STENCIL
1765 | WINED3D_BIND_UNORDERED_ACCESS;
1766 if (!(bind_flags & WINED3D_BIND_SHADER_RESOURCE))
1768 if (!wined3d_check_surface_format(format))
1770 TRACE("%s is not supported for plain surfaces.\n", debug_d3dformat(format->id));
1771 return WINED3DERR_NOTAVAILABLE;
1774 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_RB;
1775 break;
1777 allowed_usage |= WINED3DUSAGE_DYNAMIC
1778 | WINED3DUSAGE_LEGACY_CUBEMAP
1779 | WINED3DUSAGE_SOFTWAREPROCESSING
1780 | WINED3DUSAGE_QUERY_FILTER
1781 | WINED3DUSAGE_QUERY_GENMIPMAP
1782 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
1783 | WINED3DUSAGE_QUERY_SRGBREAD
1784 | WINED3DUSAGE_QUERY_SRGBWRITE
1785 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1786 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1787 allowed_bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
1788 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_2D;
1789 if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
1791 allowed_usage &= ~WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
1792 allowed_bind_flags &= ~WINED3D_BIND_DEPTH_STENCIL;
1793 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_CUBE;
1795 break;
1797 case WINED3D_RTYPE_TEXTURE_3D:
1798 allowed_usage = WINED3DUSAGE_DYNAMIC
1799 | WINED3DUSAGE_SOFTWAREPROCESSING
1800 | WINED3DUSAGE_QUERY_FILTER
1801 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
1802 | WINED3DUSAGE_QUERY_SRGBREAD
1803 | WINED3DUSAGE_QUERY_SRGBWRITE
1804 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1805 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1806 allowed_bind_flags = WINED3D_BIND_SHADER_RESOURCE
1807 | WINED3D_BIND_UNORDERED_ACCESS;
1808 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
1809 break;
1811 case WINED3D_RTYPE_BUFFER:
1812 if (wined3d_format_is_typeless(format))
1814 TRACE("Requested WINED3D_RTYPE_BUFFER, but format %s is typeless.\n", debug_d3dformat(check_format_id));
1815 return WINED3DERR_NOTAVAILABLE;
1818 allowed_usage = WINED3DUSAGE_DYNAMIC;
1819 allowed_bind_flags = WINED3D_BIND_SHADER_RESOURCE
1820 | WINED3D_BIND_UNORDERED_ACCESS;
1821 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_BUFFER;
1822 break;
1824 default:
1825 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
1826 return WINED3DERR_NOTAVAILABLE;
1829 if ((usage & allowed_usage) != usage)
1831 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
1832 usage, debug_d3dresourcetype(resource_type), allowed_usage);
1833 return WINED3DERR_NOTAVAILABLE;
1836 if ((bind_flags & allowed_bind_flags) != bind_flags)
1838 TRACE("Requested bind flags %s, but resource type %s only allows %s.\n",
1839 wined3d_debug_bind_flags(bind_flags), debug_d3dresourcetype(resource_type),
1840 wined3d_debug_bind_flags(allowed_bind_flags));
1841 return WINED3DERR_NOTAVAILABLE;
1844 if (bind_flags & WINED3D_BIND_SHADER_RESOURCE)
1845 format_flags |= WINED3DFMT_FLAG_TEXTURE;
1846 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
1847 format_flags |= WINED3DFMT_FLAG_RENDERTARGET;
1848 if (bind_flags & WINED3D_BIND_DEPTH_STENCIL)
1849 format_flags |= WINED3DFMT_FLAG_DEPTH_STENCIL;
1850 if (bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
1851 format_flags |= WINED3DFMT_FLAG_UNORDERED_ACCESS;
1852 if (usage & WINED3DUSAGE_QUERY_FILTER)
1853 format_flags |= WINED3DFMT_FLAG_FILTERING;
1854 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
1855 format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
1856 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
1857 format_flags |= WINED3DFMT_FLAG_SRGB_READ;
1858 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
1859 format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
1860 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
1861 format_flags |= WINED3DFMT_FLAG_VTF;
1862 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
1863 format_flags |= WINED3DFMT_FLAG_BUMPMAP;
1865 if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
1867 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
1868 return WINED3DERR_NOTAVAILABLE;
1871 for (; gl_type <= gl_type_end; ++gl_type)
1873 if ((bind_flags & WINED3D_BIND_RENDER_TARGET)
1874 && !adapter->adapter_ops->adapter_check_format(adapter, adapter_format, format, NULL))
1876 TRACE("Requested WINED3D_BIND_RENDER_TARGET, but format %s is not supported for render targets.\n",
1877 debug_d3dformat(check_format_id));
1878 return WINED3DERR_NOTAVAILABLE;
1881 /* 3D depth / stencil textures are never supported. */
1882 if (bind_flags == WINED3D_BIND_DEPTH_STENCIL && gl_type == WINED3D_GL_RES_TYPE_TEX_3D)
1883 continue;
1885 if ((bind_flags & WINED3D_BIND_DEPTH_STENCIL)
1886 && !wined3d_check_depth_stencil_format(adapter, adapter_format, format, gl_type))
1888 TRACE("Requested WINED3D_BIND_DEPTH_STENCIL, but format %s is not supported for depth/stencil buffers.\n",
1889 debug_d3dformat(check_format_id));
1890 return WINED3DERR_NOTAVAILABLE;
1893 if ((bind_flags & WINED3D_BIND_UNORDERED_ACCESS) && wined3d_format_is_typeless(format))
1895 TRACE("Requested WINED3D_BIND_UNORDERED_ACCESS, but format %s is typeless.\n",
1896 debug_d3dformat(check_format_id));
1897 return WINED3DERR_NOTAVAILABLE;
1900 if ((format->flags[gl_type] & format_flags) != format_flags)
1902 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
1903 format_flags, debug_d3dformat(check_format_id), format->flags[gl_type]);
1904 return WINED3DERR_NOTAVAILABLE;
1907 if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP))
1908 mipmap_gen_supported = FALSE;
1911 if ((usage & WINED3DUSAGE_QUERY_GENMIPMAP) && !mipmap_gen_supported)
1913 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
1914 return WINED3DOK_NOMIPGEN;
1917 return WINED3D_OK;
1920 unsigned int CDECL wined3d_calculate_format_pitch(const struct wined3d_adapter *adapter,
1921 enum wined3d_format_id format_id, unsigned int width)
1923 unsigned int row_pitch, slice_pitch;
1925 TRACE("adapter %p, format_id %s, width %u.\n", adapter, debug_d3dformat(format_id), width);
1927 wined3d_format_calculate_pitch(wined3d_get_format(adapter, format_id, 0),
1928 1, width, 1, &row_pitch, &slice_pitch);
1930 return row_pitch;
1933 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d_output *output,
1934 enum wined3d_device_type device_type, enum wined3d_format_id src_format,
1935 enum wined3d_format_id dst_format)
1937 FIXME("output %p, device_type %s, src_format %s, dst_format %s stub!\n",
1938 output, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
1939 debug_d3dformat(dst_format));
1941 return WINED3D_OK;
1944 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d,
1945 const struct wined3d_output *output, enum wined3d_device_type device_type,
1946 enum wined3d_format_id display_format, enum wined3d_format_id backbuffer_format,
1947 BOOL windowed)
1949 BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
1951 TRACE("wined3d %p, output %p, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
1952 wined3d, output, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
1953 debug_d3dformat(backbuffer_format), windowed);
1955 /* The task of this function is to check whether a certain display / backbuffer format
1956 * combination is available on the given output. In fullscreen mode microsoft specified
1957 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
1958 * and display format should match exactly.
1959 * In windowed mode format conversion can occur and this depends on the driver. */
1961 /* There are only 4 display formats. */
1962 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
1963 || display_format == WINED3DFMT_B5G5R5X1_UNORM
1964 || display_format == WINED3DFMT_B8G8R8X8_UNORM
1965 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
1967 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
1968 return WINED3DERR_NOTAVAILABLE;
1971 if (!windowed)
1973 /* If the requested display format is not available, don't continue. */
1974 if (!wined3d_output_get_mode_count(output, display_format,
1975 WINED3D_SCANLINE_ORDERING_UNKNOWN))
1977 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
1978 return WINED3DERR_NOTAVAILABLE;
1981 present_conversion = FALSE;
1983 else if (display_format == WINED3DFMT_B10G10R10A2_UNORM)
1985 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
1986 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
1987 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1988 return WINED3DERR_NOTAVAILABLE;
1991 if (present_conversion)
1993 /* Use the display format as back buffer format if the latter is
1994 * WINED3DFMT_UNKNOWN. */
1995 if (backbuffer_format == WINED3DFMT_UNKNOWN)
1996 backbuffer_format = display_format;
1998 if (FAILED(wined3d_check_device_format_conversion(output, device_type, backbuffer_format,
1999 display_format)))
2001 TRACE("Format conversion from %s to %s not supported.\n",
2002 debug_d3dformat(backbuffer_format), debug_d3dformat(display_format));
2003 return WINED3DERR_NOTAVAILABLE;
2006 else
2008 /* When format conversion from the back buffer format to the display
2009 * format is not allowed, only a limited number of combinations are
2010 * valid. */
2012 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
2014 TRACE("Unsupported format combination %s / %s.\n",
2015 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
2016 return WINED3DERR_NOTAVAILABLE;
2019 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
2020 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
2022 TRACE("Unsupported format combination %s / %s.\n",
2023 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
2024 return WINED3DERR_NOTAVAILABLE;
2027 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
2028 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
2030 TRACE("Unsupported format combination %s / %s.\n",
2031 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
2032 return WINED3DERR_NOTAVAILABLE;
2035 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
2036 && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM)
2038 TRACE("Unsupported format combination %s / %s.\n",
2039 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
2040 return WINED3DERR_NOTAVAILABLE;
2044 /* Validate that the back buffer format is usable for render targets. */
2045 if (FAILED(wined3d_check_device_format(wined3d, output->adapter, device_type,
2046 display_format, 0, WINED3D_BIND_RENDER_TARGET, WINED3D_RTYPE_TEXTURE_2D,
2047 backbuffer_format)))
2049 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format));
2050 return WINED3DERR_NOTAVAILABLE;
2053 return WINED3D_OK;
2056 HRESULT CDECL wined3d_get_device_caps(const struct wined3d_adapter *adapter,
2057 enum wined3d_device_type device_type, struct wined3d_caps *caps)
2059 const struct wined3d_d3d_info *d3d_info;
2060 struct wined3d_vertex_caps vertex_caps;
2061 DWORD ckey_caps, blit_caps, fx_caps;
2062 struct fragment_caps fragment_caps;
2063 struct shader_caps shader_caps;
2065 TRACE("adapter %p, device_type %s, caps %p.\n",
2066 adapter, debug_d3ddevicetype(device_type), caps);
2068 d3d_info = &adapter->d3d_info;
2070 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
2072 caps->Caps = 0;
2073 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
2074 WINED3DCAPS2_FULLSCREENGAMMA |
2075 WINED3DCAPS2_DYNAMICTEXTURES;
2077 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
2078 WINED3DCAPS3_COPY_TO_VIDMEM |
2079 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
2081 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
2082 WINED3DCURSORCAPS_LOWRES;
2084 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
2085 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
2086 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
2087 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
2088 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
2089 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
2090 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
2091 WINED3DDEVCAPS_PUREDEVICE |
2092 WINED3DDEVCAPS_HWRASTERIZATION |
2093 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
2094 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
2095 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
2096 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
2097 WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
2099 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
2100 WINED3DPMISCCAPS_CULLCCW |
2101 WINED3DPMISCCAPS_CULLCW |
2102 WINED3DPMISCCAPS_COLORWRITEENABLE |
2103 WINED3DPMISCCAPS_CLIPTLVERTS |
2104 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
2105 WINED3DPMISCCAPS_MASKZ |
2106 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
2107 /* TODO:
2108 WINED3DPMISCCAPS_NULLREFERENCE
2109 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
2110 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
2112 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
2113 WINED3DPRASTERCAPS_PAT |
2114 WINED3DPRASTERCAPS_WFOG |
2115 WINED3DPRASTERCAPS_ZFOG |
2116 WINED3DPRASTERCAPS_FOGVERTEX |
2117 WINED3DPRASTERCAPS_FOGTABLE |
2118 WINED3DPRASTERCAPS_STIPPLE |
2119 WINED3DPRASTERCAPS_SUBPIXEL |
2120 WINED3DPRASTERCAPS_ZTEST |
2121 WINED3DPRASTERCAPS_SCISSORTEST |
2122 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
2123 WINED3DPRASTERCAPS_DEPTHBIAS;
2125 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
2126 WINED3DPCMPCAPS_EQUAL |
2127 WINED3DPCMPCAPS_GREATER |
2128 WINED3DPCMPCAPS_GREATEREQUAL |
2129 WINED3DPCMPCAPS_LESS |
2130 WINED3DPCMPCAPS_LESSEQUAL |
2131 WINED3DPCMPCAPS_NEVER |
2132 WINED3DPCMPCAPS_NOTEQUAL;
2134 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
2135 * are legacy settings for srcblend only. */
2136 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
2137 WINED3DPBLENDCAPS_BOTHSRCALPHA |
2138 WINED3DPBLENDCAPS_DESTALPHA |
2139 WINED3DPBLENDCAPS_DESTCOLOR |
2140 WINED3DPBLENDCAPS_INVDESTALPHA |
2141 WINED3DPBLENDCAPS_INVDESTCOLOR |
2142 WINED3DPBLENDCAPS_INVSRCALPHA |
2143 WINED3DPBLENDCAPS_INVSRCCOLOR |
2144 WINED3DPBLENDCAPS_ONE |
2145 WINED3DPBLENDCAPS_SRCALPHA |
2146 WINED3DPBLENDCAPS_SRCALPHASAT |
2147 WINED3DPBLENDCAPS_SRCCOLOR |
2148 WINED3DPBLENDCAPS_ZERO;
2150 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
2151 WINED3DPBLENDCAPS_DESTCOLOR |
2152 WINED3DPBLENDCAPS_INVDESTALPHA |
2153 WINED3DPBLENDCAPS_INVDESTCOLOR |
2154 WINED3DPBLENDCAPS_INVSRCALPHA |
2155 WINED3DPBLENDCAPS_INVSRCCOLOR |
2156 WINED3DPBLENDCAPS_ONE |
2157 WINED3DPBLENDCAPS_SRCALPHA |
2158 WINED3DPBLENDCAPS_SRCCOLOR |
2159 WINED3DPBLENDCAPS_ZERO;
2161 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
2162 WINED3DPCMPCAPS_EQUAL |
2163 WINED3DPCMPCAPS_GREATER |
2164 WINED3DPCMPCAPS_GREATEREQUAL |
2165 WINED3DPCMPCAPS_LESS |
2166 WINED3DPCMPCAPS_LESSEQUAL |
2167 WINED3DPCMPCAPS_NEVER |
2168 WINED3DPCMPCAPS_NOTEQUAL;
2170 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
2171 WINED3DPSHADECAPS_COLORGOURAUDRGB |
2172 WINED3DPSHADECAPS_ALPHAFLATBLEND |
2173 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
2174 WINED3DPSHADECAPS_COLORFLATRGB |
2175 WINED3DPSHADECAPS_FOGFLAT |
2176 WINED3DPSHADECAPS_FOGGOURAUD |
2177 WINED3DPSHADECAPS_SPECULARFLATRGB;
2179 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
2180 WINED3DPTEXTURECAPS_ALPHAPALETTE |
2181 WINED3DPTEXTURECAPS_TRANSPARENCY |
2182 WINED3DPTEXTURECAPS_BORDER |
2183 WINED3DPTEXTURECAPS_MIPMAP |
2184 WINED3DPTEXTURECAPS_PROJECTED |
2185 WINED3DPTEXTURECAPS_PERSPECTIVE;
2187 if (!d3d_info->texture_npot)
2189 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2;
2190 if (d3d_info->texture_npot_conditional)
2191 caps->TextureCaps |= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
2194 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
2195 WINED3DPTFILTERCAPS_MAGFPOINT |
2196 WINED3DPTFILTERCAPS_MINFLINEAR |
2197 WINED3DPTFILTERCAPS_MINFPOINT |
2198 WINED3DPTFILTERCAPS_MIPFLINEAR |
2199 WINED3DPTFILTERCAPS_MIPFPOINT |
2200 WINED3DPTFILTERCAPS_LINEAR |
2201 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
2202 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
2203 WINED3DPTFILTERCAPS_MIPLINEAR |
2204 WINED3DPTFILTERCAPS_MIPNEAREST |
2205 WINED3DPTFILTERCAPS_NEAREST;
2207 caps->CubeTextureFilterCaps = 0;
2208 caps->VolumeTextureFilterCaps = 0;
2210 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
2211 WINED3DPTADDRESSCAPS_CLAMP |
2212 WINED3DPTADDRESSCAPS_WRAP;
2214 caps->VolumeTextureAddressCaps = 0;
2216 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
2217 WINED3DLINECAPS_ZTEST |
2218 WINED3DLINECAPS_BLEND |
2219 WINED3DLINECAPS_ALPHACMP |
2220 WINED3DLINECAPS_FOG;
2221 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
2222 * idea how generating the smoothing alpha values works; the result is different
2225 caps->MaxTextureWidth = d3d_info->limits.texture_size;
2226 caps->MaxTextureHeight = d3d_info->limits.texture_size;
2228 caps->MaxVolumeExtent = 0;
2230 caps->MaxTextureRepeat = 32768;
2231 caps->MaxTextureAspectRatio = d3d_info->limits.texture_size;
2232 caps->MaxVertexW = 1e10f;
2234 caps->GuardBandLeft = -32768.0f;
2235 caps->GuardBandTop = -32768.0f;
2236 caps->GuardBandRight = 32768.0f;
2237 caps->GuardBandBottom = 32768.0f;
2239 caps->ExtentsAdjust = 0.0f;
2241 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
2242 WINED3DSTENCILCAPS_INCRSAT |
2243 WINED3DSTENCILCAPS_INVERT |
2244 WINED3DSTENCILCAPS_KEEP |
2245 WINED3DSTENCILCAPS_REPLACE |
2246 WINED3DSTENCILCAPS_ZERO;
2248 caps->MaxAnisotropy = 0;
2249 caps->MaxPointSize = d3d_info->limits.pointsize_max;
2251 caps->MaxPrimitiveCount = 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2252 caps->MaxVertexIndex = 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2253 caps->MaxStreams = WINED3D_MAX_STREAMS;
2254 caps->MaxStreamStride = 1024;
2256 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
2257 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
2258 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
2259 caps->MaxNpatchTessellationLevel = 0;
2261 caps->NumSimultaneousRTs = d3d_info->limits.max_rt_count;
2263 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
2264 WINED3DPTFILTERCAPS_MAGFPOINT |
2265 WINED3DPTFILTERCAPS_MINFLINEAR |
2266 WINED3DPTFILTERCAPS_MAGFLINEAR;
2267 caps->VertexTextureFilterCaps = 0;
2269 adapter->shader_backend->shader_get_caps(adapter, &shader_caps);
2270 adapter->fragment_pipe->get_caps(adapter, &fragment_caps);
2271 adapter->vertex_pipe->vp_get_caps(adapter, &vertex_caps);
2273 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
2274 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
2276 caps->VertexShaderVersion = shader_caps.vs_version;
2277 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
2279 caps->PixelShaderVersion = shader_caps.ps_version;
2280 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
2282 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
2283 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
2284 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
2286 caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
2287 caps->MaxActiveLights = vertex_caps.max_active_lights;
2288 caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
2289 caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
2290 caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
2291 caps->FVFCaps = vertex_caps.fvf_caps;
2292 caps->RasterCaps |= vertex_caps.raster_caps;
2294 /* The following caps are shader specific, but they are things we cannot detect, or which
2295 * are the same among all shader models. So to avoid code duplication set the shader version
2296 * specific, but otherwise constant caps here
2298 if (caps->VertexShaderVersion >= 3)
2300 /* Where possible set the caps based on OpenGL extensions and if they
2301 * aren't set (in case of software rendering) use the VS 3.0 from
2302 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2303 * VS3.0 value. */
2304 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
2305 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2306 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
2307 caps->VS20Caps.temp_count = 32;
2308 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
2309 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
2311 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
2312 caps->MaxVertexShader30InstructionSlots = WINED3DMIN30SHADERINSTRUCTIONS;
2313 caps->VertexTextureFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT;
2315 else if (caps->VertexShaderVersion == 2)
2317 caps->VS20Caps.caps = 0;
2318 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
2319 caps->VS20Caps.temp_count = WINED3DVS20_MIN_NUMTEMPS;
2320 caps->VS20Caps.static_flow_control_depth = 1;
2322 caps->MaxVShaderInstructionsExecuted = 65535;
2323 caps->MaxVertexShader30InstructionSlots = 0;
2325 else /* VS 1.x */
2327 caps->VS20Caps.caps = 0;
2328 caps->VS20Caps.dynamic_flow_control_depth = 0;
2329 caps->VS20Caps.temp_count = 0;
2330 caps->VS20Caps.static_flow_control_depth = 0;
2332 caps->MaxVShaderInstructionsExecuted = 0;
2333 caps->MaxVertexShader30InstructionSlots = 0;
2336 if (caps->PixelShaderVersion >= 3)
2338 /* Where possible set the caps based on OpenGL extensions and if they
2339 * aren't set (in case of software rendering) use the PS 3.0 from
2340 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2341 * PS 3.0 value. */
2343 /* Caps is more or less undocumented on MSDN but it appears to be
2344 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
2345 * cards from Windows */
2346 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
2347 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
2348 WINED3DPS20CAPS_PREDICATION |
2349 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
2350 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
2351 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2352 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
2353 caps->PS20Caps.temp_count = 32;
2354 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
2355 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
2356 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
2357 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
2359 caps->MaxPShaderInstructionsExecuted = 65535;
2360 caps->MaxPixelShader30InstructionSlots = WINED3DMIN30SHADERINSTRUCTIONS;
2362 else if (caps->PixelShaderVersion == 2)
2364 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
2365 caps->PS20Caps.caps = 0;
2366 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
2367 caps->PS20Caps.temp_count = WINED3DPS20_MIN_NUMTEMPS;
2368 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
2369 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
2370 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
2372 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
2373 caps->MaxPixelShader30InstructionSlots = 0;
2375 else /* PS 1.x */
2377 caps->PS20Caps.caps = 0;
2378 caps->PS20Caps.dynamic_flow_control_depth = 0;
2379 caps->PS20Caps.temp_count = 0;
2380 caps->PS20Caps.static_flow_control_depth = 0;
2381 caps->PS20Caps.instruction_slot_count = 0;
2383 caps->MaxPShaderInstructionsExecuted = 0;
2384 caps->MaxPixelShader30InstructionSlots = 0;
2387 if (caps->VertexShaderVersion >= 2)
2389 /* OpenGL supports all the formats below, perhaps not always
2390 * without conversion, but it supports them.
2391 * Further GLSL doesn't seem to have an official unsigned type so
2392 * don't advertise it yet as I'm not sure how we handle it.
2393 * We might need to add some clamping in the shader engine to
2394 * support it.
2395 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
2396 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
2397 WINED3DDTCAPS_UBYTE4N |
2398 WINED3DDTCAPS_SHORT2N |
2399 WINED3DDTCAPS_SHORT4N;
2401 else
2403 caps->DeclTypes = 0;
2406 /* Set DirectDraw helper Caps */
2407 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
2408 WINEDDCKEYCAPS_SRCBLT;
2409 fx_caps = WINEDDFXCAPS_BLTALPHA |
2410 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
2411 WINEDDFXCAPS_BLTMIRRORUPDOWN |
2412 WINEDDFXCAPS_BLTROTATION90 |
2413 WINEDDFXCAPS_BLTSHRINKX |
2414 WINEDDFXCAPS_BLTSHRINKXN |
2415 WINEDDFXCAPS_BLTSHRINKY |
2416 WINEDDFXCAPS_BLTSHRINKYN |
2417 WINEDDFXCAPS_BLTSTRETCHX |
2418 WINEDDFXCAPS_BLTSTRETCHXN |
2419 WINEDDFXCAPS_BLTSTRETCHY |
2420 WINEDDFXCAPS_BLTSTRETCHYN;
2421 blit_caps = WINEDDCAPS_BLT |
2422 WINEDDCAPS_BLTCOLORFILL |
2423 WINEDDCAPS_BLTDEPTHFILL |
2424 WINEDDCAPS_BLTSTRETCH |
2425 WINEDDCAPS_CANBLTSYSMEM |
2426 WINEDDCAPS_CANCLIP |
2427 WINEDDCAPS_CANCLIPSTRETCHED |
2428 WINEDDCAPS_COLORKEY |
2429 WINEDDCAPS_COLORKEYHWASSIST;
2431 /* Fill the ddraw caps structure */
2432 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
2433 WINEDDCAPS_PALETTE |
2434 blit_caps;
2435 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
2436 WINEDDCAPS2_NOPAGELOCKREQUIRED |
2437 WINEDDCAPS2_PRIMARYGAMMA |
2438 WINEDDCAPS2_WIDESURFACES |
2439 WINEDDCAPS2_CANRENDERWINDOWED;
2440 caps->ddraw_caps.color_key_caps = ckey_caps;
2441 caps->ddraw_caps.fx_caps = fx_caps;
2442 caps->ddraw_caps.svb_caps = blit_caps;
2443 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
2444 caps->ddraw_caps.svb_fx_caps = fx_caps;
2445 caps->ddraw_caps.vsb_caps = blit_caps;
2446 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
2447 caps->ddraw_caps.vsb_fx_caps = fx_caps;
2448 caps->ddraw_caps.ssb_caps = blit_caps;
2449 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
2450 caps->ddraw_caps.ssb_fx_caps = fx_caps;
2452 caps->ddraw_caps.dds_caps = WINEDDSCAPS_FLIP
2453 | WINEDDSCAPS_OFFSCREENPLAIN
2454 | WINEDDSCAPS_PALETTE
2455 | WINEDDSCAPS_PRIMARYSURFACE
2456 | WINEDDSCAPS_TEXTURE
2457 | WINEDDSCAPS_ZBUFFER
2458 | WINEDDSCAPS_MIPMAP;
2460 caps->shader_double_precision = d3d_info->shader_double_precision;
2461 caps->viewport_array_index_any_shader = d3d_info->viewport_array_index_any_shader;
2463 caps->max_feature_level = d3d_info->feature_level;
2465 adapter->adapter_ops->adapter_get_wined3d_caps(adapter, caps);
2467 return WINED3D_OK;
2470 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, struct wined3d_adapter *adapter,
2471 enum wined3d_device_type device_type, HWND focus_window, DWORD flags, BYTE surface_alignment,
2472 const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
2473 struct wined3d_device_parent *device_parent, struct wined3d_device **device)
2475 struct wined3d_device *object;
2476 HRESULT hr;
2478 TRACE("wined3d %p, adapter %p, device_type %#x, focus_window %p, flags %#x, "
2479 "surface_alignment %u, feature_levels %p, feature_level_count %u, device_parent %p, device %p.\n",
2480 wined3d, adapter, device_type, focus_window, flags, surface_alignment,
2481 feature_levels, feature_level_count, device_parent, device);
2483 if (FAILED(hr = adapter->adapter_ops->adapter_create_device(wined3d, adapter,
2484 device_type, focus_window, flags, surface_alignment,
2485 feature_levels, feature_level_count, device_parent, &object)))
2486 return hr;
2488 TRACE("Created device %p.\n", object);
2489 *device = object;
2491 device_parent->ops->wined3d_device_created(device_parent, *device);
2493 return WINED3D_OK;
2496 static const struct wined3d_state_entry_template misc_state_template_no3d[] =
2498 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), {STATE_VDECL}},
2499 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL), {STATE_VDECL}},
2500 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN), {STATE_VDECL}},
2501 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY), {STATE_VDECL}},
2502 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), {STATE_VDECL}},
2503 {STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE), {STATE_VDECL}},
2504 {STATE_GRAPHICS_SHADER_RESOURCE_BINDING, {STATE_VDECL}},
2505 {STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING, {STATE_VDECL}},
2506 {STATE_COMPUTE_SHADER_RESOURCE_BINDING, {STATE_VDECL}},
2507 {STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, {STATE_VDECL}},
2508 {STATE_STREAM_OUTPUT, {STATE_VDECL}},
2509 {STATE_BLEND, {STATE_VDECL}},
2510 {STATE_BLEND_FACTOR, {STATE_VDECL}},
2511 {STATE_SAMPLE_MASK, {STATE_VDECL}},
2512 {STATE_DEPTH_STENCIL, {STATE_VDECL}},
2513 {STATE_STENCIL_REF, {STATE_VDECL}},
2514 {STATE_STREAMSRC, {STATE_VDECL}},
2515 {STATE_VDECL, {STATE_VDECL, state_nop}},
2516 {STATE_RASTERIZER, {STATE_VDECL}},
2517 {STATE_SCISSORRECT, {STATE_VDECL}},
2518 {STATE_POINTSPRITECOORDORIGIN, {STATE_VDECL}},
2520 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2521 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2522 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2523 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2524 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2525 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2526 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2527 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2528 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2529 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2530 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2531 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2532 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2533 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2534 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2535 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2536 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2537 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2538 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2539 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2540 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2541 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2542 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2543 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2544 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2545 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2546 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2547 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2548 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), {STATE_VDECL}},
2549 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01), {STATE_VDECL}},
2550 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10), {STATE_VDECL}},
2551 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11), {STATE_VDECL}},
2552 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2553 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2554 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2555 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2556 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2557 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2558 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2559 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2560 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2561 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2562 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2563 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2564 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2565 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2566 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE), {STATE_VDECL}},
2567 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET), {STATE_VDECL}},
2569 {STATE_VIEWPORT, {STATE_VDECL}},
2570 {STATE_INDEXBUFFER, {STATE_VDECL}},
2571 {STATE_RENDER(WINED3D_RS_ANTIALIAS), {STATE_VDECL}},
2572 {STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE), {STATE_VDECL}},
2573 {STATE_RENDER(WINED3D_RS_WRAPU), {STATE_VDECL}},
2574 {STATE_RENDER(WINED3D_RS_WRAPV), {STATE_VDECL}},
2575 {STATE_RENDER(WINED3D_RS_LINEPATTERN), {STATE_VDECL}},
2576 {STATE_RENDER(WINED3D_RS_MONOENABLE), {STATE_VDECL}},
2577 {STATE_RENDER(WINED3D_RS_ROP2), {STATE_VDECL}},
2578 {STATE_RENDER(WINED3D_RS_PLANEMASK), {STATE_VDECL}},
2579 {STATE_RENDER(WINED3D_RS_LASTPIXEL), {STATE_VDECL}},
2580 {STATE_RENDER(WINED3D_RS_ZFUNC), {STATE_VDECL}},
2581 {STATE_RENDER(WINED3D_RS_DITHERENABLE), {STATE_VDECL}},
2582 {STATE_RENDER(WINED3D_RS_SUBPIXEL), {STATE_VDECL}},
2583 {STATE_RENDER(WINED3D_RS_SUBPIXELX), {STATE_VDECL}},
2584 {STATE_RENDER(WINED3D_RS_STIPPLEDALPHA), {STATE_VDECL}},
2585 {STATE_RENDER(WINED3D_RS_STIPPLEENABLE), {STATE_VDECL}},
2586 {STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS), {STATE_VDECL}},
2587 {STATE_RENDER(WINED3D_RS_ANISOTROPY), {STATE_VDECL}},
2588 {STATE_RENDER(WINED3D_RS_FLUSHBATCH), {STATE_VDECL}},
2589 {STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT), {STATE_VDECL}},
2590 {STATE_RENDER(WINED3D_RS_WRAP0), {STATE_VDECL}},
2591 {STATE_RENDER(WINED3D_RS_WRAP1), {STATE_VDECL}},
2592 {STATE_RENDER(WINED3D_RS_WRAP2), {STATE_VDECL}},
2593 {STATE_RENDER(WINED3D_RS_WRAP3), {STATE_VDECL}},
2594 {STATE_RENDER(WINED3D_RS_WRAP4), {STATE_VDECL}},
2595 {STATE_RENDER(WINED3D_RS_WRAP5), {STATE_VDECL}},
2596 {STATE_RENDER(WINED3D_RS_WRAP6), {STATE_VDECL}},
2597 {STATE_RENDER(WINED3D_RS_WRAP7), {STATE_VDECL}},
2598 {STATE_RENDER(WINED3D_RS_WRAP8), {STATE_VDECL}},
2599 {STATE_RENDER(WINED3D_RS_WRAP9), {STATE_VDECL}},
2600 {STATE_RENDER(WINED3D_RS_WRAP10), {STATE_VDECL}},
2601 {STATE_RENDER(WINED3D_RS_WRAP11), {STATE_VDECL}},
2602 {STATE_RENDER(WINED3D_RS_WRAP12), {STATE_VDECL}},
2603 {STATE_RENDER(WINED3D_RS_WRAP13), {STATE_VDECL}},
2604 {STATE_RENDER(WINED3D_RS_WRAP14), {STATE_VDECL}},
2605 {STATE_RENDER(WINED3D_RS_WRAP15), {STATE_VDECL}},
2606 {STATE_RENDER(WINED3D_RS_EXTENTS), {STATE_VDECL}},
2607 {STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE), {STATE_VDECL}},
2608 {STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING), {STATE_VDECL}},
2609 {STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE), {STATE_VDECL}},
2610 {STATE_RENDER(WINED3D_RS_PATCHSEGMENTS), {STATE_VDECL}},
2611 {STATE_RENDER(WINED3D_RS_POSITIONDEGREE), {STATE_VDECL}},
2612 {STATE_RENDER(WINED3D_RS_NORMALDEGREE), {STATE_VDECL}},
2613 {STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL), {STATE_VDECL}},
2614 {STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL), {STATE_VDECL}},
2615 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X), {STATE_VDECL}},
2616 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y), {STATE_VDECL}},
2617 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z), {STATE_VDECL}},
2618 {STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W), {STATE_VDECL}},
2619 {STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION), {STATE_VDECL}},
2620 {STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), {STATE_VDECL}},
2621 {STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), {STATE_VDECL}},
2622 {STATE_RENDER(WINED3D_RS_ZVISIBLE), {STATE_VDECL}},
2623 /* Samplers */
2624 {STATE_SAMPLER(0), {STATE_VDECL}},
2625 {STATE_SAMPLER(1), {STATE_VDECL}},
2626 {STATE_SAMPLER(2), {STATE_VDECL}},
2627 {STATE_SAMPLER(3), {STATE_VDECL}},
2628 {STATE_SAMPLER(4), {STATE_VDECL}},
2629 {STATE_SAMPLER(5), {STATE_VDECL}},
2630 {STATE_SAMPLER(6), {STATE_VDECL}},
2631 {STATE_SAMPLER(7), {STATE_VDECL}},
2632 {STATE_SAMPLER(8), {STATE_VDECL}},
2633 {STATE_SAMPLER(9), {STATE_VDECL}},
2634 {STATE_SAMPLER(10), {STATE_VDECL}},
2635 {STATE_SAMPLER(11), {STATE_VDECL}},
2636 {STATE_SAMPLER(12), {STATE_VDECL}},
2637 {STATE_SAMPLER(13), {STATE_VDECL}},
2638 {STATE_SAMPLER(14), {STATE_VDECL}},
2639 {STATE_SAMPLER(15), {STATE_VDECL}},
2640 {STATE_SAMPLER(16), /* Vertex sampler 0 */ {STATE_VDECL}},
2641 {STATE_SAMPLER(17), /* Vertex sampler 1 */ {STATE_VDECL}},
2642 {STATE_SAMPLER(18), /* Vertex sampler 2 */ {STATE_VDECL}},
2643 {STATE_SAMPLER(19), /* Vertex sampler 3 */ {STATE_VDECL}},
2644 {STATE_BASEVERTEXINDEX, {STATE_VDECL}},
2645 {STATE_FRAMEBUFFER, {STATE_VDECL}},
2646 {STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), {STATE_VDECL}},
2647 {STATE_SHADER(WINED3D_SHADER_TYPE_HULL), {STATE_VDECL}},
2648 {STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN), {STATE_VDECL}},
2649 {STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY), {STATE_VDECL}},
2650 {STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE), {STATE_VDECL}},
2651 {0}, /* Terminate */
2654 static void adapter_no3d_destroy(struct wined3d_adapter *adapter)
2656 wined3d_adapter_cleanup(adapter);
2657 heap_free(adapter);
2660 static HRESULT adapter_no3d_create_device(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
2661 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment,
2662 const enum wined3d_feature_level *levels, unsigned int level_count,
2663 struct wined3d_device_parent *device_parent, struct wined3d_device **device)
2665 struct wined3d_device_no3d *device_no3d;
2666 HRESULT hr;
2668 if (!(device_no3d = heap_alloc_zero(sizeof(*device_no3d))))
2669 return E_OUTOFMEMORY;
2671 if (FAILED(hr = wined3d_device_init(&device_no3d->d, wined3d, adapter->ordinal, device_type, focus_window,
2672 flags, surface_alignment, levels, level_count, adapter->gl_info.supported, device_parent)))
2674 WARN("Failed to initialize device, hr %#x.\n", hr);
2675 heap_free(device_no3d);
2676 return hr;
2679 *device = &device_no3d->d;
2681 return WINED3D_OK;
2684 static void adapter_no3d_destroy_device(struct wined3d_device *device)
2686 wined3d_device_cleanup(device);
2687 heap_free(device);
2690 static struct wined3d_context *adapter_no3d_acquire_context(struct wined3d_device *device,
2691 struct wined3d_texture *texture, unsigned int sub_resource_idx)
2693 TRACE("device %p, texture %p, sub_resource_idx %u.\n", device, texture, sub_resource_idx);
2695 wined3d_from_cs(device->cs);
2697 if (!device->context_count)
2698 return NULL;
2700 return &wined3d_device_no3d(device)->context_no3d;
2703 static void adapter_no3d_release_context(struct wined3d_context *context)
2705 TRACE("context %p.\n", context);
2708 static void adapter_no3d_get_wined3d_caps(const struct wined3d_adapter *adapter, struct wined3d_caps *caps)
2712 static BOOL adapter_no3d_check_format(const struct wined3d_adapter *adapter,
2713 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
2714 const struct wined3d_format *ds_format)
2716 return TRUE;
2719 static HRESULT adapter_no3d_init_3d(struct wined3d_device *device)
2721 struct wined3d_context *context_no3d;
2722 HRESULT hr;
2724 TRACE("device %p.\n", device);
2726 context_no3d = &wined3d_device_no3d(device)->context_no3d;
2727 if (FAILED(hr = wined3d_context_no3d_init(context_no3d, device->swapchains[0])))
2729 WARN("Failed to initialise context.\n");
2730 return hr;
2733 if (!device_context_add(device, context_no3d))
2735 ERR("Failed to add the newly created context to the context list.\n");
2736 wined3d_context_cleanup(context_no3d);
2737 return E_FAIL;
2740 TRACE("Initialised context %p.\n", context_no3d);
2742 if (!(device->blitter = wined3d_cpu_blitter_create()))
2744 ERR("Failed to create CPU blitter.\n");
2745 device_context_remove(device, context_no3d);
2746 wined3d_context_cleanup(context_no3d);
2747 return E_FAIL;
2750 return WINED3D_OK;
2753 static void adapter_no3d_uninit_3d(struct wined3d_device *device)
2755 struct wined3d_context *context_no3d;
2757 TRACE("device %p.\n", device);
2759 context_no3d = &wined3d_device_no3d(device)->context_no3d;
2760 device->blitter->ops->blitter_destroy(device->blitter, NULL);
2761 wined3d_cs_finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
2763 device_context_remove(device, context_no3d);
2764 wined3d_context_cleanup(context_no3d);
2767 static void *adapter_no3d_map_bo_address(struct wined3d_context *context,
2768 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)
2770 if (data->buffer_object)
2772 ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
2773 return NULL;
2776 return data->addr;
2779 static void adapter_no3d_unmap_bo_address(struct wined3d_context *context,
2780 const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
2782 if (data->buffer_object)
2783 ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
2786 static void adapter_no3d_copy_bo_address(struct wined3d_context *context,
2787 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
2789 if (dst->buffer_object)
2790 ERR("Unsupported dst buffer object %#lx.\n", dst->buffer_object);
2791 if (src->buffer_object)
2792 ERR("Unsupported src buffer object %#lx.\n", src->buffer_object);
2793 if (dst->buffer_object || src->buffer_object)
2794 return;
2795 memcpy(dst->addr, src->addr, size);
2798 static HRESULT adapter_no3d_create_swapchain(struct wined3d_device *device,
2799 struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
2800 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain)
2802 struct wined3d_swapchain *swapchain_no3d;
2803 HRESULT hr;
2805 TRACE("device %p, desc %p, state_parent %p, parent %p, parent_ops %p, swapchain %p.\n",
2806 device, desc, state_parent, parent, parent_ops, swapchain);
2808 if (!(swapchain_no3d = heap_alloc_zero(sizeof(*swapchain_no3d))))
2809 return E_OUTOFMEMORY;
2811 if (FAILED(hr = wined3d_swapchain_no3d_init(swapchain_no3d, device, desc, state_parent, parent,
2812 parent_ops)))
2814 WARN("Failed to initialise swapchain, hr %#x.\n", hr);
2815 heap_free(swapchain_no3d);
2816 return hr;
2819 TRACE("Created swapchain %p.\n", swapchain_no3d);
2820 *swapchain = swapchain_no3d;
2822 return hr;
2825 static void adapter_no3d_destroy_swapchain(struct wined3d_swapchain *swapchain)
2827 wined3d_swapchain_cleanup(swapchain);
2828 heap_free(swapchain);
2831 static HRESULT adapter_no3d_create_buffer(struct wined3d_device *device,
2832 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
2833 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
2835 struct wined3d_buffer *buffer_no3d;
2836 HRESULT hr;
2838 TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n",
2839 device, desc, data, parent, parent_ops, buffer);
2841 if (!(buffer_no3d = heap_alloc_zero(sizeof(*buffer_no3d))))
2842 return E_OUTOFMEMORY;
2844 if (FAILED(hr = wined3d_buffer_no3d_init(buffer_no3d, device, desc, data, parent, parent_ops)))
2846 WARN("Failed to initialise buffer, hr %#x.\n", hr);
2847 heap_free(buffer_no3d);
2848 return hr;
2851 TRACE("Created buffer %p.\n", buffer_no3d);
2852 *buffer = buffer_no3d;
2854 return hr;
2857 static void adapter_no3d_destroy_buffer(struct wined3d_buffer *buffer)
2859 struct wined3d_device *device = buffer->resource.device;
2860 unsigned int swapchain_count = device->swapchain_count;
2862 TRACE("buffer %p.\n", buffer);
2864 /* Take a reference to the device, in case releasing the buffer would
2865 * cause the device to be destroyed. However, swapchain resources don't
2866 * take a reference to the device, and we wouldn't want to increment the
2867 * refcount on a device that's in the process of being destroyed. */
2868 if (swapchain_count)
2869 wined3d_device_incref(device);
2870 wined3d_buffer_cleanup(buffer);
2871 wined3d_cs_destroy_object(device->cs, heap_free, buffer);
2872 if (swapchain_count)
2873 wined3d_device_decref(device);
2876 static HRESULT adapter_no3d_create_texture(struct wined3d_device *device,
2877 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
2878 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
2880 struct wined3d_texture *texture_no3d;
2881 HRESULT hr;
2883 TRACE("device %p, desc %p, layer_count %u, level_count %u, flags %#x, parent %p, parent_ops %p, texture %p.\n",
2884 device, desc, layer_count, level_count, flags, parent, parent_ops, texture);
2886 if (!(texture_no3d = wined3d_texture_allocate_object_memory(sizeof(*texture_no3d), level_count, layer_count)))
2887 return E_OUTOFMEMORY;
2889 if (FAILED(hr = wined3d_texture_no3d_init(texture_no3d, device, desc,
2890 layer_count, level_count, flags, parent, parent_ops)))
2892 WARN("Failed to initialise texture, hr %#x.\n", hr);
2893 heap_free(texture_no3d);
2894 return hr;
2897 TRACE("Created texture %p.\n", texture_no3d);
2898 *texture = texture_no3d;
2900 return hr;
2903 static void adapter_no3d_destroy_texture(struct wined3d_texture *texture)
2905 struct wined3d_device *device = texture->resource.device;
2906 unsigned int swapchain_count = device->swapchain_count;
2908 TRACE("texture %p.\n", texture);
2910 /* Take a reference to the device, in case releasing the texture would
2911 * cause the device to be destroyed. However, swapchain resources don't
2912 * take a reference to the device, and we wouldn't want to increment the
2913 * refcount on a device that's in the process of being destroyed. */
2914 if (swapchain_count)
2915 wined3d_device_incref(device);
2917 wined3d_texture_sub_resources_destroyed(texture);
2918 texture->resource.parent_ops->wined3d_object_destroyed(texture->resource.parent);
2920 wined3d_texture_cleanup(texture);
2921 wined3d_cs_destroy_object(device->cs, heap_free, texture);
2923 if (swapchain_count)
2924 wined3d_device_decref(device);
2927 static HRESULT adapter_no3d_create_rendertarget_view(const struct wined3d_view_desc *desc,
2928 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2929 struct wined3d_rendertarget_view **view)
2931 struct wined3d_rendertarget_view *view_no3d;
2932 HRESULT hr;
2934 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
2935 wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops, view);
2937 if (!(view_no3d = heap_alloc_zero(sizeof(*view_no3d))))
2938 return E_OUTOFMEMORY;
2940 if (FAILED(hr = wined3d_rendertarget_view_no3d_init(view_no3d, desc, resource, parent, parent_ops)))
2942 WARN("Failed to initialise view, hr %#x.\n", hr);
2943 heap_free(view_no3d);
2944 return hr;
2947 TRACE("Created render target view %p.\n", view_no3d);
2948 *view = view_no3d;
2950 return hr;
2953 static void adapter_no3d_destroy_rendertarget_view(struct wined3d_rendertarget_view *view)
2955 struct wined3d_device *device = view->resource->device;
2956 unsigned int swapchain_count = device->swapchain_count;
2958 TRACE("view %p.\n", view);
2960 /* Take a reference to the device, in case releasing the view's resource
2961 * would cause the device to be destroyed. However, swapchain resources
2962 * don't take a reference to the device, and we wouldn't want to increment
2963 * the refcount on a device that's in the process of being destroyed. */
2964 if (swapchain_count)
2965 wined3d_device_incref(device);
2966 wined3d_rendertarget_view_cleanup(view);
2967 wined3d_cs_destroy_object(device->cs, heap_free, view);
2968 if (swapchain_count)
2969 wined3d_device_decref(device);
2972 static HRESULT adapter_no3d_create_shader_resource_view(const struct wined3d_view_desc *desc,
2973 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2974 struct wined3d_shader_resource_view **view)
2976 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
2977 wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops, view);
2979 return E_NOTIMPL;
2982 static void adapter_no3d_destroy_shader_resource_view(struct wined3d_shader_resource_view *view)
2984 TRACE("view %p.\n", view);
2987 static HRESULT adapter_no3d_create_unordered_access_view(const struct wined3d_view_desc *desc,
2988 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2989 struct wined3d_unordered_access_view **view)
2991 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
2992 wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops, view);
2994 return E_NOTIMPL;
2997 static void adapter_no3d_destroy_unordered_access_view(struct wined3d_unordered_access_view *view)
2999 TRACE("view %p.\n", view);
3002 static HRESULT adapter_no3d_create_sampler(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3003 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler)
3005 TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n",
3006 device, desc, parent, parent_ops, sampler);
3008 return E_NOTIMPL;
3011 static void adapter_no3d_destroy_sampler(struct wined3d_sampler *sampler)
3013 TRACE("sampler %p.\n", sampler);
3016 static HRESULT adapter_no3d_create_query(struct wined3d_device *device, enum wined3d_query_type type,
3017 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
3019 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
3020 device, type, parent, parent_ops, query);
3022 return WINED3DERR_NOTAVAILABLE;
3025 static void adapter_no3d_destroy_query(struct wined3d_query *query)
3027 TRACE("query %p.\n", query);
3030 static void adapter_no3d_flush_context(struct wined3d_context *context)
3032 TRACE("context %p.\n", context);
3035 static void adapter_no3d_draw_primitive(struct wined3d_device *device,
3036 const struct wined3d_state *state, const struct wined3d_draw_parameters *parameters)
3038 ERR("device %p, state %p, parameters %p.\n", device, state, parameters);
3041 static void adapter_no3d_dispatch_compute(struct wined3d_device *device,
3042 const struct wined3d_state *state, const struct wined3d_dispatch_parameters *parameters)
3044 ERR("device %p, state %p, parameters %p.\n", device, state, parameters);
3047 static void adapter_no3d_clear_uav(struct wined3d_context *context,
3048 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value)
3050 ERR("context %p, view %p, clear_value %s.\n", context, view, debug_uvec4(clear_value));
3053 static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
3055 .adapter_destroy = adapter_no3d_destroy,
3056 .adapter_create_device = adapter_no3d_create_device,
3057 .adapter_destroy_device = adapter_no3d_destroy_device,
3058 .adapter_acquire_context = adapter_no3d_acquire_context,
3059 .adapter_release_context = adapter_no3d_release_context,
3060 .adapter_get_wined3d_caps = adapter_no3d_get_wined3d_caps,
3061 .adapter_check_format = adapter_no3d_check_format,
3062 .adapter_init_3d = adapter_no3d_init_3d,
3063 .adapter_uninit_3d = adapter_no3d_uninit_3d,
3064 .adapter_map_bo_address = adapter_no3d_map_bo_address,
3065 .adapter_unmap_bo_address = adapter_no3d_unmap_bo_address,
3066 .adapter_copy_bo_address = adapter_no3d_copy_bo_address,
3067 .adapter_create_swapchain = adapter_no3d_create_swapchain,
3068 .adapter_destroy_swapchain = adapter_no3d_destroy_swapchain,
3069 .adapter_create_buffer = adapter_no3d_create_buffer,
3070 .adapter_destroy_buffer = adapter_no3d_destroy_buffer,
3071 .adapter_create_texture = adapter_no3d_create_texture,
3072 .adapter_destroy_texture = adapter_no3d_destroy_texture,
3073 .adapter_create_rendertarget_view = adapter_no3d_create_rendertarget_view,
3074 .adapter_destroy_rendertarget_view = adapter_no3d_destroy_rendertarget_view,
3075 .adapter_create_shader_resource_view = adapter_no3d_create_shader_resource_view,
3076 .adapter_destroy_shader_resource_view = adapter_no3d_destroy_shader_resource_view,
3077 .adapter_create_unordered_access_view = adapter_no3d_create_unordered_access_view,
3078 .adapter_destroy_unordered_access_view = adapter_no3d_destroy_unordered_access_view,
3079 .adapter_create_sampler = adapter_no3d_create_sampler,
3080 .adapter_destroy_sampler = adapter_no3d_destroy_sampler,
3081 .adapter_create_query = adapter_no3d_create_query,
3082 .adapter_destroy_query = adapter_no3d_destroy_query,
3083 .adapter_flush_context = adapter_no3d_flush_context,
3084 .adapter_draw_primitive = adapter_no3d_draw_primitive,
3085 .adapter_dispatch_compute = adapter_no3d_dispatch_compute,
3086 .adapter_clear_uav = adapter_no3d_clear_uav,
3089 static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, unsigned int wined3d_creation_flags)
3091 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
3093 d3d_info->wined3d_creation_flags = wined3d_creation_flags;
3094 d3d_info->texture_npot = TRUE;
3095 d3d_info->feature_level = WINED3D_FEATURE_LEVEL_5;
3098 static struct wined3d_adapter *wined3d_adapter_no3d_create(unsigned int ordinal, unsigned int wined3d_creation_flags)
3100 struct wined3d_adapter *adapter;
3101 LUID primary_luid, *luid = NULL;
3103 static const struct wined3d_gpu_description gpu_description =
3105 HW_VENDOR_SOFTWARE, CARD_WINE, "WineD3D DirectDraw Emulation", DRIVER_WINE, 128,
3108 TRACE("ordinal %u, wined3d_creation_flags %#x.\n", ordinal, wined3d_creation_flags);
3110 if (!(adapter = heap_alloc_zero(sizeof(*adapter))))
3111 return NULL;
3113 if (ordinal == 0 && wined3d_get_primary_adapter_luid(&primary_luid))
3114 luid = &primary_luid;
3116 if (!wined3d_adapter_init(adapter, ordinal, luid, &wined3d_adapter_no3d_ops))
3118 heap_free(adapter);
3119 return NULL;
3122 if (!wined3d_adapter_no3d_init_format_info(adapter))
3124 wined3d_adapter_cleanup(adapter);
3125 heap_free(adapter);
3126 return NULL;
3129 if (!wined3d_driver_info_init(&adapter->driver_info, &gpu_description, WINED3D_FEATURE_LEVEL_NONE, 0, 0))
3131 wined3d_adapter_cleanup(adapter);
3132 heap_free(adapter);
3133 return NULL;
3135 adapter->vram_bytes_used = 0;
3136 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->driver_info.vram_bytes));
3138 adapter->vertex_pipe = &none_vertex_pipe;
3139 adapter->fragment_pipe = &none_fragment_pipe;
3140 adapter->misc_state_template = misc_state_template_no3d;
3141 adapter->shader_backend = &none_shader_backend;
3143 wined3d_adapter_no3d_init_d3d_info(adapter, wined3d_creation_flags);
3145 TRACE("Created adapter %p.\n", adapter);
3147 return adapter;
3150 static BOOL wined3d_adapter_create_output(struct wined3d_adapter *adapter, const WCHAR *output_name)
3152 struct wined3d_output *outputs;
3153 HRESULT hr;
3155 if (!adapter->outputs && !(adapter->outputs = heap_calloc(1, sizeof(*adapter->outputs))))
3157 return FALSE;
3159 else
3161 if (!(outputs = heap_realloc(adapter->outputs,
3162 sizeof(*adapter->outputs) * (adapter->output_count + 1))))
3163 return FALSE;
3165 adapter->outputs = outputs;
3168 if (FAILED(hr = wined3d_output_init(&adapter->outputs[adapter->output_count],
3169 adapter->output_count, adapter, output_name)))
3171 ERR("Failed to initialise output %s, hr %#x.\n", wine_dbgstr_w(output_name), hr);
3172 return FALSE;
3175 ++adapter->output_count;
3176 TRACE("Initialised output %s.\n", wine_dbgstr_w(output_name));
3177 return TRUE;
3180 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, const LUID *luid,
3181 const struct wined3d_adapter_ops *adapter_ops)
3183 unsigned int output_idx = 0, primary_idx = 0;
3184 DISPLAY_DEVICEW display_device;
3185 BOOL ret = FALSE;
3187 adapter->ordinal = ordinal;
3188 adapter->output_count = 0;
3189 adapter->outputs = NULL;
3191 if (luid)
3193 adapter->luid = *luid;
3195 else
3197 WARN("Allocating a random LUID.\n");
3198 if (!AllocateLocallyUniqueId(&adapter->luid))
3200 ERR("Failed to allocate a LUID, error %#x.\n", GetLastError());
3201 return FALSE;
3204 TRACE("adapter %p LUID %08x:%08x.\n", adapter, adapter->luid.HighPart, adapter->luid.LowPart);
3206 display_device.cb = sizeof(display_device);
3207 while (EnumDisplayDevicesW(NULL, output_idx++, &display_device, 0))
3209 /* Detached outputs are not enumerated */
3210 if (!(display_device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
3211 continue;
3213 if (display_device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
3214 primary_idx = adapter->output_count;
3216 if (!wined3d_adapter_create_output(adapter, display_device.DeviceName))
3217 goto done;
3219 TRACE("Initialised %d outputs for adapter %p.\n", adapter->output_count, adapter);
3221 /* Make the primary output first */
3222 if (primary_idx)
3224 struct wined3d_output tmp = adapter->outputs[0];
3225 adapter->outputs[0] = adapter->outputs[primary_idx];
3226 adapter->outputs[0].ordinal = 0;
3227 adapter->outputs[primary_idx] = tmp;
3228 adapter->outputs[primary_idx].ordinal = primary_idx;
3231 memset(&adapter->driver_uuid, 0, sizeof(adapter->driver_uuid));
3232 memset(&adapter->device_uuid, 0, sizeof(adapter->device_uuid));
3234 adapter->formats = NULL;
3235 adapter->adapter_ops = adapter_ops;
3236 ret = TRUE;
3237 done:
3238 if (!ret)
3240 for (output_idx = 0; output_idx < adapter->output_count; ++output_idx)
3241 wined3d_output_cleanup(&adapter->outputs[output_idx]);
3242 heap_free(adapter->outputs);
3244 return ret;
3247 static struct wined3d_adapter *wined3d_adapter_create(unsigned int ordinal, DWORD wined3d_creation_flags)
3249 if (wined3d_creation_flags & WINED3D_NO3D)
3250 return wined3d_adapter_no3d_create(ordinal, wined3d_creation_flags);
3252 if (wined3d_settings.renderer == WINED3D_RENDERER_VULKAN)
3253 return wined3d_adapter_vk_create(ordinal, wined3d_creation_flags);
3255 return wined3d_adapter_gl_create(ordinal, wined3d_creation_flags);
3258 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
3260 const struct wined3d_parent_ops wined3d_null_parent_ops =
3262 wined3d_null_wined3d_object_destroyed,
3265 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
3267 wined3d->ref = 1;
3268 wined3d->flags = flags;
3270 TRACE("Initialising adapters.\n");
3272 if (!(wined3d->adapters[0] = wined3d_adapter_create(0, flags)))
3274 WARN("Failed to create adapter.\n");
3275 return E_FAIL;
3277 wined3d->adapter_count = 1;
3279 return WINED3D_OK;