VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/directx.c@ 59741

最後變更 在這個檔案從59741是 57933,由 vboxsync 提交於 9 年 前

Devices/Graphics: fixed wrong comparison between gl_vendor and HW_VENDOR_XYZ (must be GL_VENDOR_XYZ)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 117.0 KB
 
1/*
2 * IWineD3D implementation
3 *
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 * Copyright 2005 Oliver Stieber
8 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
9 * Copyright 2009 Henri Verbeet for CodeWeavers
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26/*
27 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
28 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
29 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
30 * a choice of LGPL license versions is made available with the language indicating
31 * that LGPLv2 or any later version may be used, or where a choice of which version
32 * of the LGPL is applied is otherwise unspecified.
33 */
34
35#include "config.h"
36#include <stdio.h>
37#include "wined3d_private.h"
38
39#ifdef VBOX_WITH_WDDM
40# include <VBox/VBoxCrHgsmi.h>
41#endif
42
43#ifdef VBOX_WITH_VMSVGA
44# ifdef RT_OS_WINDOWS
45DECLIMPORT(void) APIENTRY glFinish(void);
46# else
47void glFinish(void);
48# endif
49#endif
50
51WINE_DEFAULT_DEBUG_CHANNEL(d3d);
52WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
53
54#define GLINFO_LOCATION (*gl_info)
55#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
56
57/* The d3d device ID */
58static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
59
60
61/* Extension detection */
62static const struct {
63 const char *extension_string;
64 GL_SupportedExt extension;
65 DWORD version;
66} EXTENSION_MAP[] = {
67 /* APPLE */
68 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 },
69 {"GL_APPLE_fence", APPLE_FENCE, 0 },
70 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 },
71 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE, 0 },
72 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 },
73 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 },
74
75 /* ARB */
76 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 },
77 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT, 0 },
78 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP, 0 },
79 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE, 0 },
80 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS, 0 },
81 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM, 0 },
82 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER, 0 },
83 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 },
84 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 },
85 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 },
86 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 },
87 {"GL_ARB_imaging", ARB_IMAGING, 0 },
88 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 },
89 {"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
90 {"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 },
91 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 },
92 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT, 0 },
93 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 },
94 {"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 },
95 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 },
96 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 },
97 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 },
98 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100, 0 },
99 {"GL_ARB_sync", ARB_SYNC, 0 },
100 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 },
101 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 },
102 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 },
103 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD, 0 },
104 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE, 0 },
105 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3, 0 },
106 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT, 0 },
107 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
108 {"GL_IBM_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
109 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) },
110 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 },
111 {"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 },
112 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA, 0 },
113 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 },
114 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 },
115 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 },
116 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 },
117
118 /* ATI */
119 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 },
120 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 },
121 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 },
122 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 },
123 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 },
124
125 /* EXT */
126 {"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 },
127 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 },
128 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 },
129 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 },
130 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2, 0 },
131 {"GL_EXT_fog_coord", EXT_FOG_COORD, 0 },
132 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 },
133 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 },
134 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 },
135 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 },
136 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4, 0 },
137 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 },
138 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 },
139 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 },
140 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX, 0 },
141 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR, 0 },
142 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 },
143 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 },
144 {"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) },
145 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 },
146 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 },
147 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 },
148 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 },
149 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 },
150 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
151 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
152 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
153 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
154
155 /* NV */
156 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 },
157 {"GL_NV_fence", NV_FENCE, 0 },
158 {"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 },
159 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 },
160 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 },
161 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 },
162 {"GL_NV_half_float", NV_HALF_FLOAT, 0 },
163 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 },
164 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 },
165 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 },
166 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 },
167 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 },
168 {"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 },
169 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 },
170 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 },
171 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 },
172 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 },
173 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 },
174 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 },
175
176 /* SGI */
177 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 },
178};
179
180/**********************************************************
181 * Utility functions follow
182 **********************************************************/
183
184const struct min_lookup minMipLookup[] =
185{
186 /* NONE POINT LINEAR */
187 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
188 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
189 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
190};
191
192const struct min_lookup minMipLookup_noFilter[] =
193{
194 /* NONE POINT LINEAR */
195 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
196 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
197 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
198};
199
200const struct min_lookup minMipLookup_noMip[] =
201{
202 /* NONE POINT LINEAR */
203 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
204 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
205 {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
206};
207
208const GLenum magLookup[] =
209{
210 /* NONE POINT LINEAR */
211 GL_NEAREST, GL_NEAREST, GL_LINEAR,
212};
213
214const GLenum magLookup_noFilter[] =
215{
216 /* NONE POINT LINEAR */
217 GL_NEAREST, GL_NEAREST, GL_NEAREST,
218};
219
220/* drawStridedSlow attributes */
221glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
222glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
223glAttribFunc specular_func_3ubv;
224glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
225glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
226glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
227
228
229/**********************************************************
230 * IWineD3D parts follows
231 **********************************************************/
232
233/* GL locking is done by the caller */
234static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
235{
236 GLuint prog;
237 BOOL ret = FALSE;
238 const char *testcode =
239 "!!ARBvp1.0\n"
240 "PARAM C[66] = { program.env[0..65] };\n"
241 "ADDRESS A0;"
242 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
243 "ARL A0.x, zero.x;\n"
244 "MOV result.position, C[A0.x + 65];\n"
245 "END\n";
246
247 while(glGetError());
248 GL_EXTCALL(glGenProgramsARB(1, &prog));
249 if(!prog) {
250 ERR("Failed to create an ARB offset limit test program\n");
251 }
252 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
253 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
254 strlen(testcode), testcode));
255 if(glGetError() != 0) {
256 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
257 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
258 ret = TRUE;
259 } else TRACE("OpenGL implementation allows offsets > 63\n");
260
261 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
262 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
263 checkGLcall("ARB vp offset limit test cleanup");
264
265 return ret;
266}
267
268static DWORD ver_for_ext(GL_SupportedExt ext)
269{
270 unsigned int i;
271 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i) {
272 if(EXTENSION_MAP[i].extension == ext) {
273 return EXTENSION_MAP[i].version;
274 }
275 }
276 return 0;
277}
278
279static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
280 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
281{
282 if (card_vendor != HW_VENDOR_ATI) return FALSE;
283 if (device == CARD_ATI_RADEON_9500) return TRUE;
284 if (device == CARD_ATI_RADEON_X700) return TRUE;
285 if (device == CARD_ATI_RADEON_X1600) return TRUE;
286 return FALSE;
287}
288
289static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
290 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
291{
292 if (card_vendor == HW_VENDOR_NVIDIA)
293 {
294 if (device == CARD_NVIDIA_GEFORCEFX_5800 || device == CARD_NVIDIA_GEFORCEFX_5600)
295 {
296 return TRUE;
297 }
298 }
299 return FALSE;
300}
301
302static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
303 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
304{
305 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
306 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
307 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
308 *
309 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
310 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
311 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
312 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
313 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
314 * the chance that other implementations support them is rather small since Win32 QuickTime uses
315 * DirectDraw, not OpenGL.
316 *
317 * This test has been moved into wined3d_guess_gl_vendor()
318 */
319 if (gl_vendor == GL_VENDOR_APPLE)
320 {
321 return TRUE;
322 }
323 return FALSE;
324}
325
326/* Context activation is done by the caller. */
327static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
328{
329 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
330 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
331 * all the texture. This function detects this bug by its symptom and disables PBOs
332 * if the test fails.
333 *
334 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
335 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
336 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
337 * read back is compared to the original. If they are equal PBOs are assumed to work,
338 * otherwise the PBO extension is disabled. */
339 GLuint texture, pbo;
340 static const unsigned int pattern[] =
341 {
342 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
343 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
344 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
345 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
346 };
347 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
348
349 /* No PBO -> No point in testing them. */
350 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
351
352 ENTER_GL();
353
354 while (glGetError());
355 glGenTextures(1, &texture);
356 glBindTexture(GL_TEXTURE_2D, texture);
357
358 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
359 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
360 checkGLcall("Specifying the PBO test texture");
361
362 GL_EXTCALL(glGenBuffersARB(1, &pbo));
363 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
364 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
365 checkGLcall("Specifying the PBO test pbo");
366
367 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
368 checkGLcall("Loading the PBO test texture");
369
370 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
371#ifdef VBOX_WITH_VMSVGA
372 glFinish();
373#else
374 wglFinish(); /* just to be sure */
375#endif
376 memset(check, 0, sizeof(check));
377 glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
378 checkGLcall("Reading back the PBO test texture");
379
380 glDeleteTextures(1, &texture);
381 GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
382 checkGLcall("PBO test cleanup");
383
384 LEAVE_GL();
385
386 if (memcmp(check, pattern, sizeof(check)))
387 {
388 WARN_(d3d_caps)("PBO test failed, read back data doesn't match original.\n");
389 WARN_(d3d_caps)("Disabling PBOs. This may result in slower performance.\n");
390 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
391 }
392 else
393 {
394 TRACE_(d3d_caps)("PBO test successful.\n");
395 }
396}
397
398static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
399 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
400{
401 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
402}
403
404static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
405 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
406{
407 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
408 if (card_vendor != HW_VENDOR_ATI) return FALSE;
409 if (device == CARD_ATI_RADEON_X1600) return FALSE;
410 return TRUE;
411}
412
413static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
414 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
415{
416 return gl_vendor == GL_VENDOR_FGLRX;
417
418}
419
420static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
421 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
422{
423 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
424 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
425 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
426 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
427 * hardcoded
428 *
429 * dx10 cards usually have 64 varyings */
430 return gl_info->limits.glsl_varyings > 44;
431}
432
433/* A GL context is provided by the caller */
434static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
435 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
436{
437 GLenum error;
438 DWORD data[16];
439
440 if (!gl_info->supported[EXT_SECONDARY_COLOR]) return FALSE;
441
442 ENTER_GL();
443 while(glGetError());
444 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
445 error = glGetError();
446 LEAVE_GL();
447
448 if(error == GL_NO_ERROR)
449 {
450 TRACE("GL Implementation accepts 4 component specular color pointers\n");
451 return TRUE;
452 }
453 else
454 {
455 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
456 debug_glerror(error));
457 return FALSE;
458 }
459}
460
461static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
462 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
463{
464 if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE;
465 return gl_info->supported[NV_TEXTURE_SHADER];
466}
467
468/* A GL context is provided by the caller */
469static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
470 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
471{
472 GLuint prog;
473 BOOL ret = FALSE;
474 GLint pos;
475 const char *testcode =
476 "!!ARBvp1.0\n"
477 "OPTION NV_vertex_program2;\n"
478 "MOV result.clip[0], 0.0;\n"
479 "MOV result.position, 0.0;\n"
480 "END\n";
481
482 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
483
484 ENTER_GL();
485 while(glGetError());
486
487 GL_EXTCALL(glGenProgramsARB(1, &prog));
488 if(!prog)
489 {
490 ERR("Failed to create the NVvp clip test program\n");
491 LEAVE_GL();
492 return FALSE;
493 }
494 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
495 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
496 strlen(testcode), testcode));
497 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
498 if(pos != -1)
499 {
500 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
501 TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
502 ret = TRUE;
503 while(glGetError());
504 }
505 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
506
507 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
508 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
509 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
510
511 LEAVE_GL();
512 return ret;
513}
514
515/* Context activation is done by the caller. */
516static BOOL match_fbo_tex_update(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 char data[4 * 4 * 4];
520 GLuint tex, fbo;
521 GLenum status;
522
523#ifndef VBOX_WITH_VMSVGA
524 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
525#endif
526 memset(data, 0xcc, sizeof(data));
527
528 ENTER_GL();
529
530 glGenTextures(1, &tex);
531 glBindTexture(GL_TEXTURE_2D, tex);
532 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
533 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
534 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
535 checkGLcall("glTexImage2D");
536
537 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
538 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
539 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
540 checkGLcall("glFramebufferTexture2D");
541
542 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
543 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
544 checkGLcall("glCheckFramebufferStatus");
545
546 memset(data, 0x11, sizeof(data));
547 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
548 checkGLcall("glTexSubImage2D");
549
550 glClearColor(0.996, 0.729, 0.745, 0.792);
551 glClear(GL_COLOR_BUFFER_BIT);
552 checkGLcall("glClear");
553
554 glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
555 checkGLcall("glGetTexImage");
556
557 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
558 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
559 glBindTexture(GL_TEXTURE_2D, 0);
560 checkGLcall("glBindTexture");
561
562 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
563 glDeleteTextures(1, &tex);
564 checkGLcall("glDeleteTextures");
565
566 LEAVE_GL();
567
568 return *(DWORD *)data == 0x11111111;
569}
570
571static void quirk_arb_constants(struct wined3d_gl_info *gl_info)
572{
573 TRACE_(d3d_caps)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info->limits.arb_vs_native_constants);
574 gl_info->limits.glsl_vs_float_constants = gl_info->limits.arb_vs_native_constants;
575 TRACE_(d3d_caps)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info->limits.arb_ps_native_constants);
576 gl_info->limits.glsl_ps_float_constants = gl_info->limits.arb_ps_native_constants;
577}
578
579static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
580{
581 quirk_arb_constants(gl_info);
582 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
583 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
584 * allow 48 different offsets or other helper immediate values. */
585 TRACE_(d3d_caps)("Reserving 12 GLSL constants for compiler private use.\n");
586 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
587}
588
589/* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
590 * on more than one texture unit. This means that the d3d9 visual point size test will cause a
591 * kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
592 * quirk only enables point sprites on the first texture unit. This keeps point sprites working in
593 * most games, but avoids the crash
594 *
595 * A more sophisticated way would be to find all units that need texture coordinates and enable
596 * point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
597 * if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
598 *
599 * Note that disabling the extension entirely does not gain predictability because there is no point
600 * sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
601static void quirk_one_point_sprite(struct wined3d_gl_info *gl_info)
602{
603 if (gl_info->supported[ARB_POINT_SPRITE])
604 {
605 TRACE("Limiting point sprites to one texture unit.\n");
606 gl_info->limits.point_sprite_units = 1;
607 }
608}
609
610static void quirk_ati_dx9(struct wined3d_gl_info *gl_info)
611{
612 quirk_arb_constants(gl_info);
613
614 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
615 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
616 * If real NP2 textures are used, the driver falls back to software. We could just remove the
617 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
618 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
619 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
620 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
621 *
622 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
623 * has this extension promoted to core. The extension loading code sets this extension supported
624 * due to that, so this code works on fglrx as well. */
625 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
626 {
627 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
628 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
629 gl_info->supported[WINE_NORMALIZED_TEXRECT] = TRUE;
630 }
631
632 /* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
633 * it is generally more efficient. Reserve just 8 constants. */
634 TRACE_(d3d_caps)("Reserving 8 GLSL constants for compiler private use.\n");
635 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 8);
636}
637
638static void quirk_no_np2(struct wined3d_gl_info *gl_info)
639{
640 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
641 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
642 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
643 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
644 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
645 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
646 *
647 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
648 * triggering the software fallback. There is not much we can do here apart from disabling the
649 * software-emulated extension and reenable ARB_tex_rect (which was previously disabled
650 * in IWineD3DImpl_FillGLCaps).
651 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
652 * post-processing effects in the game "Max Payne 2").
653 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
654 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
655 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
656 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
657}
658
659static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
660{
661 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
662 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
663 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
664 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
665 * according to the spec.
666 *
667 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
668 * makes the shader slower and eats instruction slots which should be available to the d3d app.
669 *
670 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
671 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
672 * this workaround is activated on cards that do not need it, it won't break things, just affect
673 * performance negatively. */
674 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
675 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
676}
677
678static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
679{
680 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
681}
682
683static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
684{
685 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
686}
687
688static void quirk_apple_nvts(struct wined3d_gl_info *gl_info)
689{
690 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
691 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
692}
693
694static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
695{
696 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
697}
698
699static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
700{
701 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
702}
703
704static BOOL match_ati_hd4800(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
705 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
706{
707 if (card_vendor != HW_VENDOR_ATI) return FALSE;
708 if (device == CARD_ATI_RADEON_HD4800) return TRUE;
709 return FALSE;
710}
711
712static void quirk_fullsize_blit(struct wined3d_gl_info *gl_info)
713{
714 gl_info->quirks |= WINED3D_QUIRK_FULLSIZE_BLIT;
715}
716
717#ifdef VBOX_WITH_WDDM
718static BOOL match_mesa_nvidia(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
719 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
720{
721 if (card_vendor != HW_VENDOR_NVIDIA) return FALSE;
722 if (gl_vendor != GL_VENDOR_MESA) return FALSE;
723 return TRUE;
724}
725
726static void quirk_no_shader_3(struct wined3d_gl_info *gl_info)
727{
728 int vs_selected_mode, ps_selected_mode;
729 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
730 if (vs_selected_mode != SHADER_GLSL && ps_selected_mode != SHADER_GLSL)
731 return;
732
733 gl_info->limits.arb_ps_instructions = 512;
734}
735#endif
736
737static BOOL match_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
738 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
739{
740 if (card_vendor == HW_VENDOR_INTEL) return TRUE;
741 if (gl_vendor == GL_VENDOR_INTEL) return TRUE;
742 return FALSE;
743}
744
745static void quirk_force_blit(struct wined3d_gl_info *gl_info)
746{
747 gl_info->quirks |= WINED3D_QUIRK_FORCE_BLIT;
748}
749
750struct driver_quirk
751{
752 BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
753 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
754 void (*apply)(struct wined3d_gl_info *gl_info);
755 const char *description;
756};
757
758static const struct driver_quirk quirk_table[] =
759{
760 {
761 match_ati_r300_to_500,
762 quirk_ati_dx9,
763 "ATI GLSL constant and normalized texrect quirk"
764 },
765 /* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
766 * used it falls back to software. While the compiler can detect if the shader uses all declared
767 * uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
768 * using relative addressing falls back to software.
769 *
770 * ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
771 {
772 match_apple,
773 quirk_apple_glsl_constants,
774 "Apple GLSL uniform override"
775 },
776 {
777 match_geforce5,
778 quirk_no_np2,
779 "Geforce 5 NP2 disable"
780 },
781 {
782 match_apple_intel,
783 quirk_texcoord_w,
784 "Init texcoord .w for Apple Intel GPU driver"
785 },
786 {
787 match_apple_nonr500ati,
788 quirk_texcoord_w,
789 "Init texcoord .w for Apple ATI >= r600 GPU driver"
790 },
791 {
792 match_fglrx,
793 quirk_one_point_sprite,
794 "Fglrx point sprite crash workaround"
795 },
796 {
797 match_dx10_capable,
798 quirk_clip_varying,
799 "Reserved varying for gl_ClipPos"
800 },
801 {
802 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
803 * GL implementations accept it. The Mac GL is the only implementation known to
804 * reject it.
805 *
806 * If we can pass 4 component specular colors, do it, because (a) we don't have
807 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
808 * passes specular alpha to the pixel shader if any is used. Otherwise the
809 * specular alpha is used to pass the fog coordinate, which we pass to opengl
810 * via GL_EXT_fog_coord.
811 */
812 match_allows_spec_alpha,
813 quirk_allows_specular_alpha,
814 "Allow specular alpha quirk"
815 },
816 {
817 /* The pixel formats provided by GL_NV_texture_shader are broken on OSX
818 * (rdar://5682521).
819 */
820 match_apple_nvts,
821 quirk_apple_nvts,
822 "Apple NV_texture_shader disable"
823 },
824#ifndef VBOX_WITH_VMSVGA
825 {
826 match_broken_nv_clip,
827 quirk_disable_nvvp_clip,
828 "Apple NV_vertex_program clip bug quirk"
829 },
830#endif
831 {
832 match_fbo_tex_update,
833 quirk_fbo_tex_update,
834 "FBO rebind for attachment updates"
835 },
836 {
837 match_ati_hd4800,
838 quirk_fullsize_blit,
839 "Fullsize blit"
840 },
841#ifdef VBOX_WITH_WDDM
842 {
843 match_mesa_nvidia,
844 quirk_no_shader_3,
845 "disable shader 3 support"
846 },
847#endif
848 {
849 match_intel,
850 quirk_force_blit,
851 "force framebuffer blit when possible"
852 }
853};
854
855/* Context activation is done by the caller. */
856static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
857 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
858{
859 unsigned int i;
860
861 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
862 {
863 if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
864 TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description);
865 quirk_table[i].apply(gl_info);
866 }
867
868 /* Find out if PBOs work as they are supposed to. */
869 test_pbo_functionality(gl_info);
870}
871
872
873/* Certain applications (Steam) complain if we report an outdated driver version. In general,
874 * reporting a driver version is moot because we are not the Windows driver, and we have different
875 * bugs, features, etc.
876 *
877 * The driver version has the form "x.y.z.w".
878 *
879 * "x" is the Windows version the driver is meant for:
880 * 4 -> 95/98/NT4
881 * 5 -> 2000
882 * 6 -> 2000/XP
883 * 7 -> Vista
884 * 8 -> Win 7
885 *
886 * "y" is the Direct3D level the driver supports:
887 * 11 -> d3d6
888 * 12 -> d3d7
889 * 13 -> d3d8
890 * 14 -> d3d9
891 * 15 -> d3d10
892 *
893 * "z" is unknown, possibly vendor specific.
894 *
895 * "w" is the vendor specific driver version.
896 */
897struct driver_version_information
898{
899 WORD vendor; /* reported PCI card vendor ID */
900 WORD card; /* reported PCI card device ID */
901 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
902 WORD d3d_level; /* driver hiword to report */
903 WORD lopart_hi, lopart_lo; /* driver loword to report */
904};
905
906static const struct driver_version_information driver_version_table[] =
907{
908 /* Nvidia drivers. Geforce6 and newer cards are supported by the current driver (180.x)
909 * GeforceFX support is up to 173.x, - driver uses numbering x.y.11.7341 for 173.41 where x is the windows revision (6=2000/xp, 7=vista), y is unknown
910 * Geforce2MX/3/4 up to 96.x - driver uses numbering 9.6.8.9 for 96.89
911 * TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86
912 *
913 * All version numbers used below are from the Linux nvidia drivers. */
914 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 },
915 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 },
916 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 },
917 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 },
918 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 },
919 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 },
920 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 },
921 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 },
922 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 },
923 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 },
924 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 },
925 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 },
926 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 },
927 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 },
928 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 },
929 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 },
930 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 },
931 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 },
932 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 },
933 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 },
934 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 },
935 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 },
936 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 },
937 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 },
938 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 },
939 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 },
940 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 },
941 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 },
942 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 },
943 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 },
944 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 },
945
946 /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */
947 {HW_VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 },
948 {HW_VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 },
949 {HW_VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 },
950 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2350, "ATI Mobility Radeon HD 2350", 14, 10, 6764 },
951 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 },
952 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 },
953 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 },
954 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 },
955 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 },
956 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 },
957 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 },
958 {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 },
959
960 /* TODO: Add information about legacy ATI hardware, Intel and other cards. */
961};
962
963
964static DWORD wined3d_parse_gl_version(const char *gl_version)
965{
966 const char *ptr = gl_version;
967 int major, minor;
968
969 major = atoi(ptr);
970 if (major <= 0) ERR_(d3d_caps)("Invalid opengl major version: %d.\n", major);
971
972 while (isdigit(*ptr)) ++ptr;
973 if (*ptr++ != '.') ERR_(d3d_caps)("Invalid opengl version string: %s.\n", debugstr_a(gl_version));
974
975 minor = atoi(ptr);
976
977 TRACE_(d3d_caps)("Found OpenGL version: %d.%d.\n", major, minor);
978
979 return MAKEDWORD_VERSION(major, minor);
980}
981
982static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl_info, const char *gl_vendor_string, const char *gl_renderer)
983{
984
985 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
986 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
987 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
988 *
989 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
990 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
991 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
992 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
993 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
994 * the chance that other implementations support them is rather small since Win32 QuickTime uses
995 * DirectDraw, not OpenGL. */
996 if (gl_info->supported[APPLE_FENCE]
997 && gl_info->supported[APPLE_CLIENT_STORAGE]
998 && gl_info->supported[APPLE_FLUSH_RENDER]
999 && gl_info->supported[APPLE_YCBCR_422])
1000 return GL_VENDOR_APPLE;
1001
1002 if (strstr(gl_vendor_string, "NVIDIA"))
1003 return GL_VENDOR_NVIDIA;
1004
1005 if (strstr(gl_vendor_string, "ATI"))
1006 return GL_VENDOR_FGLRX;
1007
1008 if (strstr(gl_vendor_string, "Intel(R)")
1009 || strstr(gl_renderer, "Intel(R)")
1010 || strstr(gl_vendor_string, "Intel Inc."))
1011 {
1012 if (strstr(gl_renderer, "Mesa"))
1013 return GL_VENDOR_MESA;
1014 return GL_VENDOR_INTEL;
1015 }
1016
1017 if (strstr(gl_vendor_string, "Mesa")
1018 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1019 || strstr(gl_vendor_string, "DRI R300 Project")
1020 || strstr(gl_vendor_string, "X.Org R300 Project")
1021 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1022 || strstr(gl_vendor_string, "VMware, Inc.")
1023 || strstr(gl_renderer, "Mesa")
1024 || strstr(gl_renderer, "Gallium"))
1025 return GL_VENDOR_MESA;
1026
1027 FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1028 debugstr_a(gl_vendor_string));
1029
1030 return GL_VENDOR_UNKNOWN;
1031}
1032
1033static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1034{
1035 if (strstr(gl_vendor_string, "NVIDIA"))
1036 return HW_VENDOR_NVIDIA;
1037
1038 if (strstr(gl_vendor_string, "ATI")
1039 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1040 || strstr(gl_vendor_string, "X.Org R300 Project")
1041 || strstr(gl_vendor_string, "DRI R300 Project"))
1042 return HW_VENDOR_ATI;
1043
1044 if (strstr(gl_vendor_string, "Intel(R)")
1045 || strstr(gl_renderer, "Intel(R)")
1046 || strstr(gl_vendor_string, "Intel Inc."))
1047 return HW_VENDOR_INTEL;
1048
1049 if (strstr(gl_vendor_string, "Mesa")
1050 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1051 || strstr(gl_vendor_string, "VMware, Inc."))
1052 return HW_VENDOR_SOFTWARE;
1053
1054 FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1055
1056 return HW_VENDOR_NVIDIA;
1057}
1058
1059
1060
1061static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
1062 const char *gl_renderer, unsigned int *vidmem)
1063{
1064#ifndef VBOX_WITH_WDDM
1065 if (WINE_D3D10_CAPABLE(gl_info))
1066#endif
1067 {
1068 /* Geforce 200 - highend */
1069 if (strstr(gl_renderer, "GTX 280")
1070 || strstr(gl_renderer, "GTX 285")
1071 || strstr(gl_renderer, "GTX 295"))
1072 {
1073 *vidmem = 1024;
1074 return CARD_NVIDIA_GEFORCE_GTX280;
1075 }
1076
1077 /* Geforce 200 - midend high */
1078 if (strstr(gl_renderer, "GTX 275"))
1079 {
1080 *vidmem = 896;
1081 return CARD_NVIDIA_GEFORCE_GTX275;
1082 }
1083
1084 /* Geforce 200 - midend */
1085 if (strstr(gl_renderer, "GTX 260"))
1086 {
1087 *vidmem = 1024;
1088 return CARD_NVIDIA_GEFORCE_GTX260;
1089 }
1090 /* Geforce 200 - midend */
1091 if (strstr(gl_renderer, "GT 240"))
1092 {
1093 *vidmem = 512;
1094 return CARD_NVIDIA_GEFORCE_GT240;
1095 }
1096
1097 /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
1098 if (strstr(gl_renderer, "9800")
1099 || strstr(gl_renderer, "GTS 150")
1100 || strstr(gl_renderer, "GTS 250"))
1101 {
1102 *vidmem = 512;
1103 return CARD_NVIDIA_GEFORCE_9800GT;
1104 }
1105
1106 /* Geforce9 - midend */
1107 if (strstr(gl_renderer, "9600"))
1108 {
1109 *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
1110 return CARD_NVIDIA_GEFORCE_9600GT;
1111 }
1112
1113 /* Geforce9 - midend low / Geforce 200 - low */
1114 if (strstr(gl_renderer, "9500")
1115 || strstr(gl_renderer, "GT 120")
1116 || strstr(gl_renderer, "GT 130"))
1117 {
1118 *vidmem = 256; /* The 9500GT has 256-1024MB */
1119 return CARD_NVIDIA_GEFORCE_9500GT;
1120 }
1121
1122 /* Geforce9 - lowend */
1123 if (strstr(gl_renderer, "9400"))
1124 {
1125 *vidmem = 256; /* The 9400GT has 256-1024MB */
1126 return CARD_NVIDIA_GEFORCE_9400GT;
1127 }
1128
1129 /* Geforce9 - lowend low */
1130 if (strstr(gl_renderer, "9100")
1131 || strstr(gl_renderer, "9200")
1132 || strstr(gl_renderer, "9300")
1133 || strstr(gl_renderer, "G 100"))
1134 {
1135 *vidmem = 256; /* The 9100-9300 cards have 256MB */
1136 return CARD_NVIDIA_GEFORCE_9200;
1137 }
1138
1139 /* Geforce8 - highend */
1140 if (strstr(gl_renderer, "8800"))
1141 {
1142 *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
1143 return CARD_NVIDIA_GEFORCE_8800GTS;
1144 }
1145
1146 /* Geforce8 - midend mobile */
1147 if (strstr(gl_renderer, "8600 M"))
1148 {
1149 *vidmem = 512;
1150 return CARD_NVIDIA_GEFORCE_8600MGT;
1151 }
1152
1153 /* Geforce8 - midend */
1154 if (strstr(gl_renderer, "8600")
1155 || strstr(gl_renderer, "8700"))
1156 {
1157 *vidmem = 256;
1158 return CARD_NVIDIA_GEFORCE_8600GT;
1159 }
1160
1161 /* Geforce8 - lowend */
1162 if (strstr(gl_renderer, "8100")
1163 || strstr(gl_renderer, "8200")
1164 || strstr(gl_renderer, "8300")
1165 || strstr(gl_renderer, "8400")
1166 || strstr(gl_renderer, "8500"))
1167 {
1168 *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
1169 return CARD_NVIDIA_GEFORCE_8300GS;
1170 }
1171
1172 /* Geforce8-compatible fall back if the GPU is not in the list yet */
1173 *vidmem = 128;
1174 return CARD_NVIDIA_GEFORCE_8300GS;
1175 }
1176
1177 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1178 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1179 */
1180 if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
1181 {
1182 /* Geforce7 - highend */
1183 if (strstr(gl_renderer, "7800")
1184 || strstr(gl_renderer, "7900")
1185 || strstr(gl_renderer, "7950")
1186 || strstr(gl_renderer, "Quadro FX 4")
1187 || strstr(gl_renderer, "Quadro FX 5"))
1188 {
1189 *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
1190 return CARD_NVIDIA_GEFORCE_7800GT;
1191 }
1192
1193 /* Geforce7 midend */
1194 if (strstr(gl_renderer, "7600")
1195 || strstr(gl_renderer, "7700"))
1196 {
1197 *vidmem = 256; /* The 7600 uses 256-512MB */
1198 return CARD_NVIDIA_GEFORCE_7600;
1199 }
1200
1201 /* Geforce7 lower medium */
1202 if (strstr(gl_renderer, "7400"))
1203 {
1204 *vidmem = 256; /* The 7400 uses 256-512MB */
1205 return CARD_NVIDIA_GEFORCE_7400;
1206 }
1207
1208 /* Geforce7 lowend */
1209 if (strstr(gl_renderer, "7300"))
1210 {
1211 *vidmem = 256; /* Mac Pros with this card have 256 MB */
1212 return CARD_NVIDIA_GEFORCE_7300;
1213 }
1214
1215 /* Geforce6 highend */
1216 if (strstr(gl_renderer, "6800"))
1217 {
1218 *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
1219 return CARD_NVIDIA_GEFORCE_6800;
1220 }
1221
1222 /* Geforce6 - midend */
1223 if (strstr(gl_renderer, "6600")
1224 || strstr(gl_renderer, "6610")
1225 || strstr(gl_renderer, "6700"))
1226 {
1227 *vidmem = 128; /* A 6600GT has 128-256MB */
1228 return CARD_NVIDIA_GEFORCE_6600GT;
1229 }
1230
1231 /* Geforce6/7 lowend */
1232 *vidmem = 64; /* */
1233 return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
1234 }
1235
1236 if (WINE_D3D9_CAPABLE(gl_info))
1237 {
1238 /* GeforceFX - highend */
1239 if (strstr(gl_renderer, "5800")
1240 || strstr(gl_renderer, "5900")
1241 || strstr(gl_renderer, "5950")
1242 || strstr(gl_renderer, "Quadro FX"))
1243 {
1244 *vidmem = 256; /* 5800-5900 cards use 256MB */
1245 return CARD_NVIDIA_GEFORCEFX_5800;
1246 }
1247
1248 /* GeforceFX - midend */
1249 if (strstr(gl_renderer, "5600")
1250 || strstr(gl_renderer, "5650")
1251 || strstr(gl_renderer, "5700")
1252 || strstr(gl_renderer, "5750"))
1253 {
1254 *vidmem = 128; /* A 5600 uses 128-256MB */
1255 return CARD_NVIDIA_GEFORCEFX_5600;
1256 }
1257
1258 /* GeforceFX - lowend */
1259 *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
1260 return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
1261 }
1262
1263 if (WINE_D3D8_CAPABLE(gl_info))
1264 {
1265 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
1266 {
1267 *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
1268 return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1269 }
1270
1271 *vidmem = 64; /* Geforce3 cards have 64-128MB */
1272 return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1273 }
1274
1275 if (WINE_D3D7_CAPABLE(gl_info))
1276 {
1277 if (strstr(gl_renderer, "GeForce4 MX"))
1278 {
1279 /* Most Geforce4MX GPUs have at least 64MB of memory, some
1280 * early models had 32MB but most have 64MB or even 128MB. */
1281 *vidmem = 64;
1282 return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
1283 }
1284
1285 if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
1286 {
1287 *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
1288 return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1289 }
1290
1291 if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
1292 {
1293 *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
1294 return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1295 }
1296
1297 /* Most Geforce1 cards have 32MB, there are also some rare 16
1298 * and 64MB (Dell) models. */
1299 *vidmem = 32;
1300 return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
1301 }
1302
1303 if (strstr(gl_renderer, "TNT2"))
1304 {
1305 *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
1306 return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
1307 }
1308
1309 *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
1310 return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
1311
1312}
1313
1314static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info,
1315 const char *gl_renderer, unsigned int *vidmem)
1316{
1317 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1318 *
1319 * Beware: renderer string do not match exact card model,
1320 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1321#ifndef VBOX_WITH_WDDM
1322 if (WINE_D3D10_CAPABLE(gl_info))
1323#endif
1324 {
1325 /* Radeon EG CYPRESS XT / PRO HD5800 - highend */
1326 if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */
1327 || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */
1328 || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */
1329 {
1330 *vidmem = 1024; /* note: HD58xx cards use 1024MB */
1331 return CARD_ATI_RADEON_HD5800;
1332 }
1333
1334 /* Radeon EG JUNIPER XT / LE HD5700 - midend */
1335 if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */
1336 || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */
1337 || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */
1338 {
1339 *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */
1340 return CARD_ATI_RADEON_HD5700;
1341 }
1342
1343 /* Radeon R7xx HD4800 - highend */
1344 if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */
1345 || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */
1346 || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */
1347 || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */
1348 || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */
1349 {
1350 *vidmem = 512; /* note: HD4890 cards use 1024MB */
1351 return CARD_ATI_RADEON_HD4800;
1352 }
1353
1354 /* Radeon R740 HD4700 - midend */
1355 if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */
1356 || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */
1357 {
1358 *vidmem = 512;
1359 return CARD_ATI_RADEON_HD4700;
1360 }
1361
1362 /* Radeon R730 HD4600 - midend */
1363 if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */
1364 || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */
1365 || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */
1366 {
1367 *vidmem = 512;
1368 return CARD_ATI_RADEON_HD4600;
1369 }
1370
1371 /* Radeon R710 HD4500/HD4350 - lowend */
1372 if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */
1373 || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */
1374 {
1375 *vidmem = 256;
1376 return CARD_ATI_RADEON_HD4350;
1377 }
1378
1379 /* Radeon R6xx HD2900/HD3800 - highend */
1380 if (strstr(gl_renderer, "HD 2900")
1381 || strstr(gl_renderer, "HD 3870")
1382 || strstr(gl_renderer, "HD 3850"))
1383 {
1384 *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
1385 return CARD_ATI_RADEON_HD2900;
1386 }
1387
1388 /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
1389 if (strstr(gl_renderer, "HD 2600")
1390 || strstr(gl_renderer, "HD 3830")
1391 || strstr(gl_renderer, "HD 3690")
1392 || strstr(gl_renderer, "HD 3650"))
1393 {
1394 *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
1395 return CARD_ATI_RADEON_HD2600;
1396 }
1397
1398 /* Radeon R6xx HD2350/HD2400/HD3400 - lowend
1399 * Note HD2300=DX9, HD2350=DX10 */
1400 if (strstr(gl_renderer, "HD 2350")
1401 || strstr(gl_renderer, "HD 2400")
1402 || strstr(gl_renderer, "HD 3470")
1403 || strstr(gl_renderer, "HD 3450")
1404 || strstr(gl_renderer, "HD 3430")
1405 || strstr(gl_renderer, "HD 3400"))
1406 {
1407 *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
1408 return CARD_ATI_RADEON_HD2350;
1409 }
1410
1411 /* Radeon R6xx/R7xx integrated */
1412 if (strstr(gl_renderer, "HD 3100")
1413 || strstr(gl_renderer, "HD 3200")
1414 || strstr(gl_renderer, "HD 3300"))
1415 {
1416 *vidmem = 128; /* 128MB */
1417 return CARD_ATI_RADEON_HD3200;
1418 }
1419
1420 /* Default for when no GPU has been found */
1421 *vidmem = 128; /* 128MB */
1422 return CARD_ATI_RADEON_HD3200;
1423 }
1424
1425 if (WINE_D3D8_CAPABLE(gl_info))
1426 {
1427 /* Radeon R5xx */
1428 if (strstr(gl_renderer, "X1600")
1429 || strstr(gl_renderer, "X1650")
1430 || strstr(gl_renderer, "X1800")
1431 || strstr(gl_renderer, "X1900")
1432 || strstr(gl_renderer, "X1950"))
1433 {
1434 *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
1435 return CARD_ATI_RADEON_X1600;
1436 }
1437
1438 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1439 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1440 if (strstr(gl_renderer, "X700")
1441 || strstr(gl_renderer, "X800")
1442 || strstr(gl_renderer, "X850")
1443 || strstr(gl_renderer, "X1300")
1444 || strstr(gl_renderer, "X1400")
1445 || strstr(gl_renderer, "X1450")
1446 || strstr(gl_renderer, "X1550")
1447 || strstr(gl_renderer, "X2300")
1448 || strstr(gl_renderer, "X2500")
1449 || strstr(gl_renderer, "HD 2300")
1450 )
1451 {
1452 *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
1453 return CARD_ATI_RADEON_X700;
1454 }
1455
1456 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1457 if (strstr(gl_renderer, "Radeon Xpress"))
1458 {
1459 *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
1460 return CARD_ATI_RADEON_XPRESS_200M;
1461 }
1462
1463 /* Radeon R3xx */
1464 *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
1465 return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1466 }
1467
1468 if (WINE_D3D8_CAPABLE(gl_info))
1469 {
1470 *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
1471 return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
1472 }
1473
1474 if (WINE_D3D7_CAPABLE(gl_info))
1475 {
1476 *vidmem = 32; /* There are models with up to 64MB */
1477 return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
1478 }
1479
1480 *vidmem = 16; /* There are 16-32MB models */
1481 return CARD_ATI_RAGE_128PRO;
1482
1483}
1484
1485static enum wined3d_pci_device select_card_intel_binary(const struct wined3d_gl_info *gl_info,
1486 const char *gl_renderer, unsigned int *vidmem)
1487{
1488 if (strstr(gl_renderer, "X3100"))
1489 {
1490 /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
1491 *vidmem = 128;
1492 return CARD_INTEL_X3100;
1493 }
1494
1495 if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
1496 {
1497 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
1498 *vidmem = 64;
1499 return CARD_INTEL_I945GM;
1500 }
1501
1502 if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
1503 if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
1504 if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
1505 if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
1506 if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
1507 return CARD_INTEL_I915G;
1508
1509}
1510
1511static enum wined3d_pci_device select_card_ati_mesa(const struct wined3d_gl_info *gl_info,
1512 const char *gl_renderer, unsigned int *vidmem)
1513{
1514 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1515 *
1516 * Beware: renderer string do not match exact card model,
1517 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1518 if (strstr(gl_renderer, "Gallium"))
1519 {
1520 /* Radeon R7xx HD4800 - highend */
1521 if (strstr(gl_renderer, "R700") /* Radeon R7xx HD48xx generic renderer string */
1522 || strstr(gl_renderer, "RV770") /* Radeon RV770 */
1523 || strstr(gl_renderer, "RV790")) /* Radeon RV790 */
1524 {
1525 *vidmem = 512; /* note: HD4890 cards use 1024MB */
1526 return CARD_ATI_RADEON_HD4800;
1527 }
1528
1529 /* Radeon R740 HD4700 - midend */
1530 if (strstr(gl_renderer, "RV740")) /* Radeon RV740 */
1531 {
1532 *vidmem = 512;
1533 return CARD_ATI_RADEON_HD4700;
1534 }
1535
1536 /* Radeon R730 HD4600 - midend */
1537 if (strstr(gl_renderer, "RV730")) /* Radeon RV730 */
1538 {
1539 *vidmem = 512;
1540 return CARD_ATI_RADEON_HD4600;
1541 }
1542
1543 /* Radeon R710 HD4500/HD4350 - lowend */
1544 if (strstr(gl_renderer, "RV710")) /* Radeon RV710 */
1545 {
1546 *vidmem = 256;
1547 return CARD_ATI_RADEON_HD4350;
1548 }
1549
1550 /* Radeon R6xx HD2900/HD3800 - highend */
1551 if (strstr(gl_renderer, "R600")
1552 || strstr(gl_renderer, "RV670")
1553 || strstr(gl_renderer, "R680"))
1554 {
1555 *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
1556 return CARD_ATI_RADEON_HD2900;
1557 }
1558
1559 /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
1560 if (strstr(gl_renderer, "RV630")
1561 || strstr(gl_renderer, "RV635"))
1562 {
1563 *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
1564 return CARD_ATI_RADEON_HD2600;
1565 }
1566
1567 /* Radeon R6xx HD2350/HD2400/HD3400 - lowend */
1568 if (strstr(gl_renderer, "RV610")
1569 || strstr(gl_renderer, "RV620"))
1570 {
1571 *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
1572 return CARD_ATI_RADEON_HD2350;
1573 }
1574
1575 /* Radeon R6xx/R7xx integrated */
1576 if (strstr(gl_renderer, "RS780")
1577 || strstr(gl_renderer, "RS880"))
1578 {
1579 *vidmem = 128; /* 128MB */
1580 return CARD_ATI_RADEON_HD3200;
1581 }
1582
1583 /* Radeon R5xx */
1584 if (strstr(gl_renderer, "RV530")
1585 || strstr(gl_renderer, "RV535")
1586 || strstr(gl_renderer, "RV560")
1587 || strstr(gl_renderer, "R520")
1588 || strstr(gl_renderer, "RV570")
1589 || strstr(gl_renderer, "R580"))
1590 {
1591 *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
1592 return CARD_ATI_RADEON_X1600;
1593 }
1594
1595 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
1596 if (strstr(gl_renderer, "R410")
1597 || strstr(gl_renderer, "R420")
1598 || strstr(gl_renderer, "R423")
1599 || strstr(gl_renderer, "R430")
1600 || strstr(gl_renderer, "R480")
1601 || strstr(gl_renderer, "R481")
1602 || strstr(gl_renderer, "RV410")
1603 || strstr(gl_renderer, "RV515")
1604 || strstr(gl_renderer, "RV516"))
1605 {
1606 *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
1607 return CARD_ATI_RADEON_X700;
1608 }
1609
1610 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1611 if (strstr(gl_renderer, "RS400")
1612 || strstr(gl_renderer, "RS480")
1613 || strstr(gl_renderer, "RS482")
1614 || strstr(gl_renderer, "RS485")
1615 || strstr(gl_renderer, "RS600")
1616 || strstr(gl_renderer, "RS690")
1617 || strstr(gl_renderer, "RS740"))
1618 {
1619 *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
1620 return CARD_ATI_RADEON_XPRESS_200M;
1621 }
1622
1623 /* Radeon R3xx */
1624 if (strstr(gl_renderer, "R300")
1625 || strstr(gl_renderer, "RV350")
1626 || strstr(gl_renderer, "RV351")
1627 || strstr(gl_renderer, "RV360")
1628 || strstr(gl_renderer, "RV370")
1629 || strstr(gl_renderer, "R350")
1630 || strstr(gl_renderer, "R360"))
1631 {
1632 *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
1633 return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
1634 }
1635 }
1636
1637 if (WINE_D3D9_CAPABLE(gl_info))
1638 {
1639 /* Radeon R7xx HD4800 - highend */
1640 if (strstr(gl_renderer, "(R700") /* Radeon R7xx HD48xx generic renderer string */
1641 || strstr(gl_renderer, "(RV770") /* Radeon RV770 */
1642 || strstr(gl_renderer, "(RV790")) /* Radeon RV790 */
1643 {
1644 *vidmem = 512; /* note: HD4890 cards use 1024MB */
1645 return CARD_ATI_RADEON_HD4800;
1646 }
1647
1648 /* Radeon R740 HD4700 - midend */
1649 if (strstr(gl_renderer, "(RV740")) /* Radeon RV740 */
1650 {
1651 *vidmem = 512;
1652 return CARD_ATI_RADEON_HD4700;
1653 }
1654
1655 /* Radeon R730 HD4600 - midend */
1656 if (strstr(gl_renderer, "(RV730")) /* Radeon RV730 */
1657 {
1658 *vidmem = 512;
1659 return CARD_ATI_RADEON_HD4600;
1660 }
1661
1662 /* Radeon R710 HD4500/HD4350 - lowend */
1663 if (strstr(gl_renderer, "(RV710")) /* Radeon RV710 */
1664 {
1665 *vidmem = 256;
1666 return CARD_ATI_RADEON_HD4350;
1667 }
1668
1669 /* Radeon R6xx HD2900/HD3800 - highend */
1670 if (strstr(gl_renderer, "(R600")
1671 || strstr(gl_renderer, "(RV670")
1672 || strstr(gl_renderer, "(R680"))
1673 {
1674 *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
1675 return CARD_ATI_RADEON_HD2900;
1676 }
1677
1678 /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
1679 if (strstr(gl_renderer, "(RV630")
1680 || strstr(gl_renderer, "(RV635"))
1681 {
1682 *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
1683 return CARD_ATI_RADEON_HD2600;
1684 }
1685
1686 /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
1687 if (strstr(gl_renderer, "(RV610")
1688 || strstr(gl_renderer, "(RV620"))
1689 {
1690 *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
1691 return CARD_ATI_RADEON_HD2350;
1692 }
1693
1694 /* Radeon R6xx/R7xx integrated */
1695 if (strstr(gl_renderer, "(RS780")
1696 || strstr(gl_renderer, "(RS880"))
1697 {
1698 *vidmem = 128; /* 128MB */
1699 return CARD_ATI_RADEON_HD3200;
1700 }
1701 }
1702
1703 if (WINE_D3D8_CAPABLE(gl_info))
1704 {
1705 *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
1706 return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
1707 }
1708
1709 if (WINE_D3D7_CAPABLE(gl_info))
1710 {
1711 *vidmem = 32; /* There are models with up to 64MB */
1712 return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
1713 }
1714
1715 *vidmem = 16; /* There are 16-32MB models */
1716 return CARD_ATI_RAGE_128PRO;
1717
1718}
1719
1720static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
1721 const char *gl_renderer, unsigned int *vidmem)
1722{
1723 FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n");
1724#ifndef VBOX_WITH_WDDM
1725 if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
1726#else
1727 /* tmp work around to disable quirk_no_np2 quirk for mesa drivers */
1728 if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE_6200;
1729#endif
1730 if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
1731 if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
1732 if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
1733 return CARD_NVIDIA_RIVA_128;
1734}
1735
1736static enum wined3d_pci_device select_card_intel_cmn(const struct wined3d_gl_info *gl_info,
1737 const char *gl_renderer, unsigned int *vidmem)
1738{
1739 if (strstr(gl_renderer, "HD Graphics")
1740 || strstr(gl_renderer, "Sandybridge"))
1741 return CARD_INTEL_SBHD;
1742 FIXME_(d3d_caps)("Card selection not handled for Windows Intel driver\n");
1743 return CARD_INTEL_I915G;
1744}
1745
1746static enum wined3d_pci_device select_card_intel_mesa(const struct wined3d_gl_info *gl_info,
1747 const char *gl_renderer, unsigned int *vidmem)
1748{
1749 return select_card_intel_cmn(gl_info, gl_renderer, vidmem);
1750}
1751
1752struct vendor_card_selection
1753{
1754 enum wined3d_gl_vendor gl_vendor;
1755 enum wined3d_pci_vendor card_vendor;
1756 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
1757 enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
1758 unsigned int *vidmem );
1759};
1760
1761static const struct vendor_card_selection vendor_card_select_table[] =
1762{
1763 {GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
1764 {GL_VENDOR_APPLE, HW_VENDOR_NVIDIA, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
1765 {GL_VENDOR_APPLE, HW_VENDOR_ATI, "Apple OSX AMD/ATI binary driver", select_card_ati_binary},
1766 {GL_VENDOR_APPLE, HW_VENDOR_INTEL, "Apple OSX Intel binary driver", select_card_intel_binary},
1767 {GL_VENDOR_FGLRX, HW_VENDOR_ATI, "AMD/ATI binary driver", select_card_ati_binary},
1768 {GL_VENDOR_MESA, HW_VENDOR_ATI, "Mesa AMD/ATI driver", select_card_ati_mesa},
1769 {GL_VENDOR_MESA, HW_VENDOR_NVIDIA, "Mesa Nouveau driver", select_card_nvidia_mesa},
1770 {GL_VENDOR_MESA, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel_mesa},
1771 {GL_VENDOR_INTEL, HW_VENDOR_INTEL, "Windows Intel binary driver", select_card_intel_cmn}
1772};
1773
1774
1775static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
1776 enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor, unsigned int *vidmem)
1777{
1778 /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
1779 * different GPUs with roughly the same features. In most cases GPUs from a
1780 * certain family differ in clockspeeds, the amount of video memory and the
1781 * number of shader pipelines.
1782 *
1783 * A Direct3D device object contains the PCI id (vendor + device) of the
1784 * videocard which is used for rendering. Various applications use this
1785 * information to get a rough estimation of the features of the card and
1786 * some might use it for enabling 3d effects only on certain types of
1787 * videocards. In some cases games might even use it to work around bugs
1788 * which happen on certain videocards/driver combinations. The problem is
1789 * that OpenGL only exposes a rendering string containing the name of the
1790 * videocard and not the PCI id.
1791 *
1792 * Various games depend on the PCI id, so somehow we need to provide one.
1793 * A simple option is to parse the renderer string and translate this to
1794 * the right PCI id. This is a lot of work because there are more than 200
1795 * GPUs just for Nvidia. Various cards share the same renderer string, so
1796 * the amount of code might be 'small' but there are quite a number of
1797 * exceptions which would make this a pain to maintain. Another way would
1798 * be to query the PCI id from the operating system (assuming this is the
1799 * videocard which is used for rendering which is not always the case).
1800 * This would work but it is not very portable. Second it would not work
1801 * well in, let's say, a remote X situation in which the amount of 3d
1802 * features which can be used is limited.
1803 *
1804 * As said most games only use the PCI id to get an indication of the
1805 * capabilities of the card. It doesn't really matter if the given id is
1806 * the correct one if we return the id of a card with similar 3d features.
1807 *
1808 * The code below checks the OpenGL capabilities of a videocard and matches
1809 * that to a certain level of Direct3D functionality. Once a card passes
1810 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
1811 * least a GeforceFX. To give a better estimate we do a basic check on the
1812 * renderer string but if that won't pass we return a default card. This
1813 * way is better than maintaining a full card database as even without a
1814 * full database we can return a card with similar features. Second the
1815 * size of the database can be made quite small because when you know what
1816 * type of 3d functionality a card has, you know to which GPU family the
1817 * GPU must belong. Because of this you only have to check a small part of
1818 * the renderer string to distinguishes between different models from that
1819 * family.
1820 *
1821 * The code also selects a default amount of video memory which we will
1822 * use for an estimation of the amount of free texture memory. In case of
1823 * real D3D the amount of texture memory includes video memory and system
1824 * memory (to be specific AGP memory or in case of PCIE TurboCache /
1825 * HyperMemory). We don't know how much system memory can be addressed by
1826 * the system but we can make a reasonable estimation about the amount of
1827 * video memory. If the value is slightly wrong it doesn't matter as we
1828 * didn't include AGP-like memory which makes the amount of addressable
1829 * memory higher and second OpenGL isn't that critical it moves to system
1830 * memory behind our backs if really needed. Note that the amount of video
1831 * memory can be overruled using a registry setting. */
1832
1833#ifndef VBOX
1834 int i;
1835#else
1836 size_t i;
1837#endif
1838
1839 for (i = 0; i < (sizeof(vendor_card_select_table) / sizeof(*vendor_card_select_table)); ++i)
1840 {
1841 if ((vendor_card_select_table[i].gl_vendor != *gl_vendor)
1842 || (vendor_card_select_table[i].card_vendor != *card_vendor))
1843 continue;
1844 TRACE_(d3d_caps)("Applying card_selector \"%s\".\n", vendor_card_select_table[i].description);
1845 return vendor_card_select_table[i].select_card(gl_info, gl_renderer, vidmem);
1846 }
1847
1848 FIXME_(d3d_caps)("No card selector available for GL vendor %d and card vendor %04x.\n",
1849 *gl_vendor, *card_vendor);
1850
1851 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
1852 * for Nvidia was because the hardware and drivers they make are of good quality. This makes
1853 * them a good generic choice. */
1854 *card_vendor = HW_VENDOR_NVIDIA;
1855#ifndef VBOX_WITH_WDDM
1856 if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
1857#else
1858 /* tmp work around to disable quirk_no_np2 quirk for not-recognized drivers */
1859 if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE_6200;
1860#endif
1861
1862 if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
1863 if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
1864 if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
1865 return CARD_NVIDIA_RIVA_128;
1866}
1867
1868#ifndef VBOX_WITH_VMSVGA
1869static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter)
1870{
1871 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
1872 int vs_selected_mode, ps_selected_mode;
1873
1874 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
1875 if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
1876 && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline;
1877 else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline;
1878 else if (gl_info->supported[NV_REGISTER_COMBINERS]
1879 && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline;
1880 else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline;
1881 else return &ffp_fragment_pipeline;
1882}
1883#endif
1884
1885static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter)
1886{
1887 int vs_selected_mode, ps_selected_mode;
1888
1889 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
1890 if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
1891#ifndef VBOX_WITH_VMSVGA
1892 if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
1893#endif
1894 return &none_shader_backend;
1895}
1896
1897#ifndef VBOX_WITH_VMSVGA
1898static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter)
1899{
1900 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
1901 int vs_selected_mode, ps_selected_mode;
1902
1903 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
1904 if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
1905 && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
1906 else return &ffp_blit;
1907}
1908#endif
1909
1910#ifdef VBOX_WITH_VMSVGA
1911/** Checks if @a pszExtension is one of the extensions we're looking for and
1912 * updates @a pGlInfo->supported accordingly. */
1913static void check_gl_extension(struct wined3d_gl_info *pGlInfo, const char *pszExtension)
1914{
1915 size_t i;
1916 TRACE_(d3d_caps)("- %s\n", debugstr_a(pszExtension));
1917 for (i = 0; i < RT_ELEMENTS(EXTENSION_MAP); i++)
1918 if (!strcmp(pszExtension, EXTENSION_MAP[i].extension_string))
1919 {
1920 TRACE_(d3d_caps)(" FOUND: %s support.\n", EXTENSION_MAP[i].extension_string);
1921 pGlInfo->supported[EXTENSION_MAP[i].extension] = TRUE;
1922 return;
1923 }
1924}
1925#endif
1926
1927/* Context activation is done by the caller. */
1928BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter, struct VBOXVMSVGASHADERIF *pVBoxShaderIf)
1929{
1930 struct wined3d_driver_info *driver_info = &adapter->driver_info;
1931 struct wined3d_gl_info *gl_info = &adapter->gl_info;
1932#ifndef VBOX_WITH_VMSVGA
1933 const char *GL_Extensions = NULL;
1934 const char *WGL_Extensions = NULL;
1935#endif
1936 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
1937 struct fragment_caps fragment_caps;
1938 enum wined3d_gl_vendor gl_vendor;
1939 enum wined3d_pci_vendor card_vendor;
1940 enum wined3d_pci_device device;
1941 GLint gl_max;
1942 GLfloat gl_floatv[2];
1943 unsigned i;
1944 HDC hdc;
1945 unsigned int vidmem=0;
1946 DWORD gl_version;
1947 size_t len;
1948
1949 TRACE_(d3d_caps)("(%p)\n", gl_info);
1950
1951 ENTER_GL();
1952
1953 VBOX_CHECK_GL_CALL(gl_renderer_str = (const char *)glGetString(GL_RENDERER));
1954 TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
1955 if (!gl_renderer_str)
1956 {
1957 LEAVE_GL();
1958 ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n");
1959 return FALSE;
1960 }
1961
1962 VBOX_CHECK_GL_CALL(gl_vendor_str = (const char *)glGetString(GL_VENDOR));
1963 TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
1964 if (!gl_vendor_str)
1965 {
1966 LEAVE_GL();
1967 ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n");
1968 return FALSE;
1969 }
1970
1971 /* Parse the GL_VERSION field into major and minor information */
1972 VBOX_CHECK_GL_CALL(gl_version_str = (const char *)glGetString(GL_VERSION));
1973 TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
1974 if (!gl_version_str)
1975 {
1976 LEAVE_GL();
1977 ERR_(d3d_caps)("Received a NULL GL_VERSION.\n");
1978 return FALSE;
1979 }
1980 gl_version = wined3d_parse_gl_version(gl_version_str);
1981
1982 /*
1983 * Initialize openGL extension related variables
1984 * with Default values
1985 */
1986 memset(gl_info->supported, 0, sizeof(gl_info->supported));
1987 gl_info->limits.blends = 1;
1988 gl_info->limits.buffers = 1;
1989 gl_info->limits.textures = 1;
1990 gl_info->limits.fragment_samplers = 1;
1991 gl_info->limits.vertex_samplers = 0;
1992 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
1993 gl_info->limits.sampler_stages = 1;
1994 gl_info->limits.glsl_vs_float_constants = 0;
1995 gl_info->limits.glsl_ps_float_constants = 0;
1996 gl_info->limits.arb_vs_float_constants = 0;
1997 gl_info->limits.arb_vs_native_constants = 0;
1998 gl_info->limits.arb_vs_instructions = 0;
1999 gl_info->limits.arb_vs_temps = 0;
2000 gl_info->limits.arb_ps_float_constants = 0;
2001 gl_info->limits.arb_ps_local_constants = 0;
2002 gl_info->limits.arb_ps_instructions = 0;
2003 gl_info->limits.arb_ps_temps = 0;
2004
2005 /* Retrieve opengl defaults */
2006 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max));
2007 gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
2008 TRACE_(d3d_caps)("ClipPlanes support - num Planes=%d\n", gl_max);
2009
2010#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2011 glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
2012 if (glGetError() != GL_NO_ERROR)
2013 {
2014 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2015 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_LIGHTS, &gl_max));
2016 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2017 }
2018#else
2019 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_LIGHTS, &gl_max));
2020#endif
2021 gl_info->limits.lights = gl_max;
2022 TRACE_(d3d_caps)("Lights support - max lights=%d\n", gl_max);
2023
2024 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max));
2025 gl_info->limits.texture_size = gl_max;
2026 TRACE_(d3d_caps)("Maximum texture size support - max texture size=%d\n", gl_max);
2027
2028#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2029 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
2030 if (glGetError() != GL_NO_ERROR)
2031 {
2032 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2033 VBOX_CHECK_GL_CALL(glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv));
2034 if (glGetError() != GL_NO_ERROR)
2035 gl_floatv[0] = gl_floatv[1] = 1;
2036 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2037 }
2038#else
2039 VBOX_CHECK_GL_CALL(glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv));
2040#endif
2041 gl_info->limits.pointsize_min = gl_floatv[0];
2042 gl_info->limits.pointsize_max = gl_floatv[1];
2043 TRACE_(d3d_caps)("Maximum point size support - max point size=%f\n", gl_floatv[1]);
2044
2045 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2046#ifndef VBOX_WITH_VMSVGA
2047 GL_Extensions = (const char *)glGetString(GL_EXTENSIONS);
2048 if (!GL_Extensions)
2049 {
2050 LEAVE_GL();
2051 ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n");
2052 return FALSE;
2053 }
2054
2055 LEAVE_GL();
2056
2057 TRACE_(d3d_caps)("GL_Extensions reported:\n");
2058#endif
2059
2060 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
2061
2062 gl_info->supported[VBOX_SHARED_CONTEXTS] = TRUE;
2063
2064#ifdef VBOX_WITH_VMSVGA
2065 {
2066 void *pvEnumCtx = NULL;
2067 char szCurExt[256];
2068 while (pVBoxShaderIf->pfnGetNextExtension(pVBoxShaderIf, &pvEnumCtx, szCurExt, sizeof(szCurExt), false /*fOtherProfile*/))
2069 check_gl_extension(gl_info, szCurExt);
2070
2071 /* The cheap way out. */
2072 pvEnumCtx = NULL;
2073 while (pVBoxShaderIf->pfnGetNextExtension(pVBoxShaderIf, &pvEnumCtx, szCurExt, sizeof(szCurExt), true /*fOtherProfile*/))
2074 check_gl_extension(gl_info, szCurExt);
2075 }
2076#else /* VBOX_WITH_VMSVGA */
2077 while (*GL_Extensions)
2078 {
2079 const char *start;
2080 char current_ext[256];
2081
2082 while (isspace(*GL_Extensions)) ++GL_Extensions;
2083 start = GL_Extensions;
2084 while (!isspace(*GL_Extensions) && *GL_Extensions) ++GL_Extensions;
2085
2086 len = GL_Extensions - start;
2087 if (!len || len >= sizeof(current_ext)) continue;
2088
2089 memcpy(current_ext, start, len);
2090 current_ext[len] = '\0';
2091 TRACE_(d3d_caps)("- %s\n", debugstr_a(current_ext));
2092
2093 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
2094 {
2095 if (!strcmp(current_ext, EXTENSION_MAP[i].extension_string))
2096 {
2097 TRACE_(d3d_caps)(" FOUND: %s support.\n", EXTENSION_MAP[i].extension_string);
2098 gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
2099 break;
2100 }
2101 }
2102 }
2103#endif
2104
2105#ifdef VBOX_WITH_VMSVGA
2106# ifdef RT_OS_WINDOWS
2107# define OGLGETPROCADDRESS wglGetProcAddress
2108# elif RT_OS_DARWIN
2109# define OGLGETPROCADDRESS(x) MyNSGLGetProcAddress(x)
2110# else
2111extern void (*glXGetProcAddress(const GLubyte *procname))( void );
2112# define OGLGETPROCADDRESS(x) glXGetProcAddress((const GLubyte *)x)
2113# endif
2114#endif
2115
2116 /* Now work out what GL support this card really has */
2117#define USE_GL_FUNC(type, pfn, ext, replace) \
2118{ \
2119 DWORD ver = ver_for_ext(ext); \
2120 if (gl_info->supported[ext]) gl_info->pfn = (type)OGLGETPROCADDRESS(#pfn); \
2121 else if (ver && ver <= gl_version) gl_info->pfn = (type)OGLGETPROCADDRESS(#replace); \
2122 else gl_info->pfn = NULL; \
2123}
2124 GL_EXT_FUNCS_GEN;
2125#undef USE_GL_FUNC
2126
2127#ifndef VBOX_WITH_VMSVGA
2128#define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)OGLGETPROCADDRESS(#pfn);
2129 WGL_EXT_FUNCS_GEN;
2130#undef USE_GL_FUNC
2131#endif
2132
2133 ENTER_GL();
2134
2135 /* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
2136 * loading the functions, otherwise the code above will load the extension entry points instead of the
2137 * core functions, which may not work. */
2138 for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
2139 {
2140 if (!gl_info->supported[EXTENSION_MAP[i].extension]
2141 && EXTENSION_MAP[i].version <= gl_version && EXTENSION_MAP[i].version)
2142 {
2143 TRACE_(d3d_caps)(" GL CORE: %s support.\n", EXTENSION_MAP[i].extension_string);
2144 gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
2145 }
2146 }
2147
2148 if (gl_info->supported[APPLE_FENCE])
2149 {
2150 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2151 * The apple extension interacts with some other apple exts. Disable the NV
2152 * extension if the apple one is support to prevent confusion in other parts
2153 * of the code. */
2154 gl_info->supported[NV_FENCE] = FALSE;
2155 }
2156 if (gl_info->supported[APPLE_FLOAT_PIXELS])
2157 {
2158 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2159 *
2160 * The enums are the same:
2161 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
2162 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
2163 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2164 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2165 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
2166 */
2167 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
2168 {
2169 TRACE_(d3d_caps)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
2170 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
2171 }
2172 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
2173 {
2174 TRACE_(d3d_caps)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
2175 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
2176 }
2177 }
2178 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
2179 {
2180 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2181 * functionality. Prefer the ARB extension */
2182 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
2183 }
2184 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2185 {
2186 TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2187 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
2188 }
2189 if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
2190 {
2191 TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2192 gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
2193 }
2194 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
2195 {
2196 TRACE_(d3d_caps)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2197 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
2198 }
2199 if (gl_info->supported[NV_TEXTURE_SHADER2])
2200 {
2201 if (gl_info->supported[NV_REGISTER_COMBINERS])
2202 {
2203 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2204 * are supported. The nv extensions provide the same functionality as the
2205 * ATI one, and a bit more(signed pixelformats). */
2206 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
2207 }
2208 }
2209
2210 if (gl_info->supported[NV_REGISTER_COMBINERS])
2211 {
2212 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max));
2213 gl_info->limits.general_combiners = gl_max;
2214 TRACE_(d3d_caps)("Max general combiners: %d.\n", gl_max);
2215 }
2216 if (gl_info->supported[ARB_DRAW_BUFFERS])
2217 {
2218 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max));
2219 gl_info->limits.buffers = gl_max;
2220 TRACE_(d3d_caps)("Max draw buffers: %u.\n", gl_max);
2221 }
2222 if (gl_info->supported[ARB_MULTITEXTURE])
2223 {
2224#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2225 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
2226 if (glGetError() != GL_NO_ERROR)
2227 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max));
2228#else
2229 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max));
2230#endif
2231 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
2232 TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->limits.textures);
2233
2234 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2235 {
2236 GLint tmp;
2237 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp));
2238 gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
2239 }
2240 else
2241 {
2242 gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, (UINT)gl_max);
2243 }
2244 TRACE_(d3d_caps)("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
2245
2246 if (gl_info->supported[ARB_VERTEX_SHADER])
2247 {
2248 GLint tmp;
2249 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp));
2250 gl_info->limits.vertex_samplers = tmp;
2251 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp));
2252 gl_info->limits.combined_samplers = tmp;
2253
2254 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2255 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2256 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2257 * shader is used with fixed function vertex processing we're fine too because fixed function
2258 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2259 * used we have to make sure that all vertex sampler setups are valid together with all
2260 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2261 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2262 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2263 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2264 * a fixed function pipeline anymore.
2265 *
2266 * So this is just a check to check that our assumption holds true. If not, write a warning
2267 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2268 if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
2269 && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
2270 {
2271 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2272 gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
2273 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2274 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
2275 gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
2276 else
2277 gl_info->limits.vertex_samplers = 0;
2278 }
2279 }
2280 else
2281 {
2282 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
2283 }
2284 TRACE_(d3d_caps)("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
2285 TRACE_(d3d_caps)("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
2286 }
2287 if (gl_info->supported[ARB_VERTEX_BLEND])
2288 {
2289#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2290 glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
2291 if (glGetError() != GL_NO_ERROR)
2292 {
2293 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2294 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max));
2295 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2296 }
2297#else
2298 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max));
2299#endif
2300 gl_info->limits.blends = gl_max;
2301 TRACE_(d3d_caps)("Max blends: %u.\n", gl_info->limits.blends);
2302 }
2303 if (gl_info->supported[EXT_TEXTURE3D])
2304 {
2305 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max));
2306 gl_info->limits.texture3d_size = gl_max;
2307 TRACE_(d3d_caps)("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
2308 }
2309 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
2310 {
2311 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max));
2312 gl_info->limits.anisotropy = gl_max;
2313 TRACE_(d3d_caps)("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
2314 }
2315 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2316 {
2317#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2318 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2319 if (glGetError() != GL_NO_ERROR)
2320 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2321#endif
2322 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max)));
2323 gl_info->limits.arb_ps_float_constants = gl_max;
2324 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
2325 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max)));
2326 gl_info->limits.arb_ps_native_constants = gl_max;
2327 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2328 gl_info->limits.arb_ps_native_constants);
2329 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max)));
2330 gl_info->limits.arb_ps_temps = gl_max;
2331 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
2332 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max)));
2333 gl_info->limits.arb_ps_instructions = gl_max;
2334 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
2335 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max)));
2336 gl_info->limits.arb_ps_local_constants = gl_max;
2337 TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
2338#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2339 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2340#endif
2341 }
2342 if (gl_info->supported[ARB_VERTEX_PROGRAM])
2343 {
2344#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2345 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2346 if (glGetError() != GL_NO_ERROR)
2347 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2348#endif
2349 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max)));
2350 gl_info->limits.arb_vs_float_constants = gl_max;
2351 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
2352 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max)));
2353 gl_info->limits.arb_vs_native_constants = gl_max;
2354 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2355 gl_info->limits.arb_vs_native_constants);
2356 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max)));
2357 gl_info->limits.arb_vs_temps = gl_max;
2358 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
2359 VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max)));
2360 gl_info->limits.arb_vs_instructions = gl_max;
2361 TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
2362#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2363 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2364#endif
2365#ifndef VBOX_WITH_VMSVGA
2366 if (test_arb_vs_offset_limit(gl_info)) gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
2367#endif
2368 }
2369 if (gl_info->supported[ARB_VERTEX_SHADER])
2370 {
2371 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max));
2372 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
2373#ifdef VBOX_WITH_WDDM
2374 /* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
2375 * thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
2376 * win8 Aero won't properly work with this constant < 256 in any way,
2377 * while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
2378 * so use it here.
2379 * @todo: add logging
2380 * @todo: perhaps should be movet to quirks?
2381 * */
2382 if (gl_info->limits.glsl_vs_float_constants < 256 && gl_max >= 256)
2383 {
2384 DWORD dwVersion = GetVersion();
2385 DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
2386 DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
2387 /* tmp workaround Win8 Aero requirement for 256 */
2388 if (dwMajor > 6 || dwMinor > 1)
2389 {
2390 gl_info->limits.glsl_vs_float_constants = 256;
2391 }
2392 }
2393#endif
2394 TRACE_(d3d_caps)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
2395 }
2396 if (gl_info->supported[ARB_FRAGMENT_SHADER])
2397 {
2398 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max));
2399 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
2400#ifdef VBOX_WITH_WDDM
2401 /* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
2402 * thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
2403 * win8 Aero won't properly work with this constant < 256 in any way,
2404 * while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
2405 * so use it here.
2406 * @todo: add logging
2407 * @todo: perhaps should be movet to quirks?
2408 * */
2409 if (gl_info->limits.glsl_ps_float_constants < 256 && gl_max >= 256)
2410 {
2411 DWORD dwVersion = GetVersion();
2412 DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
2413 DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
2414 /* tmp workaround Win8 Aero requirement for 256 */
2415 if (dwMajor > 6 || dwMinor > 1)
2416 {
2417 gl_info->limits.glsl_ps_float_constants = 256;
2418 }
2419 }
2420#endif
2421 TRACE_(d3d_caps)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
2422#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2423 glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
2424 if (glGetError() != GL_NO_ERROR)
2425 {
2426 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2427 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max));
2428 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2429 }
2430#else
2431 VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max));
2432#endif
2433 gl_info->limits.glsl_varyings = gl_max;
2434 TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
2435 }
2436 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
2437 {
2438 const char *str = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
2439 unsigned int major, minor;
2440
2441 TRACE_(d3d_caps)("GLSL version string: %s.\n", debugstr_a(str));
2442
2443 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2444 sscanf(str, "%u.%u", &major, &minor);
2445 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
2446 }
2447 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
2448 {
2449#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
2450 glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
2451 if (glGetError() != GL_NO_ERROR)
2452 {
2453 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
2454 VBOX_CHECK_GL_CALL(glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess));
2455 pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
2456 }
2457#else
2458 VBOX_CHECK_GL_CALL(glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess));
2459#endif
2460 }
2461 else
2462 {
2463 gl_info->limits.shininess = 128.0f;
2464 }
2465 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
2466 {
2467 /* If we have full NP2 texture support, disable
2468 * GL_ARB_texture_rectangle because we will never use it.
2469 * This saves a few redundant glDisable calls. */
2470 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
2471 }
2472 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2473 {
2474 /* Disable NV_register_combiners and fragment shader if this is supported.
2475 * generally the NV extensions are preferred over the ATI ones, and this
2476 * extension is disabled if register_combiners and texture_shader2 are both
2477 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2478 * fragment processing support. */
2479 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
2480 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
2481 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
2482 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
2483 }
2484 if (gl_info->supported[NV_HALF_FLOAT])
2485 {
2486 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2487 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
2488 }
2489 if (gl_info->supported[ARB_POINT_SPRITE])
2490 {
2491 gl_info->limits.point_sprite_units = gl_info->limits.textures;
2492 }
2493 else
2494 {
2495 gl_info->limits.point_sprite_units = 0;
2496 }
2497#ifndef VBOX_WITH_VMSVGA
2498 checkGLcall("extension detection");
2499#endif
2500 LEAVE_GL();
2501
2502#ifndef VBOX_WITH_VMSVGA
2503 adapter->fragment_pipe = select_fragment_implementation(adapter);
2504#endif
2505 adapter->shader_backend = select_shader_backend(adapter);
2506#ifndef VBOX_WITH_VMSVGA
2507 adapter->blitter = select_blit_implementation(adapter);
2508
2509 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
2510 gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
2511 TRACE_(d3d_caps)("Max texture stages: %u.\n", gl_info->limits.texture_stages);
2512
2513 /* In some cases the number of texture stages can be larger than the number
2514 * of samplers. The GF4 for example can use only 2 samplers (no fragment
2515 * shaders), but 8 texture stages (register combiners). */
2516 gl_info->limits.sampler_stages = max(gl_info->limits.fragment_samplers, gl_info->limits.texture_stages);
2517#endif
2518
2519 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
2520 {
2521 gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbuffer;
2522 gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbuffer;
2523 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffers;
2524 gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffers;
2525 gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorage;
2526 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisample;
2527 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameteriv;
2528 gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebuffer;
2529 gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebuffer;
2530 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffers;
2531 gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffers;
2532 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatus;
2533 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1D;
2534 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2D;
2535 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3D;
2536 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbuffer;
2537 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameteriv;
2538 gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebuffer;
2539 gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmap;
2540 }
2541 else
2542 {
2543 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
2544 {
2545 gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbufferEXT;
2546 gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbufferEXT;
2547 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffersEXT;
2548 gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffersEXT;
2549 gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorageEXT;
2550 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameterivEXT;
2551 gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebufferEXT;
2552 gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebufferEXT;
2553 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffersEXT;
2554 gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffersEXT;
2555 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatusEXT;
2556 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1DEXT;
2557 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2DEXT;
2558 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3DEXT;
2559 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbufferEXT;
2560 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameterivEXT;
2561 gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmapEXT;
2562 }
2563#ifndef VBOX_WITH_VMSVGA
2564 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2565 {
2566 WARN_(d3d_caps)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2567 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
2568 }
2569#endif
2570 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
2571 {
2572 gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebufferEXT;
2573 }
2574 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2575 {
2576 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisampleEXT;
2577 }
2578 }
2579
2580#ifndef VBOX_WITH_VMSVGA
2581 /* MRTs are currently only supported when FBOs are used. */
2582 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
2583 {
2584 gl_info->limits.buffers = 1;
2585 }
2586#endif
2587 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
2588 card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
2589 TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
2590
2591 device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor, &vidmem);
2592 TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor, device);
2593
2594 /* If we have an estimate use it, else default to 64MB; */
2595 if(vidmem)
2596 gl_info->vidmem = vidmem*1024*1024; /* convert from MBs to bytes */
2597 else
2598 gl_info->vidmem = WINE_DEFAULT_VIDMEM;
2599
2600 gl_info->wrap_lookup[WINED3DTADDRESS_WRAP - WINED3DTADDRESS_WRAP] = GL_REPEAT;
2601 gl_info->wrap_lookup[WINED3DTADDRESS_MIRROR - WINED3DTADDRESS_WRAP] =
2602 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
2603 gl_info->wrap_lookup[WINED3DTADDRESS_CLAMP - WINED3DTADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
2604 gl_info->wrap_lookup[WINED3DTADDRESS_BORDER - WINED3DTADDRESS_WRAP] =
2605 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
2606 gl_info->wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP] =
2607 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
2608
2609#ifndef VBOX_WITH_VMSVGA
2610 /* Make sure there's an active HDC else the WGL extensions will fail */
2611 hdc = pwglGetCurrentDC();
2612 if (hdc) {
2613 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
2614 if(GL_EXTCALL(wglGetExtensionsStringARB))
2615 WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
2616
2617 if (NULL == WGL_Extensions) {
2618 ERR(" WGL_Extensions returns NULL\n");
2619 } else {
2620 TRACE_(d3d_caps)("WGL_Extensions reported:\n");
2621 while (*WGL_Extensions != 0x00) {
2622 const char *Start;
2623 char ThisExtn[256];
2624
2625 while (isspace(*WGL_Extensions)) WGL_Extensions++;
2626 Start = WGL_Extensions;
2627 while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) {
2628 WGL_Extensions++;
2629 }
2630
2631 len = WGL_Extensions - Start;
2632 if (len == 0 || len >= sizeof(ThisExtn))
2633 continue;
2634
2635 memcpy(ThisExtn, Start, len);
2636 ThisExtn[len] = '\0';
2637 TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
2638
2639 if (!strcmp(ThisExtn, "WGL_ARB_pixel_format")) {
2640 gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
2641 TRACE_(d3d_caps)("FOUND: WGL_ARB_pixel_format support\n");
2642 }
2643 if (!strcmp(ThisExtn, "WGL_WINE_pixel_format_passthrough")) {
2644 gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH] = TRUE;
2645 TRACE_(d3d_caps)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
2646 }
2647 }
2648 }
2649 }
2650#endif
2651
2652 fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
2653#ifndef VBOX_WITH_VMSVGA
2654 init_driver_info(driver_info, card_vendor, device);
2655 add_gl_compat_wrappers(gl_info);
2656#endif
2657
2658 return TRUE;
2659}
2660
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette