[WINED3D]
[reactos.git] / reactos / dll / directx / wine / wined3d / directx.c
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
8 *
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.
13 *
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.
18 *
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
22 */
23
24 #include "wined3d_private.h"
25
26 #include <wine/unicode.h>
27
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
30
31 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
32 #define DEFAULT_REFRESH_RATE 0
33
34 /* The driver names reflect the lowest GPU supported
35 * by a certain driver, so DRIVER_AMD_R300 supports
36 * R3xx, R4xx and R5xx GPUs. */
37 enum wined3d_display_driver
38 {
39 DRIVER_AMD_RAGE_128PRO,
40 DRIVER_AMD_R100,
41 DRIVER_AMD_R300,
42 DRIVER_AMD_R600,
43 DRIVER_INTEL_GMA800,
44 DRIVER_INTEL_GMA900,
45 DRIVER_INTEL_GMA950,
46 DRIVER_INTEL_GMA3000,
47 DRIVER_NVIDIA_TNT,
48 DRIVER_NVIDIA_GEFORCE2MX,
49 DRIVER_NVIDIA_GEFORCEFX,
50 DRIVER_NVIDIA_GEFORCE6,
51 DRIVER_UNKNOWN
52 };
53
54 enum wined3d_driver_model
55 {
56 DRIVER_MODEL_WIN9X,
57 DRIVER_MODEL_NT40,
58 DRIVER_MODEL_NT5X,
59 DRIVER_MODEL_NT6X
60 };
61
62 enum wined3d_gl_vendor
63 {
64 GL_VENDOR_UNKNOWN,
65 GL_VENDOR_APPLE,
66 GL_VENDOR_FGLRX,
67 GL_VENDOR_INTEL,
68 GL_VENDOR_MESA,
69 GL_VENDOR_NVIDIA,
70 };
71
72 /* The d3d device ID */
73 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
74
75 /* Extension detection */
76 struct wined3d_extension_map
77 {
78 const char *extension_string;
79 enum wined3d_gl_extension extension;
80 };
81
82 static const struct wined3d_extension_map gl_extension_map[] =
83 {
84 /* APPLE */
85 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE },
86 {"GL_APPLE_fence", APPLE_FENCE },
87 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
88 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
89 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
90
91 /* ARB */
92 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
93 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
94 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
95 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
96 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
97 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
98 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
99 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
100 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
101 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
102 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
103 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
104 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
105 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
106 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
107 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS, },
108 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2, },
109 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
110 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
111 {"GL_ARB_multisample", ARB_MULTISAMPLE }, /* needs GLX_ARB_MULTISAMPLE as well */
112 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
113 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
114 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
115 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
116 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
117 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
118 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
119 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS },
120 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
121 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
122 {"GL_ARB_shadow", ARB_SHADOW },
123 {"GL_ARB_sync", ARB_SYNC },
124 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
125 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
126 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
127 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
128 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD },
129 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
130 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
131 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
132 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
133 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
134 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
135 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
136 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
137 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
138 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
139 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
140 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
141
142 /* ATI */
143 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
144 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
145 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
146 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
147 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
148
149 /* EXT */
150 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
151 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
152 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
153 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
154 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
155 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
156 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
157 {"GL_EXT_fog_coord", EXT_FOG_COORD },
158 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
159 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
160 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
161 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
162 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
163 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
164 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
165 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
166 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
167 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
168 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
169 {"GL_EXT_texture3D", EXT_TEXTURE3D },
170 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
171 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
172 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD },
173 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
174 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
175 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
176 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
177 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
178 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
179 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
180
181 /* NV */
182 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP },
183 {"GL_NV_fence", NV_FENCE },
184 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
185 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
186 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
187 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
188 {"GL_NV_half_float", NV_HALF_FLOAT },
189 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
190 {"GL_NV_point_sprite", NV_POINT_SPRITE },
191 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
192 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
193 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
194 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
195 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
196 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
197 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
198 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
199 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
200 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
201 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
202
203 /* SGI */
204 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
205 };
206
207 static const struct wined3d_extension_map wgl_extension_map[] =
208 {
209 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
210 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
211 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
212 };
213
214 /**********************************************************
215 * Utility functions follow
216 **********************************************************/
217
218 const struct min_lookup minMipLookup[] =
219 {
220 /* NONE POINT LINEAR */
221 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
222 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
223 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
224 };
225
226 const struct min_lookup minMipLookup_noFilter[] =
227 {
228 /* NONE POINT LINEAR */
229 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
230 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
231 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
232 };
233
234 const struct min_lookup minMipLookup_noMip[] =
235 {
236 /* NONE POINT LINEAR */
237 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
238 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
239 {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
240 };
241
242 const GLenum magLookup[] =
243 {
244 /* NONE POINT LINEAR */
245 GL_NEAREST, GL_NEAREST, GL_LINEAR,
246 };
247
248 const GLenum magLookup_noFilter[] =
249 {
250 /* NONE POINT LINEAR */
251 GL_NEAREST, GL_NEAREST, GL_NEAREST,
252 };
253
254 struct wined3d_fake_gl_ctx
255 {
256 HDC dc;
257 HWND wnd;
258 HGLRC gl_ctx;
259 HDC restore_dc;
260 HGLRC restore_gl_ctx;
261 };
262
263 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
264 {
265 TRACE("Destroying fake GL context.\n");
266
267 if (!wglMakeCurrent(NULL, NULL))
268 ERR("Failed to disable fake GL context.\n");
269
270 if (!wglDeleteContext(ctx->gl_ctx))
271 {
272 DWORD err = GetLastError();
273 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
274 }
275
276 ReleaseDC(ctx->wnd, ctx->dc);
277 DestroyWindow(ctx->wnd);
278
279 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
280 ERR("Failed to restore previous GL context.\n");
281 }
282
283 static void wined3d_create_fake_gl_context_attribs(struct wined3d_fake_gl_ctx *fake_gl_ctx,
284 struct wined3d_gl_info *gl_info, const GLint *ctx_attribs)
285 {
286 HGLRC new_ctx;
287
288 if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
289 return;
290
291 if (!(new_ctx = gl_info->p_wglCreateContextAttribsARB(fake_gl_ctx->dc, NULL, ctx_attribs)))
292 {
293 ERR("Failed to create a context using wglCreateContextAttribsARB(), last error %#x.\n", GetLastError());
294 gl_info->p_wglCreateContextAttribsARB = NULL;
295 return;
296 }
297
298 if (!wglMakeCurrent(fake_gl_ctx->dc, new_ctx))
299 {
300 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
301 if (!wglDeleteContext(new_ctx))
302 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
303 gl_info->p_wglCreateContextAttribsARB = NULL;
304 return;
305 }
306
307 if (!wglDeleteContext(fake_gl_ctx->gl_ctx))
308 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
309 fake_gl_ctx->gl_ctx = new_ctx;
310 }
311
312 /* Do not call while under the GL lock. */
313 static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
314 {
315 PIXELFORMATDESCRIPTOR pfd;
316 int iPixelFormat;
317
318 TRACE("getting context...\n");
319
320 ctx->restore_dc = wglGetCurrentDC();
321 ctx->restore_gl_ctx = wglGetCurrentContext();
322
323 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
324 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
325 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
326 if (!ctx->wnd)
327 {
328 ERR("Failed to create a window.\n");
329 goto fail;
330 }
331
332 ctx->dc = GetDC(ctx->wnd);
333 if (!ctx->dc)
334 {
335 ERR("Failed to get a DC.\n");
336 goto fail;
337 }
338
339 /* PixelFormat selection */
340 ZeroMemory(&pfd, sizeof(pfd));
341 pfd.nSize = sizeof(pfd);
342 pfd.nVersion = 1;
343 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
344 pfd.iPixelType = PFD_TYPE_RGBA;
345 pfd.cColorBits = 32;
346 pfd.iLayerType = PFD_MAIN_PLANE;
347
348 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
349 {
350 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
351 ERR("Failed to find a suitable pixel format.\n");
352 goto fail;
353 }
354 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
355 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
356
357 /* Create a GL context. */
358 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
359 {
360 WARN("Failed to create default context for capabilities initialization.\n");
361 goto fail;
362 }
363
364 /* Make it the current GL context. */
365 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
366 {
367 ERR("Failed to make fake GL context current.\n");
368 goto fail;
369 }
370
371 return TRUE;
372
373 fail:
374 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
375 ctx->gl_ctx = NULL;
376 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
377 ctx->dc = NULL;
378 if (ctx->wnd) DestroyWindow(ctx->wnd);
379 ctx->wnd = NULL;
380 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
381 ERR("Failed to restore previous GL context.\n");
382
383 return FALSE;
384 }
385
386 /* Adjust the amount of used texture memory */
387 unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount)
388 {
389 adapter->UsedTextureRam += amount;
390 TRACE("Adjusted adapter memory by %d to %d.\n", amount, adapter->UsedTextureRam);
391 return adapter->UsedTextureRam;
392 }
393
394 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
395 {
396 HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
397 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
398 }
399
400 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
401 {
402 ULONG refcount = InterlockedIncrement(&wined3d->ref);
403
404 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
405
406 return refcount;
407 }
408
409 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
410 {
411 ULONG refcount = InterlockedDecrement(&wined3d->ref);
412
413 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
414
415 if (!refcount)
416 {
417 unsigned int i;
418
419 for (i = 0; i < wined3d->adapter_count; ++i)
420 {
421 wined3d_adapter_cleanup(&wined3d->adapters[i]);
422 }
423 HeapFree(GetProcessHeap(), 0, wined3d);
424 }
425
426 return refcount;
427 }
428
429 /* Context activation is done by the caller. */
430 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
431 {
432 GLuint prog;
433 BOOL ret = FALSE;
434 const char *testcode =
435 "!!ARBvp1.0\n"
436 "PARAM C[66] = { program.env[0..65] };\n"
437 "ADDRESS A0;"
438 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
439 "ARL A0.x, zero.x;\n"
440 "MOV result.position, C[A0.x + 65];\n"
441 "END\n";
442
443 while (gl_info->gl_ops.gl.p_glGetError());
444 GL_EXTCALL(glGenProgramsARB(1, &prog));
445 if(!prog) {
446 ERR("Failed to create an ARB offset limit test program\n");
447 }
448 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
449 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
450 strlen(testcode), testcode));
451 if (gl_info->gl_ops.gl.p_glGetError())
452 {
453 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
454 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
455 ret = TRUE;
456 } else TRACE("OpenGL implementation allows offsets > 63\n");
457
458 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
459 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
460 checkGLcall("ARB vp offset limit test cleanup");
461
462 return ret;
463 }
464
465 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
466 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
467 {
468 if (card_vendor != HW_VENDOR_AMD) return FALSE;
469 if (device == CARD_AMD_RADEON_9500) return TRUE;
470 if (device == CARD_AMD_RADEON_X700) return TRUE;
471 if (device == CARD_AMD_RADEON_X1600) return TRUE;
472 return FALSE;
473 }
474
475 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
476 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
477 {
478 if (card_vendor == HW_VENDOR_NVIDIA)
479 {
480 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
481 device == CARD_NVIDIA_GEFORCEFX_5600 ||
482 device == CARD_NVIDIA_GEFORCEFX_5800)
483 {
484 return TRUE;
485 }
486 }
487 return FALSE;
488 }
489
490 static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
491 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
492 {
493 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
494 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
495 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
496 *
497 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
498 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
499 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
500 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
501 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
502 * the chance that other implementations support them is rather small since Win32 QuickTime uses
503 * DirectDraw, not OpenGL.
504 *
505 * This test has been moved into wined3d_guess_gl_vendor()
506 */
507 if (gl_vendor == GL_VENDOR_APPLE)
508 {
509 return TRUE;
510 }
511 return FALSE;
512 }
513
514 /* Context activation is done by the caller. */
515 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
516 {
517 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
518 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
519 * all the texture. This function detects this bug by its symptom and disables PBOs
520 * if the test fails.
521 *
522 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
523 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
524 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
525 * read back is compared to the original. If they are equal PBOs are assumed to work,
526 * otherwise the PBO extension is disabled. */
527 GLuint texture, pbo;
528 static const unsigned int pattern[] =
529 {
530 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
531 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
532 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
533 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
534 };
535 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
536
537 /* No PBO -> No point in testing them. */
538 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
539
540 while (gl_info->gl_ops.gl.p_glGetError());
541 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
542 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
543
544 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
545 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
546 checkGLcall("Specifying the PBO test texture");
547
548 GL_EXTCALL(glGenBuffersARB(1, &pbo));
549 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
550 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
551 checkGLcall("Specifying the PBO test pbo");
552
553 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
554 checkGLcall("Loading the PBO test texture");
555
556 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
557
558 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
559
560 memset(check, 0, sizeof(check));
561 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
562 checkGLcall("Reading back the PBO test texture");
563
564 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
565 GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
566 checkGLcall("PBO test cleanup");
567
568 if (memcmp(check, pattern, sizeof(check)))
569 {
570 WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
571 "Disabling PBOs. This may result in slower performance.\n");
572 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
573 }
574 else
575 {
576 TRACE("PBO test successful.\n");
577 }
578 }
579
580 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
581 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
582 {
583 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
584 }
585
586 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
587 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
588 {
589 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
590 if (card_vendor != HW_VENDOR_AMD) return FALSE;
591 if (device == CARD_AMD_RADEON_X1600) return FALSE;
592 return TRUE;
593 }
594
595 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
596 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
597 {
598 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
599 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
600 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
601 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
602 * hardcoded
603 *
604 * dx10 cards usually have 64 varyings */
605 return gl_info->limits.glsl_varyings > 44;
606 }
607
608 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
609 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
610 {
611 return !match_dx10_capable(gl_info, gl_renderer, gl_vendor, card_vendor, device);
612 }
613
614 /* A GL context is provided by the caller */
615 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
616 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
617 {
618 GLenum error;
619 DWORD data[16];
620
621 if (!gl_info->supported[EXT_SECONDARY_COLOR])
622 return FALSE;
623
624 while (gl_info->gl_ops.gl.p_glGetError());
625 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
626 error = gl_info->gl_ops.gl.p_glGetError();
627
628 if (error == GL_NO_ERROR)
629 {
630 TRACE("GL Implementation accepts 4 component specular color pointers\n");
631 return TRUE;
632 }
633 else
634 {
635 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
636 debug_glerror(error));
637 return FALSE;
638 }
639 }
640
641 /* A GL context is provided by the caller */
642 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
643 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
644 {
645 GLuint prog;
646 BOOL ret = FALSE;
647 GLint pos;
648 const char *testcode =
649 "!!ARBvp1.0\n"
650 "OPTION NV_vertex_program2;\n"
651 "MOV result.clip[0], 0.0;\n"
652 "MOV result.position, 0.0;\n"
653 "END\n";
654
655 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
656
657 while (gl_info->gl_ops.gl.p_glGetError());
658
659 GL_EXTCALL(glGenProgramsARB(1, &prog));
660 if(!prog)
661 {
662 ERR("Failed to create the NVvp clip test program\n");
663 return FALSE;
664 }
665 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
666 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
667 strlen(testcode), testcode));
668 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
669 if(pos != -1)
670 {
671 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
672 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
673 ret = TRUE;
674 while (gl_info->gl_ops.gl.p_glGetError());
675 }
676 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
677
678 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
679 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
680 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
681
682 return ret;
683 }
684
685 /* Context activation is done by the caller. */
686 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
687 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
688 {
689 char data[4 * 4 * 4];
690 GLuint tex, fbo;
691 GLenum status;
692
693 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
694
695 memset(data, 0xcc, sizeof(data));
696
697 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
698 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
699 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
700 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
701 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
702 checkGLcall("glTexImage2D");
703
704 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
705 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
706 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
707 checkGLcall("glFramebufferTexture2D");
708
709 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
710 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
711 checkGLcall("glCheckFramebufferStatus");
712
713 memset(data, 0x11, sizeof(data));
714 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
715 checkGLcall("glTexSubImage2D");
716
717 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
718 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
719 checkGLcall("glClear");
720
721 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
722 checkGLcall("glGetTexImage");
723
724 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
725 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
726 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
727 checkGLcall("glBindTexture");
728
729 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
730 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
731 checkGLcall("glDeleteTextures");
732
733 return *(DWORD *)data == 0x11111111;
734 }
735
736 /* Context activation is done by the caller. */
737 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
738 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
739 {
740 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
741 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
742 GLuint tex;
743 GLint size;
744
745 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
746 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
747 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
748 checkGLcall("glTexImage2D");
749
750 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
751 checkGLcall("glGetTexLevelParameteriv");
752 TRACE("Real color depth is %d\n", size);
753
754 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
755 checkGLcall("glBindTexture");
756 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
757 checkGLcall("glDeleteTextures");
758
759 return size < 16;
760 }
761
762 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
763 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
764 {
765 return gl_vendor == GL_VENDOR_FGLRX;
766 }
767
768 static BOOL match_r200(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
769 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
770 {
771 if (card_vendor != HW_VENDOR_AMD) return FALSE;
772 if (device == CARD_AMD_RADEON_8500) return TRUE;
773 return FALSE;
774 }
775
776 static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
777 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
778 {
779 DWORD data[4];
780 GLuint tex, fbo;
781 GLenum status;
782 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
783 GLuint prog;
784 GLint err_pos;
785 static const char *program_code =
786 "!!ARBfp1.0\n"
787 "OPTION ARB_fog_linear;\n"
788 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
789 "END\n";
790
791 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
792 return FALSE;
793 if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
794 return FALSE;
795
796 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
797 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
798 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
799 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
800 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 4, 1, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
801 checkGLcall("glTexImage2D");
802
803 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
804 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
805 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
806 checkGLcall("glFramebufferTexture2D");
807
808 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
809 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
810 checkGLcall("glCheckFramebufferStatus");
811
812 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
813 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
814 checkGLcall("glClear");
815 gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
816 checkGLcall("glViewport");
817
818 gl_info->gl_ops.gl.p_glEnable(GL_FOG);
819 gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
820 gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
821 gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
822 gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
823 gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
824 checkGLcall("fog setup");
825
826 GL_EXTCALL(glGenProgramsARB(1, &prog));
827 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
828 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
829 strlen(program_code), program_code));
830 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
831 checkGLcall("Test fragment program setup");
832
833 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
834 if (err_pos != -1)
835 {
836 const char *error_str;
837 error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
838 FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
839 }
840
841 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
842 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
843 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
844 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
845 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
846 gl_info->gl_ops.gl.p_glEnd();
847 checkGLcall("ARBfp fog test draw");
848
849 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
850 checkGLcall("glGetTexImage");
851 data[0] &= 0x00ffffff;
852 data[1] &= 0x00ffffff;
853 data[2] &= 0x00ffffff;
854 data[3] &= 0x00ffffff;
855
856 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
857 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
858
859 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
860 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
861 gl_info->gl_ops.gl.p_glDisable(GL_FOG);
862 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
863 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
864 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
865 checkGLcall("ARBfp fog test teardown");
866
867 TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
868 return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
869 }
870
871 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
872 {
873 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
874 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
875 * allow 48 different offsets or other helper immediate values. */
876 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
877 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
878 }
879
880 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
881 {
882 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
883 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
884 * If real NP2 textures are used, the driver falls back to software. We could just remove the
885 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
886 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
887 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
888 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
889 *
890 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
891 * has this extension promoted to core. The extension loading code sets this extension supported
892 * due to that, so this code works on fglrx as well. */
893 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
894 {
895 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
896 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
897 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
898 }
899 }
900
901 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
902 {
903 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
904 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
905 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
906 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
907 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
908 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
909 *
910 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
911 * triggering the software fallback. There is not much we can do here apart from disabling the
912 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
913 * in wined3d_adapter_init_gl_caps).
914 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
915 * post-processing effects in the game "Max Payne 2").
916 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
917 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
918 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
919 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
920 }
921
922 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
923 {
924 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
925 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
926 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
927 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
928 * according to the spec.
929 *
930 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
931 * makes the shader slower and eats instruction slots which should be available to the d3d app.
932 *
933 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
934 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
935 * this workaround is activated on cards that do not need it, it won't break things, just affect
936 * performance negatively. */
937 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
938 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
939 }
940
941 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
942 {
943 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
944 }
945
946 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
947 {
948 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
949 }
950
951 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
952 {
953 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
954 }
955
956 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
957 {
958 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
959 }
960
961 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
962 {
963 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
964 }
965
966 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
967 {
968 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
969 }
970
971 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
972 {
973 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
974 selected texture formats. They are apparently the only DX9 class GPUs
975 supporting VTF.
976 Also, DX9-era GPUs are somewhat limited with float textures
977 filtering and blending. */
978 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
979 }
980
981 static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
982 {
983 /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
984 * loads some fog parameters (start, end, exponent, but not the color) into the
985 * program.
986 *
987 * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
988 * and it is the responsibility of the vertex pipeline to handle non-linear fog and
989 * linear fog with start and end other than 0.0 and 1.0. */
990 TRACE("Reserving 1 ARB constant for compiler private use.\n");
991 gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
992 }
993
994 static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
995 {
996 gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
997 }
998
999 struct driver_quirk
1000 {
1001 BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
1002 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
1003 void (*apply)(struct wined3d_gl_info *gl_info);
1004 const char *description;
1005 };
1006
1007 static const struct driver_quirk quirk_table[] =
1008 {
1009 {
1010 match_amd_r300_to_500,
1011 quirk_amd_dx9,
1012 "AMD normalized texrect quirk"
1013 },
1014 {
1015 match_apple,
1016 quirk_apple_glsl_constants,
1017 "Apple GLSL uniform override"
1018 },
1019 {
1020 match_geforce5,
1021 quirk_no_np2,
1022 "Geforce 5 NP2 disable"
1023 },
1024 {
1025 match_apple_intel,
1026 quirk_texcoord_w,
1027 "Init texcoord .w for Apple Intel GPU driver"
1028 },
1029 {
1030 match_apple_nonr500ati,
1031 quirk_texcoord_w,
1032 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1033 },
1034 {
1035 match_dx10_capable,
1036 quirk_clip_varying,
1037 "Reserved varying for gl_ClipPos"
1038 },
1039 {
1040 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
1041 * GL implementations accept it. The Mac GL is the only implementation known to
1042 * reject it.
1043 *
1044 * If we can pass 4 component specular colors, do it, because (a) we don't have
1045 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
1046 * passes specular alpha to the pixel shader if any is used. Otherwise the
1047 * specular alpha is used to pass the fog coordinate, which we pass to opengl
1048 * via GL_EXT_fog_coord.
1049 */
1050 match_allows_spec_alpha,
1051 quirk_allows_specular_alpha,
1052 "Allow specular alpha quirk"
1053 },
1054 {
1055 match_broken_nv_clip,
1056 quirk_disable_nvvp_clip,
1057 "Apple NV_vertex_program clip bug quirk"
1058 },
1059 {
1060 match_fbo_tex_update,
1061 quirk_fbo_tex_update,
1062 "FBO rebind for attachment updates"
1063 },
1064 {
1065 match_broken_rgba16,
1066 quirk_broken_rgba16,
1067 "True RGBA16 is not available"
1068 },
1069 {
1070 match_fglrx,
1071 quirk_infolog_spam,
1072 "Not printing GLSL infolog"
1073 },
1074 {
1075 match_not_dx10_capable,
1076 quirk_limited_tex_filtering,
1077 "Texture filtering, blending and VTF support is limited"
1078 },
1079 {
1080 match_r200,
1081 quirk_r200_constants,
1082 "r200 vertex shader constants"
1083 },
1084 {
1085 match_broken_arb_fog,
1086 quirk_broken_arb_fog,
1087 "ARBfp fogstart == fogend workaround"
1088 },
1089 };
1090
1091 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1092 * reporting a driver version is moot because we are not the Windows driver, and we have different
1093 * bugs, features, etc.
1094 *
1095 * The driver version has the form "x.y.z.w".
1096 *
1097 * "x" is the Windows version the driver is meant for:
1098 * 4 -> 95/98/NT4
1099 * 5 -> 2000
1100 * 6 -> 2000/XP
1101 * 7 -> Vista
1102 * 8 -> Win 7
1103 *
1104 * "y" is the maximum Direct3D version the driver supports.
1105 * y -> d3d version mapping:
1106 * 11 -> d3d6
1107 * 12 -> d3d7
1108 * 13 -> d3d8
1109 * 14 -> d3d9
1110 * 15 -> d3d10
1111 * 16 -> d3d10.1
1112 * 17 -> d3d11
1113 *
1114 * "z" is the subversion number.
1115 *
1116 * "w" is the vendor specific driver build number.
1117 */
1118
1119 struct driver_version_information
1120 {
1121 enum wined3d_display_driver driver;
1122 enum wined3d_driver_model driver_model;
1123 const char *driver_name; /* name of Windows driver */
1124 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1125 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1126 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1127 };
1128
1129 /* The driver version table contains driver information for different devices on several OS versions. */
1130 static const struct driver_version_information driver_version_table[] =
1131 {
1132 /* AMD
1133 * - Radeon HD2x00 (R600) and up supported by current drivers.
1134 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1135 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1136 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1137 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
1138 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
1139 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
1140 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
1141 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1142 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1143
1144 /* Intel
1145 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1146 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1147 * igxprd32.dll but the GMA800 driver was never updated. */
1148 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1149 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1150 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1151 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1152 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1153 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1154
1155 /* Nvidia
1156 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1157 * - GeforceFX support is up to 173.x on <= XP
1158 * - Geforce2MX/3/4 up to 96.x on <= XP
1159 * - TNT/Geforce1/2 up to 71.x on <= XP
1160 * All version numbers used below are from the Linux nvidia drivers. */
1161 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1162 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1163 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1164 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 12, 6658},
1165 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 12, 6658},
1166 };
1167
1168 struct gpu_description
1169 {
1170 WORD vendor; /* reported PCI card vendor ID */
1171 WORD card; /* reported PCI card device ID */
1172 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1173 enum wined3d_display_driver driver;
1174 unsigned int vidmem;
1175 };
1176
1177 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1178 * found on a board containing a specific GPU. */
1179 static const struct gpu_description gpu_description_table[] =
1180 {
1181 /* Nvidia cards */
1182 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1183 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1184 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1185 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1186 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1187 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1188 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1189 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1190 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1191 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1192 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1193 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1194 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1195 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1196 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1197 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1198 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1199 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1200 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1201 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1202 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1203 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1204 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6, 320 },
1205 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6, 768 },
1206 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6, 256 },
1207 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE6, 256 },
1208 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6, 256 },
1209 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1210 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1211 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6, 384 },
1212 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1213 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6, 512 },
1214 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6, 512 },
1215 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6, 512 },
1216 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6, 1024},
1217 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6, 896 },
1218 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6, 1024},
1219 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE6, 512 },
1220 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6, 256},
1221 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE6, 512},
1222 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6, 1024},
1223 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6, 1024},
1224 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6, 1024},
1225 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6, 1024},
1226 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6, 2048},
1227 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6, 1024},
1228 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6, 1024},
1229 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6, 1024},
1230 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6, 768 },
1231 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6, 1536},
1232 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6, 1024},
1233 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6, 1280},
1234 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6, 1536},
1235 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE6, 1024},
1236 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6, 1024},
1237 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1238 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6, 1024},
1239 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1240 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6, 1024},
1241 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6, 1280},
1242 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6, 1536},
1243 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE6, 1024},
1244 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE6, 1024},
1245 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE6, 1024},
1246 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE6, 1024},
1247 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE6, 2048},
1248 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE6, 1024},
1249 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1250 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE6, 2048},
1251 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE6, 2048},
1252 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6, 2048},
1253 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE6, 3072},
1254 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6, 2048},
1255 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE6, 3072},
1256 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE6, 2048},
1257
1258 /* AMD cards */
1259 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1260 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1261 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1262 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1263 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1264 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1265 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1266 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1267 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1268 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1269 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1270 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
1271 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1272 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1273 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1274 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1275 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1276 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1277 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1278 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1279 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1280 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1281 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1282 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1283 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1284 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1285 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1286 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1287 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1288 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1289 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1290 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1291 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1292 /* Intel cards */
1293 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1294 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1295 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1296 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1297 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1298 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1299 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1300 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1301 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1302 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1303 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1304 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1305 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1306 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1307 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1308 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1309 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1310 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1311 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1312 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1313 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1314 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1315 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1316 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1317 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1318 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1319 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000, 1024},
1320 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000, 1024},
1321 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1322 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1323 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000, 1024},
1324 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1325 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1326 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000, 1024},
1327 };
1328
1329 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1330 enum wined3d_driver_model driver_model)
1331 {
1332 unsigned int i;
1333
1334 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1335 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
1336 {
1337 const struct driver_version_information *entry = &driver_version_table[i];
1338
1339 if (entry->driver == driver && entry->driver_model == driver_model)
1340 {
1341 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1342 entry->driver_name, entry->version, entry->subversion, entry->build);
1343 return entry;
1344 }
1345 }
1346 return NULL;
1347 }
1348
1349 static void init_driver_info(struct wined3d_driver_info *driver_info,
1350 enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
1351 {
1352 OSVERSIONINFOW os_version;
1353 WORD driver_os_version;
1354 unsigned int i;
1355 enum wined3d_display_driver driver = DRIVER_UNKNOWN;
1356 enum wined3d_driver_model driver_model;
1357 const struct driver_version_information *version_info;
1358
1359 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1360 {
1361 TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings.pci_vendor_id);
1362 vendor = wined3d_settings.pci_vendor_id;
1363 }
1364 driver_info->vendor = vendor;
1365
1366 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1367 {
1368 TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings.pci_device_id);
1369 device = wined3d_settings.pci_device_id;
1370 }
1371 driver_info->device = device;
1372
1373 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1374 * overrides the pci ids to a card which is not in our database. */
1375 driver_info->vidmem = WINE_DEFAULT_VIDMEM;
1376
1377 memset(&os_version, 0, sizeof(os_version));
1378 os_version.dwOSVersionInfoSize = sizeof(os_version);
1379 if (!GetVersionExW(&os_version))
1380 {
1381 ERR("Failed to get OS version, reporting 2000/XP.\n");
1382 driver_os_version = 6;
1383 driver_model = DRIVER_MODEL_NT5X;
1384 }
1385 else
1386 {
1387 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1388 switch (os_version.dwMajorVersion)
1389 {
1390 case 4:
1391 /* If needed we could distinguish between 9x and NT4, but this code won't make
1392 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1393 */
1394 driver_os_version = 4;
1395 driver_model = DRIVER_MODEL_WIN9X;
1396 break;
1397
1398 case 5:
1399 driver_os_version = 6;
1400 driver_model = DRIVER_MODEL_NT5X;
1401 break;
1402
1403 case 6:
1404 if (os_version.dwMinorVersion == 0)
1405 {
1406 driver_os_version = 7;
1407 driver_model = DRIVER_MODEL_NT6X;
1408 }
1409 else if (os_version.dwMinorVersion == 1)
1410 {
1411 driver_os_version = 8;
1412 driver_model = DRIVER_MODEL_NT6X;
1413 }
1414 else
1415 {
1416 if (os_version.dwMinorVersion > 2)
1417 {
1418 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
1419 os_version.dwMajorVersion, os_version.dwMinorVersion);
1420 }
1421 driver_os_version = 9;
1422 driver_model = DRIVER_MODEL_NT6X;
1423 }
1424 break;
1425
1426 default:
1427 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1428 os_version.dwMajorVersion, os_version.dwMinorVersion);
1429 driver_os_version = 6;
1430 driver_model = DRIVER_MODEL_NT5X;
1431 break;
1432 }
1433 }
1434
1435 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1436 * This means that unless the ids are overridden, we will always find a GPU description. */
1437 for (i = 0; i < (sizeof(gpu_description_table) / sizeof(gpu_description_table[0])); i++)
1438 {
1439 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1440 {
1441 TRACE("Found card %04x:%04x in driver DB.\n", vendor, device);
1442
1443 driver_info->description = gpu_description_table[i].description;
1444 driver_info->vidmem = gpu_description_table[i].vidmem * 1024*1024;
1445 driver = gpu_description_table[i].driver;
1446 break;
1447 }
1448 }
1449
1450 if (wined3d_settings.emulated_textureram)
1451 {
1452 TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings.emulated_textureram);
1453 driver_info->vidmem = wined3d_settings.emulated_textureram;
1454 }
1455
1456 /* Try to obtain driver version information for the current Windows version. This fails in
1457 * some cases:
1458 * - the gpu is not available on the currently selected OS version:
1459 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1460 * version information for the current Windows version is returned instead of faked info.
1461 * We do the same and assume the default Windows version to emulate is WinXP.
1462 *
1463 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1464 * For now return the XP driver info. Perhaps later on we should return VESA.
1465 *
1466 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1467 * This could be an indication that our database is not up to date, so this should be fixed.
1468 */
1469 version_info = get_driver_version_info(driver, driver_model);
1470 if (version_info)
1471 {
1472 driver_info->name = version_info->driver_name;
1473 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1474 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1475 }
1476 else
1477 {
1478 version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X);
1479 if (version_info)
1480 {
1481 driver_info->name = version_info->driver_name;
1482 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1483 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1484 }
1485 else
1486 {
1487 driver_info->description = "Direct3D HAL";
1488 driver_info->name = "Display";
1489 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1490 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1491
1492 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1493 vendor, device, driver_model);
1494 }
1495 }
1496
1497 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1498 driver_info->version_high, driver_info->version_low);
1499 }
1500
1501 /* Context activation is done by the caller. */
1502 static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
1503 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1504 {
1505 unsigned int i;
1506
1507 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
1508 {
1509 if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
1510 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1511 quirk_table[i].apply(gl_info);
1512 }
1513
1514 /* Find out if PBOs work as they are supposed to. */
1515 test_pbo_functionality(gl_info);
1516 }
1517
1518 static DWORD wined3d_parse_gl_version(const char *gl_version)
1519 {
1520 const char *ptr = gl_version;
1521 int major, minor;
1522
1523 major = atoi(ptr);
1524 if (major <= 0)
1525 ERR("Invalid OpenGL major version %d.\n", major);
1526
1527 while (isdigit(*ptr)) ++ptr;
1528 if (*ptr++ != '.')
1529 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1530
1531 minor = atoi(ptr);
1532
1533 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1534
1535 return MAKEDWORD_VERSION(major, minor);
1536 }
1537
1538 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1539 const char *gl_vendor_string, const char *gl_renderer)
1540 {
1541
1542 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1543 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1544 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1545 *
1546 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1547 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1548 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1549 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1550 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1551 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1552 * DirectDraw, not OpenGL. */
1553 if (gl_info->supported[APPLE_FENCE]
1554 && gl_info->supported[APPLE_CLIENT_STORAGE]
1555 && gl_info->supported[APPLE_YCBCR_422])
1556 return GL_VENDOR_APPLE;
1557
1558 if (strstr(gl_vendor_string, "NVIDIA"))
1559 return GL_VENDOR_NVIDIA;
1560
1561 if (strstr(gl_vendor_string, "ATI"))
1562 return GL_VENDOR_FGLRX;
1563
1564 if (strstr(gl_vendor_string, "Intel(R)")
1565 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1566 || strstr(gl_renderer, "Intel")
1567 || strstr(gl_vendor_string, "Intel Inc."))
1568 return GL_VENDOR_INTEL;
1569
1570 if (strstr(gl_vendor_string, "Mesa")
1571 || strstr(gl_vendor_string, "X.Org")
1572 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1573 || strstr(gl_vendor_string, "DRI R300 Project")
1574 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1575 || strstr(gl_vendor_string, "VMware, Inc.")
1576 || strstr(gl_renderer, "Mesa")
1577 || strstr(gl_renderer, "Gallium"))
1578 return GL_VENDOR_MESA;
1579
1580 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1581 debugstr_a(gl_vendor_string));
1582
1583 return GL_VENDOR_UNKNOWN;
1584 }
1585
1586 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1587 {
1588 if (strstr(gl_vendor_string, "NVIDIA")
1589 || strstr(gl_vendor_string, "Nouveau")
1590 || strstr(gl_vendor_string, "nouveau"))
1591 return HW_VENDOR_NVIDIA;
1592
1593 if (strstr(gl_vendor_string, "ATI")
1594 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1595 || strstr(gl_vendor_string, "X.Org R300 Project")
1596 || strstr(gl_renderer, "AMD")
1597 || strstr(gl_renderer, "R100")
1598 || strstr(gl_renderer, "R200")
1599 || strstr(gl_renderer, "R300")
1600 || strstr(gl_renderer, "R600")
1601 || strstr(gl_renderer, "R700"))
1602 return HW_VENDOR_AMD;
1603
1604 if (strstr(gl_vendor_string, "Intel(R)")
1605 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1606 || strstr(gl_renderer, "Intel")
1607 || strstr(gl_renderer, "i915")
1608 || strstr(gl_vendor_string, "Intel Inc."))
1609 return HW_VENDOR_INTEL;
1610
1611 if (strstr(gl_vendor_string, "Mesa")
1612 || strstr(gl_vendor_string, "Brian Paul")
1613 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1614 || strstr(gl_vendor_string, "VMware, Inc."))
1615 return HW_VENDOR_SOFTWARE;
1616
1617 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1618
1619 return HW_VENDOR_NVIDIA;
1620 }
1621
1622 static UINT d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info)
1623 {
1624 UINT level = 0;
1625
1626 if (gl_info->supported[ARB_MULTITEXTURE])
1627 level = 6;
1628 if (gl_info->supported[ARB_TEXTURE_COMPRESSION]
1629 && gl_info->supported[ARB_TEXTURE_CUBE_MAP]
1630 && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
1631 level = 7;
1632 if (level == 7 && gl_info->supported[ARB_MULTISAMPLE]
1633 && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
1634 level = 8;
1635 if (level == 8 && gl_info->supported[ARB_FRAGMENT_PROGRAM]
1636 && gl_info->supported[ARB_VERTEX_SHADER])
1637 level = 9;
1638 if (level == 9 && gl_info->supported[EXT_GPU_SHADER4])
1639 level = 10;
1640
1641 return level;
1642 }
1643
1644 static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
1645 const char *gl_renderer)
1646 {
1647 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1648 unsigned int i;
1649
1650 if (d3d_level >= 10)
1651 {
1652 static const struct
1653 {
1654 const char *renderer;
1655 enum wined3d_pci_device id;
1656 }
1657 cards[] =
1658 {
1659 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
1660 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */
1661 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1662 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
1663 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1664 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
1665 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
1666 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
1667 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
1668 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1669 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1670 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1671 {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
1672 {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
1673 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1674 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1675 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1676 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1677 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1678 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1679 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1680 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1681 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1682 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1683 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1684 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1685 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1686 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1687 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1688 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1689 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1690 {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
1691 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1692 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1693 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1694 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1695 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1696 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1697 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1698 {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
1699 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1700 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1701 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1702 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1703 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1704 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1705 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1706 {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1707 {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1708 {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1709 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1710 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1711 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1712 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1713 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1714 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1715 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1716 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1717 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1718 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1719 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1720 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1721 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1722 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1723 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1724 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1725 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1726 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1727 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1728 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1729 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1730 {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1731 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1732 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1733 {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1734 {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1735 };
1736
1737 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1738 {
1739 if (strstr(gl_renderer, cards[i].renderer))
1740 return cards[i].id;
1741 }
1742 return PCI_DEVICE_NONE;
1743 }
1744
1745 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1746 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1747 */
1748 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
1749 {
1750 static const struct
1751 {
1752 const char *renderer;
1753 enum wined3d_pci_device id;
1754 }
1755 cards[] =
1756 {
1757 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1758 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1759 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1760 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1761 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1762 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1763 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1764 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
1765 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
1766 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
1767 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1768 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1769 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1770 };
1771
1772 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1773 {
1774 if (strstr(gl_renderer, cards[i].renderer))
1775 return cards[i].id;
1776 }
1777 return PCI_DEVICE_NONE;
1778 }
1779
1780 if (d3d_level >= 9)
1781 {
1782 /* GeforceFX - highend */
1783 if (strstr(gl_renderer, "5800")
1784 || strstr(gl_renderer, "5900")
1785 || strstr(gl_renderer, "5950")
1786 || strstr(gl_renderer, "Quadro FX"))
1787 {
1788 return CARD_NVIDIA_GEFORCEFX_5800;
1789 }
1790
1791 /* GeforceFX - midend */
1792 if (strstr(gl_renderer, "5600")
1793 || strstr(gl_renderer, "5650")
1794 || strstr(gl_renderer, "5700")
1795 || strstr(gl_renderer, "5750"))
1796 {
1797 return CARD_NVIDIA_GEFORCEFX_5600;
1798 }
1799
1800 /* GeforceFX - lowend */
1801 return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
1802 }
1803
1804 if (d3d_level >= 8)
1805 {
1806 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
1807 {
1808 return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1809 }
1810
1811 return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1812 }
1813
1814 if (d3d_level >= 7)
1815 {
1816 if (strstr(gl_renderer, "GeForce4 MX"))
1817 {
1818 return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
1819 }
1820
1821 if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
1822 {
1823 return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1824 }
1825
1826 if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
1827 {
1828 return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1829 }
1830
1831 return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
1832 }
1833
1834 if (strstr(gl_renderer, "TNT2"))
1835 {
1836 return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
1837 }
1838
1839 return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
1840 }
1841
1842 static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info,
1843 const char *gl_renderer)
1844 {
1845 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1846
1847 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1848 *
1849 * Beware: renderer string do not match exact card model,
1850 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1851 if (d3d_level >= 10)
1852 {
1853 unsigned int i;
1854
1855 static const struct
1856 {
1857 const char *renderer;
1858 enum wined3d_pci_device id;
1859 }
1860 cards[] =
1861 {
1862 /* Southern Islands */
1863 {"HD 7900", CARD_AMD_RADEON_HD7900},
1864 {"HD 7800", CARD_AMD_RADEON_HD7800},
1865 {"HD 7700", CARD_AMD_RADEON_HD7700},
1866 /* Northern Islands */
1867 {"HD 6970", CARD_AMD_RADEON_HD6900},
1868 {"HD 6900", CARD_AMD_RADEON_HD6900},
1869 {"HD 6800", CARD_AMD_RADEON_HD6800},
1870 {"HD 6770M",CARD_AMD_RADEON_HD6600M},
1871 {"HD 6750M",CARD_AMD_RADEON_HD6600M},
1872 {"HD 6700", CARD_AMD_RADEON_HD6700},
1873 {"HD 6670", CARD_AMD_RADEON_HD6600},
1874 {"HD 6630M",CARD_AMD_RADEON_HD6600M},
1875 {"HD 6600M",CARD_AMD_RADEON_HD6600M},
1876 {"HD 6600", CARD_AMD_RADEON_HD6600},
1877 {"HD 6570", CARD_AMD_RADEON_HD6600},
1878 {"HD 6500M",CARD_AMD_RADEON_HD6600M},
1879 {"HD 6500", CARD_AMD_RADEON_HD6600},
1880 {"HD 6400", CARD_AMD_RADEON_HD6400},
1881 {"HD 6300", CARD_AMD_RADEON_HD6300},
1882 {"HD 6200", CARD_AMD_RADEON_HD6300},
1883 /* Evergreen */
1884 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
1885 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
1886 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1887 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
1888 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
1889 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1890 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
1891 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1892 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1893 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
1894 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
1895 /* R700 */
1896 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
1897 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1898 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1899 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1900 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
1901 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
1902 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
1903 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1904 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1905 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1906 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1907 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1908 /* R600/R700 integrated */
1909 {"HD 4200M", CARD_AMD_RADEON_HD4200M},
1910 {"HD 3300", CARD_AMD_RADEON_HD3200},
1911 {"HD 3200", CARD_AMD_RADEON_HD3200},
1912 {"HD 3100", CARD_AMD_RADEON_HD3200},
1913 /* R600 */
1914 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1915 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1916 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1917 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
1918 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1919 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1920 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1921 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1922 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1923 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1924 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1925 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1926 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1927 };
1928
1929 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1930 {
1931 if (strstr(gl_renderer, cards[i].renderer))
1932 return cards[i].id;
1933 }
1934 return PCI_DEVICE_NONE;
1935 }
1936
1937 if (d3d_level >= 9)
1938 {
1939 /* Radeon R5xx */
1940 if (strstr(gl_renderer, "X1600")
1941 || strstr(gl_renderer, "X1650")
1942 || strstr(gl_renderer, "X1800")
1943 || strstr(gl_renderer, "X1900")
1944 || strstr(gl_renderer, "X1950"))
1945 {
1946 return CARD_AMD_RADEON_X1600;
1947 }
1948
1949 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1950 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1951 if (strstr(gl_renderer, "X700")
1952 || strstr(gl_renderer, "X800")
1953 || strstr(gl_renderer, "X850")
1954 || strstr(gl_renderer, "X1300")
1955 || strstr(gl_renderer, "X1400")
1956 || strstr(gl_renderer, "X1450")
1957 || strstr(gl_renderer, "X1550")
1958 || strstr(gl_renderer, "X2300")
1959 || strstr(gl_renderer, "X2500")
1960 || strstr(gl_renderer, "HD 2300")
1961 )
1962 {
1963 return CARD_AMD_RADEON_X700;
1964 }
1965
1966 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1967 if (strstr(gl_renderer, "Radeon Xpress"))
1968 {
1969 return CARD_AMD_RADEON_XPRESS_200M;
1970 }
1971 }
1972 return PCI_DEVICE_NONE;
1973 }
1974
1975 static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info,
1976 const char *gl_renderer)
1977 {
1978 unsigned int i;
1979
1980 static const struct
1981 {
1982 const char *renderer;
1983 enum wined3d_pci_device id;
1984 }
1985 cards[] =
1986 {
1987 /* Ivybridge */
1988 {"Ivybridge Server", CARD_INTEL_IVBS},
1989 {"Ivybridge Mobile", CARD_INTEL_IVBM},
1990 {"Ivybridge Desktop", CARD_INTEL_IVBD},
1991 /* Sandybridge */
1992 {"Sandybridge Server", CARD_INTEL_SNBS},
1993 {"Sandybridge Mobile", CARD_INTEL_SNBM},
1994 {"Sandybridge Desktop", CARD_INTEL_SNBD},
1995 /* Ironlake */
1996 {"Ironlake Mobile", CARD_INTEL_ILKM},
1997 {"Ironlake Desktop", CARD_INTEL_ILKD},
1998 /* G4x */
1999 {"B43", CARD_INTEL_B43},
2000 {"G41", CARD_INTEL_G41},
2001 {"G45", CARD_INTEL_G45},
2002 {"Q45", CARD_INTEL_Q45},
2003 {"Integrated Graphics Device", CARD_INTEL_IGD},
2004 {"GM45", CARD_INTEL_GM45},
2005 /* i965 */
2006 {"965GME", CARD_INTEL_965GME},
2007 {"965GM", CARD_INTEL_965GM},
2008 {"X3100", CARD_INTEL_965GM}, /* MacOS */
2009 {"946GZ", CARD_INTEL_946GZ},
2010 {"965G", CARD_INTEL_965G},
2011 {"965Q", CARD_INTEL_965Q},
2012 /* i945 */
2013 {"Pineview M", CARD_INTEL_PNVM},
2014 {"Pineview G", CARD_INTEL_PNVG},
2015 {"IGD", CARD_INTEL_PNVG},
2016 {"Q33", CARD_INTEL_Q33},
2017 {"G33", CARD_INTEL_G33},
2018 {"Q35", CARD_INTEL_Q35},
2019 {"945GME", CARD_INTEL_945GME},
2020 {"945GM", CARD_INTEL_945GM},
2021 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
2022 {"945G", CARD_INTEL_945G},
2023 /* i915 */
2024 {"915GM", CARD_INTEL_915GM},
2025 {"E7221G", CARD_INTEL_E7221G},
2026 {"915G", CARD_INTEL_915G},
2027 /* i8xx */
2028 {"865G", CARD_INTEL_865G},
2029 {"845G", CARD_INTEL_845G},
2030 {"855GM", CARD_INTEL_855GM},
2031 {"830M", CARD_INTEL_830M},
2032 };
2033
2034 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2035 {
2036 if (strstr(gl_renderer, cards[i].renderer))
2037 return cards[i].id;
2038 }
2039
2040 return PCI_DEVICE_NONE;
2041 }
2042
2043 static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info,
2044 const char *gl_renderer)
2045 {
2046 unsigned int i;
2047
2048 /* 20101109 - These are never returned by current Gallium radeon
2049 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
2050 *
2051 * These are returned but not handled: RC410, RV380. */
2052 static const struct
2053 {
2054 const char *renderer;
2055 enum wined3d_pci_device id;
2056 }
2057 cards[] =
2058 {
2059 /* Southern Islands */
2060 {"TAHITI", CARD_AMD_RADEON_HD7900},
2061 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
2062 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
2063 /* Northern Islands */
2064 {"CAYMAN", CARD_AMD_RADEON_HD6900},
2065 {"BARTS", CARD_AMD_RADEON_HD6800},
2066 {"TURKS", CARD_AMD_RADEON_HD6600},
2067 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
2068 {"SUMO", CARD_AMD_RADEON_HD6550D},
2069 {"CAICOS", CARD_AMD_RADEON_HD6400},
2070 {"PALM", CARD_AMD_RADEON_HD6300},
2071 /* Evergreen */
2072 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
2073 {"CYPRESS", CARD_AMD_RADEON_HD5800},
2074 {"JUNIPER", CARD_AMD_RADEON_HD5700},
2075 {"REDWOOD", CARD_AMD_RADEON_HD5600},
2076 {"CEDAR", CARD_AMD_RADEON_HD5400},
2077 /* R700 */
2078 {"R700", CARD_AMD_RADEON_HD4800},
2079 {"RV790", CARD_AMD_RADEON_HD4800},
2080 {"RV770", CARD_AMD_RADEON_HD4800},
2081 {"RV740", CARD_AMD_RADEON_HD4700},
2082 {"RV730", CARD_AMD_RADEON_HD4600},
2083 {"RV710", CARD_AMD_RADEON_HD4350},
2084 /* R600/R700 integrated */
2085 {"RS880", CARD_AMD_RADEON_HD4200M},
2086 {"RS780", CARD_AMD_RADEON_HD3200},
2087 /* R600 */
2088 {"R680", CARD_AMD_RADEON_HD2900},
2089 {"R600", CARD_AMD_RADEON_HD2900},
2090 {"RV670", CARD_AMD_RADEON_HD2900},
2091 {"RV635", CARD_AMD_RADEON_HD2600},
2092 {"RV630", CARD_AMD_RADEON_HD2600},
2093 {"RV620", CARD_AMD_RADEON_HD2350},
2094 {"RV610", CARD_AMD_RADEON_HD2350},
2095 /* R500 */
2096 {"R580", CARD_AMD_RADEON_X1600},
2097 {"R520", CARD_AMD_RADEON_X1600},
2098 {"RV570", CARD_AMD_RADEON_X1600},
2099 {"RV560", CARD_AMD_RADEON_X1600},
2100 {"RV535", CARD_AMD_RADEON_X1600},
2101 {"RV530", CARD_AMD_RADEON_X1600},
2102 {"RV516", CARD_AMD_RADEON_X700},
2103 {"RV515", CARD_AMD_RADEON_X700},
2104 /* R400 */
2105 {"R481", CARD_AMD_RADEON_X700},
2106 {"R480", CARD_AMD_RADEON_X700},
2107 {"R430", CARD_AMD_RADEON_X700},
2108 {"R423", CARD_AMD_RADEON_X700},
2109 {"R420", CARD_AMD_RADEON_X700},
2110 {"R410", CARD_AMD_RADEON_X700},
2111 {"RV410", CARD_AMD_RADEON_X700},
2112 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
2113 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
2114 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
2115 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
2116 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
2117 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
2118 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
2119 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
2120 /* R300 */
2121 {"R360", CARD_AMD_RADEON_9500},
2122 {"R350", CARD_AMD_RADEON_9500},
2123 {"R300", CARD_AMD_RADEON_9500},
2124 {"RV370", CARD_AMD_RADEON_9500},
2125 {"RV360", CARD_AMD_RADEON_9500},
2126 {"RV351", CARD_AMD_RADEON_9500},
2127 {"RV350", CARD_AMD_RADEON_9500},
2128 };
2129
2130 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2131 {
2132 if (strstr(gl_renderer, cards[i].renderer))
2133 return cards[i].id;
2134 }
2135
2136 return PCI_DEVICE_NONE;
2137 }
2138
2139 static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
2140 const char *gl_renderer)
2141 {
2142 unsigned int i;
2143
2144 static const struct
2145 {
2146 const char *renderer;
2147 enum wined3d_pci_device id;
2148 }
2149 cards[] =
2150 {
2151 /* Kepler */
2152 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
2153 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680},
2154 /* Fermi */
2155 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
2156 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2157 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2158 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2159 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2160 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2161 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2162 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2163 /* Tesla */
2164 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2165 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2166 {"NVAA", CARD_NVIDIA_GEFORCE_8200},
2167 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2168 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2169 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2170 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2171 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2172 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2173 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2174 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2175 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2176 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2177 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2178 /* Curie */
2179 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2180 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2181 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2182 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2183 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2184 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2185 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2186 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2187 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2188 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2189 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2190 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2191 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2192 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2193 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2194 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2195 /* Rankine */
2196 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2197 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2198 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2199 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2200 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2201 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2202 /* Kelvin */
2203 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2204 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2205 {"nv20", CARD_NVIDIA_GEFORCE3},
2206 /* Celsius */
2207 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2208 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2209 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2210 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2211 {"nv16", CARD_NVIDIA_GEFORCE2},
2212 {"nv15", CARD_NVIDIA_GEFORCE2},
2213 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2214 {"nv10", CARD_NVIDIA_GEFORCE},
2215 /* Fahrenheit */
2216 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2217 {"nv04", CARD_NVIDIA_RIVA_TNT},
2218 {"nv03", CARD_NVIDIA_RIVA_128},
2219 };
2220
2221 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2222 {
2223 if (strstr(gl_renderer, cards[i].renderer))
2224 return cards[i].id;
2225 }
2226 return PCI_DEVICE_NONE;
2227 }
2228
2229 static const struct gl_vendor_selection
2230 {
2231 enum wined3d_gl_vendor gl_vendor;
2232 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2233 enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer);
2234 }
2235 nvidia_gl_vendor_table[] =
2236 {
2237 {GL_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
2238 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
2239 {GL_VENDOR_MESA, "Mesa Nouveau driver", select_card_nvidia_mesa},
2240 },
2241 amd_gl_vendor_table[] =
2242 {
2243 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", select_card_amd_binary},
2244 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", select_card_amd_binary},
2245 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", select_card_amd_mesa},
2246 },
2247 intel_gl_vendor_table[] =
2248 {
2249 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", select_card_intel},
2250 {GL_VENDOR_INTEL, "Mesa Intel driver", select_card_intel},
2251 {GL_VENDOR_MESA, "Mesa Intel driver", select_card_intel},
2252 };
2253
2254 static enum wined3d_pci_device select_card_fallback_nvidia(const struct wined3d_gl_info *gl_info)
2255 {
2256 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2257 if (d3d_level >= 10)
2258 return CARD_NVIDIA_GEFORCE_8800GTX;
2259 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
2260 return CARD_NVIDIA_GEFORCE_6800;
2261 if (d3d_level >= 9)
2262 return CARD_NVIDIA_GEFORCEFX_5800;
2263 if (d3d_level >= 8)
2264 return CARD_NVIDIA_GEFORCE3;
2265 if (d3d_level >= 7)
2266 return CARD_NVIDIA_GEFORCE;
2267 if (d3d_level >= 6)
2268 return CARD_NVIDIA_RIVA_TNT;
2269 return CARD_NVIDIA_RIVA_128;
2270 }
2271
2272 static enum wined3d_pci_device select_card_fallback_amd(const struct wined3d_gl_info *gl_info)
2273 {
2274 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2275 if (d3d_level >= 10)
2276 return CARD_AMD_RADEON_HD2900;
2277 if (d3d_level >= 9)
2278 return CARD_AMD_RADEON_9500;
2279 if (d3d_level >= 8)
2280 return CARD_AMD_RADEON_8500;
2281 if (d3d_level >= 7)
2282 return CARD_AMD_RADEON_7200;
2283 return CARD_AMD_RAGE_128PRO;
2284 }
2285
2286 static enum wined3d_pci_device select_card_fallback_intel(const struct wined3d_gl_info *gl_info)
2287 {
2288 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2289 if (d3d_level >= 10)
2290 return CARD_INTEL_G45;
2291 return CARD_INTEL_915G;
2292 }
2293
2294 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2295 unsigned int table_size, enum wined3d_gl_vendor gl_vendor,
2296 const struct wined3d_gl_info *gl_info, const char *gl_renderer)
2297 {
2298 unsigned int i;
2299
2300 for (i = 0; i < table_size; ++i)
2301 {
2302 if (table[i].gl_vendor != gl_vendor)
2303 continue;
2304
2305 TRACE("Applying card selector \"%s\".\n", table[i].description);
2306 return table[i].select_card(gl_info, gl_renderer);
2307 }
2308 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2309 gl_vendor, debugstr_a(gl_renderer));
2310
2311 return PCI_DEVICE_NONE;
2312 }
2313
2314 static const struct
2315 {
2316 enum wined3d_pci_vendor card_vendor;
2317 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2318 const struct gl_vendor_selection *gl_vendor_selection;
2319 unsigned int gl_vendor_count;
2320 enum wined3d_pci_device (*select_card_fallback)(const struct wined3d_gl_info *gl_info);
2321 }
2322 card_vendor_table[] =
2323 {
2324 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2325 sizeof(nvidia_gl_vendor_table) / sizeof(nvidia_gl_vendor_table[0]),
2326 select_card_fallback_nvidia},
2327 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2328 sizeof(amd_gl_vendor_table) / sizeof(amd_gl_vendor_table[0]),
2329 select_card_fallback_amd},
2330 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2331 sizeof(intel_gl_vendor_table) / sizeof(intel_gl_vendor_table[0]),
2332 select_card_fallback_intel},
2333 };
2334
2335
2336 static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
2337 enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2338 {
2339 /* A Direct3D device object contains the PCI id (vendor + device) of the
2340 * videocard which is used for rendering. Various applications use this
2341 * information to get a rough estimation of the features of the card and
2342 * some might use it for enabling 3d effects only on certain types of
2343 * videocards. In some cases games might even use it to work around bugs
2344 * which happen on certain videocards/driver combinations. The problem is
2345 * that OpenGL only exposes a rendering string containing the name of the
2346 * videocard and not the PCI id.
2347 *
2348 * Various games depend on the PCI id, so somehow we need to provide one.
2349 * A simple option is to parse the renderer string and translate this to
2350 * the right PCI id. This is a lot of work because there are more than 200
2351 * GPUs just for Nvidia. Various cards share the same renderer string, so
2352 * the amount of code might be 'small' but there are quite a number of
2353 * exceptions which would make this a pain to maintain. Another way would
2354 * be to query the PCI id from the operating system (assuming this is the
2355 * videocard which is used for rendering which is not always the case).
2356 * This would work but it is not very portable. Second it would not work
2357 * well in, let's say, a remote X situation in which the amount of 3d
2358 * features which can be used is limited.
2359 *
2360 * As said most games only use the PCI id to get an indication of the
2361 * capabilities of the card. It doesn't really matter if the given id is
2362 * the correct one if we return the id of a card with similar 3d features.
2363 *
2364 * The code below checks the OpenGL capabilities of a videocard and matches
2365 * that to a certain level of Direct3D functionality. Once a card passes
2366 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2367 * least a GeforceFX. To give a better estimate we do a basic check on the
2368 * renderer string but if that won't pass we return a default card. This
2369 * way is better than maintaining a full card database as even without a
2370 * full database we can return a card with similar features. Second the
2371 * size of the database can be made quite small because when you know what
2372 * type of 3d functionality a card has, you know to which GPU family the
2373 * GPU must belong. Because of this you only have to check a small part of
2374 * the renderer string to distinguishes between different models from that
2375 * family.
2376 *
2377 * The code also selects a default amount of video memory which we will
2378 * use for an estimation of the amount of free texture memory. In case of
2379 * real D3D the amount of texture memory includes video memory and system
2380 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2381 * HyperMemory). We don't know how much system memory can be addressed by
2382 * the system but we can make a reasonable estimation about the amount of
2383 * video memory. If the value is slightly wrong it doesn't matter as we
2384 * didn't include AGP-like memory which makes the amount of addressable
2385 * memory higher and second OpenGL isn't that critical it moves to system
2386 * memory behind our backs if really needed. Note that the amount of video
2387 * memory can be overruled using a registry setting. */
2388
2389 unsigned int i;
2390 enum wined3d_pci_device device;
2391
2392 for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
2393 {
2394 if (card_vendor_table[i].card_vendor != *card_vendor)
2395 continue;
2396
2397 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2398 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2399 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_info, gl_renderer);
2400 if (device != PCI_DEVICE_NONE)
2401 return device;
2402
2403 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2404 return card_vendor_table[i].select_card_fallback(gl_info);
2405 }
2406
2407 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2408 *card_vendor, debugstr_a(gl_renderer));
2409
2410 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2411 *card_vendor = HW_VENDOR_NVIDIA;
2412 return select_card_fallback_nvidia(gl_info);
2413 }
2414
2415 static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
2416 const struct wined3d_shader_backend_ops *shader_backend_ops)
2417 {
2418 if (shader_backend_ops == &glsl_shader_backend)
2419 return &glsl_vertex_pipe;
2420 return &ffp_vertex_pipe;
2421 }
2422
2423 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
2424 const struct wined3d_shader_backend_ops *shader_backend_ops)
2425 {
2426 if (shader_backend_ops == &glsl_shader_backend)
2427 return &glsl_fragment_pipe;
2428 if (shader_backend_ops == &arb_program_shader_backend && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2429 return &arbfp_fragment_pipeline;
2430 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2431 return &atifs_fragment_pipeline;
2432 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2433 return &nvts_fragment_pipeline;
2434 if (gl_info->supported[NV_REGISTER_COMBINERS])
2435 return &nvrc_fragment_pipeline;
2436 return &ffp_fragment_pipeline;
2437 }
2438
2439 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2440 {
2441 BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
2442
2443 if (glsl && gl_info->supported[ARB_FRAGMENT_SHADER])
2444 return &glsl_shader_backend;
2445 if (glsl && gl_info->supported[ARB_VERTEX_SHADER])
2446 {
2447 /* Geforce4 cards support GLSL but for vertex shaders only. Further
2448 * its reported GLSL caps are wrong. This combined with the fact that
2449 * GLSL won't offer more features or performance, use ARB shaders only
2450 * on this card. */
2451 if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2])
2452 return &arb_program_shader_backend;
2453 return &glsl_shader_backend;
2454 }
2455 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
2456 return &arb_program_shader_backend;
2457 return &none_shader_backend;
2458 }
2459
2460 static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info,
2461 const struct wined3d_shader_backend_ops *shader_backend_ops)
2462 {
2463 if ((shader_backend_ops == &glsl_shader_backend
2464 || shader_backend_ops == &arb_program_shader_backend)
2465 && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2466 return &arbfp_blit;
2467 return &ffp_blit;
2468 }
2469
2470 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2471 const struct wined3d_extension_map *map, UINT entry_count)
2472 {
2473 while (*extensions)
2474 {
2475 const char *start;
2476 size_t len;
2477 UINT i;
2478
2479 while (isspace(*extensions))
2480 ++extensions;
2481 start = extensions;
2482 while (!isspace(*extensions) && *extensions)
2483 ++extensions;
2484
2485 len = extensions - start;
2486 if (!len)
2487 continue;
2488
2489 TRACE("- %s.\n", debugstr_an(start, len));
2490
2491 for (i = 0; i < entry_count; ++i)
2492 {
2493 if (len == strlen(map[i].extension_string)
2494 && !memcmp(start, map[i].extension_string, len))
2495 {
2496 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2497 gl_info->supported[map[i].extension] = TRUE;
2498 break;
2499 }
2500 }
2501 }
2502 }
2503
2504 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2505 {
2506 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2507 GL_EXT_FUNCS_GEN;
2508 #undef USE_GL_FUNC
2509
2510 #ifndef USE_WIN32_OPENGL
2511 /* hack: use the functions directly from the TEB table to bypass the thunks */
2512 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2513 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
2514 #endif
2515 }
2516
2517 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
2518 {
2519 GLfloat gl_floatv[2];
2520 GLint gl_max;
2521
2522 gl_info->limits.blends = 1;
2523 gl_info->limits.buffers = 1;
2524 gl_info->limits.textures = 1;
2525 gl_info->limits.texture_coords = 1;
2526 gl_info->limits.fragment_samplers = 1;
2527 gl_info->limits.vertex_samplers = 0;
2528 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
2529 gl_info->limits.vertex_attribs = 16;
2530 gl_info->limits.glsl_vs_float_constants = 0;
2531 gl_info->limits.glsl_ps_float_constants = 0;
2532 gl_info->limits.arb_vs_float_constants = 0;
2533 gl_info->limits.arb_vs_native_constants = 0;
2534 gl_info->limits.arb_vs_instructions = 0;
2535 gl_info->limits.arb_vs_temps = 0;
2536 gl_info->limits.arb_ps_float_constants = 0;
2537 gl_info->limits.arb_ps_local_constants = 0;
2538 gl_info->limits.arb_ps_instructions = 0;
2539 gl_info->limits.arb_ps_temps = 0;
2540
2541 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
2542 gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
2543 TRACE("Clip plane support - max planes %d.\n", gl_max);
2544
2545 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
2546 gl_info->limits.lights = gl_max;
2547 TRACE("Light support - max lights %d.\n", gl_max);
2548
2549 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
2550 gl_info->limits.texture_size = gl_max;
2551 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
2552
2553 gl_info->gl_ops.gl.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
2554 gl_info->limits.pointsize_min = gl_floatv[0];
2555 gl_info->limits.pointsize_max = gl_floatv[1];
2556 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
2557
2558 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
2559 {
2560 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
2561 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
2562 }
2563 else
2564 {
2565 WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2566 }
2567 if (gl_info->supported[NV_REGISTER_COMBINERS])
2568 {
2569 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
2570 gl_info->limits.general_combiners = gl_max;
2571 TRACE("Max general combiners: %d.\n", gl_max);
2572 }
2573 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2574 {
2575 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
2576 gl_info->limits.buffers = gl_max;
2577 TRACE("Max draw buffers: %u.\n", gl_max);
2578 }
2579 if (gl_info->supported[ARB_MULTITEXTURE])
2580 {
2581 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
2582 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
2583 TRACE("Max textures: %d.\n", gl_info->limits.textures);
2584
2585 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2586 {
2587 GLint tmp;
2588 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
2589 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
2590 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2591 gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
2592 }
2593 else
2594 {
2595 gl_info->limits.texture_coords = max(gl_info->limits.texture_coords, gl_max);
2596 gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, gl_max);
2597 }
2598 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
2599 TRACE("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
2600
2601 if (gl_info->supported[ARB_VERTEX_SHADER])
2602 {
2603 GLint tmp;
2604 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2605 gl_info->limits.vertex_samplers = tmp;
2606 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2607 gl_info->limits.combined_samplers = tmp;
2608 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &tmp);
2609 gl_info->limits.vertex_attribs = tmp;
2610
2611 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2612 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2613 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2614 * shader is used with fixed function vertex processing we're fine too because fixed function
2615 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2616 * used we have to make sure that all vertex sampler setups are valid together with all
2617 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2618 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2619 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2620 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2621 * a fixed function pipeline anymore.
2622 *
2623 * So this is just a check to check that our assumption holds true. If not, write a warning
2624 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2625 if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
2626 && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
2627 {
2628 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2629 gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
2630 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2631 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
2632 gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
2633 else
2634 gl_info->limits.vertex_samplers = 0;
2635 }
2636 }
2637 else
2638 {
2639 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
2640 }
2641 TRACE("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
2642 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
2643 }
2644 if (gl_info->supported[ARB_VERTEX_BLEND])
2645 {
2646 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
2647 gl_info->limits.blends = gl_max;
2648 TRACE("Max blends: %u.\n", gl_info->limits.blends);
2649 }
2650 if (gl_info->supported[EXT_TEXTURE3D])
2651 {
2652 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
2653 gl_info->limits.texture3d_size = gl_max;
2654 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
2655 }
2656 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
2657 {
2658 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
2659 gl_info->limits.anisotropy = gl_max;
2660 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
2661 }
2662 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2663 {
2664 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2665 gl_info->limits.arb_ps_float_constants = gl_max;
2666 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
2667 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2668 gl_info->limits.arb_ps_native_constants = gl_max;
2669 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2670 gl_info->limits.arb_ps_native_constants);
2671 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2672 gl_info->limits.arb_ps_temps = gl_max;
2673 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
2674 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2675 gl_info->limits.arb_ps_instructions = gl_max;
2676 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
2677 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
2678 gl_info->limits.arb_ps_local_constants = gl_max;
2679 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
2680 }
2681 if (gl_info->supported[ARB_VERTEX_PROGRAM])
2682 {
2683 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2684 gl_info->limits.arb_vs_float_constants = gl_max;
2685 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
2686 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2687 gl_info->limits.arb_vs_native_constants = gl_max;
2688 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2689 gl_info->limits.arb_vs_native_constants);
2690 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2691 gl_info->limits.arb_vs_temps = gl_max;
2692 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
2693 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2694 gl_info->limits.arb_vs_instructions = gl_max;
2695 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
2696 }
2697 if (gl_info->supported[ARB_VERTEX_SHADER])
2698 {
2699 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
2700 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
2701 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
2702 }
2703 if (gl_info->supported[ARB_FRAGMENT_SHADER])
2704 {
2705 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
2706 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
2707 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
2708 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
2709 gl_info->limits.glsl_varyings = gl_max;
2710 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
2711 }
2712
2713 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
2714 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
2715 else
2716 gl_info->limits.shininess = 128.0f;
2717
2718 if ((gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2719 && wined3d_settings.allow_multisampling)
2720 {
2721 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
2722 gl_info->limits.samples = gl_max;
2723 }
2724 }
2725
2726 /* Context activation is done by the caller. */
2727 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
2728 {
2729 struct wined3d_driver_info *driver_info = &adapter->driver_info;
2730 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
2731 struct wined3d_gl_info *gl_info = &adapter->gl_info;
2732 struct wined3d_vertex_caps vertex_caps;
2733 enum wined3d_pci_vendor card_vendor;
2734 struct fragment_caps fragment_caps;
2735 struct shader_caps shader_caps;
2736 const char *WGL_Extensions = NULL;
2737 const char *GL_Extensions = NULL;
2738 enum wined3d_gl_vendor gl_vendor;
2739 enum wined3d_pci_device device;
2740 DWORD gl_version;
2741 HDC hdc;
2742 unsigned int i;
2743
2744 TRACE("adapter %p.\n", adapter);
2745
2746 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
2747 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
2748 if (!gl_renderer_str)
2749 {
2750 ERR("Received a NULL GL_RENDERER.\n");
2751 return FALSE;
2752 }
2753
2754 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
2755 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
2756 if (!gl_vendor_str)
2757 {