user32/listbox: Make SetCount fail if LBS_NODATA is not set.
[wine.git] / dlls / wined3d / directx.c
blob4a135860dcfc427b24f8a4fab3204993025ccb05
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);
32 #define DEFAULT_REFRESH_RATE 0
34 enum wined3d_driver_model
36 DRIVER_MODEL_GENERIC,
37 DRIVER_MODEL_WIN9X,
38 DRIVER_MODEL_NT40,
39 DRIVER_MODEL_NT5X,
40 DRIVER_MODEL_NT6X
43 /* The d3d device ID */
44 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
46 /**********************************************************
47 * Utility functions follow
48 **********************************************************/
50 const struct min_lookup minMipLookup[] =
52 /* NONE POINT LINEAR */
53 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
54 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
55 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
58 const GLenum magLookup[] =
60 /* NONE POINT LINEAR */
61 GL_NEAREST, GL_NEAREST, GL_LINEAR,
64 /* Adjust the amount of used texture memory */
65 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
67 adapter->vram_bytes_used += amount;
68 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
69 wine_dbgstr_longlong(amount),
70 wine_dbgstr_longlong(adapter->vram_bytes_used));
71 return adapter->vram_bytes_used;
74 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
76 heap_free(adapter->formats);
77 heap_free(adapter->cfgs);
80 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
82 ULONG refcount = InterlockedIncrement(&wined3d->ref);
84 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
86 return refcount;
89 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
91 ULONG refcount = InterlockedDecrement(&wined3d->ref);
93 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
95 if (!refcount)
97 unsigned int i;
99 for (i = 0; i < wined3d->adapter_count; ++i)
101 wined3d_adapter_cleanup(&wined3d->adapters[i]);
103 heap_free(wined3d);
106 return refcount;
109 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
110 * reporting a driver version is moot because we are not the Windows driver, and we have different
111 * bugs, features, etc.
113 * The driver version has the form "x.y.z.w".
115 * "x" is the Windows version the driver is meant for:
116 * 4 -> 95/98/NT4
117 * 5 -> 2000
118 * 6 -> 2000/XP
119 * 7 -> Vista
120 * 8 -> Win 7
122 * "y" is the maximum Direct3D version the driver supports.
123 * y -> d3d version mapping:
124 * 11 -> d3d6
125 * 12 -> d3d7
126 * 13 -> d3d8
127 * 14 -> d3d9
128 * 15 -> d3d10
129 * 16 -> d3d10.1
130 * 17 -> d3d11
132 * "z" is the subversion number.
134 * "w" is the vendor specific driver build number.
137 struct driver_version_information
139 enum wined3d_display_driver driver;
140 enum wined3d_driver_model driver_model;
141 const char *driver_name; /* name of Windows driver */
142 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
143 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
144 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
147 /* The driver version table contains driver information for different devices on several OS versions. */
148 static const struct driver_version_information driver_version_table[] =
150 /* AMD
151 * - Radeon HD2x00 (R600) and up supported by current drivers.
152 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
153 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
154 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
155 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
156 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
157 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
158 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 17, 10, 1280},
159 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
160 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 17, 10, 1280},
161 {DRIVER_AMD_RX, DRIVER_MODEL_NT6X, "aticfx32.dll", 17, 10, 1474},
163 /* Intel
164 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
165 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
166 * igxprd32.dll but the GMA800 driver was never updated. */
167 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
168 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
169 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
170 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
171 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
172 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
173 {DRIVER_INTEL_HD4000, DRIVER_MODEL_NT6X, "igdumdim32.dll", 19, 15, 4352},
175 /* Nvidia
176 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
177 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
178 * - GeforceFX support is up to 173.x on <= XP
179 * - Geforce2MX/3/4 up to 96.x on <= XP
180 * - TNT/Geforce1/2 up to 71.x on <= XP
181 * All version numbers used below are from the Linux nvidia drivers. */
182 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
183 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
184 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
185 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 783},
186 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 4052},
187 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 783},
188 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 4052},
190 /* VMware */
191 {DRIVER_VMWARE, DRIVER_MODEL_NT5X, "vm3dum.dll", 14, 1, 1134},
193 /* Wine */
194 {DRIVER_WINE, DRIVER_MODEL_GENERIC, "wined3d.dll", 0, 0, 0},
197 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
198 * found on a board containing a specific GPU. */
199 static const struct wined3d_gpu_description gpu_description_table[] =
201 /* Nvidia cards */
202 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT, 4 },
203 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
204 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
205 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
206 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
207 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
208 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
209 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
210 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
211 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
212 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
213 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
214 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
215 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
216 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
217 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
218 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
219 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
220 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
221 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8200, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8, 512 },
222 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
223 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
224 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8500GT, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
225 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
226 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
227 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8, 320 },
228 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8, 768 },
229 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8, 256 },
230 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8, 256 },
231 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8, 256 },
232 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
233 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
234 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
235 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9700MGT, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
236 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
237 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8, 512 },
238 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8, 512 },
239 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8, 512 },
240 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS250, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8, 1024},
241 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8, 1024},
242 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8, 896 },
243 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8, 1024},
244 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8, 512 },
245 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8, 256},
246 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8, 1024},
247 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8, 1024},
248 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8, 1024},
249 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8, 1024},
250 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE8, 512},
251 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE8, 2048},
252 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT425M, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_GEFORCE8, 1024},
253 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE8, 1024},
254 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE8, 1024},
255 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE8, 1024},
256 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE8, 768 },
257 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE8, 1536},
258 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE8, 1024},
259 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE8, 1280},
260 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE8, 1536},
261 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE8, 1024},
262 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT525M, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_GEFORCE8, 1024},
263 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE8, 1024},
264 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
265 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024},
266 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
267 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560M, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_GEFORCE8, 3072},
268 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024},
269 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280},
270 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536},
271 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE8, 1024},
272 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE8, 1024},
273 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE8, 1024},
274 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE8, 1024},
275 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE8, 2048},
276 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE8, 1024},
277 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
278 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE8, 2048},
279 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660M, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_GEFORCE8, 2048},
280 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
281 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE8, 2048},
282 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE8, 3072},
283 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_GEFORCE8, 4096},
284 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE8, 2048},
285 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX690, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_GEFORCE8, 2048},
286 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT720, "NVIDIA GeForce GT 720", DRIVER_NVIDIA_GEFORCE8, 2048},
287 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_GEFORCE8, 2048},
288 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730M, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_GEFORCE8, 1024},
289 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT740M, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_GEFORCE8, 2048},
290 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_GEFORCE8, 1024},
291 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_GEFORCE8, 1024},
292 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
293 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_GEFORCE8, 2048},
294 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760TI, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
295 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE8, 2048},
296 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE8, 3072},
297 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE8, 2048},
298 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_GEFORCE8, 3072},
299 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_GEFORCE8, 3072},
300 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITAN, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_GEFORCE8, 6144},
301 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANB, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_GEFORCE8, 6144},
302 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANX, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_GEFORCE8, 12288},
303 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANZ, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_GEFORCE8, 12288},
304 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_820M, "NVIDIA GeForce 820M", DRIVER_NVIDIA_GEFORCE8, 2048},
305 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_830M, "NVIDIA GeForce 830M", DRIVER_NVIDIA_GEFORCE8, 2048},
306 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_840M, "NVIDIA GeForce 840M", DRIVER_NVIDIA_GEFORCE8, 2048},
307 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_845M, "NVIDIA GeForce 845M", DRIVER_NVIDIA_GEFORCE8, 2048},
308 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX850M, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_GEFORCE8, 2048},
309 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX860M, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_GEFORCE8, 2048},
310 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX870M, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_GEFORCE8, 3072},
311 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX880M, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_GEFORCE8, 4096},
312 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_940M, "NVIDIA GeForce 940M", DRIVER_NVIDIA_GEFORCE8, 4096},
313 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_GEFORCE8, 2048},
314 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950M, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_GEFORCE8, 4096},
315 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_GEFORCE8, 4096},
316 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960M, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_GEFORCE8, 2048},
317 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_GEFORCE8, 4096},
318 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970M, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_GEFORCE8, 3072},
319 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_GEFORCE8, 4096},
320 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980TI, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_GEFORCE8, 6144},
321 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_GEFORCE8, 2048},
322 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050TI, "NVIDIA GeForce GTX 1050 Ti", DRIVER_NVIDIA_GEFORCE8, 4096},
323 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_GEFORCE8, 6144},
324 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1070, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_GEFORCE8, 8192},
325 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_GEFORCE8, 8192},
326 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080TI, "NVIDIA GeForce GTX 1080 Ti", DRIVER_NVIDIA_GEFORCE8, 11264},
327 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANX_PASCAL, "NVIDIA TITAN X (Pascal)", DRIVER_NVIDIA_GEFORCE8, 12288},
328 {HW_VENDOR_NVIDIA, CARD_NVIDIA_TITANV, "NVIDIA TITAN V", DRIVER_NVIDIA_GEFORCE8, 12288},
330 /* AMD cards */
331 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
332 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
333 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
334 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
335 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
336 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
337 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
338 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
339 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
340 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
341 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
342 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3850, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600, 512 },
343 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
344 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
345 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
346 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
347 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
348 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
349 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
350 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
351 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
352 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
353 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
354 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
355 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
356 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6480G, "AMD Radeon HD 6480G", DRIVER_AMD_R600, 512 },
357 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
358 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
359 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
360 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
361 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
362 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
363 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048},
364 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
365 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
366 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
367 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024},
368 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048},
369 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048},
370 {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048},
371 {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048},
372 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_285, "AMD Radeon R9 285", DRIVER_AMD_RX, 2048},
373 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290, "AMD Radeon R9 290", DRIVER_AMD_RX, 4096},
374 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_FURY, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX, 4096},
375 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_460, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX, 4096},
376 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_480, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX, 4096},
377 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_VEGA, "Radeon RX Vega", DRIVER_AMD_RX, 8192},
379 /* VMware */
380 {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024},
382 /* Intel cards */
383 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
384 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
385 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
386 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
387 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
388 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
389 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
390 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
391 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
392 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
393 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
394 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
395 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
396 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
397 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
398 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
399 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
400 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
401 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
402 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
403 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
404 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
405 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
406 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
407 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
408 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
409 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
410 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
411 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
412 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
413 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000, 1536},
414 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
415 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
416 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
417 {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
418 {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
419 {HW_VENDOR_INTEL, CARD_INTEL_HD5000, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536},
420 {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
421 {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
422 {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
423 {HW_VENDOR_INTEL, CARD_INTEL_I5100_4, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
424 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_1, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
425 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_2, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
426 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_3, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
427 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_4, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
428 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_5, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
429 {HW_VENDOR_INTEL, CARD_INTEL_HD5300, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000, 2048},
430 {HW_VENDOR_INTEL, CARD_INTEL_HD5500, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000, 2048},
431 {HW_VENDOR_INTEL, CARD_INTEL_HD5600, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000, 2048},
432 {HW_VENDOR_INTEL, CARD_INTEL_HD6000, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000, 2048},
433 {HW_VENDOR_INTEL, CARD_INTEL_I6100, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000, 2048},
434 {HW_VENDOR_INTEL, CARD_INTEL_IP6200, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000, 2048},
435 {HW_VENDOR_INTEL, CARD_INTEL_IPP6300, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000, 2048},
436 {HW_VENDOR_INTEL, CARD_INTEL_HD510_1, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
437 {HW_VENDOR_INTEL, CARD_INTEL_HD510_2, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
438 {HW_VENDOR_INTEL, CARD_INTEL_HD510_3, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
439 {HW_VENDOR_INTEL, CARD_INTEL_HD515, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000, 2048},
440 {HW_VENDOR_INTEL, CARD_INTEL_HD520_1, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
441 {HW_VENDOR_INTEL, CARD_INTEL_HD520_2, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
442 {HW_VENDOR_INTEL, CARD_INTEL_HD530_1, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
443 {HW_VENDOR_INTEL, CARD_INTEL_HD530_2, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
444 {HW_VENDOR_INTEL, CARD_INTEL_HDP530, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000, 2048},
445 {HW_VENDOR_INTEL, CARD_INTEL_I540, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000, 2048},
446 {HW_VENDOR_INTEL, CARD_INTEL_I550, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000, 2048},
447 {HW_VENDOR_INTEL, CARD_INTEL_I555, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000, 2048},
448 {HW_VENDOR_INTEL, CARD_INTEL_IP555, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000, 2048},
449 {HW_VENDOR_INTEL, CARD_INTEL_IP580_1, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
450 {HW_VENDOR_INTEL, CARD_INTEL_IP580_2, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
451 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_1, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
452 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_2, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
453 {HW_VENDOR_INTEL, CARD_INTEL_HD630, "Intel(R) HD Graphics 630", DRIVER_INTEL_HD4000, 3072},
456 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
457 enum wined3d_driver_model driver_model)
459 unsigned int i;
461 TRACE("Looking up version info for driver %#x, driver_model %#x.\n", driver, driver_model);
463 for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i)
465 const struct driver_version_information *entry = &driver_version_table[i];
467 if (entry->driver == driver && (driver_model == DRIVER_MODEL_GENERIC
468 || entry->driver_model == driver_model))
470 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
471 entry->driver_name, entry->version, entry->subversion, entry->build);
472 return entry;
475 return NULL;
478 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
479 enum wined3d_pci_device device)
481 unsigned int i;
483 for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i)
485 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].device)
486 return &gpu_description_table[i];
489 return NULL;
492 void wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
493 const struct wined3d_gpu_description *gpu_desc, UINT64 vram_bytes)
495 OSVERSIONINFOW os_version;
496 WORD driver_os_version;
497 enum wined3d_display_driver driver;
498 enum wined3d_driver_model driver_model;
499 const struct driver_version_information *version_info;
501 memset(&os_version, 0, sizeof(os_version));
502 os_version.dwOSVersionInfoSize = sizeof(os_version);
503 if (!GetVersionExW(&os_version))
505 ERR("Failed to get OS version, reporting 2000/XP.\n");
506 driver_os_version = 6;
507 driver_model = DRIVER_MODEL_NT5X;
509 else
511 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
512 switch (os_version.dwMajorVersion)
514 case 4:
515 /* If needed we could distinguish between 9x and NT4, but this code won't make
516 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
518 driver_os_version = 4;
519 driver_model = DRIVER_MODEL_WIN9X;
520 break;
522 case 5:
523 driver_os_version = 6;
524 driver_model = DRIVER_MODEL_NT5X;
525 break;
527 case 6:
528 if (os_version.dwMinorVersion == 0)
530 driver_os_version = 7;
531 driver_model = DRIVER_MODEL_NT6X;
533 else if (os_version.dwMinorVersion == 1)
535 driver_os_version = 8;
536 driver_model = DRIVER_MODEL_NT6X;
538 else
540 if (os_version.dwMinorVersion > 2)
542 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
543 os_version.dwMajorVersion, os_version.dwMinorVersion);
545 driver_os_version = 9;
546 driver_model = DRIVER_MODEL_NT6X;
548 break;
550 case 10:
551 driver_os_version = 10;
552 driver_model = DRIVER_MODEL_NT6X;
553 break;
555 default:
556 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
557 os_version.dwMajorVersion, os_version.dwMinorVersion);
558 driver_os_version = 6;
559 driver_model = DRIVER_MODEL_NT5X;
560 break;
564 driver_info->vendor = gpu_desc->vendor;
565 driver_info->device = gpu_desc->device;
566 driver_info->description = gpu_desc->description;
567 driver_info->vram_bytes = vram_bytes ? vram_bytes : (UINT64)gpu_desc->vidmem * 1024 * 1024;
568 driver = gpu_desc->driver;
570 if (wined3d_settings.emulated_textureram)
572 driver_info->vram_bytes = wined3d_settings.emulated_textureram;
573 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
574 wine_dbgstr_longlong(driver_info->vram_bytes));
578 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
579 * In order to avoid this application bug we limit the amount of video memory
580 * to LONG_MAX for older Windows versions.
582 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
584 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
585 driver_info->vram_bytes = LONG_MAX;
588 /* Try to obtain driver version information for the current Windows version. This fails in
589 * some cases:
590 * - the gpu is not available on the currently selected OS version:
591 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
592 * version information for the current Windows version is returned instead of faked info.
593 * We do the same and assume the default Windows version to emulate is WinXP.
595 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
596 * For now return the XP driver info. Perhaps later on we should return VESA.
598 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
599 * This could be an indication that our database is not up to date, so this should be fixed.
601 if ((version_info = get_driver_version_info(driver, driver_model))
602 || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))
604 driver_info->name = version_info->driver_name;
605 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
606 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
608 else
610 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
611 driver_info->vendor, driver_info->device, driver_model);
612 driver_info->name = "Display";
613 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
614 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* NVIDIA RIVA TNT, arbitrary */
618 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
619 enum wined3d_feature_level feature_level)
621 static const struct wined3d_fallback_card
623 enum wined3d_feature_level feature_level;
624 enum wined3d_pci_device device_id;
626 card_fallback_nvidia[] =
628 {WINED3D_FEATURE_LEVEL_5, CARD_NVIDIA_RIVA_128},
629 {WINED3D_FEATURE_LEVEL_6, CARD_NVIDIA_RIVA_TNT},
630 {WINED3D_FEATURE_LEVEL_7, CARD_NVIDIA_GEFORCE},
631 {WINED3D_FEATURE_LEVEL_8, CARD_NVIDIA_GEFORCE3},
632 {WINED3D_FEATURE_LEVEL_9_SM2, CARD_NVIDIA_GEFORCEFX_5800},
633 {WINED3D_FEATURE_LEVEL_9_SM3, CARD_NVIDIA_GEFORCE_6800},
634 {WINED3D_FEATURE_LEVEL_10, CARD_NVIDIA_GEFORCE_8800GTX},
635 {WINED3D_FEATURE_LEVEL_11, CARD_NVIDIA_GEFORCE_GTX470},
636 {WINED3D_FEATURE_LEVEL_NONE},
638 card_fallback_amd[] =
640 {WINED3D_FEATURE_LEVEL_5, CARD_AMD_RAGE_128PRO},
641 {WINED3D_FEATURE_LEVEL_7, CARD_AMD_RADEON_7200},
642 {WINED3D_FEATURE_LEVEL_8, CARD_AMD_RADEON_8500},
643 {WINED3D_FEATURE_LEVEL_9_SM2, CARD_AMD_RADEON_9500},
644 {WINED3D_FEATURE_LEVEL_9_SM3, CARD_AMD_RADEON_X1600},
645 {WINED3D_FEATURE_LEVEL_10, CARD_AMD_RADEON_HD2900},
646 {WINED3D_FEATURE_LEVEL_11, CARD_AMD_RADEON_HD5600},
647 {WINED3D_FEATURE_LEVEL_NONE},
649 card_fallback_intel[] =
651 {WINED3D_FEATURE_LEVEL_5, CARD_INTEL_845G},
652 {WINED3D_FEATURE_LEVEL_8, CARD_INTEL_915G},
653 {WINED3D_FEATURE_LEVEL_9_SM3, CARD_INTEL_945G},
654 {WINED3D_FEATURE_LEVEL_10, CARD_INTEL_G45},
655 {WINED3D_FEATURE_LEVEL_11, CARD_INTEL_IVBD},
656 {WINED3D_FEATURE_LEVEL_NONE},
659 static const struct
661 enum wined3d_pci_vendor vendor;
662 const struct wined3d_fallback_card *cards;
664 fallbacks[] =
666 {HW_VENDOR_AMD, card_fallback_amd},
667 {HW_VENDOR_NVIDIA, card_fallback_nvidia},
668 {HW_VENDOR_VMWARE, card_fallback_amd},
669 {HW_VENDOR_INTEL, card_fallback_intel},
672 const struct wined3d_fallback_card *cards;
673 enum wined3d_pci_device device_id;
674 unsigned int i;
676 cards = NULL;
677 for (i = 0; i < ARRAY_SIZE(fallbacks); ++i)
679 if (*vendor == fallbacks[i].vendor)
680 cards = fallbacks[i].cards;
682 if (!cards)
684 *vendor = HW_VENDOR_NVIDIA;
685 cards = card_fallback_nvidia;
688 device_id = cards->device_id;
689 for (i = 0; cards[i].feature_level; ++i)
691 if (feature_level >= cards[i].feature_level)
692 device_id = cards[i].device_id;
694 return device_id;
697 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
699 TRACE("wined3d %p, reporting %u adapters.\n",
700 wined3d, wined3d->adapter_count);
702 return wined3d->adapter_count;
705 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
707 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
709 return WINED3D_OK;
712 HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
713 struct wined3d_output_desc *desc)
715 enum wined3d_display_rotation rotation;
716 const struct wined3d_adapter *adapter;
717 struct wined3d_display_mode mode;
718 HMONITOR monitor;
719 HRESULT hr;
721 TRACE("wined3d %p, adapter_idx %u, desc %p.\n", wined3d, adapter_idx, desc);
723 if (adapter_idx >= wined3d->adapter_count)
724 return WINED3DERR_INVALIDCALL;
726 adapter = &wined3d->adapters[adapter_idx];
727 if (!(monitor = MonitorFromPoint(adapter->monitor_position, MONITOR_DEFAULTTOPRIMARY)))
728 return WINED3DERR_INVALIDCALL;
730 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, &rotation)))
731 return hr;
733 memcpy(desc->device_name, adapter->DeviceName, sizeof(desc->device_name));
734 SetRect(&desc->desktop_rect, 0, 0, mode.width, mode.height);
735 OffsetRect(&desc->desktop_rect, adapter->monitor_position.x, adapter->monitor_position.y);
736 /* FIXME: We should get this from EnumDisplayDevices() when the adapters
737 * are created. */
738 desc->attached_to_desktop = TRUE;
739 desc->rotation = rotation;
740 desc->monitor = monitor;
742 return WINED3D_OK;
745 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
746 of the same bpp but different resolutions */
748 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
749 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
750 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
752 const struct wined3d_adapter *adapter;
753 const struct wined3d_format *format;
754 unsigned int i = 0;
755 unsigned int j = 0;
756 UINT format_bits;
757 DEVMODEW mode;
759 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
760 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
762 if (adapter_idx >= wined3d->adapter_count)
763 return 0;
765 adapter = &wined3d->adapters[adapter_idx];
766 format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
767 format_bits = format->byte_count * CHAR_BIT;
769 memset(&mode, 0, sizeof(mode));
770 mode.dmSize = sizeof(mode);
772 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
774 if (mode.dmFields & DM_DISPLAYFLAGS)
776 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
777 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
778 continue;
780 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
781 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
782 continue;
785 if (format_id == WINED3DFMT_UNKNOWN)
787 /* This is for d3d8, do not enumerate P8 here. */
788 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
790 else if (mode.dmBitsPerPel == format_bits)
792 ++i;
796 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
798 return i;
801 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
802 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
803 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
804 UINT mode_idx, struct wined3d_display_mode *mode)
806 const struct wined3d_adapter *adapter;
807 const struct wined3d_format *format;
808 UINT format_bits;
809 DEVMODEW m;
810 UINT i = 0;
811 int j = 0;
813 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
814 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
816 if (!mode || adapter_idx >= wined3d->adapter_count)
817 return WINED3DERR_INVALIDCALL;
819 adapter = &wined3d->adapters[adapter_idx];
820 format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
821 format_bits = format->byte_count * CHAR_BIT;
823 memset(&m, 0, sizeof(m));
824 m.dmSize = sizeof(m);
826 while (i <= mode_idx)
828 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
830 WARN("Invalid mode_idx %u.\n", mode_idx);
831 return WINED3DERR_INVALIDCALL;
834 if (m.dmFields & DM_DISPLAYFLAGS)
836 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
837 && (m.u2.dmDisplayFlags & DM_INTERLACED))
838 continue;
840 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
841 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
842 continue;
845 if (format_id == WINED3DFMT_UNKNOWN)
847 /* This is for d3d8, do not enumerate P8 here. */
848 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
850 else if (m.dmBitsPerPel == format_bits)
852 ++i;
856 mode->width = m.dmPelsWidth;
857 mode->height = m.dmPelsHeight;
858 mode->refresh_rate = DEFAULT_REFRESH_RATE;
859 if (m.dmFields & DM_DISPLAYFREQUENCY)
860 mode->refresh_rate = m.dmDisplayFrequency;
862 if (format_id == WINED3DFMT_UNKNOWN)
863 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
864 else
865 mode->format_id = format_id;
867 if (!(m.dmFields & DM_DISPLAYFLAGS))
868 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
869 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
870 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
871 else
872 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
874 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
875 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
877 return WINED3D_OK;
880 HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
881 unsigned int adapter_idx, struct wined3d_display_mode *mode)
883 unsigned int i, j, mode_count, matching_mode_count, closest;
884 struct wined3d_display_mode **matching_modes;
885 struct wined3d_display_mode *modes;
886 HRESULT hr;
888 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
890 if (!(mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
891 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
893 WARN("Adapter has 0 matching modes.\n");
894 return E_FAIL;
897 if (!(modes = heap_calloc(mode_count, sizeof(*modes))))
898 return E_OUTOFMEMORY;
899 if (!(matching_modes = heap_calloc(mode_count, sizeof(*matching_modes))))
901 heap_free(modes);
902 return E_OUTOFMEMORY;
905 for (i = 0; i < mode_count; ++i)
907 if (FAILED(hr = wined3d_enum_adapter_modes(wined3d, adapter_idx,
908 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
910 heap_free(matching_modes);
911 heap_free(modes);
912 return hr;
914 matching_modes[i] = &modes[i];
917 matching_mode_count = mode_count;
919 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
921 for (i = 0, j = 0; i < matching_mode_count; ++i)
923 if (matching_modes[i]->scanline_ordering == mode->scanline_ordering)
924 matching_modes[j++] = matching_modes[i];
926 if (j > 0)
927 matching_mode_count = j;
930 if (mode->refresh_rate)
932 for (i = 0, j = 0; i < matching_mode_count; ++i)
934 if (matching_modes[i]->refresh_rate == mode->refresh_rate)
935 matching_modes[j++] = matching_modes[i];
937 if (j > 0)
938 matching_mode_count = j;
941 if (!mode->width || !mode->height)
943 struct wined3d_display_mode current_mode;
944 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx,
945 &current_mode, NULL)))
947 heap_free(matching_modes);
948 heap_free(modes);
949 return hr;
951 mode->width = current_mode.width;
952 mode->height = current_mode.height;
955 closest = ~0u;
956 for (i = 0, j = 0; i < matching_mode_count; ++i)
958 unsigned int d = abs(mode->width - matching_modes[i]->width)
959 + abs(mode->height - matching_modes[i]->height);
961 if (closest > d)
963 closest = d;
964 j = i;
968 *mode = *matching_modes[j];
970 heap_free(matching_modes);
971 heap_free(modes);
973 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
974 mode->refresh_rate, debug_d3dformat(mode->format_id),
975 mode->scanline_ordering);
977 return WINED3D_OK;
980 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
981 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
983 const struct wined3d_adapter *adapter;
984 DEVMODEW m;
986 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
987 wined3d, adapter_idx, mode, rotation);
989 if (!mode || adapter_idx >= wined3d->adapter_count)
990 return WINED3DERR_INVALIDCALL;
992 adapter = &wined3d->adapters[adapter_idx];
994 memset(&m, 0, sizeof(m));
995 m.dmSize = sizeof(m);
997 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
998 mode->width = m.dmPelsWidth;
999 mode->height = m.dmPelsHeight;
1000 mode->refresh_rate = DEFAULT_REFRESH_RATE;
1001 if (m.dmFields & DM_DISPLAYFREQUENCY)
1002 mode->refresh_rate = m.dmDisplayFrequency;
1003 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
1005 /* Lie about the format. X11 can't change the color depth, and some apps
1006 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
1007 * that GetDisplayMode still returns 24 bpp. This should probably be
1008 * handled in winex11 instead. */
1009 if (adapter->screen_format && adapter->screen_format != mode->format_id)
1011 WARN("Overriding format %s with stored format %s.\n",
1012 debug_d3dformat(mode->format_id),
1013 debug_d3dformat(adapter->screen_format));
1014 mode->format_id = adapter->screen_format;
1017 if (!(m.dmFields & DM_DISPLAYFLAGS))
1018 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
1019 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
1020 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
1021 else
1022 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
1024 if (rotation)
1026 switch (m.u1.s2.dmDisplayOrientation)
1028 case DMDO_DEFAULT:
1029 *rotation = WINED3D_DISPLAY_ROTATION_0;
1030 break;
1031 case DMDO_90:
1032 *rotation = WINED3D_DISPLAY_ROTATION_90;
1033 break;
1034 case DMDO_180:
1035 *rotation = WINED3D_DISPLAY_ROTATION_180;
1036 break;
1037 case DMDO_270:
1038 *rotation = WINED3D_DISPLAY_ROTATION_270;
1039 break;
1040 default:
1041 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
1042 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
1043 break;
1047 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
1048 mode->refresh_rate, debug_d3dformat(mode->format_id),
1049 mode->scanline_ordering);
1050 return WINED3D_OK;
1053 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
1054 UINT adapter_idx, const struct wined3d_display_mode *mode)
1056 struct wined3d_adapter *adapter;
1057 DEVMODEW new_mode, current_mode;
1058 RECT clip_rc;
1059 LONG ret;
1060 enum wined3d_format_id new_format_id;
1062 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
1064 if (adapter_idx >= wined3d->adapter_count)
1065 return WINED3DERR_INVALIDCALL;
1066 adapter = &wined3d->adapters[adapter_idx];
1068 memset(&new_mode, 0, sizeof(new_mode));
1069 new_mode.dmSize = sizeof(new_mode);
1070 memset(&current_mode, 0, sizeof(current_mode));
1071 current_mode.dmSize = sizeof(current_mode);
1072 if (mode)
1074 const struct wined3d_format *format;
1076 TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
1077 debug_d3dformat(mode->format_id), mode->scanline_ordering);
1079 format = wined3d_get_format(adapter, mode->format_id, WINED3D_BIND_RENDER_TARGET);
1081 new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
1082 new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
1083 new_mode.dmPelsWidth = mode->width;
1084 new_mode.dmPelsHeight = mode->height;
1086 new_mode.dmDisplayFrequency = mode->refresh_rate;
1087 if (mode->refresh_rate)
1088 new_mode.dmFields |= DM_DISPLAYFREQUENCY;
1090 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
1092 new_mode.dmFields |= DM_DISPLAYFLAGS;
1093 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
1094 new_mode.u2.dmDisplayFlags |= DM_INTERLACED;
1096 new_format_id = mode->format_id;
1098 else
1100 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_REGISTRY_SETTINGS, &new_mode))
1102 ERR("Failed to read mode from registry.\n");
1103 return WINED3DERR_NOTAVAILABLE;
1105 new_format_id = pixelformat_for_depth(new_mode.dmBitsPerPel);
1108 /* Only change the mode if necessary. */
1109 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &current_mode))
1111 ERR("Failed to get current display mode.\n");
1113 else if (current_mode.dmPelsWidth == new_mode.dmPelsWidth
1114 && current_mode.dmPelsHeight == new_mode.dmPelsHeight
1115 && current_mode.dmBitsPerPel == new_mode.dmBitsPerPel
1116 && (current_mode.dmDisplayFrequency == new_mode.dmDisplayFrequency
1117 || !(new_mode.dmFields & DM_DISPLAYFREQUENCY))
1118 && (current_mode.u2.dmDisplayFlags == new_mode.u2.dmDisplayFlags
1119 || !(new_mode.dmFields & DM_DISPLAYFLAGS)))
1121 TRACE("Skipping redundant mode setting call.\n");
1122 adapter->screen_format = new_format_id;
1123 return WINED3D_OK;
1126 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
1127 if (ret != DISP_CHANGE_SUCCESSFUL)
1129 if (new_mode.dmFields & DM_DISPLAYFREQUENCY)
1131 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
1132 new_mode.dmFields &= ~DM_DISPLAYFREQUENCY;
1133 new_mode.dmDisplayFrequency = 0;
1134 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
1136 if (ret != DISP_CHANGE_SUCCESSFUL)
1137 return WINED3DERR_NOTAVAILABLE;
1140 /* Store the new values. */
1141 adapter->screen_format = new_format_id;
1143 /* And finally clip mouse to our screen. */
1144 SetRect(&clip_rc, 0, 0, new_mode.dmPelsWidth, new_mode.dmPelsHeight);
1145 ClipCursor(&clip_rc);
1147 return WINED3D_OK;
1150 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
1151 and fields being inserted in the middle, a new structure is used in place */
1152 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
1153 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
1155 const struct wined3d_adapter *adapter;
1156 size_t len;
1158 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
1159 wined3d, adapter_idx, flags, identifier);
1161 if (adapter_idx >= wined3d->adapter_count)
1162 return WINED3DERR_INVALIDCALL;
1164 adapter = &wined3d->adapters[adapter_idx];
1166 if (identifier->driver_size)
1168 const char *name = adapter->driver_info.name;
1169 len = min(strlen(name), identifier->driver_size - 1);
1170 memcpy(identifier->driver, name, len);
1171 memset(&identifier->driver[len], 0, identifier->driver_size - len);
1174 if (identifier->description_size)
1176 const char *description = adapter->driver_info.description;
1177 len = min(strlen(description), identifier->description_size - 1);
1178 memcpy(identifier->description, description, len);
1179 memset(&identifier->description[len], 0, identifier->description_size - len);
1182 /* Note that d3d8 doesn't supply a device name. */
1183 if (identifier->device_name_size)
1185 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
1186 identifier->device_name_size, NULL, NULL))
1188 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
1189 return WINED3DERR_INVALIDCALL;
1193 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
1194 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
1195 identifier->vendor_id = adapter->driver_info.vendor;
1196 identifier->device_id = adapter->driver_info.device;
1197 identifier->subsystem_id = 0;
1198 identifier->revision = 0;
1199 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
1200 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
1201 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
1202 identifier->video_memory = min(~(SIZE_T)0, adapter->vram_bytes);
1204 return WINED3D_OK;
1207 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
1208 struct wined3d_raster_status *raster_status)
1210 LONGLONG freq_per_frame, freq_per_line;
1211 LARGE_INTEGER counter, freq_per_sec;
1212 struct wined3d_display_mode mode;
1213 static UINT once;
1215 if (!once++)
1216 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
1217 wined3d, adapter_idx, raster_status);
1218 else
1219 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
1220 wined3d, adapter_idx, raster_status);
1222 /* Obtaining the raster status is a widely implemented but optional
1223 * feature. When this method returns OK StarCraft 2 expects the
1224 * raster_status->InVBlank value to actually change over time.
1225 * And Endless Alice Crysis doesn't care even if this method fails.
1226 * Thus this method returns OK and fakes raster_status by
1227 * QueryPerformanceCounter. */
1229 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
1230 return WINED3DERR_INVALIDCALL;
1231 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
1232 return WINED3DERR_INVALIDCALL;
1233 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
1234 mode.refresh_rate = 60;
1236 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
1237 /* Assume 20 scan lines in the vertical blank. */
1238 freq_per_line = freq_per_frame / (mode.height + 20);
1239 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
1240 if (raster_status->scan_line < mode.height)
1241 raster_status->in_vblank = FALSE;
1242 else
1244 raster_status->scan_line = 0;
1245 raster_status->in_vblank = TRUE;
1248 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
1249 raster_status->in_vblank, raster_status->scan_line);
1251 return WINED3D_OK;
1254 static BOOL wined3d_check_pixel_format_color(const struct wined3d_pixel_format *cfg,
1255 const struct wined3d_format *format)
1257 /* Float formats need FBOs. If FBOs are used this function isn't called */
1258 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
1259 return FALSE;
1261 /* Probably a RGBA_float or color index mode. */
1262 if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
1263 return FALSE;
1265 if (cfg->redSize < format->red_size
1266 || cfg->greenSize < format->green_size
1267 || cfg->blueSize < format->blue_size
1268 || cfg->alphaSize < format->alpha_size)
1269 return FALSE;
1271 return TRUE;
1274 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_pixel_format *cfg,
1275 const struct wined3d_format *format)
1277 BOOL lockable = FALSE;
1279 /* Float formats need FBOs. If FBOs are used this function isn't called */
1280 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
1281 return FALSE;
1283 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
1284 lockable = TRUE;
1286 /* On some modern cards like the Geforce8/9, GLX doesn't offer some
1287 * depth/stencil formats which D3D9 reports. We can safely report
1288 * "compatible" formats (e.g. D24 can be used for D16) as long as we
1289 * aren't dealing with a lockable format. This also helps D3D <= 7 as they
1290 * expect D16 which isn't offered without this on Geforce8 cards. */
1291 if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size)))
1292 return FALSE;
1294 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also
1295 * need a format without stencil. We can allow a mismatch if the format
1296 * doesn't have any stencil bits. If it does have stencil bits the size
1297 * must match, or stencil wrapping would break. */
1298 if (format->stencil_size && cfg->stencilSize != format->stencil_size)
1299 return FALSE;
1301 return TRUE;
1304 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
1305 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
1306 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
1308 const struct wined3d_format *rt_format;
1309 const struct wined3d_format *ds_format;
1310 const struct wined3d_adapter *adapter;
1312 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
1313 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
1314 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
1315 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
1317 if (adapter_idx >= wined3d->adapter_count)
1318 return WINED3DERR_INVALIDCALL;
1320 adapter = &wined3d->adapters[adapter_idx];
1321 rt_format = wined3d_get_format(adapter, render_target_format_id, WINED3D_BIND_RENDER_TARGET);
1322 ds_format = wined3d_get_format(adapter, depth_stencil_format_id, WINED3D_BIND_DEPTH_STENCIL);
1323 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
1325 if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
1326 && (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
1328 TRACE("Formats match.\n");
1329 return WINED3D_OK;
1332 else
1334 const struct wined3d_pixel_format *cfgs;
1335 unsigned int cfg_count;
1336 unsigned int i;
1338 cfgs = adapter->cfgs;
1339 cfg_count = adapter->cfg_count;
1340 for (i = 0; i < cfg_count; ++i)
1342 if (wined3d_check_pixel_format_color(&cfgs[i], rt_format)
1343 && wined3d_check_pixel_format_depth(&cfgs[i], ds_format))
1345 TRACE("Formats match.\n");
1346 return WINED3D_OK;
1351 TRACE("Unsupported format pair: %s and %s.\n",
1352 debug_d3dformat(render_target_format_id),
1353 debug_d3dformat(depth_stencil_format_id));
1355 return WINED3DERR_NOTAVAILABLE;
1358 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
1359 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
1360 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
1362 const struct wined3d_adapter *adapter;
1363 const struct wined3d_format *format;
1364 HRESULT hr = WINED3D_OK;
1366 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
1367 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
1368 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
1369 windowed, multisample_type, quality_levels);
1371 if (adapter_idx >= wined3d->adapter_count)
1372 return WINED3DERR_INVALIDCALL;
1373 if (surface_format_id == WINED3DFMT_UNKNOWN)
1374 return WINED3DERR_INVALIDCALL;
1375 if (multisample_type < WINED3D_MULTISAMPLE_NONE)
1376 return WINED3DERR_INVALIDCALL;
1377 if (multisample_type > WINED3D_MULTISAMPLE_16_SAMPLES)
1379 FIXME("multisample_type %u not handled yet.\n", multisample_type);
1380 return WINED3DERR_NOTAVAILABLE;
1383 adapter = &wined3d->adapters[adapter_idx];
1384 format = wined3d_get_format(adapter, surface_format_id, 0);
1386 if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
1387 hr = WINED3DERR_NOTAVAILABLE;
1389 if (SUCCEEDED(hr) || (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && format->multisample_types))
1391 if (quality_levels)
1393 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
1394 *quality_levels = wined3d_popcount(format->multisample_types);
1395 else
1396 *quality_levels = 1;
1398 return WINED3D_OK;
1401 TRACE("Returning not supported.\n");
1402 return hr;
1405 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
1406 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
1407 const struct wined3d_format *display_format, const struct wined3d_format *ds_format,
1408 enum wined3d_gl_resource_type gl_type)
1410 /* Only allow depth/stencil formats */
1411 if (!(ds_format->depth_size || ds_format->stencil_size))
1412 return FALSE;
1414 /* Blacklist formats not supported on Windows */
1415 switch (ds_format->id)
1417 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
1418 case WINED3DFMT_S4X4_UINT_D24_UNORM:
1419 TRACE("[FAILED] - not supported on windows.\n");
1420 return FALSE;
1422 default:
1423 break;
1426 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
1428 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
1429 if (ds_format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
1430 return TRUE;
1432 else
1434 unsigned int i;
1436 /* Walk through all WGL pixel formats to find a match */
1437 for (i = 0; i < adapter->cfg_count; ++i)
1439 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
1440 if (wined3d_check_pixel_format_color(cfg, display_format)
1441 && wined3d_check_pixel_format_depth(cfg, ds_format))
1442 return TRUE;
1446 return FALSE;
1449 /* Check the render target capabilities of a format */
1450 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
1451 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format,
1452 enum wined3d_gl_resource_type gl_type)
1454 /* Filter out non-RT formats */
1455 if (!(check_format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
1456 return FALSE;
1457 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
1458 return TRUE;
1459 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
1461 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
1462 unsigned int i;
1464 /* In backbuffer mode the front and backbuffer share the same WGL
1465 * pixelformat. The format must match in RGB, alpha is allowed to be
1466 * different. (Only the backbuffer can have alpha.) */
1467 if (adapter_format->red_size != check_format->red_size
1468 || adapter_format->green_size != check_format->green_size
1469 || adapter_format->blue_size != check_format->blue_size)
1471 TRACE("[FAILED]\n");
1472 return FALSE;
1475 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
1476 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
1477 for (i = 0; i < adapter->cfg_count; ++i)
1479 if (cfgs[i].windowDrawable
1480 && wined3d_check_pixel_format_color(&cfgs[i], check_format))
1482 TRACE("Pixel format %d is compatible with format %s.\n",
1483 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
1484 return TRUE;
1488 return FALSE;
1491 static BOOL wined3d_check_surface_capability(const struct wined3d_format *format)
1493 if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] | format->flags[WINED3D_GL_RES_TYPE_RB]) & WINED3DFMT_FLAG_BLIT)
1495 TRACE("[OK]\n");
1496 return TRUE;
1499 if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
1500 == (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
1502 TRACE("[OK]\n");
1503 return TRUE;
1506 /* Reject other formats */
1507 TRACE("[FAILED]\n");
1508 return FALSE;
1511 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
1512 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
1513 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
1514 * show that wrapping is supported. The lack of filtering will sort out the
1515 * mipmapping capability anyway.
1517 * For now lets report this on all formats, but in the future we may want to
1518 * restrict it to some should applications need that. */
1519 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
1520 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
1521 unsigned int bind_flags, enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
1523 const struct wined3d_format *adapter_format, *format;
1524 enum wined3d_gl_resource_type gl_type, gl_type_end;
1525 const struct wined3d_adapter *adapter;
1526 BOOL mipmap_gen_supported = TRUE;
1527 unsigned int allowed_bind_flags;
1528 DWORD format_flags = 0;
1529 DWORD allowed_usage;
1531 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s, "
1532 "bind_flags %s, resource_type %s, check_format %s.\n",
1533 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
1534 debug_d3dusage(usage), debug_d3dusagequery(usage), wined3d_debug_bind_flags(bind_flags),
1535 debug_d3dresourcetype(resource_type), debug_d3dformat(check_format_id));
1537 if (adapter_idx >= wined3d->adapter_count)
1538 return WINED3DERR_INVALIDCALL;
1540 adapter = &wined3d->adapters[adapter_idx];
1541 adapter_format = wined3d_get_format(adapter, adapter_format_id, WINED3D_BIND_RENDER_TARGET);
1542 format = wined3d_get_format(adapter, check_format_id, bind_flags);
1544 switch (resource_type)
1546 case WINED3D_RTYPE_NONE:
1547 allowed_usage = 0;
1548 allowed_bind_flags = WINED3D_BIND_RENDER_TARGET
1549 | WINED3D_BIND_DEPTH_STENCIL;
1550 gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
1551 gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
1552 break;
1554 case WINED3D_RTYPE_TEXTURE_1D:
1555 allowed_usage = WINED3DUSAGE_DYNAMIC
1556 | WINED3DUSAGE_SOFTWAREPROCESSING
1557 | WINED3DUSAGE_QUERY_FILTER
1558 | WINED3DUSAGE_QUERY_GENMIPMAP
1559 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
1560 | WINED3DUSAGE_QUERY_SRGBREAD
1561 | WINED3DUSAGE_QUERY_SRGBWRITE
1562 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1563 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1564 allowed_bind_flags = WINED3D_BIND_SHADER_RESOURCE;
1565 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D;
1566 break;
1568 case WINED3D_RTYPE_TEXTURE_2D:
1569 allowed_usage = WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
1570 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
1571 allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
1572 allowed_bind_flags = WINED3D_BIND_RENDER_TARGET
1573 | WINED3D_BIND_DEPTH_STENCIL;
1574 if (!(bind_flags & WINED3D_BIND_SHADER_RESOURCE))
1576 if (!wined3d_check_surface_capability(format))
1578 TRACE("[FAILED] - Not supported for plain surfaces.\n");
1579 return WINED3DERR_NOTAVAILABLE;
1582 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_RB;
1583 break;
1585 allowed_usage |= WINED3DUSAGE_DYNAMIC
1586 | WINED3DUSAGE_LEGACY_CUBEMAP
1587 | WINED3DUSAGE_SOFTWAREPROCESSING
1588 | WINED3DUSAGE_QUERY_FILTER
1589 | WINED3DUSAGE_QUERY_GENMIPMAP
1590 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
1591 | WINED3DUSAGE_QUERY_SRGBREAD
1592 | WINED3DUSAGE_QUERY_SRGBWRITE
1593 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1594 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1595 allowed_bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
1596 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_2D;
1597 if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
1599 allowed_usage &= ~WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
1600 allowed_bind_flags &= ~WINED3D_BIND_DEPTH_STENCIL;
1601 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_CUBE;
1603 else if ((bind_flags & WINED3D_BIND_DEPTH_STENCIL)
1604 && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
1605 && !adapter->gl_info.supported[ARB_SHADOW])
1607 TRACE("[FAILED] - No shadow sampler support.\n");
1608 return WINED3DERR_NOTAVAILABLE;
1610 break;
1612 case WINED3D_RTYPE_TEXTURE_3D:
1613 allowed_usage = WINED3DUSAGE_DYNAMIC
1614 | WINED3DUSAGE_SOFTWAREPROCESSING
1615 | WINED3DUSAGE_QUERY_FILTER
1616 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
1617 | WINED3DUSAGE_QUERY_SRGBREAD
1618 | WINED3DUSAGE_QUERY_SRGBWRITE
1619 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
1620 | WINED3DUSAGE_QUERY_WRAPANDMIP;
1621 allowed_bind_flags = WINED3D_BIND_SHADER_RESOURCE;
1622 gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
1623 break;
1625 default:
1626 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
1627 return WINED3DERR_NOTAVAILABLE;
1630 if ((usage & allowed_usage) != usage)
1632 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
1633 usage, debug_d3dresourcetype(resource_type), allowed_usage);
1634 return WINED3DERR_NOTAVAILABLE;
1637 if ((bind_flags & allowed_bind_flags) != bind_flags)
1639 TRACE("Requested bind flags %s, but resource type %s only allows %s.\n",
1640 wined3d_debug_bind_flags(bind_flags), debug_d3dresourcetype(resource_type),
1641 wined3d_debug_bind_flags(allowed_bind_flags));
1642 return WINED3DERR_NOTAVAILABLE;
1645 if (bind_flags & WINED3D_BIND_SHADER_RESOURCE)
1646 format_flags |= WINED3DFMT_FLAG_TEXTURE;
1647 if (usage & WINED3DUSAGE_QUERY_FILTER)
1648 format_flags |= WINED3DFMT_FLAG_FILTERING;
1649 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
1650 format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
1651 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
1652 format_flags |= WINED3DFMT_FLAG_SRGB_READ;
1653 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
1654 format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
1655 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
1656 format_flags |= WINED3DFMT_FLAG_VTF;
1657 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
1658 format_flags |= WINED3DFMT_FLAG_BUMPMAP;
1660 if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
1662 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
1663 return WINED3DERR_NOTAVAILABLE;
1666 for (; gl_type <= gl_type_end; ++gl_type)
1668 if ((format->flags[gl_type] & format_flags) != format_flags)
1670 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
1671 format_flags, debug_d3dformat(check_format_id), format->flags[gl_type]);
1672 return WINED3DERR_NOTAVAILABLE;
1675 if ((bind_flags & WINED3D_BIND_RENDER_TARGET)
1676 && !CheckRenderTargetCapability(adapter, adapter_format, format, gl_type))
1678 TRACE("Requested WINED3D_BIND_RENDER_TARGET, but format %s is not supported for render targets.\n",
1679 debug_d3dformat(check_format_id));
1680 return WINED3DERR_NOTAVAILABLE;
1683 /* 3D depth / stencil textures are never supported. */
1684 if (bind_flags == WINED3D_BIND_DEPTH_STENCIL && gl_type == WINED3D_GL_RES_TYPE_TEX_3D)
1685 continue;
1687 if ((bind_flags & WINED3D_BIND_DEPTH_STENCIL)
1688 && !CheckDepthStencilCapability(adapter, adapter_format, format, gl_type))
1690 TRACE("Requested WINED3D_BIND_DEPTH_STENCIL, but format %s is not supported for depth/stencil buffers.\n",
1691 debug_d3dformat(check_format_id));
1692 return WINED3DERR_NOTAVAILABLE;
1695 if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP))
1696 mipmap_gen_supported = FALSE;
1699 if ((usage & WINED3DUSAGE_QUERY_GENMIPMAP) && !mipmap_gen_supported)
1701 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
1702 return WINED3DOK_NOMIPGEN;
1705 return WINED3D_OK;
1708 UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
1709 enum wined3d_format_id format_id, UINT width)
1711 const struct wined3d_adapter *adapter;
1712 unsigned int row_pitch, slice_pitch;
1714 TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
1715 wined3d, adapter_idx, debug_d3dformat(format_id), width);
1717 if (adapter_idx >= wined3d->adapter_count)
1718 return ~0u;
1720 adapter = &wined3d->adapters[adapter_idx];
1721 wined3d_format_calculate_pitch(wined3d_get_format(adapter, format_id, 0),
1722 1, width, 1, &row_pitch, &slice_pitch);
1724 return row_pitch;
1727 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
1728 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
1730 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
1731 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
1732 debug_d3dformat(dst_format));
1734 return WINED3D_OK;
1737 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
1738 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
1739 enum wined3d_format_id backbuffer_format, BOOL windowed)
1741 BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
1743 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
1744 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
1745 debug_d3dformat(backbuffer_format), windowed);
1747 if (adapter_idx >= wined3d->adapter_count)
1748 return WINED3DERR_INVALIDCALL;
1750 /* The task of this function is to check whether a certain display / backbuffer format
1751 * combination is available on the given adapter. In fullscreen mode microsoft specified
1752 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
1753 * and display format should match exactly.
1754 * In windowed mode format conversion can occur and this depends on the driver. */
1756 /* There are only 4 display formats. */
1757 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
1758 || display_format == WINED3DFMT_B5G5R5X1_UNORM
1759 || display_format == WINED3DFMT_B8G8R8X8_UNORM
1760 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
1762 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
1763 return WINED3DERR_NOTAVAILABLE;
1766 if (!windowed)
1768 /* If the requested display format is not available, don't continue. */
1769 if (!wined3d_get_adapter_mode_count(wined3d, adapter_idx,
1770 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
1772 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
1773 return WINED3DERR_NOTAVAILABLE;
1776 present_conversion = FALSE;
1778 else if (display_format == WINED3DFMT_B10G10R10A2_UNORM)
1780 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
1781 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
1782 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1783 return WINED3DERR_NOTAVAILABLE;
1786 if (present_conversion)
1788 /* Use the display format as back buffer format if the latter is
1789 * WINED3DFMT_UNKNOWN. */
1790 if (backbuffer_format == WINED3DFMT_UNKNOWN)
1791 backbuffer_format = display_format;
1793 if (FAILED(wined3d_check_device_format_conversion(wined3d, adapter_idx,
1794 device_type, backbuffer_format, display_format)))
1796 TRACE("Format conversion from %s to %s not supported.\n",
1797 debug_d3dformat(backbuffer_format), debug_d3dformat(display_format));
1798 return WINED3DERR_NOTAVAILABLE;
1801 else
1803 /* When format conversion from the back buffer format to the display
1804 * format is not allowed, only a limited number of combinations are
1805 * valid. */
1807 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
1809 TRACE("Unsupported format combination %s / %s.\n",
1810 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1811 return WINED3DERR_NOTAVAILABLE;
1814 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
1815 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
1817 TRACE("Unsupported format combination %s / %s.\n",
1818 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1819 return WINED3DERR_NOTAVAILABLE;
1822 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
1823 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
1825 TRACE("Unsupported format combination %s / %s.\n",
1826 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1827 return WINED3DERR_NOTAVAILABLE;
1830 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
1831 && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM)
1833 TRACE("Unsupported format combination %s / %s.\n",
1834 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
1835 return WINED3DERR_NOTAVAILABLE;
1839 /* Validate that the back buffer format is usable for render targets. */
1840 if (FAILED(wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
1841 0, WINED3D_BIND_RENDER_TARGET, WINED3D_RTYPE_TEXTURE_2D, backbuffer_format)))
1843 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format));
1844 return WINED3DERR_NOTAVAILABLE;
1847 return WINED3D_OK;
1850 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
1851 enum wined3d_device_type device_type, struct wined3d_caps *caps)
1853 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
1854 const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
1855 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
1856 struct wined3d_vertex_caps vertex_caps;
1857 DWORD ckey_caps, blit_caps, fx_caps;
1858 struct fragment_caps fragment_caps;
1859 struct shader_caps shader_caps;
1861 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
1862 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
1864 if (adapter_idx >= wined3d->adapter_count)
1865 return WINED3DERR_INVALIDCALL;
1867 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
1868 caps->AdapterOrdinal = adapter_idx;
1870 caps->Caps = 0;
1871 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
1872 WINED3DCAPS2_FULLSCREENGAMMA |
1873 WINED3DCAPS2_DYNAMICTEXTURES;
1874 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
1875 caps->Caps2 |= WINED3DCAPS2_CANGENMIPMAP;
1877 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
1878 WINED3DCAPS3_COPY_TO_VIDMEM |
1879 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
1881 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
1882 WINED3DCURSORCAPS_LOWRES;
1884 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
1885 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
1886 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
1887 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
1888 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
1889 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
1890 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
1891 WINED3DDEVCAPS_PUREDEVICE |
1892 WINED3DDEVCAPS_HWRASTERIZATION |
1893 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
1894 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
1895 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
1896 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
1897 WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
1899 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
1900 WINED3DPMISCCAPS_CULLCCW |
1901 WINED3DPMISCCAPS_CULLCW |
1902 WINED3DPMISCCAPS_COLORWRITEENABLE |
1903 WINED3DPMISCCAPS_CLIPTLVERTS |
1904 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
1905 WINED3DPMISCCAPS_MASKZ |
1906 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
1907 /* TODO:
1908 WINED3DPMISCCAPS_NULLREFERENCE
1909 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
1910 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
1911 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
1913 if (gl_info->supported[WINED3D_GL_BLEND_EQUATION])
1914 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_BLENDOP;
1915 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
1916 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
1917 if (gl_info->supported[EXT_DRAW_BUFFERS2])
1918 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
1919 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
1920 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
1922 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
1923 WINED3DPRASTERCAPS_PAT |
1924 WINED3DPRASTERCAPS_WFOG |
1925 WINED3DPRASTERCAPS_ZFOG |
1926 WINED3DPRASTERCAPS_FOGVERTEX |
1927 WINED3DPRASTERCAPS_FOGTABLE |
1928 WINED3DPRASTERCAPS_STIPPLE |
1929 WINED3DPRASTERCAPS_SUBPIXEL |
1930 WINED3DPRASTERCAPS_ZTEST |
1931 WINED3DPRASTERCAPS_SCISSORTEST |
1932 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
1933 WINED3DPRASTERCAPS_DEPTHBIAS;
1935 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
1937 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
1938 WINED3DPRASTERCAPS_ZBIAS |
1939 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
1942 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
1943 WINED3DPCMPCAPS_EQUAL |
1944 WINED3DPCMPCAPS_GREATER |
1945 WINED3DPCMPCAPS_GREATEREQUAL |
1946 WINED3DPCMPCAPS_LESS |
1947 WINED3DPCMPCAPS_LESSEQUAL |
1948 WINED3DPCMPCAPS_NEVER |
1949 WINED3DPCMPCAPS_NOTEQUAL;
1951 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
1952 * are legacy settings for srcblend only. */
1953 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
1954 WINED3DPBLENDCAPS_BOTHSRCALPHA |
1955 WINED3DPBLENDCAPS_DESTALPHA |
1956 WINED3DPBLENDCAPS_DESTCOLOR |
1957 WINED3DPBLENDCAPS_INVDESTALPHA |
1958 WINED3DPBLENDCAPS_INVDESTCOLOR |
1959 WINED3DPBLENDCAPS_INVSRCALPHA |
1960 WINED3DPBLENDCAPS_INVSRCCOLOR |
1961 WINED3DPBLENDCAPS_ONE |
1962 WINED3DPBLENDCAPS_SRCALPHA |
1963 WINED3DPBLENDCAPS_SRCALPHASAT |
1964 WINED3DPBLENDCAPS_SRCCOLOR |
1965 WINED3DPBLENDCAPS_ZERO;
1967 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
1968 WINED3DPBLENDCAPS_DESTCOLOR |
1969 WINED3DPBLENDCAPS_INVDESTALPHA |
1970 WINED3DPBLENDCAPS_INVDESTCOLOR |
1971 WINED3DPBLENDCAPS_INVSRCALPHA |
1972 WINED3DPBLENDCAPS_INVSRCCOLOR |
1973 WINED3DPBLENDCAPS_ONE |
1974 WINED3DPBLENDCAPS_SRCALPHA |
1975 WINED3DPBLENDCAPS_SRCCOLOR |
1976 WINED3DPBLENDCAPS_ZERO;
1978 if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED])
1979 caps->DestBlendCaps |= WINED3DPBLENDCAPS_SRCALPHASAT;
1981 if (gl_info->supported[EXT_BLEND_COLOR])
1983 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
1984 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
1988 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
1989 WINED3DPCMPCAPS_EQUAL |
1990 WINED3DPCMPCAPS_GREATER |
1991 WINED3DPCMPCAPS_GREATEREQUAL |
1992 WINED3DPCMPCAPS_LESS |
1993 WINED3DPCMPCAPS_LESSEQUAL |
1994 WINED3DPCMPCAPS_NEVER |
1995 WINED3DPCMPCAPS_NOTEQUAL;
1997 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
1998 WINED3DPSHADECAPS_COLORGOURAUDRGB |
1999 WINED3DPSHADECAPS_ALPHAFLATBLEND |
2000 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
2001 WINED3DPSHADECAPS_COLORFLATRGB |
2002 WINED3DPSHADECAPS_FOGFLAT |
2003 WINED3DPSHADECAPS_FOGGOURAUD |
2004 WINED3DPSHADECAPS_SPECULARFLATRGB;
2006 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
2007 WINED3DPTEXTURECAPS_ALPHAPALETTE |
2008 WINED3DPTEXTURECAPS_TRANSPARENCY |
2009 WINED3DPTEXTURECAPS_BORDER |
2010 WINED3DPTEXTURECAPS_MIPMAP |
2011 WINED3DPTEXTURECAPS_PROJECTED |
2012 WINED3DPTEXTURECAPS_PERSPECTIVE;
2014 if (!d3d_info->texture_npot)
2016 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2;
2017 if (d3d_info->texture_npot_conditional)
2018 caps->TextureCaps |= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
2021 if (gl_info->supported[EXT_TEXTURE3D])
2023 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP
2024 | WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
2025 if (!d3d_info->texture_npot)
2026 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
2029 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2031 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP
2032 | WINED3DPTEXTURECAPS_MIPCUBEMAP;
2033 if (!d3d_info->texture_npot)
2034 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
2037 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
2038 WINED3DPTFILTERCAPS_MAGFPOINT |
2039 WINED3DPTFILTERCAPS_MINFLINEAR |
2040 WINED3DPTFILTERCAPS_MINFPOINT |
2041 WINED3DPTFILTERCAPS_MIPFLINEAR |
2042 WINED3DPTFILTERCAPS_MIPFPOINT |
2043 WINED3DPTFILTERCAPS_LINEAR |
2044 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
2045 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
2046 WINED3DPTFILTERCAPS_MIPLINEAR |
2047 WINED3DPTFILTERCAPS_MIPNEAREST |
2048 WINED3DPTFILTERCAPS_NEAREST;
2050 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
2052 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
2053 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
2056 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2058 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
2059 WINED3DPTFILTERCAPS_MAGFPOINT |
2060 WINED3DPTFILTERCAPS_MINFLINEAR |
2061 WINED3DPTFILTERCAPS_MINFPOINT |
2062 WINED3DPTFILTERCAPS_MIPFLINEAR |
2063 WINED3DPTFILTERCAPS_MIPFPOINT |
2064 WINED3DPTFILTERCAPS_LINEAR |
2065 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
2066 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
2067 WINED3DPTFILTERCAPS_MIPLINEAR |
2068 WINED3DPTFILTERCAPS_MIPNEAREST |
2069 WINED3DPTFILTERCAPS_NEAREST;
2071 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
2073 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
2074 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
2077 else
2079 caps->CubeTextureFilterCaps = 0;
2082 if (gl_info->supported[EXT_TEXTURE3D])
2084 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
2085 WINED3DPTFILTERCAPS_MAGFPOINT |
2086 WINED3DPTFILTERCAPS_MINFLINEAR |
2087 WINED3DPTFILTERCAPS_MINFPOINT |
2088 WINED3DPTFILTERCAPS_MIPFLINEAR |
2089 WINED3DPTFILTERCAPS_MIPFPOINT |
2090 WINED3DPTFILTERCAPS_LINEAR |
2091 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
2092 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
2093 WINED3DPTFILTERCAPS_MIPLINEAR |
2094 WINED3DPTFILTERCAPS_MIPNEAREST |
2095 WINED3DPTFILTERCAPS_NEAREST;
2097 else
2099 caps->VolumeTextureFilterCaps = 0;
2102 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
2103 WINED3DPTADDRESSCAPS_CLAMP |
2104 WINED3DPTADDRESSCAPS_WRAP;
2106 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
2108 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
2110 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
2112 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
2114 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
2116 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
2119 if (gl_info->supported[EXT_TEXTURE3D])
2121 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
2122 WINED3DPTADDRESSCAPS_CLAMP |
2123 WINED3DPTADDRESSCAPS_WRAP;
2124 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
2126 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
2128 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
2130 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
2132 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
2134 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
2137 else
2139 caps->VolumeTextureAddressCaps = 0;
2142 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
2143 WINED3DLINECAPS_ZTEST |
2144 WINED3DLINECAPS_BLEND |
2145 WINED3DLINECAPS_ALPHACMP |
2146 WINED3DLINECAPS_FOG;
2147 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
2148 * idea how generating the smoothing alpha values works; the result is different
2151 caps->MaxTextureWidth = d3d_info->limits.texture_size;
2152 caps->MaxTextureHeight = d3d_info->limits.texture_size;
2154 if (gl_info->supported[EXT_TEXTURE3D])
2155 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
2156 else
2157 caps->MaxVolumeExtent = 0;
2159 caps->MaxTextureRepeat = 32768;
2160 caps->MaxTextureAspectRatio = d3d_info->limits.texture_size;
2161 caps->MaxVertexW = 1.0f;
2163 caps->GuardBandLeft = 0.0f;
2164 caps->GuardBandTop = 0.0f;
2165 caps->GuardBandRight = 0.0f;
2166 caps->GuardBandBottom = 0.0f;
2168 caps->ExtentsAdjust = 0.0f;
2170 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
2171 WINED3DSTENCILCAPS_INCRSAT |
2172 WINED3DSTENCILCAPS_INVERT |
2173 WINED3DSTENCILCAPS_KEEP |
2174 WINED3DSTENCILCAPS_REPLACE |
2175 WINED3DSTENCILCAPS_ZERO;
2176 if (gl_info->supported[EXT_STENCIL_WRAP])
2178 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
2179 WINED3DSTENCILCAPS_INCR;
2181 if (gl_info->supported[WINED3D_GL_VERSION_2_0] || gl_info->supported[EXT_STENCIL_TWO_SIDE]
2182 || gl_info->supported[ATI_SEPARATE_STENCIL])
2184 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
2187 caps->MaxAnisotropy = gl_info->limits.anisotropy;
2188 caps->MaxPointSize = d3d_info->limits.pointsize_max;
2190 caps->MaxPrimitiveCount = 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2191 caps->MaxVertexIndex = 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
2192 caps->MaxStreams = MAX_STREAMS;
2193 caps->MaxStreamStride = 1024;
2195 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
2196 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
2197 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
2198 caps->MaxNpatchTessellationLevel = 0;
2199 caps->MasterAdapterOrdinal = 0;
2200 caps->AdapterOrdinalInGroup = 0;
2201 caps->NumberOfAdaptersInGroup = 1;
2203 caps->NumSimultaneousRTs = d3d_info->limits.max_rt_count;
2205 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
2206 WINED3DPTFILTERCAPS_MAGFPOINT |
2207 WINED3DPTFILTERCAPS_MINFLINEAR |
2208 WINED3DPTFILTERCAPS_MAGFLINEAR;
2209 caps->VertexTextureFilterCaps = 0;
2211 adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
2212 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
2213 adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
2215 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
2216 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
2218 caps->VertexShaderVersion = shader_caps.vs_version;
2219 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
2221 caps->PixelShaderVersion = shader_caps.ps_version;
2222 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
2224 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
2225 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
2226 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
2228 caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
2229 caps->MaxActiveLights = vertex_caps.max_active_lights;
2230 caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
2231 caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
2232 caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
2233 caps->FVFCaps = vertex_caps.fvf_caps;
2234 caps->RasterCaps |= vertex_caps.raster_caps;
2236 /* The following caps are shader specific, but they are things we cannot detect, or which
2237 * are the same among all shader models. So to avoid code duplication set the shader version
2238 * specific, but otherwise constant caps here
2240 if (caps->VertexShaderVersion >= 3)
2242 /* Where possible set the caps based on OpenGL extensions and if they
2243 * aren't set (in case of software rendering) use the VS 3.0 from
2244 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2245 * VS3.0 value. */
2246 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
2247 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2248 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
2249 caps->VS20Caps.temp_count = max(32, gl_info->limits.arb_vs_temps);
2250 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
2251 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
2253 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
2254 caps->MaxVertexShader30InstructionSlots = max(512, gl_info->limits.arb_vs_instructions);
2255 caps->VertexTextureFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT;
2257 else if (caps->VertexShaderVersion == 2)
2259 caps->VS20Caps.caps = 0;
2260 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
2261 caps->VS20Caps.temp_count = max(12, gl_info->limits.arb_vs_temps);
2262 caps->VS20Caps.static_flow_control_depth = 1;
2264 caps->MaxVShaderInstructionsExecuted = 65535;
2265 caps->MaxVertexShader30InstructionSlots = 0;
2267 else
2268 { /* VS 1.x */
2269 caps->VS20Caps.caps = 0;
2270 caps->VS20Caps.dynamic_flow_control_depth = 0;
2271 caps->VS20Caps.temp_count = 0;
2272 caps->VS20Caps.static_flow_control_depth = 0;
2274 caps->MaxVShaderInstructionsExecuted = 0;
2275 caps->MaxVertexShader30InstructionSlots = 0;
2278 if (caps->PixelShaderVersion >= 3)
2280 /* Where possible set the caps based on OpenGL extensions and if they
2281 * aren't set (in case of software rendering) use the PS 3.0 from
2282 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
2283 * PS 3.0 value. */
2285 /* Caps is more or less undocumented on MSDN but it appears to be
2286 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
2287 * cards from Windows */
2288 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
2289 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
2290 WINED3DPS20CAPS_PREDICATION |
2291 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
2292 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
2293 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
2294 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
2295 caps->PS20Caps.temp_count = max(32, gl_info->limits.arb_ps_temps);
2296 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
2297 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
2298 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
2299 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
2301 caps->MaxPShaderInstructionsExecuted = 65535;
2302 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
2303 gl_info->limits.arb_ps_instructions);
2305 else if(caps->PixelShaderVersion == 2)
2307 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
2308 caps->PS20Caps.caps = 0;
2309 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
2310 caps->PS20Caps.temp_count = max(12, gl_info->limits.arb_ps_temps);
2311 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
2312 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
2313 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
2315 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
2316 caps->MaxPixelShader30InstructionSlots = 0;
2318 else /* PS 1.x */
2320 caps->PS20Caps.caps = 0;
2321 caps->PS20Caps.dynamic_flow_control_depth = 0;
2322 caps->PS20Caps.temp_count = 0;
2323 caps->PS20Caps.static_flow_control_depth = 0;
2324 caps->PS20Caps.instruction_slot_count = 0;
2326 caps->MaxPShaderInstructionsExecuted = 0;
2327 caps->MaxPixelShader30InstructionSlots = 0;
2330 if (caps->VertexShaderVersion >= 2)
2332 /* OpenGL supports all the formats below, perhaps not always
2333 * without conversion, but it supports them.
2334 * Further GLSL doesn't seem to have an official unsigned type so
2335 * don't advertise it yet as I'm not sure how we handle it.
2336 * We might need to add some clamping in the shader engine to
2337 * support it.
2338 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
2339 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
2340 WINED3DDTCAPS_UBYTE4N |
2341 WINED3DDTCAPS_SHORT2N |
2342 WINED3DDTCAPS_SHORT4N;
2343 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
2345 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
2346 WINED3DDTCAPS_FLOAT16_4;
2349 else
2351 caps->DeclTypes = 0;
2354 /* Set DirectDraw helper Caps */
2355 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
2356 WINEDDCKEYCAPS_SRCBLT;
2357 fx_caps = WINEDDFXCAPS_BLTALPHA |
2358 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
2359 WINEDDFXCAPS_BLTMIRRORUPDOWN |
2360 WINEDDFXCAPS_BLTROTATION90 |
2361 WINEDDFXCAPS_BLTSHRINKX |
2362 WINEDDFXCAPS_BLTSHRINKXN |
2363 WINEDDFXCAPS_BLTSHRINKY |
2364 WINEDDFXCAPS_BLTSHRINKYN |
2365 WINEDDFXCAPS_BLTSTRETCHX |
2366 WINEDDFXCAPS_BLTSTRETCHXN |
2367 WINEDDFXCAPS_BLTSTRETCHY |
2368 WINEDDFXCAPS_BLTSTRETCHYN;
2369 blit_caps = WINEDDCAPS_BLT |
2370 WINEDDCAPS_BLTCOLORFILL |
2371 WINEDDCAPS_BLTDEPTHFILL |
2372 WINEDDCAPS_BLTSTRETCH |
2373 WINEDDCAPS_CANBLTSYSMEM |
2374 WINEDDCAPS_CANCLIP |
2375 WINEDDCAPS_CANCLIPSTRETCHED |
2376 WINEDDCAPS_COLORKEY |
2377 WINEDDCAPS_COLORKEYHWASSIST;
2379 /* Fill the ddraw caps structure */
2380 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
2381 WINEDDCAPS_PALETTE |
2382 blit_caps;
2383 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
2384 WINEDDCAPS2_NOPAGELOCKREQUIRED |
2385 WINEDDCAPS2_PRIMARYGAMMA |
2386 WINEDDCAPS2_WIDESURFACES |
2387 WINEDDCAPS2_CANRENDERWINDOWED;
2388 caps->ddraw_caps.color_key_caps = ckey_caps;
2389 caps->ddraw_caps.fx_caps = fx_caps;
2390 caps->ddraw_caps.svb_caps = blit_caps;
2391 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
2392 caps->ddraw_caps.svb_fx_caps = fx_caps;
2393 caps->ddraw_caps.vsb_caps = blit_caps;
2394 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
2395 caps->ddraw_caps.vsb_fx_caps = fx_caps;
2396 caps->ddraw_caps.ssb_caps = blit_caps;
2397 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
2398 caps->ddraw_caps.ssb_fx_caps = fx_caps;
2400 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA
2401 | WINEDDSCAPS_BACKBUFFER
2402 | WINEDDSCAPS_FLIP
2403 | WINEDDSCAPS_FRONTBUFFER
2404 | WINEDDSCAPS_OFFSCREENPLAIN
2405 | WINEDDSCAPS_PALETTE
2406 | WINEDDSCAPS_PRIMARYSURFACE
2407 | WINEDDSCAPS_SYSTEMMEMORY
2408 | WINEDDSCAPS_VISIBLE;
2410 if (!(wined3d->flags & WINED3D_NO3D))
2412 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE
2413 | WINEDDSCAPS_MIPMAP
2414 | WINEDDSCAPS_TEXTURE
2415 | WINEDDSCAPS_VIDEOMEMORY
2416 | WINEDDSCAPS_ZBUFFER;
2417 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
2420 caps->shader_double_precision = d3d_info->shader_double_precision;
2421 caps->viewport_array_index_any_shader = d3d_info->viewport_array_index_any_shader;
2423 caps->max_feature_level = d3d_info->feature_level;
2425 return WINED3D_OK;
2428 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapter_idx,
2429 enum wined3d_device_type device_type, HWND focus_window, DWORD flags, BYTE surface_alignment,
2430 const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
2431 struct wined3d_device_parent *device_parent, struct wined3d_device **device)
2433 struct wined3d_device_gl *device_gl;
2434 HRESULT hr;
2436 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, "
2437 "surface_alignment %u, feature_levels %p, feature_level_count %u, device_parent %p, device %p.\n",
2438 wined3d, adapter_idx, device_type, focus_window, flags, surface_alignment,
2439 feature_levels, feature_level_count, device_parent, device);
2441 if (adapter_idx >= wined3d->adapter_count)
2442 return WINED3DERR_INVALIDCALL;
2444 if (!(device_gl = heap_alloc_zero(sizeof(*device_gl))))
2445 return E_OUTOFMEMORY;
2447 if (FAILED(hr = device_init(&device_gl->d, wined3d, adapter_idx,
2448 device_type, focus_window, flags, surface_alignment,
2449 feature_levels, feature_level_count, device_parent)))
2451 WARN("Failed to initialize device, hr %#x.\n", hr);
2452 heap_free(device_gl);
2453 return hr;
2456 TRACE("Created device %p.\n", device_gl);
2457 *device = &device_gl->d;
2459 device_parent->ops->wined3d_device_created(device_parent, *device);
2461 return WINED3D_OK;
2464 static BOOL wined3d_adapter_no3d_create_context(struct wined3d_context *context,
2465 struct wined3d_texture *target, const struct wined3d_format *ds_format)
2467 return TRUE;
2470 static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
2472 wined3d_adapter_no3d_create_context,
2475 static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, DWORD wined3d_creation_flags)
2477 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
2479 d3d_info->wined3d_creation_flags = wined3d_creation_flags;
2480 d3d_info->texture_npot = TRUE;
2481 d3d_info->feature_level = WINED3D_FEATURE_LEVEL_5;
2484 static BOOL wined3d_adapter_no3d_init(struct wined3d_adapter *adapter, DWORD wined3d_creation_flags)
2486 static const struct wined3d_gpu_description gpu_description =
2488 HW_VENDOR_SOFTWARE, CARD_WINE, "WineD3D DirectDraw Emulation", DRIVER_WINE, 128,
2491 TRACE("adapter %p.\n", adapter);
2493 wined3d_driver_info_init(&adapter->driver_info, &gpu_description, 0);
2494 adapter->vram_bytes = adapter->driver_info.vram_bytes;
2495 adapter->vram_bytes_used = 0;
2496 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
2498 if (!wined3d_adapter_no3d_init_format_info(adapter))
2499 return FALSE;
2501 adapter->vertex_pipe = &none_vertex_pipe;
2502 adapter->fragment_pipe = &none_fragment_pipe;
2503 adapter->shader_backend = &none_shader_backend;
2504 adapter->adapter_ops = &wined3d_adapter_no3d_ops;
2506 wined3d_adapter_no3d_init_d3d_info(adapter, wined3d_creation_flags);
2508 return TRUE;
2511 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, DWORD wined3d_creation_flags)
2513 DISPLAY_DEVICEW display_device;
2515 adapter->ordinal = ordinal;
2517 display_device.cb = sizeof(display_device);
2518 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
2519 TRACE("Display device: %s\n", debugstr_w(display_device.DeviceName));
2520 strcpyW(adapter->DeviceName, display_device.DeviceName);
2522 if (!AllocateLocallyUniqueId(&adapter->luid))
2524 ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
2525 return FALSE;
2527 TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
2528 adapter->luid.HighPart, adapter->luid.LowPart, adapter);
2530 adapter->formats = NULL;
2532 if (wined3d_creation_flags & WINED3D_NO3D)
2533 return wined3d_adapter_no3d_init(adapter, wined3d_creation_flags);
2534 return wined3d_adapter_gl_init(adapter, wined3d_creation_flags);
2537 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
2539 const struct wined3d_parent_ops wined3d_null_parent_ops =
2541 wined3d_null_wined3d_object_destroyed,
2544 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
2546 wined3d->ref = 1;
2547 wined3d->flags = flags;
2549 TRACE("Initialising adapters.\n");
2551 if (!wined3d_adapter_init(&wined3d->adapters[0], 0, flags))
2553 WARN("Failed to initialise adapter.\n");
2554 return E_FAIL;
2556 wined3d->adapter_count = 1;
2558 return WINED3D_OK;