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