2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
29 #include "wined3d_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
34 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
36 /* The driver names reflect the lowest GPU supported
37 * by a certain driver, so DRIVER_AMD_R300 supports
38 * R3xx, R4xx and R5xx GPUs. */
39 enum wined3d_display_driver
41 DRIVER_AMD_RAGE_128PRO,
50 DRIVER_NVIDIA_GEFORCE2MX,
51 DRIVER_NVIDIA_GEFORCEFX,
52 DRIVER_NVIDIA_GEFORCE6,
56 enum wined3d_driver_model
64 enum wined3d_gl_vendor
74 /* The d3d device ID */
75 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
77 /* Extension detection */
78 struct wined3d_extension_map
80 const char *extension_string;
81 enum wined3d_gl_extension extension;
84 static const struct wined3d_extension_map gl_extension_map[] =
87 {"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE },
88 {"GL_APPLE_fence", APPLE_FENCE },
89 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
90 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
91 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
94 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
95 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
96 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
97 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
98 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
99 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
100 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
101 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
102 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
103 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
104 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
105 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
106 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
107 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
108 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
109 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
110 {"GL_ARB_multisample", ARB_MULTISAMPLE }, /* needs GLX_ARB_MULTISAMPLE as well */
111 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
112 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
113 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
114 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
115 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
116 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
117 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
118 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS },
119 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
120 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
121 {"GL_ARB_shadow", ARB_SHADOW },
122 {"GL_ARB_sync", ARB_SYNC },
123 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
124 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
125 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
126 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
127 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD },
128 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
129 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
130 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
131 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
132 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
133 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
134 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
135 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
136 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
137 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
138 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
139 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
142 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
143 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
144 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
145 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
146 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
149 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
150 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
151 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
152 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
153 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
154 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
155 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
156 {"GL_EXT_fog_coord", EXT_FOG_COORD },
157 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
158 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
159 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
160 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
161 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
162 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
163 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE },
164 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
165 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
166 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
167 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
168 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
169 {"GL_EXT_texture3D", EXT_TEXTURE3D },
170 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
171 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
172 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD },
173 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
174 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
175 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
176 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
177 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
178 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
179 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
182 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP },
183 {"GL_NV_fence", NV_FENCE },
184 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
185 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
186 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
187 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
188 {"GL_NV_half_float", NV_HALF_FLOAT },
189 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
190 {"GL_NV_point_sprite", NV_POINT_SPRITE },
191 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
192 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
193 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
194 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
195 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
196 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
197 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
198 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
199 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
200 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
201 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
204 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
207 static const struct wined3d_extension_map wgl_extension_map[] =
209 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
210 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
211 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
214 /**********************************************************
215 * Utility functions follow
216 **********************************************************/
218 const struct min_lookup minMipLookup[] =
220 /* NONE POINT LINEAR */
221 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
222 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
223 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
226 const struct min_lookup minMipLookup_noFilter[] =
228 /* NONE POINT LINEAR */
229 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
230 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
231 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
234 const struct min_lookup minMipLookup_noMip[] =
236 /* NONE POINT LINEAR */
237 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
238 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
239 {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
242 const GLenum magLookup[] =
244 /* NONE POINT LINEAR */
245 GL_NEAREST, GL_NEAREST, GL_LINEAR,
248 const GLenum magLookup_noFilter[] =
250 /* NONE POINT LINEAR */
251 GL_NEAREST, GL_NEAREST, GL_NEAREST,
254 /* drawStridedSlow attributes */
255 glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
256 glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
257 glAttribFunc specular_func_3ubv;
258 glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
259 glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
260 glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
263 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
264 * i.e., there is no GL Context - Get a default rendering context to enable the
265 * function query some info from GL.
268 struct wined3d_fake_gl_ctx
274 HGLRC restore_gl_ctx;
277 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
279 TRACE("Destroying fake GL context.\n");
281 if (!wglMakeCurrent(NULL, NULL))
282 ERR("Failed to disable fake GL context.\n");
284 if (!wglDeleteContext(ctx->gl_ctx))
286 DWORD err = GetLastError();
287 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
290 ReleaseDC(ctx->wnd, ctx->dc);
291 DestroyWindow(ctx->wnd);
293 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
294 ERR("Failed to restore previous GL context.\n");
297 /* Do not call while under the GL lock. */
298 static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
300 PIXELFORMATDESCRIPTOR pfd;
303 TRACE("getting context...\n");
305 ctx->restore_dc = wglGetCurrentDC();
306 ctx->restore_gl_ctx = wglGetCurrentContext();
308 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
309 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
310 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
313 ERR("Failed to create a window.\n");
317 ctx->dc = GetDC(ctx->wnd);
320 ERR("Failed to get a DC.\n");
324 /* PixelFormat selection */
325 ZeroMemory(&pfd, sizeof(pfd));
326 pfd.nSize = sizeof(pfd);
328 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
329 pfd.iPixelType = PFD_TYPE_RGBA;
331 pfd.iLayerType = PFD_MAIN_PLANE;
333 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
335 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
336 ERR("Failed to find a suitable pixel format.\n");
339 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
340 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
342 /* Create a GL context. */
343 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
345 WARN("Failed to create default context for capabilities initialization.\n");
349 /* Make it the current GL context. */
350 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
352 ERR("Failed to make fake GL context current.\n");
359 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
361 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
363 if (ctx->wnd) DestroyWindow(ctx->wnd);
365 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
366 ERR("Failed to restore previous GL context.\n");
371 /* Adjust the amount of used texture memory */
372 unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount)
374 adapter->UsedTextureRam += amount;
375 TRACE("Adjusted adapter memory by %d to %d.\n", amount, adapter->UsedTextureRam);
376 return adapter->UsedTextureRam;
379 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
381 HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
382 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
385 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
387 ULONG refcount = InterlockedIncrement(&wined3d->ref);
389 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
394 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
396 ULONG refcount = InterlockedDecrement(&wined3d->ref);
398 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
404 for (i = 0; i < wined3d->adapter_count; ++i)
406 wined3d_adapter_cleanup(&wined3d->adapters[i]);
408 HeapFree(GetProcessHeap(), 0, wined3d);
414 /* GL locking is done by the caller */
415 static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
419 const char *testcode =
421 "PARAM C[66] = { program.env[0..65] };\n"
423 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
424 "ARL A0.x, zero.x;\n"
425 "MOV result.position, C[A0.x + 65];\n"
428 while (gl_info->gl_ops.gl.p_glGetError());
429 GL_EXTCALL(glGenProgramsARB(1, &prog));
431 ERR("Failed to create an ARB offset limit test program\n");
433 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
434 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
435 strlen(testcode), testcode));
436 if (gl_info->gl_ops.gl.p_glGetError())
438 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
439 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
441 } else TRACE("OpenGL implementation allows offsets > 63\n");
443 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
444 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
445 checkGLcall("ARB vp offset limit test cleanup");
450 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
451 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
453 if (card_vendor != HW_VENDOR_AMD) return FALSE;
454 if (device == CARD_AMD_RADEON_9500) return TRUE;
455 if (device == CARD_AMD_RADEON_X700) return TRUE;
456 if (device == CARD_AMD_RADEON_X1600) return TRUE;
460 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
461 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
463 if (card_vendor == HW_VENDOR_NVIDIA)
465 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
466 device == CARD_NVIDIA_GEFORCEFX_5600 ||
467 device == CARD_NVIDIA_GEFORCEFX_5800)
475 static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
476 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
478 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
479 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
480 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
482 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
483 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
484 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
485 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
486 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
487 * the chance that other implementations support them is rather small since Win32 QuickTime uses
488 * DirectDraw, not OpenGL.
490 * This test has been moved into wined3d_guess_gl_vendor()
492 if (gl_vendor == GL_VENDOR_APPLE)
499 /* Context activation is done by the caller. */
500 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
502 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
503 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
504 * all the texture. This function detects this bug by its symptom and disables PBOs
507 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
508 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
509 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
510 * read back is compared to the original. If they are equal PBOs are assumed to work,
511 * otherwise the PBO extension is disabled. */
513 static const unsigned int pattern[] =
515 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
516 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
517 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
518 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
520 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
522 /* No PBO -> No point in testing them. */
523 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
527 while (gl_info->gl_ops.gl.p_glGetError());
528 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
529 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
531 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
532 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
533 checkGLcall("Specifying the PBO test texture");
535 GL_EXTCALL(glGenBuffersARB(1, &pbo));
536 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
537 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
538 checkGLcall("Specifying the PBO test pbo");
540 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
541 checkGLcall("Loading the PBO test texture");
543 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
546 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
548 memset(check, 0, sizeof(check));
550 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
551 checkGLcall("Reading back the PBO test texture");
553 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
554 GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
555 checkGLcall("PBO test cleanup");
559 if (memcmp(check, pattern, sizeof(check)))
561 WARN("PBO test failed, read back data doesn't match original.\n"
562 "Disabling PBOs. This may result in slower performance.\n");
563 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
567 TRACE("PBO test successful.\n");
571 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
572 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
574 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
577 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
578 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
580 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
581 if (card_vendor != HW_VENDOR_AMD) return FALSE;
582 if (device == CARD_AMD_RADEON_X1600) return FALSE;
586 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
587 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
589 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
590 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
591 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
592 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
595 * dx10 cards usually have 64 varyings */
596 return gl_info->limits.glsl_varyings > 44;
599 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
600 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
602 return !match_dx10_capable(gl_info, gl_renderer, gl_vendor, card_vendor, device);
605 /* A GL context is provided by the caller */
606 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
607 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
612 if (!gl_info->supported[EXT_SECONDARY_COLOR])
616 while (gl_info->gl_ops.gl.p_glGetError());
617 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
618 error = gl_info->gl_ops.gl.p_glGetError();
621 if (error == GL_NO_ERROR)
623 TRACE("GL Implementation accepts 4 component specular color pointers\n");
628 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
629 debug_glerror(error));
634 /* A GL context is provided by the caller */
635 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
636 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
641 const char *testcode =
643 "OPTION NV_vertex_program2;\n"
644 "MOV result.clip[0], 0.0;\n"
645 "MOV result.position, 0.0;\n"
648 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
651 while (gl_info->gl_ops.gl.p_glGetError());
653 GL_EXTCALL(glGenProgramsARB(1, &prog));
656 ERR("Failed to create the NVvp clip test program\n");
660 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
661 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
662 strlen(testcode), testcode));
663 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
666 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
667 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
669 while (gl_info->gl_ops.gl.p_glGetError());
671 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
673 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
674 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
675 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
681 /* Context activation is done by the caller. */
682 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
683 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
685 char data[4 * 4 * 4];
689 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
691 memset(data, 0xcc, sizeof(data));
695 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
696 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
697 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
698 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
699 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
700 checkGLcall("glTexImage2D");
702 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
703 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
704 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
705 checkGLcall("glFramebufferTexture2D");
707 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
708 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
709 checkGLcall("glCheckFramebufferStatus");
711 memset(data, 0x11, sizeof(data));
712 gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
713 checkGLcall("glTexSubImage2D");
715 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
716 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
717 checkGLcall("glClear");
719 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
720 checkGLcall("glGetTexImage");
722 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
723 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
724 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
725 checkGLcall("glBindTexture");
727 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
728 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
729 checkGLcall("glDeleteTextures");
733 return *(DWORD *)data == 0x11111111;
736 /* Context activation is done by the caller. */
737 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
738 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
740 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
741 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
747 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
748 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
749 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
750 checkGLcall("glTexImage2D");
752 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
753 checkGLcall("glGetTexLevelParameteriv");
754 TRACE("Real color depth is %d\n", size);
756 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
757 checkGLcall("glBindTexture");
758 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
759 checkGLcall("glDeleteTextures");
766 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
767 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
769 return gl_vendor == GL_VENDOR_FGLRX;
772 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
774 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
775 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
776 * allow 48 different offsets or other helper immediate values. */
777 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
778 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
781 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
783 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
784 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
785 * If real NP2 textures are used, the driver falls back to software. We could just remove the
786 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
787 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
788 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
789 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
791 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
792 * has this extension promoted to core. The extension loading code sets this extension supported
793 * due to that, so this code works on fglrx as well. */
794 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
796 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
797 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
798 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
802 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
804 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
805 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
806 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
807 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
808 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
809 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
811 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
812 * triggering the software fallback. There is not much we can do here apart from disabling the
813 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
814 * in wined3d_adapter_init_gl_caps).
815 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
816 * post-processing effects in the game "Max Payne 2").
817 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
818 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
819 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
820 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
823 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
825 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
826 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
827 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
828 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
829 * according to the spec.
831 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
832 * makes the shader slower and eats instruction slots which should be available to the d3d app.
834 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
835 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
836 * this workaround is activated on cards that do not need it, it won't break things, just affect
837 * performance negatively. */
838 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
839 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
842 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
844 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
847 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
849 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
852 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
854 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
857 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
859 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
862 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
864 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
867 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
869 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
872 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
874 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
875 selected texture formats. They are apparently the only DX9 class GPUs
877 Also, DX9-era GPUs are somewhat limited with float textures
878 filtering and blending. */
879 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
884 BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
885 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
886 void (*apply)(struct wined3d_gl_info *gl_info);
887 const char *description;
890 static const struct driver_quirk quirk_table[] =
893 match_amd_r300_to_500,
895 "AMD normalized texrect quirk"
899 quirk_apple_glsl_constants,
900 "Apple GLSL uniform override"
905 "Geforce 5 NP2 disable"
910 "Init texcoord .w for Apple Intel GPU driver"
913 match_apple_nonr500ati,
915 "Init texcoord .w for Apple ATI >= r600 GPU driver"
920 "Reserved varying for gl_ClipPos"
923 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
924 * GL implementations accept it. The Mac GL is the only implementation known to
927 * If we can pass 4 component specular colors, do it, because (a) we don't have
928 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
929 * passes specular alpha to the pixel shader if any is used. Otherwise the
930 * specular alpha is used to pass the fog coordinate, which we pass to opengl
931 * via GL_EXT_fog_coord.
933 match_allows_spec_alpha,
934 quirk_allows_specular_alpha,
935 "Allow specular alpha quirk"
938 match_broken_nv_clip,
939 quirk_disable_nvvp_clip,
940 "Apple NV_vertex_program clip bug quirk"
943 match_fbo_tex_update,
944 quirk_fbo_tex_update,
945 "FBO rebind for attachment updates"
950 "True RGBA16 is not available"
955 "Not printing GLSL infolog"
958 match_not_dx10_capable,
959 quirk_limited_tex_filtering,
960 "Texture filtering, blending and VTF support is limited"
964 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
965 * reporting a driver version is moot because we are not the Windows driver, and we have different
966 * bugs, features, etc.
968 * The driver version has the form "x.y.z.w".
970 * "x" is the Windows version the driver is meant for:
977 * "y" is the maximum Direct3D version the driver supports.
978 * y -> d3d version mapping:
987 * "z" is the subversion number.
989 * "w" is the vendor specific driver build number.
992 struct driver_version_information
994 enum wined3d_display_driver driver;
995 enum wined3d_driver_model driver_model;
996 const char *driver_name; /* name of Windows driver */
997 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
998 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
999 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1002 /* The driver version table contains driver information for different devices on several OS versions. */
1003 static const struct driver_version_information driver_version_table[] =
1006 * - Radeon HD2x00 (R600) and up supported by current drivers.
1007 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1008 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1009 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1010 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
1011 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
1012 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
1013 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
1014 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1015 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1018 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1019 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1020 * igxprd32.dll but the GMA800 driver was never updated. */
1021 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1022 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1023 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1024 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1025 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1026 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1029 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1030 * - GeforceFX support is up to 173.x on <= XP
1031 * - Geforce2MX/3/4 up to 96.x on <= XP
1032 * - TNT/Geforce1/2 up to 71.x on <= XP
1033 * All version numbers used below are from the Linux nvidia drivers. */
1034 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1035 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1036 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1037 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 12, 6658},
1038 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 12, 6658},
1041 struct gpu_description
1043 WORD vendor; /* reported PCI card vendor ID */
1044 WORD card; /* reported PCI card device ID */
1045 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1046 enum wined3d_display_driver driver;
1047 unsigned int vidmem;
1050 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1051 * found on a board containing a specific GPU. */
1052 static const struct gpu_description gpu_description_table[] =
1055 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1056 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1057 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1058 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1059 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1060 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1061 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1062 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1063 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1064 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1065 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1066 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1067 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1068 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1069 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1070 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1071 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1072 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1073 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1074 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1075 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1076 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1077 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6, 320 },
1078 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6, 768 },
1079 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6, 256 },
1080 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE6, 256 },
1081 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6, 256 },
1082 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1083 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1084 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6, 384 },
1085 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1086 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6, 512 },
1087 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6, 512 },
1088 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6, 512 },
1089 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6, 1024},
1090 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6, 896 },
1091 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6, 1024},
1092 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6, 256},
1093 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6, 1024},
1094 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6, 1024},
1095 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6, 1024},
1096 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6, 1024},
1097 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6, 2048},
1098 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6, 1024},
1099 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6, 1024},
1100 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6, 1024},
1101 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6, 768 },
1102 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6, 1536},
1103 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6, 1024},
1104 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6, 1280},
1105 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6, 1536},
1106 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6, 1024},
1107 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1108 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6, 1024},
1109 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1110 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6, 1024},
1111 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6, 1280},
1112 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6, 1536},
1113 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE6, 1024},
1114 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE6, 1024},
1115 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE6, 2048},
1116 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6, 2048},
1117 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6, 2048},
1120 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1121 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1122 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1123 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1124 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1125 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1126 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1127 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1128 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1129 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1130 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1131 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1132 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1133 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1134 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1135 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1136 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1137 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1138 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1139 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1140 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1141 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1142 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1143 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1144 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1145 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1146 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1147 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1148 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1149 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1150 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1151 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1153 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1154 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1155 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1156 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1157 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1158 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1159 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1160 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1161 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1162 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1163 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1164 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1165 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1166 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1167 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1168 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1169 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1170 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1171 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1172 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1173 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1174 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1175 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1176 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1177 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1178 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1179 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000, 1024},
1180 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000, 1024},
1181 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1182 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1183 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000, 1024},
1184 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1185 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1186 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000, 1024},
1189 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1190 enum wined3d_driver_model driver_model)
1194 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1195 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
1197 const struct driver_version_information *entry = &driver_version_table[i];
1199 if (entry->driver == driver && entry->driver_model == driver_model)
1201 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1202 entry->driver_name, entry->version, entry->subversion, entry->build);
1209 static void init_driver_info(struct wined3d_driver_info *driver_info,
1210 enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
1212 OSVERSIONINFOW os_version;
1213 WORD driver_os_version;
1215 enum wined3d_display_driver driver = DRIVER_UNKNOWN;
1216 enum wined3d_driver_model driver_model;
1217 const struct driver_version_information *version_info;
1219 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1221 TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings.pci_vendor_id);
1222 vendor = wined3d_settings.pci_vendor_id;
1224 driver_info->vendor = vendor;
1226 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1228 TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings.pci_device_id);
1229 device = wined3d_settings.pci_device_id;
1231 driver_info->device = device;
1233 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1234 * overrides the pci ids to a card which is not in our database. */
1235 driver_info->vidmem = WINE_DEFAULT_VIDMEM;
1237 memset(&os_version, 0, sizeof(os_version));
1238 os_version.dwOSVersionInfoSize = sizeof(os_version);
1239 if (!GetVersionExW(&os_version))
1241 ERR("Failed to get OS version, reporting 2000/XP.\n");
1242 driver_os_version = 6;
1243 driver_model = DRIVER_MODEL_NT5X;
1247 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1248 switch (os_version.dwMajorVersion)
1251 /* If needed we could distinguish between 9x and NT4, but this code won't make
1252 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1254 driver_os_version = 4;
1255 driver_model = DRIVER_MODEL_WIN9X;
1259 driver_os_version = 6;
1260 driver_model = DRIVER_MODEL_NT5X;
1264 if (os_version.dwMinorVersion == 0)
1266 driver_os_version = 7;
1267 driver_model = DRIVER_MODEL_NT6X;
1271 if (os_version.dwMinorVersion > 1)
1273 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1274 os_version.dwMajorVersion, os_version.dwMinorVersion);
1276 driver_os_version = 8;
1277 driver_model = DRIVER_MODEL_NT6X;
1282 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1283 os_version.dwMajorVersion, os_version.dwMinorVersion);
1284 driver_os_version = 6;
1285 driver_model = DRIVER_MODEL_NT5X;
1290 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1291 * This means that unless the ids are overridden, we will always find a GPU description. */
1292 for (i = 0; i < (sizeof(gpu_description_table) / sizeof(gpu_description_table[0])); i++)
1294 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1296 TRACE("Found card %04x:%04x in driver DB.\n", vendor, device);
1298 driver_info->description = gpu_description_table[i].description;
1299 driver_info->vidmem = gpu_description_table[i].vidmem * 1024*1024;
1300 driver = gpu_description_table[i].driver;
1305 if (wined3d_settings.emulated_textureram)
1307 TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings.emulated_textureram);
1308 driver_info->vidmem = wined3d_settings.emulated_textureram;
1311 /* Try to obtain driver version information for the current Windows version. This fails in
1313 * - the gpu is not available on the currently selected OS version:
1314 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1315 * version information for the current Windows version is returned instead of faked info.
1316 * We do the same and assume the default Windows version to emulate is WinXP.
1318 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1319 * For now return the XP driver info. Perhaps later on we should return VESA.
1321 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1322 * This could be an indication that our database is not up to date, so this should be fixed.
1324 version_info = get_driver_version_info(driver, driver_model);
1327 driver_info->name = version_info->driver_name;
1328 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1329 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1333 version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X);
1336 driver_info->name = version_info->driver_name;
1337 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1338 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1342 driver_info->description = "Direct3D HAL";
1343 driver_info->name = "Display";
1344 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1345 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1347 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1348 vendor, device, driver_model);
1352 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1353 driver_info->version_high, driver_info->version_low);
1356 /* Context activation is done by the caller. */
1357 static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
1358 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1362 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
1364 if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
1365 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1366 quirk_table[i].apply(gl_info);
1369 /* Find out if PBOs work as they are supposed to. */
1370 test_pbo_functionality(gl_info);
1373 static DWORD wined3d_parse_gl_version(const char *gl_version)
1375 const char *ptr = gl_version;
1380 ERR("Invalid OpenGL major version %d.\n", major);
1382 while (isdigit(*ptr)) ++ptr;
1384 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1388 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1390 return MAKEDWORD_VERSION(major, minor);
1393 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1394 const char *gl_vendor_string, const char *gl_renderer)
1397 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1398 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1399 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1401 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1402 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1403 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1404 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1405 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1406 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1407 * DirectDraw, not OpenGL. */
1408 if (gl_info->supported[APPLE_FENCE]
1409 && gl_info->supported[APPLE_CLIENT_STORAGE]
1410 && gl_info->supported[APPLE_YCBCR_422])
1411 return GL_VENDOR_APPLE;
1413 if (strstr(gl_vendor_string, "NVIDIA"))
1414 return GL_VENDOR_NVIDIA;
1416 if (strstr(gl_vendor_string, "ATI"))
1417 return GL_VENDOR_FGLRX;
1419 if (strstr(gl_vendor_string, "Intel(R)")
1420 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1421 || strstr(gl_renderer, "Intel")
1422 || strstr(gl_vendor_string, "Intel Inc."))
1423 return GL_VENDOR_INTEL;
1425 if (strstr(gl_vendor_string, "Mesa")
1426 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1427 || strstr(gl_vendor_string, "DRI R300 Project")
1428 || strstr(gl_vendor_string, "X.Org R300 Project")
1429 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1430 || strstr(gl_vendor_string, "VMware, Inc.")
1431 || strstr(gl_renderer, "Mesa")
1432 || strstr(gl_renderer, "Gallium"))
1433 return GL_VENDOR_MESA;
1435 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1436 debugstr_a(gl_vendor_string));
1438 return GL_VENDOR_UNKNOWN;
1441 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1443 if (strstr(gl_vendor_string, "NVIDIA")
1444 || strstr(gl_vendor_string, "Nouveau")
1445 || strstr(gl_vendor_string, "nouveau"))
1446 return HW_VENDOR_NVIDIA;
1448 if (strstr(gl_vendor_string, "ATI")
1449 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1450 || strstr(gl_vendor_string, "X.Org R300 Project")
1451 || strstr(gl_renderer, "AMD")
1452 || strstr(gl_renderer, "R100")
1453 || strstr(gl_renderer, "R200")
1454 || strstr(gl_renderer, "R300")
1455 || strstr(gl_renderer, "R600")
1456 || strstr(gl_renderer, "R700"))
1457 return HW_VENDOR_AMD;
1459 if (strstr(gl_vendor_string, "Intel(R)")
1460 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1461 || strstr(gl_renderer, "Intel")
1462 || strstr(gl_renderer, "i915")
1463 || strstr(gl_vendor_string, "Intel Inc."))
1464 return HW_VENDOR_INTEL;
1466 if (strstr(gl_vendor_string, "Mesa")
1467 || strstr(gl_vendor_string, "Brian Paul")
1468 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1469 || strstr(gl_vendor_string, "VMware, Inc."))
1470 return HW_VENDOR_SOFTWARE;
1472 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1474 return HW_VENDOR_NVIDIA;
1477 static UINT d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info)
1481 if (gl_info->supported[ARB_MULTITEXTURE])
1483 if (gl_info->supported[ARB_TEXTURE_COMPRESSION]
1484 && gl_info->supported[ARB_TEXTURE_CUBE_MAP]
1485 && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
1487 if (level == 7 && gl_info->supported[ARB_MULTISAMPLE]
1488 && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
1490 if (level == 8 && gl_info->supported[ARB_FRAGMENT_PROGRAM]
1491 && gl_info->supported[ARB_VERTEX_SHADER])
1493 if (level == 9 && gl_info->supported[EXT_GPU_SHADER4])
1499 static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
1500 const char *gl_renderer)
1502 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1505 if (d3d_level >= 10)
1509 const char *renderer;
1510 enum wined3d_pci_device id;
1514 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1515 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1516 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1517 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1518 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1519 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1520 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1521 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1522 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1523 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1524 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1525 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1526 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1527 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1528 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1529 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1530 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1531 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1532 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1533 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1534 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1535 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1536 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1537 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1538 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1539 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1540 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1541 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1542 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1543 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1544 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1545 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1546 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1547 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1548 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1549 {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1550 {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1551 {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1552 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1553 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1554 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1555 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1556 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1557 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1558 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1559 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1560 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1561 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1562 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1563 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1564 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1565 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1566 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1567 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1568 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1569 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1570 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1571 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1572 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1573 {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1574 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1575 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1576 {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1577 {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1580 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1582 if (strstr(gl_renderer, cards[i].renderer))
1585 return PCI_DEVICE_NONE;
1588 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1589 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1591 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
1595 const char *renderer;
1596 enum wined3d_pci_device id;
1600 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1601 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1602 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1603 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1604 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1605 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1606 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1607 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
1608 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
1609 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
1610 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1611 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1612 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1615 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1617 if (strstr(gl_renderer, cards[i].renderer))
1620 return PCI_DEVICE_NONE;
1625 /* GeforceFX - highend */
1626 if (strstr(gl_renderer, "5800")
1627 || strstr(gl_renderer, "5900")
1628 || strstr(gl_renderer, "5950")
1629 || strstr(gl_renderer, "Quadro FX"))
1631 return CARD_NVIDIA_GEFORCEFX_5800;
1634 /* GeforceFX - midend */
1635 if (strstr(gl_renderer, "5600")
1636 || strstr(gl_renderer, "5650")
1637 || strstr(gl_renderer, "5700")
1638 || strstr(gl_renderer, "5750"))
1640 return CARD_NVIDIA_GEFORCEFX_5600;
1643 /* GeforceFX - lowend */
1644 return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
1649 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
1651 return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1654 return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1659 if (strstr(gl_renderer, "GeForce4 MX"))
1661 return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
1664 if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
1666 return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1669 if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
1671 return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1674 return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
1677 if (strstr(gl_renderer, "TNT2"))
1679 return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
1682 return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
1685 static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info,
1686 const char *gl_renderer)
1688 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1690 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1692 * Beware: renderer string do not match exact card model,
1693 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1694 if (d3d_level >= 10)
1700 const char *renderer;
1701 enum wined3d_pci_device id;
1705 /* Southern Islands */
1706 {"HD 7900", CARD_AMD_RADEON_HD7900},
1707 {"HD 7800", CARD_AMD_RADEON_HD7800},
1708 {"HD 7700", CARD_AMD_RADEON_HD7700},
1709 /* Northern Islands */
1710 {"HD 6970", CARD_AMD_RADEON_HD6900},
1711 {"HD 6900", CARD_AMD_RADEON_HD6900},
1712 {"HD 6800", CARD_AMD_RADEON_HD6800},
1713 {"HD 6770M",CARD_AMD_RADEON_HD6600M},
1714 {"HD 6750M",CARD_AMD_RADEON_HD6600M},
1715 {"HD 6700", CARD_AMD_RADEON_HD6700},
1716 {"HD 6670", CARD_AMD_RADEON_HD6600},
1717 {"HD 6630M",CARD_AMD_RADEON_HD6600M},
1718 {"HD 6600M",CARD_AMD_RADEON_HD6600M},
1719 {"HD 6600", CARD_AMD_RADEON_HD6600},
1720 {"HD 6500M",CARD_AMD_RADEON_HD6600M},
1721 {"HD 6500", CARD_AMD_RADEON_HD6600},
1722 {"HD 6400", CARD_AMD_RADEON_HD6400},
1723 {"HD 6300", CARD_AMD_RADEON_HD6300},
1724 {"HD 6200", CARD_AMD_RADEON_HD6300},
1726 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
1727 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
1728 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1729 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
1730 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
1731 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1732 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
1733 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1734 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1735 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
1736 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
1738 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
1739 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1740 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1741 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1742 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
1743 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
1744 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
1745 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1746 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1747 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1748 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1749 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1750 /* R600/R700 integrated */
1751 {"HD 3300", CARD_AMD_RADEON_HD3200},
1752 {"HD 3200", CARD_AMD_RADEON_HD3200},
1753 {"HD 3100", CARD_AMD_RADEON_HD3200},
1755 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1756 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1757 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1758 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
1759 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1760 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1761 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1762 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1763 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1764 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1765 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1766 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1767 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1770 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1772 if (strstr(gl_renderer, cards[i].renderer))
1775 return PCI_DEVICE_NONE;
1781 if (strstr(gl_renderer, "X1600")
1782 || strstr(gl_renderer, "X1650")
1783 || strstr(gl_renderer, "X1800")
1784 || strstr(gl_renderer, "X1900")
1785 || strstr(gl_renderer, "X1950"))
1787 return CARD_AMD_RADEON_X1600;
1790 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1791 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1792 if (strstr(gl_renderer, "X700")
1793 || strstr(gl_renderer, "X800")
1794 || strstr(gl_renderer, "X850")
1795 || strstr(gl_renderer, "X1300")
1796 || strstr(gl_renderer, "X1400")
1797 || strstr(gl_renderer, "X1450")
1798 || strstr(gl_renderer, "X1550")
1799 || strstr(gl_renderer, "X2300")
1800 || strstr(gl_renderer, "X2500")
1801 || strstr(gl_renderer, "HD 2300")
1804 return CARD_AMD_RADEON_X700;
1807 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1808 if (strstr(gl_renderer, "Radeon Xpress"))
1810 return CARD_AMD_RADEON_XPRESS_200M;
1813 return PCI_DEVICE_NONE;
1816 static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info,
1817 const char *gl_renderer)
1823 const char *renderer;
1824 enum wined3d_pci_device id;
1829 {"Ivybridge Server", CARD_INTEL_IVBS},
1830 {"Ivybridge Mobile", CARD_INTEL_IVBM},
1831 {"Ivybridge Desktop", CARD_INTEL_IVBD},
1833 {"Sandybridge Server", CARD_INTEL_SNBS},
1834 {"Sandybridge Mobile", CARD_INTEL_SNBM},
1835 {"Sandybridge Desktop", CARD_INTEL_SNBD},
1837 {"Ironlake Mobile", CARD_INTEL_ILKM},
1838 {"Ironlake Desktop", CARD_INTEL_ILKD},
1840 {"B43", CARD_INTEL_B43},
1841 {"G41", CARD_INTEL_G41},
1842 {"G45", CARD_INTEL_G45},
1843 {"Q45", CARD_INTEL_Q45},
1844 {"Integrated Graphics Device", CARD_INTEL_IGD},
1845 {"GM45", CARD_INTEL_GM45},
1847 {"965GME", CARD_INTEL_965GME},
1848 {"965GM", CARD_INTEL_965GM},
1849 {"X3100", CARD_INTEL_965GM}, /* MacOS */
1850 {"946GZ", CARD_INTEL_946GZ},
1851 {"965G", CARD_INTEL_965G},
1852 {"965Q", CARD_INTEL_965Q},
1854 {"Pineview M", CARD_INTEL_PNVM},
1855 {"Pineview G", CARD_INTEL_PNVG},
1856 {"IGD", CARD_INTEL_PNVG},
1857 {"Q33", CARD_INTEL_Q33},
1858 {"G33", CARD_INTEL_G33},
1859 {"Q35", CARD_INTEL_Q35},
1860 {"945GME", CARD_INTEL_945GME},
1861 {"945GM", CARD_INTEL_945GM},
1862 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
1863 {"945G", CARD_INTEL_945G},
1865 {"915GM", CARD_INTEL_915GM},
1866 {"E7221G", CARD_INTEL_E7221G},
1867 {"915G", CARD_INTEL_915G},
1869 {"865G", CARD_INTEL_865G},
1870 {"845G", CARD_INTEL_845G},
1871 {"855GM", CARD_INTEL_855GM},
1872 {"830M", CARD_INTEL_830M},
1875 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1877 if (strstr(gl_renderer, cards[i].renderer))
1881 return PCI_DEVICE_NONE;
1884 static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info,
1885 const char *gl_renderer)
1890 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1892 * Beware: renderer string do not match exact card model,
1893 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1894 if (strstr(gl_renderer, "Gallium"))
1896 /* 20101109 - These are never returned by current Gallium radeon
1897 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1899 * These are returned but not handled: RC410, RV380. */
1902 const char *renderer;
1903 enum wined3d_pci_device id;
1907 /* Southern Islands */
1908 {"TAHITI", CARD_AMD_RADEON_HD7900},
1909 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
1910 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
1911 /* Northern Islands */
1912 {"CAYMAN", CARD_AMD_RADEON_HD6900},
1913 {"BARTS", CARD_AMD_RADEON_HD6800},
1914 {"TURKS", CARD_AMD_RADEON_HD6600},
1915 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
1916 {"SUMO", CARD_AMD_RADEON_HD6550D},
1917 {"CAICOS", CARD_AMD_RADEON_HD6400},
1918 {"PALM", CARD_AMD_RADEON_HD6300},
1920 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
1921 {"CYPRESS", CARD_AMD_RADEON_HD5800},
1922 {"JUNIPER", CARD_AMD_RADEON_HD5700},
1923 {"REDWOOD", CARD_AMD_RADEON_HD5600},
1924 {"CEDAR", CARD_AMD_RADEON_HD5400},
1926 {"R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
1927 {"RV790", CARD_AMD_RADEON_HD4800},
1928 {"RV770", CARD_AMD_RADEON_HD4800},
1929 {"RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
1930 {"RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
1931 {"RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
1932 /* R600/R700 integrated */
1933 {"RS880", CARD_AMD_RADEON_HD3200},
1934 {"RS780", CARD_AMD_RADEON_HD3200},
1936 {"R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1937 {"R600", CARD_AMD_RADEON_HD2900},
1938 {"RV670", CARD_AMD_RADEON_HD2900},
1939 {"RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1940 {"RV630", CARD_AMD_RADEON_HD2600},
1941 {"RV620", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1942 {"RV610", CARD_AMD_RADEON_HD2350},
1944 {"R580", CARD_AMD_RADEON_X1600},
1945 {"R520", CARD_AMD_RADEON_X1600},
1946 {"RV570", CARD_AMD_RADEON_X1600},
1947 {"RV560", CARD_AMD_RADEON_X1600},
1948 {"RV535", CARD_AMD_RADEON_X1600},
1949 {"RV530", CARD_AMD_RADEON_X1600},
1950 {"RV516", CARD_AMD_RADEON_X700}, /* X700 is actually R400. */
1951 {"RV515", CARD_AMD_RADEON_X700},
1953 {"R481", CARD_AMD_RADEON_X700},
1954 {"R480", CARD_AMD_RADEON_X700},
1955 {"R430", CARD_AMD_RADEON_X700},
1956 {"R423", CARD_AMD_RADEON_X700},
1957 {"R420", CARD_AMD_RADEON_X700},
1958 {"R410", CARD_AMD_RADEON_X700},
1959 {"RV410", CARD_AMD_RADEON_X700},
1960 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1961 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
1962 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
1963 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
1964 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
1965 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
1966 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
1967 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
1969 {"R360", CARD_AMD_RADEON_9500},
1970 {"R350", CARD_AMD_RADEON_9500},
1971 {"R300", CARD_AMD_RADEON_9500},
1972 {"RV370", CARD_AMD_RADEON_9500},
1973 {"RV360", CARD_AMD_RADEON_9500},
1974 {"RV351", CARD_AMD_RADEON_9500},
1975 {"RV350", CARD_AMD_RADEON_9500},
1978 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1980 if (strstr(gl_renderer, cards[i].renderer))
1983 return PCI_DEVICE_NONE;
1986 d3d_level = d3d_level_from_gl_info(gl_info);
1991 const char *renderer;
1992 enum wined3d_pci_device id;
1997 {"(R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
1998 {"(RV790", CARD_AMD_RADEON_HD4800},
1999 {"(RV770", CARD_AMD_RADEON_HD4800},
2000 {"(RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
2001 {"(RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
2002 {"(RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
2003 /* R600/R700 integrated */
2004 {"RS880", CARD_AMD_RADEON_HD3200},
2005 {"RS780", CARD_AMD_RADEON_HD3200},
2007 {"(R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2008 {"(R600", CARD_AMD_RADEON_HD2900},
2009 {"(RV670", CARD_AMD_RADEON_HD2900},
2010 {"(RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
2011 {"(RV630", CARD_AMD_RADEON_HD2600},
2012 {"(RV620", CARD_AMD_RADEON_HD2350}, /* HD2300/HD2400/HD3400 - lowend */
2013 {"(RV610", CARD_AMD_RADEON_HD2350},
2016 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2018 if (strstr(gl_renderer, cards[i].renderer))
2022 return PCI_DEVICE_NONE;
2025 static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
2026 const char *gl_renderer)
2032 const char *renderer;
2033 enum wined3d_pci_device id;
2038 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680},
2040 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2041 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2042 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2043 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2044 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2045 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2046 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2048 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2049 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2050 {"NVAA", CARD_NVIDIA_GEFORCE_8200},
2051 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2052 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2053 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2054 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2055 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2056 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2057 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2058 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2059 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2060 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2061 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2063 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2064 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2065 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2066 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2067 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2068 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2069 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2070 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2071 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2072 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2073 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2074 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2075 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2076 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2077 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2078 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2080 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2081 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2082 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2083 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2084 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2085 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2087 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2088 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2089 {"nv20", CARD_NVIDIA_GEFORCE3},
2091 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2092 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2093 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2094 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2095 {"nv16", CARD_NVIDIA_GEFORCE2},
2096 {"nv15", CARD_NVIDIA_GEFORCE2},
2097 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2098 {"nv10", CARD_NVIDIA_GEFORCE},
2100 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2101 {"nv04", CARD_NVIDIA_RIVA_TNT},
2102 {"nv03", CARD_NVIDIA_RIVA_128},
2105 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2107 if (strstr(gl_renderer, cards[i].renderer))
2110 return PCI_DEVICE_NONE;
2113 static const struct gl_vendor_selection
2115 enum wined3d_gl_vendor gl_vendor;
2116 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2117 enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer);
2119 nvidia_gl_vendor_table[] =
2121 {GL_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
2122 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
2123 {GL_VENDOR_MESA, "Mesa Nouveau driver", select_card_nvidia_mesa},
2125 amd_gl_vendor_table[] =
2127 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", select_card_amd_binary},
2128 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", select_card_amd_binary},
2129 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", select_card_amd_mesa},
2131 intel_gl_vendor_table[] =
2133 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", select_card_intel},
2134 {GL_VENDOR_INTEL, "Mesa Intel driver", select_card_intel},
2135 {GL_VENDOR_MESA, "Mesa Intel driver", select_card_intel},
2138 static enum wined3d_pci_device select_card_fallback_nvidia(const struct wined3d_gl_info *gl_info)
2140 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2141 if (d3d_level >= 10)
2142 return CARD_NVIDIA_GEFORCE_8800GTX;
2143 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
2144 return CARD_NVIDIA_GEFORCE_6800;
2146 return CARD_NVIDIA_GEFORCEFX_5800;
2148 return CARD_NVIDIA_GEFORCE3;
2150 return CARD_NVIDIA_GEFORCE;
2152 return CARD_NVIDIA_RIVA_TNT;
2153 return CARD_NVIDIA_RIVA_128;
2156 static enum wined3d_pci_device select_card_fallback_amd(const struct wined3d_gl_info *gl_info)
2158 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2159 if (d3d_level >= 10)
2160 return CARD_AMD_RADEON_HD2900;
2162 return CARD_AMD_RADEON_9500;
2164 return CARD_AMD_RADEON_8500;
2166 return CARD_AMD_RADEON_7200;
2167 return CARD_AMD_RAGE_128PRO;
2170 static enum wined3d_pci_device select_card_fallback_intel(const struct wined3d_gl_info *gl_info)
2172 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2173 if (d3d_level >= 10)
2174 return CARD_INTEL_G45;
2175 return CARD_INTEL_915G;
2178 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2179 unsigned int table_size, enum wined3d_gl_vendor gl_vendor,
2180 const struct wined3d_gl_info *gl_info, const char *gl_renderer)
2184 for (i = 0; i < table_size; ++i)
2186 if (table[i].gl_vendor != gl_vendor)
2189 TRACE("Applying card selector \"%s\".\n", table[i].description);
2190 return table[i].select_card(gl_info, gl_renderer);
2192 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2193 gl_vendor, debugstr_a(gl_renderer));
2195 return PCI_DEVICE_NONE;
2200 enum wined3d_pci_vendor card_vendor;
2201 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2202 const struct gl_vendor_selection *gl_vendor_selection;
2203 unsigned int gl_vendor_count;
2204 enum wined3d_pci_device (*select_card_fallback)(const struct wined3d_gl_info *gl_info);
2206 card_vendor_table[] =
2208 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2209 sizeof(nvidia_gl_vendor_table) / sizeof(nvidia_gl_vendor_table[0]),
2210 select_card_fallback_nvidia},
2211 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2212 sizeof(amd_gl_vendor_table) / sizeof(amd_gl_vendor_table[0]),
2213 select_card_fallback_amd},
2214 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2215 sizeof(intel_gl_vendor_table) / sizeof(intel_gl_vendor_table[0]),
2216 select_card_fallback_intel},
2220 static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
2221 enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2223 /* A Direct3D device object contains the PCI id (vendor + device) of the
2224 * videocard which is used for rendering. Various applications use this
2225 * information to get a rough estimation of the features of the card and
2226 * some might use it for enabling 3d effects only on certain types of
2227 * videocards. In some cases games might even use it to work around bugs
2228 * which happen on certain videocards/driver combinations. The problem is
2229 * that OpenGL only exposes a rendering string containing the name of the
2230 * videocard and not the PCI id.
2232 * Various games depend on the PCI id, so somehow we need to provide one.
2233 * A simple option is to parse the renderer string and translate this to
2234 * the right PCI id. This is a lot of work because there are more than 200
2235 * GPUs just for Nvidia. Various cards share the same renderer string, so
2236 * the amount of code might be 'small' but there are quite a number of
2237 * exceptions which would make this a pain to maintain. Another way would
2238 * be to query the PCI id from the operating system (assuming this is the
2239 * videocard which is used for rendering which is not always the case).
2240 * This would work but it is not very portable. Second it would not work
2241 * well in, let's say, a remote X situation in which the amount of 3d
2242 * features which can be used is limited.
2244 * As said most games only use the PCI id to get an indication of the
2245 * capabilities of the card. It doesn't really matter if the given id is
2246 * the correct one if we return the id of a card with similar 3d features.
2248 * The code below checks the OpenGL capabilities of a videocard and matches
2249 * that to a certain level of Direct3D functionality. Once a card passes
2250 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2251 * least a GeforceFX. To give a better estimate we do a basic check on the
2252 * renderer string but if that won't pass we return a default card. This
2253 * way is better than maintaining a full card database as even without a
2254 * full database we can return a card with similar features. Second the
2255 * size of the database can be made quite small because when you know what
2256 * type of 3d functionality a card has, you know to which GPU family the
2257 * GPU must belong. Because of this you only have to check a small part of
2258 * the renderer string to distinguishes between different models from that
2261 * The code also selects a default amount of video memory which we will
2262 * use for an estimation of the amount of free texture memory. In case of
2263 * real D3D the amount of texture memory includes video memory and system
2264 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2265 * HyperMemory). We don't know how much system memory can be addressed by
2266 * the system but we can make a reasonable estimation about the amount of
2267 * video memory. If the value is slightly wrong it doesn't matter as we
2268 * didn't include AGP-like memory which makes the amount of addressable
2269 * memory higher and second OpenGL isn't that critical it moves to system
2270 * memory behind our backs if really needed. Note that the amount of video
2271 * memory can be overruled using a registry setting. */
2274 enum wined3d_pci_device device;
2276 for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
2278 if (card_vendor_table[i].card_vendor != *card_vendor)
2281 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2282 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2283 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_info, gl_renderer);
2284 if (device != PCI_DEVICE_NONE)
2287 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2288 return card_vendor_table[i].select_card_fallback(gl_info);
2291 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2292 *card_vendor, debugstr_a(gl_renderer));
2294 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2295 *card_vendor = HW_VENDOR_NVIDIA;
2296 return select_card_fallback_nvidia(gl_info);
2299 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info)
2301 int vs_selected_mode, ps_selected_mode;
2303 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2304 if (ps_selected_mode == SHADER_GLSL)
2305 return &glsl_fragment_pipe;
2306 if (ps_selected_mode == SHADER_ARB)
2307 return &arbfp_fragment_pipeline;
2308 if (ps_selected_mode == SHADER_ATI)
2309 return &atifs_fragment_pipeline;
2310 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2311 return &nvts_fragment_pipeline;
2312 if (gl_info->supported[NV_REGISTER_COMBINERS])
2313 return &nvrc_fragment_pipeline;
2314 return &ffp_fragment_pipeline;
2317 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2319 int vs_selected_mode, ps_selected_mode;
2321 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2322 if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
2323 if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
2324 return &none_shader_backend;
2327 static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info)
2329 int vs_selected_mode, ps_selected_mode;
2331 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2332 if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
2333 && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
2334 else return &ffp_blit;
2337 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2338 const struct wined3d_extension_map *map, UINT entry_count)
2346 while (isspace(*extensions))
2349 while (!isspace(*extensions) && *extensions)
2352 len = extensions - start;
2356 TRACE("- %s.\n", debugstr_an(start, len));
2358 for (i = 0; i < entry_count; ++i)
2360 if (len == strlen(map[i].extension_string)
2361 && !memcmp(start, map[i].extension_string, len))
2363 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2364 gl_info->supported[map[i].extension] = TRUE;
2371 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2373 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2377 #ifndef USE_WIN32_OPENGL
2378 /* hack: use the functions directly from the TEB table to bypass the thunks */
2379 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2380 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
2384 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
2386 GLfloat gl_floatv[2];
2389 gl_info->limits.blends = 1;
2390 gl_info->limits.buffers = 1;
2391 gl_info->limits.textures = 1;
2392 gl_info->limits.texture_coords = 1;
2393 gl_info->limits.fragment_samplers = 1;
2394 gl_info->limits.vertex_samplers = 0;
2395 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
2396 gl_info->limits.vertex_attribs = 16;
2397 gl_info->limits.glsl_vs_float_constants = 0;
2398 gl_info->limits.glsl_ps_float_constants = 0;
2399 gl_info->limits.arb_vs_float_constants = 0;
2400 gl_info->limits.arb_vs_native_constants = 0;
2401 gl_info->limits.arb_vs_instructions = 0;
2402 gl_info->limits.arb_vs_temps = 0;
2403 gl_info->limits.arb_ps_float_constants = 0;
2404 gl_info->limits.arb_ps_local_constants = 0;
2405 gl_info->limits.arb_ps_instructions = 0;
2406 gl_info->limits.arb_ps_temps = 0;
2408 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
2409 gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
2410 TRACE("Clip plane support - max planes %d.\n", gl_max);
2412 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
2413 gl_info->limits.lights = gl_max;
2414 TRACE("Light support - max lights %d.\n", gl_max);
2416 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
2417 gl_info->limits.texture_size = gl_max;
2418 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
2420 gl_info->gl_ops.gl.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
2421 gl_info->limits.pointsize_min = gl_floatv[0];
2422 gl_info->limits.pointsize_max = gl_floatv[1];
2423 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
2425 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
2427 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
2428 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
2432 WARN("Driver doesn't guarantee a minimum buffer map alignment.\n");
2434 if (gl_info->supported[NV_REGISTER_COMBINERS])
2436 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
2437 gl_info->limits.general_combiners = gl_max;
2438 TRACE("Max general combiners: %d.\n", gl_max);
2440 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2442 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
2443 gl_info->limits.buffers = gl_max;
2444 TRACE("Max draw buffers: %u.\n", gl_max);
2446 if (gl_info->supported[ARB_MULTITEXTURE])
2448 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
2449 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
2450 TRACE("Max textures: %d.\n", gl_info->limits.textures);
2452 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2455 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
2456 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
2457 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2458 gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
2462 gl_info->limits.texture_coords = max(gl_info->limits.texture_coords, gl_max);
2463 gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, gl_max);
2465 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
2466 TRACE("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
2468 if (gl_info->supported[ARB_VERTEX_SHADER])
2471 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2472 gl_info->limits.vertex_samplers = tmp;
2473 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2474 gl_info->limits.combined_samplers = tmp;
2475 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &tmp);
2476 gl_info->limits.vertex_attribs = tmp;
2478 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2479 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2480 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2481 * shader is used with fixed function vertex processing we're fine too because fixed function
2482 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2483 * used we have to make sure that all vertex sampler setups are valid together with all
2484 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2485 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2486 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2487 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2488 * a fixed function pipeline anymore.
2490 * So this is just a check to check that our assumption holds true. If not, write a warning
2491 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2492 if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
2493 && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
2495 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2496 gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
2497 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2498 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
2499 gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
2501 gl_info->limits.vertex_samplers = 0;
2506 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
2508 TRACE("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
2509 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
2511 if (gl_info->supported[ARB_VERTEX_BLEND])
2513 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
2514 gl_info->limits.blends = gl_max;
2515 TRACE("Max blends: %u.\n", gl_info->limits.blends);
2517 if (gl_info->supported[EXT_TEXTURE3D])
2519 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
2520 gl_info->limits.texture3d_size = gl_max;
2521 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
2523 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
2525 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
2526 gl_info->limits.anisotropy = gl_max;
2527 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
2529 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2531 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2532 gl_info->limits.arb_ps_float_constants = gl_max;
2533 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
2534 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2535 gl_info->limits.arb_ps_native_constants = gl_max;
2536 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2537 gl_info->limits.arb_ps_native_constants);
2538 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2539 gl_info->limits.arb_ps_temps = gl_max;
2540 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
2541 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2542 gl_info->limits.arb_ps_instructions = gl_max;
2543 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
2544 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
2545 gl_info->limits.arb_ps_local_constants = gl_max;
2546 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
2548 if (gl_info->supported[ARB_VERTEX_PROGRAM])
2550 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2551 gl_info->limits.arb_vs_float_constants = gl_max;
2552 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
2553 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2554 gl_info->limits.arb_vs_native_constants = gl_max;
2555 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2556 gl_info->limits.arb_vs_native_constants);
2557 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2558 gl_info->limits.arb_vs_temps = gl_max;
2559 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
2560 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2561 gl_info->limits.arb_vs_instructions = gl_max;
2562 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
2564 if (gl_info->supported[ARB_VERTEX_SHADER])
2566 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
2567 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
2568 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
2570 if (gl_info->supported[ARB_FRAGMENT_SHADER])
2572 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
2573 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
2574 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
2575 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
2576 gl_info->limits.glsl_varyings = gl_max;
2577 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
2580 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
2581 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
2583 gl_info->limits.shininess = 128.0f;
2585 if ((gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2586 && wined3d_settings.allow_multisampling)
2588 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
2589 gl_info->limits.samples = gl_max;
2593 /* Context activation is done by the caller. */
2594 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
2596 struct wined3d_driver_info *driver_info = &adapter->driver_info;
2597 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
2598 struct wined3d_gl_info *gl_info = &adapter->gl_info;
2599 enum wined3d_pci_vendor card_vendor;
2600 struct fragment_caps fragment_caps;
2601 const char *WGL_Extensions = NULL;
2602 const char *GL_Extensions = NULL;
2603 enum wined3d_gl_vendor gl_vendor;
2604 enum wined3d_pci_device device;
2608 TRACE("adapter %p.\n", adapter);
2612 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
2613 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
2614 if (!gl_renderer_str)
2617 ERR("Received a NULL GL_RENDERER.\n");
2621 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
2622 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
2626 ERR("Received a NULL GL_VENDOR.\n");
2630 /* Parse the GL_VERSION field into major and minor information */
2631 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
2632 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
2633 if (!gl_version_str)
2636 ERR("Received a NULL GL_VERSION.\n");
2639 gl_version = wined3d_parse_gl_version(gl_version_str);
2641 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2642 GL_Extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
2646 ERR("Received a NULL GL_EXTENSIONS.\n");
2652 memset(gl_info->supported, 0, sizeof(gl_info->supported));
2653 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
2655 TRACE("GL extensions reported:\n");
2656 parse_extension_string(gl_info, GL_Extensions, gl_extension_map,
2657 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
2659 /* Now work out what GL support this card really has. */
2660 load_gl_funcs( gl_info );
2662 hdc = wglGetCurrentDC();
2663 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
2664 if (GL_EXTCALL(wglGetExtensionsStringARB))
2665 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
2666 if (!WGL_Extensions)
2667 WARN("WGL extensions not supported.\n");
2669 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
2670 sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
2672 if (!gl_info->supported[EXT_TEXTURE3D] && gl_version >= MAKEDWORD_VERSION(1, 2))
2674 TRACE("GL CORE: GL_EXT_texture3D support.\n");
2675 gl_info->gl_ops.ext.p_glTexImage3DEXT = (void *)gl_info->gl_ops.ext.p_glTexImage3D;
2676 gl_info->gl_ops.ext.p_glTexSubImage3DEXT = gl_info->gl_ops.ext.p_glTexSubImage3D;
2677 gl_info->supported[EXT_TEXTURE3D] = TRUE;
2680 if (!gl_info->supported[NV_POINT_SPRITE] && gl_version >= MAKEDWORD_VERSION(1, 4))
2682 TRACE("GL CORE: GL_NV_point_sprite support.\n");
2683 gl_info->gl_ops.ext.p_glPointParameterivNV = gl_info->gl_ops.ext.p_glPointParameteriv;
2684 gl_info->gl_ops.ext.p_glPointParameteriNV = gl_info->gl_ops.ext.p_glPointParameteri;
2685 gl_info->supported[NV_POINT_SPRITE] = TRUE;
2688 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && gl_version >= MAKEDWORD_VERSION(2, 0))
2690 TRACE("GL CORE: GL_ARB_texture_non_power_of_two support.\n");
2691 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = TRUE;
2694 if (gl_version >= MAKEDWORD_VERSION(2, 0)) gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
2696 if (gl_info->supported[APPLE_FENCE])
2698 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2699 * The apple extension interacts with some other apple exts. Disable the NV
2700 * extension if the apple one is support to prevent confusion in other parts
2702 gl_info->supported[NV_FENCE] = FALSE;
2704 if (gl_info->supported[APPLE_FLOAT_PIXELS])
2706 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2708 * The enums are the same:
2709 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
2710 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
2711 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2712 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2713 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
2715 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
2717 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
2718 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
2720 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
2722 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
2723 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
2726 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
2728 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2729 * functionality. Prefer the ARB extension */
2730 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
2732 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2734 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2735 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
2737 if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
2739 TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2740 gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
2742 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
2744 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2745 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
2747 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
2749 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2750 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
2752 if (gl_info->supported[NV_TEXTURE_SHADER2])
2754 if (gl_info->supported[NV_REGISTER_COMBINERS])
2756 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2757 * are supported. The nv extensions provide the same functionality as the
2758 * ATI one, and a bit more(signed pixelformats). */
2759 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
2762 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
2764 /* If we have full NP2 texture support, disable
2765 * GL_ARB_texture_rectangle because we will never use it.
2766 * This saves a few redundant glDisable calls. */
2767 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
2769 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2771 /* Disable NV_register_combiners and fragment shader if this is supported.
2772 * generally the NV extensions are preferred over the ATI ones, and this
2773 * extension is disabled if register_combiners and texture_shader2 are both
2774 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2775 * fragment processing support. */
2776 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
2777 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
2778 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
2779 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
2781 if (gl_info->supported[NV_HALF_FLOAT])
2783 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2784 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
2786 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
2788 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
2789 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
2790 * we never render to sRGB surfaces). */
2791 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
2796 wined3d_adapter_init_limits(gl_info);
2798 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
2799 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
2801 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
2803 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
2804 unsigned int major, minor;
2806 TRACE("GLSL version string: %s.\n", debugstr_a(str));
2808 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2809 sscanf(str, "%u.%u", &major, &minor);
2810 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
2813 checkGLcall("extension detection");
2817 adapter->fragment_pipe = select_fragment_implementation(gl_info);
2818 adapter->shader_backend = select_shader_backend(gl_info);
2819 adapter->blitter = select_blit_implementation(gl_info);
2821 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
2822 gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
2823 TRACE("Max texture stages: %u.\n", gl_info->limits.texture_stages);
2825 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
2827 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
2828 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
2829 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
2830 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
2831 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
2832 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
2833 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
2834 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
2835 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
2836 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
2837 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
2838 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
2839 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
2840 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
2841 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
2842 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
2843 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
2844 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
2845 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
2846 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
2850 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
2852 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
2853 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
2854 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
2855 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
2856 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
2857 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
2858 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
2859 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
2860 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
2861 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
2862 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
2863 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
2864 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
2865 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
2866 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
2867 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
2868 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
2869 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
2871 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2873 WARN("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2874 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
2876 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
2878 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
2880 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2882 gl_info->fbo_ops.glRenderbufferStorageMultisample
2883 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
2887 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
2888 card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
2889 TRACE("Found GL_VENDOR (%s)->(0x%04x/0x%04x).\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
2891 device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor);
2892 TRACE("Found (fake) card: 0x%x (vendor id), 0x%x (device id).\n", card_vendor, device);
2894 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
2895 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
2896 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
2897 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
2898 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
2899 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
2900 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
2901 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
2903 fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
2904 init_driver_info(driver_info, card_vendor, device);
2905 add_gl_compat_wrappers(gl_info);
2910 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
2912 TRACE("wined3d %p, reporting %u adapters.\n",
2913 wined3d, wined3d->adapter_count);
2915 return wined3d->adapter_count;
2918 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
2920 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
2925 HMONITOR CDECL wined3d_get_adapter_monitor(const struct wined3d *wined3d, UINT adapter_idx)
2927 TRACE("wined3d %p, adapter_idx %u.\n", wined3d, adapter_idx);
2929 if (adapter_idx >= wined3d->adapter_count)
2932 return MonitorFromPoint(wined3d->adapters[adapter_idx].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
2935 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2936 of the same bpp but different resolutions */
2938 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2939 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
2940 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
2942 const struct wined3d_adapter *adapter;
2943 const struct wined3d_format *format;
2949 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
2950 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
2952 if (adapter_idx >= wined3d->adapter_count)
2955 adapter = &wined3d->adapters[adapter_idx];
2956 format = wined3d_get_format(&adapter->gl_info, format_id);
2957 format_bits = format->byte_count * CHAR_BIT;
2959 memset(&mode, 0, sizeof(mode));
2960 mode.dmSize = sizeof(mode);
2962 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
2964 if (mode.dmFields & DM_DISPLAYFLAGS)
2966 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
2967 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
2970 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
2971 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
2975 if (format_id == WINED3DFMT_UNKNOWN)
2977 /* This is for d3d8, do not enumerate P8 here. */
2978 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
2980 else if (mode.dmBitsPerPel == format_bits)
2986 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
2991 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2992 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
2993 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
2994 UINT mode_idx, struct wined3d_display_mode *mode)
2996 const struct wined3d_adapter *adapter;
2997 const struct wined3d_format *format;
3003 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
3004 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
3006 if (!mode || adapter_idx >= wined3d->adapter_count)
3007 return WINED3DERR_INVALIDCALL;
3009 adapter = &wined3d->adapters[adapter_idx];
3010 format = wined3d_get_format(&adapter->gl_info, format_id);
3011 format_bits = format->byte_count * CHAR_BIT;
3013 memset(&m, 0, sizeof(m));
3014 m.dmSize = sizeof(m);
3016 while (i <= mode_idx)
3018 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
3020 WARN("Invalid mode_idx %u.\n", mode_idx);
3021 return WINED3DERR_INVALIDCALL;
3024 if (m.dmFields & DM_DISPLAYFLAGS)
3026 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
3027 && (m.u2.dmDisplayFlags & DM_INTERLACED))
3030 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
3031 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
3035 if (format_id == WINED3DFMT_UNKNOWN)
3037 /* This is for d3d8, do not enumerate P8 here. */
3038 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
3040 else if (m.dmBitsPerPel == format_bits)
3046 mode->width = m.dmPelsWidth;
3047 mode->height = m.dmPelsHeight;
3048 mode->refresh_rate = DEFAULT_REFRESH_RATE;
3049 if (m.dmFields & DM_DISPLAYFREQUENCY)
3050 mode->refresh_rate = m.dmDisplayFrequency;
3052 if (format_id == WINED3DFMT_UNKNOWN)
3053 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
3055 mode->format_id = format_id;
3057 if (!(m.dmFields & DM_DISPLAYFLAGS))
3058 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
3059 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
3060 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
3062 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
3064 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
3065 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
3070 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
3071 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
3073 const struct wined3d_adapter *adapter;
3076 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
3077 wined3d, adapter_idx, mode, rotation);
3079 if (!mode || adapter_idx >= wined3d->adapter_count)
3080 return WINED3DERR_INVALIDCALL;
3082 adapter = &wined3d->adapters[adapter_idx];
3084 memset(&m, 0, sizeof(m));
3085 m.dmSize = sizeof(m);
3087 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
3088 mode->width = m.dmPelsWidth;
3089 mode->height = m.dmPelsHeight;
3090 mode->refresh_rate = DEFAULT_REFRESH_RATE;
3091 if (m.dmFields & DM_DISPLAYFREQUENCY)
3092 mode->refresh_rate = m.dmDisplayFrequency;
3093 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
3095 /* Lie about the format. X11 can't change the color depth, and some apps
3096 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
3097 * that GetDisplayMode still returns 24 bpp. This should probably be
3098 * handled in winex11 instead. */
3099 if (adapter->screen_format && adapter->screen_format != mode->format_id)
3101 WARN("Overriding format %s with stored format %s.\n",
3102 debug_d3dformat(mode->format_id),
3103 debug_d3dformat(adapter->screen_format));
3104 mode->format_id = adapter->screen_format;
3107 if (!(m.dmFields & DM_DISPLAYFLAGS))
3108 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
3109 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
3110 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
3112 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
3116 switch (m.u1.s2.dmDisplayOrientation)
3119 *rotation = WINED3D_DISPLAY_ROTATION_0;
3122 *rotation = WINED3D_DISPLAY_ROTATION_90;
3125 *rotation = WINED3D_DISPLAY_ROTATION_180;
3128 *rotation = WINED3D_DISPLAY_ROTATION_270;
3131 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
3132 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
3137 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
3138 mode->refresh_rate, debug_d3dformat(mode->format_id),
3139 mode->scanline_ordering);
3143 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
3144 UINT adapter_idx, const struct wined3d_display_mode *mode)
3146 struct wined3d_display_mode current_mode;
3147 const struct wined3d_format *format;
3148 struct wined3d_adapter *adapter;
3154 TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s %#x).\n", wined3d, adapter_idx, mode,
3155 mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id),
3156 mode->scanline_ordering);
3158 if (adapter_idx >= wined3d->adapter_count)
3159 return WINED3DERR_INVALIDCALL;
3161 adapter = &wined3d->adapters[adapter_idx];
3162 format = wined3d_get_format(&adapter->gl_info, mode->format_id);
3164 memset(&devmode, 0, sizeof(devmode));
3165 devmode.dmSize = sizeof(devmode);
3166 devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
3167 devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
3168 devmode.dmPelsWidth = mode->width;
3169 devmode.dmPelsHeight = mode->height;
3171 devmode.dmDisplayFrequency = mode->refresh_rate;
3172 if (mode->refresh_rate)
3173 devmode.dmFields |= DM_DISPLAYFREQUENCY;
3175 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
3177 devmode.dmFields |= DM_DISPLAYFLAGS;
3178 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
3179 devmode.u2.dmDisplayFlags |= DM_INTERLACED;
3182 /* Only change the mode if necessary. */
3183 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, ¤t_mode, NULL)))
3185 ERR("Failed to get current display mode, hr %#x.\n", hr);
3187 else if (current_mode.width == mode->width
3188 && current_mode.height == mode->height
3189 && current_mode.format_id == mode->format_id
3190 && (current_mode.refresh_rate == mode->refresh_rate
3191 || !mode->refresh_rate)
3192 && (current_mode.scanline_ordering == mode->scanline_ordering
3193 || mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_UNKNOWN))
3195 TRACE("Skipping redundant mode setting call.\n");
3199 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
3200 if (ret != DISP_CHANGE_SUCCESSFUL)
3202 if (devmode.dmDisplayFrequency)
3204 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
3205 devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
3206 devmode.dmDisplayFrequency = 0;
3207 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
3209 if (ret != DISP_CHANGE_SUCCESSFUL)
3210 return WINED3DERR_NOTAVAILABLE;
3213 /* Store the new values. */
3214 adapter->screen_format = mode->format_id;
3216 /* And finally clip mouse to our screen. */
3217 SetRect(&clip_rc, 0, 0, mode->width, mode->height);
3218 ClipCursor(&clip_rc);
3223 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3224 and fields being inserted in the middle, a new structure is used in place */
3225 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
3226 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
3228 const struct wined3d_adapter *adapter;
3231 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
3232 wined3d, adapter_idx, flags, identifier);
3234 if (adapter_idx >= wined3d->adapter_count)
3235 return WINED3DERR_INVALIDCALL;
3237 adapter = &wined3d->adapters[adapter_idx];
3239 if (identifier->driver_size)
3241 const char *name = adapter->driver_info.name;
3242 len = min(strlen(name), identifier->driver_size - 1);
3243 memcpy(identifier->driver, name, len);
3244 identifier->driver[len] = '\0';
3247 if (identifier->description_size)
3249 const char *description = adapter->driver_info.description;
3250 len = min(strlen(description), identifier->description_size - 1);
3251 memcpy(identifier->description, description, len);
3252 identifier->description[len] = '\0';
3255 /* Note that d3d8 doesn't supply a device name. */
3256 if (identifier->device_name_size)
3258 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
3259 identifier->device_name_size, NULL, NULL))
3261 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
3262 return WINED3DERR_INVALIDCALL;
3266 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
3267 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
3268 identifier->vendor_id = adapter->driver_info.vendor;
3269 identifier->device_id = adapter->driver_info.device;
3270 identifier->subsystem_id = 0;
3271 identifier->revision = 0;
3272 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
3273 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
3274 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
3275 identifier->video_memory = adapter->TextureRam;
3280 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
3281 struct wined3d_raster_status *raster_status)
3283 LONGLONG freq_per_frame, freq_per_line;
3284 LARGE_INTEGER counter, freq_per_sec;
3285 struct wined3d_display_mode mode;
3289 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3290 wined3d, adapter_idx, raster_status);
3292 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3293 wined3d, adapter_idx, raster_status);
3295 /* Obtaining the raster status is a widely implemented but optional
3296 * feature. When this method returns OK StarCraft 2 expects the
3297 * raster_status->InVBlank value to actually change over time.
3298 * And Endless Alice Crysis doesn't care even if this method fails.
3299 * Thus this method returns OK and fakes raster_status by
3300 * QueryPerformanceCounter. */
3302 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
3303 return WINED3DERR_INVALIDCALL;
3304 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
3305 return WINED3DERR_INVALIDCALL;
3306 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
3307 mode.refresh_rate = 60;
3309 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
3310 /* Assume 20 scan lines in the vertical blank. */
3311 freq_per_line = freq_per_frame / (mode.height + 20);
3312 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
3313 if (raster_status->scan_line < mode.height)
3314 raster_status->in_vblank = FALSE;
3317 raster_status->scan_line = 0;
3318 raster_status->in_vblank = TRUE;
3321 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
3322 raster_status->in_vblank, raster_status->scan_line);
3327 static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
3328 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
3330 BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
3332 /* Float formats need FBOs. If FBOs are used this function isn't called */
3333 if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
3335 if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
3336 if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
3338 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
3342 if(cfg->redSize < redSize)
3345 if(cfg->greenSize < greenSize)
3348 if(cfg->blueSize < blueSize)
3351 if(cfg->alphaSize < alphaSize)
3357 /* Probably a RGBA_float or color index mode */
3361 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
3362 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
3364 BYTE depthSize, stencilSize;
3365 BOOL lockable = FALSE;
3367 if (!getDepthStencilBits(format, &depthSize, &stencilSize))
3369 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
3373 /* Float formats need FBOs. If FBOs are used this function isn't called */
3374 if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
3376 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
3379 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3380 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3381 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3382 if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize)))
3385 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3386 * allow more stencil bits than requested. */
3387 if(cfg->stencilSize < stencilSize)
3393 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
3394 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
3395 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
3397 const struct wined3d_format *rt_format;
3398 const struct wined3d_format *ds_format;
3399 const struct wined3d_adapter *adapter;
3401 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
3402 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3403 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
3404 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
3406 if (adapter_idx >= wined3d->adapter_count)
3407 return WINED3DERR_INVALIDCALL;
3409 adapter = &wined3d->adapters[adapter_idx];
3410 rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id);
3411 ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id);
3412 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3414 if ((rt_format->flags & WINED3DFMT_FLAG_RENDERTARGET)
3415 && (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
3417 TRACE("Formats match.\n");
3423 const struct wined3d_pixel_format *cfgs;
3424 unsigned int cfg_count;
3427 cfgs = adapter->cfgs;
3428 cfg_count = adapter->cfg_count;
3429 for (i = 0; i < cfg_count; ++i)
3431 if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
3432 && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
3434 TRACE("Formats match.\n");
3440 TRACE("Unsupported format pair: %s and %s.\n",
3441 debug_d3dformat(render_target_format_id),
3442 debug_d3dformat(depth_stencil_format_id));
3444 return WINED3DERR_NOTAVAILABLE;
3447 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
3448 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
3449 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
3451 const struct wined3d_gl_info *gl_info;
3453 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3454 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3455 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
3456 windowed, multisample_type, quality_levels);
3458 if (adapter_idx >= wined3d->adapter_count)
3459 return WINED3DERR_INVALIDCALL;
3461 gl_info = &wined3d->adapters[adapter_idx].gl_info;
3463 if (multisample_type > gl_info->limits.samples)
3465 TRACE("Returning not supported.\n");
3467 *quality_levels = 0;
3469 return WINED3DERR_NOTAVAILABLE;
3474 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
3475 /* FIXME: This is probably wrong. */
3476 *quality_levels = gl_info->limits.samples;
3478 *quality_levels = 1;
3484 /* Check if we support bumpmapping for a format */
3485 static BOOL CheckBumpMapCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3487 /* Ask the fixed function pipeline implementation if it can deal
3488 * with the conversion. If we've got a GL extension giving native
3489 * support this will be an identity conversion. */
3490 return (format->flags & WINED3DFMT_FLAG_BUMPMAP)
3491 && adapter->fragment_pipe->color_fixup_supported(format->color_fixup);
3494 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3495 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
3496 const struct wined3d_format *display_format, const struct wined3d_format *ds_format)
3498 /* Only allow depth/stencil formats */
3499 if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
3501 /* Blacklist formats not supported on Windows */
3502 switch (ds_format->id)
3504 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
3505 case WINED3DFMT_S4X4_UINT_D24_UNORM:
3506 TRACE("[FAILED] - not supported on windows.\n");
3513 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3515 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3516 if (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
3522 /* Walk through all WGL pixel formats to find a match */
3523 for (i = 0; i < adapter->cfg_count; ++i)
3525 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
3526 if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
3527 && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
3535 static BOOL CheckFilterCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3537 /* The flags entry of a format contains the filtering capability */
3538 if ((format->flags & WINED3DFMT_FLAG_FILTERING)
3539 || !(adapter->gl_info.quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING))
3545 /* Check the render target capabilities of a format */
3546 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
3547 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format)
3549 /* Filter out non-RT formats */
3550 if (!(check_format->flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
3551 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
3553 BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
3554 BYTE CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
3555 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
3558 getColorBits(adapter_format, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
3559 getColorBits(check_format, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
3561 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3562 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3563 if (!((AdapterRed == CheckRed) && (AdapterGreen == CheckGreen) && (AdapterBlue == CheckBlue)))
3565 TRACE("[FAILED]\n");
3569 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3570 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3571 for (i = 0; i < adapter->cfg_count; ++i)
3573 if (cfgs[i].windowDrawable
3574 && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
3576 TRACE("Pixel format %d is compatible with format %s.\n",
3577 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
3582 else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3584 /* For now return TRUE for FBOs until we have some proper checks.
3585 * Note that this function will only be called when the format is around for texturing. */
3591 static BOOL CheckSrgbReadCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3593 return format->flags & WINED3DFMT_FLAG_SRGB_READ;
3596 static BOOL CheckSrgbWriteCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3598 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3599 * doing the color fixup in shaders.
3600 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3601 if (format->flags & WINED3DFMT_FLAG_SRGB_WRITE)
3603 int vs_selected_mode;
3604 int ps_selected_mode;
3605 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3607 if ((ps_selected_mode == SHADER_ARB) || (ps_selected_mode == SHADER_GLSL))
3614 TRACE("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format->id));
3618 /* Check if a format support blending in combination with pixel shaders */
3619 static BOOL CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter *adapter,
3620 const struct wined3d_format *format)
3622 /* The flags entry of a format contains the post pixel shader blending capability */
3623 if (format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) return TRUE;
3628 static BOOL CheckWrapAndMipCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3630 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3631 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3632 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3633 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3634 * capability anyway.
3636 * For now lets report this on all formats, but in the future we may want to
3637 * restrict it to some should games need that
3642 /* Check if a texture format is supported on the given adapter */
3643 static BOOL CheckTextureCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3645 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3650 * supported: RGB(A) formats
3652 case WINED3DFMT_B8G8R8_UNORM:
3653 TRACE("[FAILED] - Not enumerated on Windows.\n");
3655 case WINED3DFMT_B8G8R8A8_UNORM:
3656 case WINED3DFMT_B8G8R8X8_UNORM:
3657 case WINED3DFMT_B5G6R5_UNORM:
3658 case WINED3DFMT_B5G5R5X1_UNORM:
3659 case WINED3DFMT_B5G5R5A1_UNORM:
3660 case WINED3DFMT_B4G4R4A4_UNORM:
3661 case WINED3DFMT_A8_UNORM:
3662 case WINED3DFMT_B4G4R4X4_UNORM:
3663 case WINED3DFMT_R8G8B8A8_UNORM:
3664 case WINED3DFMT_R8G8B8X8_UNORM:
3665 case WINED3DFMT_B10G10R10A2_UNORM:
3666 case WINED3DFMT_R10G10B10A2_UNORM:
3667 case WINED3DFMT_R16G16_UNORM:
3671 case WINED3DFMT_B2G3R3_UNORM:
3672 TRACE("[FAILED] - Not supported on Windows.\n");
3676 * Not supported: Palettized
3677 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3678 * Since it is not widely available, don't offer it. Further no Windows driver offers
3679 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3681 case WINED3DFMT_P8_UINT:
3682 case WINED3DFMT_P8_UINT_A8_UNORM:
3686 * Supported: (Alpha)-Luminance
3688 case WINED3DFMT_L8_UNORM:
3689 case WINED3DFMT_L8A8_UNORM:
3690 case WINED3DFMT_L16_UNORM:
3694 /* Not supported on Windows, thus disabled */
3695 case WINED3DFMT_L4A4_UNORM:
3696 TRACE("[FAILED] - not supported on windows\n");
3700 * Supported: Depth/Stencil formats
3702 case WINED3DFMT_D16_LOCKABLE:
3703 case WINED3DFMT_D16_UNORM:
3704 case WINED3DFMT_X8D24_UNORM:
3705 case WINED3DFMT_D24_UNORM_S8_UINT:
3706 case WINED3DFMT_S8_UINT_D24_FLOAT:
3707 case WINED3DFMT_D32_UNORM:
3708 case WINED3DFMT_D32_FLOAT:
3711 case WINED3DFMT_INTZ:
3712 if (gl_info->supported[EXT_PACKED_DEPTH_STENCIL]
3713 || gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3717 /* Not supported on Windows */
3718 case WINED3DFMT_S1_UINT_D15_UNORM:
3719 case WINED3DFMT_S4X4_UINT_D24_UNORM:
3720 TRACE("[FAILED] - not supported on windows\n");
3724 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3725 * GL_NV_texture_shader). Emulated by shaders
3727 case WINED3DFMT_R8G8_SNORM:
3728 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
3729 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
3730 case WINED3DFMT_R8G8B8A8_SNORM:
3731 case WINED3DFMT_R16G16_SNORM:
3732 /* Ask the shader backend if it can deal with the conversion. If
3733 * we've got a GL extension giving native support this will be an
3734 * identity conversion. */
3735 if (adapter->shader_backend->shader_color_fixup_supported(format->color_fixup))
3740 TRACE("[FAILED]\n");
3743 case WINED3DFMT_DXT1:
3744 case WINED3DFMT_DXT2:
3745 case WINED3DFMT_DXT3:
3746 case WINED3DFMT_DXT4:
3747 case WINED3DFMT_DXT5:
3748 if (gl_info->supported[EXT_TEXTURE_COMPRESSION_S3TC])
3753 TRACE("[FAILED]\n");
3758 * Odd formats - not supported
3760 case WINED3DFMT_VERTEXDATA:
3761 case WINED3DFMT_R16_UINT:
3762 case WINED3DFMT_R32_UINT:
3763 case WINED3DFMT_R16G16B16A16_SNORM:
3764 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM:
3765 case WINED3DFMT_R10G11B11_SNORM:
3766 case WINED3DFMT_R16:
3767 case WINED3DFMT_AL16:
3768 TRACE("[FAILED]\n"); /* Enable when implemented */
3772 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3774 case WINED3DFMT_R8G8_SNORM_Cx:
3775 TRACE("[FAILED]\n"); /* Enable when implemented */
3779 case WINED3DFMT_UYVY:
3780 case WINED3DFMT_YUY2:
3781 if (gl_info->supported[APPLE_YCBCR_422])
3786 TRACE("[FAILED]\n");
3788 case WINED3DFMT_YV12:
3789 TRACE("[FAILED]\n");
3792 case WINED3DFMT_R16G16B16A16_UNORM:
3793 if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
3795 TRACE("[FAILED]\n");
3802 case WINED3DFMT_B2G3R3A8_UNORM:
3803 TRACE("[FAILED]\n"); /* Enable when implemented */
3806 /* Floating point formats */
3807 case WINED3DFMT_R16_FLOAT:
3808 case WINED3DFMT_R16G16_FLOAT:
3809 case WINED3DFMT_R16G16B16A16_FLOAT:
3810 if (gl_info->supported[ARB_TEXTURE_FLOAT] && gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3815 TRACE("[FAILED]\n");
3818 case WINED3DFMT_R32_FLOAT:
3819 case WINED3DFMT_R32G32_FLOAT:
3820 case WINED3DFMT_R32G32B32A32_FLOAT:
3821 if (gl_info->supported[ARB_TEXTURE_FLOAT])
3826 TRACE("[FAILED]\n");
3829 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3830 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3831 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3832 * We can do instancing with all shader versions, but we need vertex shaders.
3834 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3835 * to enable instancing. WineD3D doesn't need that and just ignores it.
3837 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3839 case WINED3DFMT_INST:
3840 TRACE("ATI Instancing check hack\n");
3841 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
3846 TRACE("[FAILED]\n");
3849 /* Some weird FOURCC formats */
3850 case WINED3DFMT_R8G8_B8G8:
3851 case WINED3DFMT_G8R8_G8B8:
3852 case WINED3DFMT_MULTI2_ARGB8:
3853 TRACE("[FAILED]\n");
3856 /* Vendor specific formats */
3857 case WINED3DFMT_ATI2N:
3858 if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC]
3859 || gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
3861 if (adapter->shader_backend->shader_color_fixup_supported(format->color_fixup)
3862 && adapter->fragment_pipe->color_fixup_supported(format->color_fixup))
3868 TRACE("[FAILED]\n");
3871 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3872 * format MAKEFOURCC('N','V','D','B') is used.
3873 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3874 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3877 case WINED3DFMT_NVDB:
3878 if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
3883 TRACE("[FAILED]\n");
3886 case WINED3DFMT_NVHU:
3887 case WINED3DFMT_NVHS:
3888 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3889 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3890 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3891 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3892 * Applications have to deal with not having NVHS and NVHU.
3894 TRACE("[FAILED]\n");
3897 case WINED3DFMT_NULL:
3898 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3902 case WINED3DFMT_UNKNOWN:
3906 ERR("Unhandled format %s.\n", debug_d3dformat(format->id));
3912 static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
3913 const struct wined3d_format *adapter_format,
3914 const struct wined3d_format *check_format,
3915 enum wined3d_surface_type surface_type)
3917 if (surface_type == WINED3D_SURFACE_TYPE_GDI)
3919 switch (check_format->id)
3921 case WINED3DFMT_B8G8R8_UNORM:
3922 TRACE("[FAILED] - Not enumerated on Windows.\n");
3924 case WINED3DFMT_B8G8R8A8_UNORM:
3925 case WINED3DFMT_B8G8R8X8_UNORM:
3926 case WINED3DFMT_B5G6R5_UNORM:
3927 case WINED3DFMT_B5G5R5X1_UNORM:
3928 case WINED3DFMT_B5G5R5A1_UNORM:
3929 case WINED3DFMT_B4G4R4A4_UNORM:
3930 case WINED3DFMT_B2G3R3_UNORM:
3931 case WINED3DFMT_A8_UNORM:
3932 case WINED3DFMT_B2G3R3A8_UNORM:
3933 case WINED3DFMT_B4G4R4X4_UNORM:
3934 case WINED3DFMT_R10G10B10A2_UNORM:
3935 case WINED3DFMT_R8G8B8A8_UNORM:
3936 case WINED3DFMT_R8G8B8X8_UNORM:
3937 case WINED3DFMT_R16G16_UNORM:
3938 case WINED3DFMT_B10G10R10A2_UNORM:
3939 case WINED3DFMT_R16G16B16A16_UNORM:
3940 case WINED3DFMT_P8_UINT:
3944 TRACE("[FAILED] - Not available on GDI surfaces.\n");
3949 /* All format that are supported for textures are supported for surfaces as well */
3950 if (CheckTextureCapability(adapter, check_format)) return TRUE;
3951 /* All depth stencil formats are supported on surfaces */
3952 if (CheckDepthStencilCapability(adapter, adapter_format, check_format)) return TRUE;
3954 /* If opengl can't process the format natively, the blitter may be able to convert it */
3955 if (adapter->blitter->blit_supported(&adapter->gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
3956 NULL, WINED3D_POOL_DEFAULT, 0, check_format,
3957 NULL, WINED3D_POOL_DEFAULT, 0, adapter_format))
3963 /* Reject other formats */
3964 TRACE("[FAILED]\n");
3968 static BOOL CheckVertexTextureCapability(const struct wined3d_adapter *adapter,
3969 const struct wined3d_format *format)
3971 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3973 if (!gl_info->limits.vertex_samplers || !(format->flags & WINED3DFMT_FLAG_VTF))
3978 case WINED3DFMT_R32G32B32A32_FLOAT:
3979 case WINED3DFMT_R32_FLOAT:
3982 return !(gl_info->quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING);
3986 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
3987 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
3988 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id,
3989 enum wined3d_surface_type surface_type)
3991 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
3992 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3993 const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id);
3994 const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id);
3995 DWORD usage_caps = 0;
3997 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3998 "resource_type %s, check_format %s, surface_type %#x.\n",
3999 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
4000 debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
4001 debug_d3dformat(check_format_id), surface_type);
4003 if (adapter_idx >= wined3d->adapter_count)
4004 return WINED3DERR_INVALIDCALL;
4006 switch (resource_type)
4008 case WINED3D_RTYPE_CUBE_TEXTURE:
4009 /* Cubetexture allows:
4010 * - WINED3DUSAGE_AUTOGENMIPMAP
4011 * - WINED3DUSAGE_DEPTHSTENCIL
4012 * - WINED3DUSAGE_DYNAMIC
4013 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4014 * - WINED3DUSAGE_RENDERTARGET
4015 * - WINED3DUSAGE_SOFTWAREPROCESSING
4016 * - WINED3DUSAGE_QUERY_WRAPANDMIP
4018 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
4020 TRACE("[FAILED]\n");
4021 return WINED3DERR_NOTAVAILABLE;
4024 if (!gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4026 TRACE("[FAILED] - No cube texture support.\n");
4027 return WINED3DERR_NOTAVAILABLE;
4030 if (!CheckTextureCapability(adapter, format))
4032 TRACE("[FAILED] - Cube texture format not supported.\n");
4033 return WINED3DERR_NOTAVAILABLE;
4036 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
4038 if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
4039 /* When autogenmipmap isn't around continue and return
4040 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
4041 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
4043 usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
4046 /* Always report dynamic locking. */
4047 if (usage & WINED3DUSAGE_DYNAMIC)
4048 usage_caps |= WINED3DUSAGE_DYNAMIC;
4050 if (usage & WINED3DUSAGE_RENDERTARGET)
4052 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4054 TRACE("[FAILED] - No render target support.\n");
4055 return WINED3DERR_NOTAVAILABLE;
4057 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4060 /* Always report software processing. */
4061 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4062 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4064 if (usage & WINED3DUSAGE_QUERY_FILTER)
4066 if (!CheckFilterCapability(adapter, format))
4068 TRACE("[FAILED] - No filter support.\n");
4069 return WINED3DERR_NOTAVAILABLE;
4071 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4074 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4076 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4078 TRACE("[FAILED] - No post pixelshader blending support.\n");
4079 return WINED3DERR_NOTAVAILABLE;
4081 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4084 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4086 if (!CheckSrgbReadCapability(adapter, format))
4088 TRACE("[FAILED] - No sRGB read support.\n");
4089 return WINED3DERR_NOTAVAILABLE;
4091 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4094 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4096 if (!CheckSrgbWriteCapability(adapter, format))
4098 TRACE("[FAILED] - No sRGB write support.\n");
4099 return WINED3DERR_NOTAVAILABLE;
4101 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4104 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4106 if (!CheckVertexTextureCapability(adapter, format))
4108 TRACE("[FAILED] - No vertex texture support.\n");
4109 return WINED3DERR_NOTAVAILABLE;
4111 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4114 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4116 if (!CheckWrapAndMipCapability(adapter, format))
4118 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4119 return WINED3DERR_NOTAVAILABLE;
4121 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4125 case WINED3D_RTYPE_SURFACE:
4127 * - WINED3DUSAGE_DEPTHSTENCIL
4128 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4129 * - WINED3DUSAGE_RENDERTARGET
4131 if (!CheckSurfaceCapability(adapter, adapter_format, format, surface_type))
4133 TRACE("[FAILED] - Not supported for plain surfaces.\n");
4134 return WINED3DERR_NOTAVAILABLE;
4137 if (usage & WINED3DUSAGE_DEPTHSTENCIL)
4139 if (!CheckDepthStencilCapability(adapter, adapter_format, format))
4141 TRACE("[FAILED] - No depth/stencil support.\n");
4142 return WINED3DERR_NOTAVAILABLE;
4144 usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
4147 if (usage & WINED3DUSAGE_RENDERTARGET)
4149 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4151 TRACE("[FAILED] - No render target support.\n");
4152 return WINED3DERR_NOTAVAILABLE;
4154 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4157 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4159 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4161 TRACE("[FAILED] - No post pixelshader blending support.\n");
4162 return WINED3DERR_NOTAVAILABLE;
4164 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4168 case WINED3D_RTYPE_TEXTURE:
4170 * - WINED3DUSAGE_AUTOGENMIPMAP
4171 * - WINED3DUSAGE_DEPTHSTENCIL
4172 * - WINED3DUSAGE_DMAP
4173 * - WINED3DUSAGE_DYNAMIC
4174 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4175 * - WINED3DUSAGE_RENDERTARGET
4176 * - WINED3DUSAGE_SOFTWAREPROCESSING
4177 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
4178 * - WINED3DUSAGE_QUERY_WRAPANDMIP
4180 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
4182 TRACE("[FAILED]\n");
4183 return WINED3DERR_NOTAVAILABLE;
4186 if (!CheckTextureCapability(adapter, format))
4188 TRACE("[FAILED] - Texture format not supported.\n");
4189 return WINED3DERR_NOTAVAILABLE;
4192 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
4194 if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
4195 /* When autogenmipmap isn't around continue and return
4196 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
4197 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
4199 usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
4202 /* Always report dynamic locking. */
4203 if (usage & WINED3DUSAGE_DYNAMIC)
4204 usage_caps |= WINED3DUSAGE_DYNAMIC;
4206 if (usage & WINED3DUSAGE_RENDERTARGET)
4208 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4210 TRACE("[FAILED] - No render target support.\n");
4211 return WINED3DERR_NOTAVAILABLE;
4213 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4216 /* Always report software processing. */
4217 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4218 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4220 if (usage & WINED3DUSAGE_QUERY_FILTER)
4222 if (!CheckFilterCapability(adapter, format))
4224 TRACE("[FAILED] - No filter support.\n");
4225 return WINED3DERR_NOTAVAILABLE;
4227 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4230 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
4232 if (!CheckBumpMapCapability(adapter, format))
4234 TRACE("[FAILED] - No legacy bumpmap support.\n");
4235 return WINED3DERR_NOTAVAILABLE;
4237 usage_caps |= WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
4240 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4242 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4244 TRACE("[FAILED] - No post pixelshader blending support.\n");
4245 return WINED3DERR_NOTAVAILABLE;
4247 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4250 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4252 if (!CheckSrgbReadCapability(adapter, format))
4254 TRACE("[FAILED] - No sRGB read support.\n");
4255 return WINED3DERR_NOTAVAILABLE;
4257 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4260 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4262 if (!CheckSrgbWriteCapability(adapter, format))
4264 TRACE("[FAILED] - No sRGB write support.\n");
4265 return WINED3DERR_NOTAVAILABLE;
4267 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4270 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4272 if (!CheckVertexTextureCapability(adapter, format))
4274 TRACE("[FAILED] - No vertex texture support.\n");
4275 return WINED3DERR_NOTAVAILABLE;
4277 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4280 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4282 if (!CheckWrapAndMipCapability(adapter, format))
4284 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4285 return WINED3DERR_NOTAVAILABLE;
4287 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4290 if (usage & WINED3DUSAGE_DEPTHSTENCIL)
4292 if (!CheckDepthStencilCapability(adapter, adapter_format, format))
4294 TRACE("[FAILED] - No depth/stencil support.\n");
4295 return WINED3DERR_NOTAVAILABLE;
4297 if ((format->flags & WINED3DFMT_FLAG_SHADOW) && !gl_info->supported[ARB_SHADOW])
4299 TRACE("[FAILED] - No shadow sampler support.\n");
4300 return WINED3DERR_NOTAVAILABLE;
4302 usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
4306 case WINED3D_RTYPE_VOLUME_TEXTURE:
4307 case WINED3D_RTYPE_VOLUME:
4308 /* Volume is to VolumeTexture what Surface is to Texture, but its
4309 * usage caps are not documented. Most driver seem to offer
4310 * (nearly) the same on Volume and VolumeTexture, so do that too.
4312 * Volumetexture allows:
4313 * - D3DUSAGE_DYNAMIC
4314 * - D3DUSAGE_NONSECURE (d3d9ex)
4315 * - D3DUSAGE_SOFTWAREPROCESSING
4316 * - D3DUSAGE_QUERY_WRAPANDMIP
4318 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
4320 TRACE("[FAILED]\n");
4321 return WINED3DERR_NOTAVAILABLE;
4324 if (!gl_info->supported[EXT_TEXTURE3D])
4326 TRACE("[FAILED] - No volume texture support.\n");
4327 return WINED3DERR_NOTAVAILABLE;
4330 if (!CheckTextureCapability(adapter, format))
4332 TRACE("[FAILED] - Format not supported.\n");
4333 return WINED3DERR_NOTAVAILABLE;
4336 /* Filter formats that need conversion; For one part, this
4337 * conversion is unimplemented, and volume textures are huge, so
4338 * it would be a big performance hit. Unless we hit an application
4339 * needing one of those formats, don't advertize them to avoid
4340 * leading applications into temptation. The windows drivers don't
4341 * support most of those formats on volumes anyway, except for
4342 * WINED3DFMT_R32_FLOAT. */
4343 switch (check_format_id)
4345 case WINED3DFMT_P8_UINT:
4346 case WINED3DFMT_L4A4_UNORM:
4347 case WINED3DFMT_R32_FLOAT:
4348 case WINED3DFMT_R16_FLOAT:
4349 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
4350 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
4351 case WINED3DFMT_R16G16_UNORM:
4352 TRACE("[FAILED] - No converted formats on volumes.\n");
4353 return WINED3DERR_NOTAVAILABLE;
4355 case WINED3DFMT_R8G8B8A8_SNORM:
4356 case WINED3DFMT_R16G16_SNORM:
4357 if (!gl_info->supported[NV_TEXTURE_SHADER])
4359 TRACE("[FAILED] - No converted formats on volumes.\n");
4360 return WINED3DERR_NOTAVAILABLE;
4364 case WINED3DFMT_R8G8_SNORM:
4365 if (!gl_info->supported[NV_TEXTURE_SHADER])
4367 TRACE("[FAILED] - No converted formats on volumes.\n");
4368 return WINED3DERR_NOTAVAILABLE;
4372 case WINED3DFMT_DXT1:
4373 case WINED3DFMT_DXT2:
4374 case WINED3DFMT_DXT3:
4375 case WINED3DFMT_DXT4:
4376 case WINED3DFMT_DXT5:
4377 /* The GL_EXT_texture_compression_s3tc spec requires that
4378 * loading an s3tc compressed texture results in an error.
4379 * While the D3D refrast does support s3tc volumes, at
4380 * least the nvidia windows driver does not, so we're free
4381 * not to support this format. */
4382 TRACE("[FAILED] - DXTn does not support 3D textures.\n");
4383 return WINED3DERR_NOTAVAILABLE;
4386 /* Do nothing, continue with checking the format below */
4390 /* Always report dynamic locking. */
4391 if (usage & WINED3DUSAGE_DYNAMIC)
4392 usage_caps |= WINED3DUSAGE_DYNAMIC;
4394 /* Always report software processing. */
4395 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4396 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4398 if (usage & WINED3DUSAGE_QUERY_FILTER)
4400 if (!CheckFilterCapability(adapter, format))
4402 TRACE("[FAILED] - No filter support.\n");
4403 return WINED3DERR_NOTAVAILABLE;
4405 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4408 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4410 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4412 TRACE("[FAILED] - No post pixelshader blending support.\n");
4413 return WINED3DERR_NOTAVAILABLE;
4415 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4418 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4420 if (!CheckSrgbReadCapability(adapter, format))
4422 TRACE("[FAILED] - No sRGB read support.\n");
4423 return WINED3DERR_NOTAVAILABLE;
4425 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4428 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4430 if (!CheckSrgbWriteCapability(adapter, format))
4432 TRACE("[FAILED] - No sRGB write support.\n");
4433 return WINED3DERR_NOTAVAILABLE;
4435 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4438 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4440 if (!CheckVertexTextureCapability(adapter, format))
4442 TRACE("[FAILED] - No vertex texture support.\n");
4443 return WINED3DERR_NOTAVAILABLE;
4445 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4448 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4450 if (!CheckWrapAndMipCapability(adapter, format))
4452 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4453 return WINED3DERR_NOTAVAILABLE;
4455 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4460 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
4461 return WINED3DERR_NOTAVAILABLE;
4464 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4465 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4466 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4467 if (usage_caps == usage)
4469 if (usage_caps == (usage & ~WINED3DUSAGE_AUTOGENMIPMAP))
4470 return WINED3DOK_NOAUTOGEN;
4472 TRACE("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4473 usage, debug_d3dformat(check_format_id), debug_d3dresourcetype(resource_type), usage_caps);
4475 return WINED3DERR_NOTAVAILABLE;
4478 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
4479 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
4481 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4482 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
4483 debug_d3dformat(dst_format));
4488 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
4489 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
4490 enum wined3d_format_id backbuffer_format, BOOL windowed)
4495 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4496 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
4497 debug_d3dformat(backbuffer_format), windowed);
4499 if (adapter_idx >= wined3d->adapter_count)
4500 return WINED3DERR_INVALIDCALL;
4502 /* The task of this function is to check whether a certain display / backbuffer format
4503 * combination is available on the given adapter. In fullscreen mode microsoft specified
4504 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4505 * and display format should match exactly.
4506 * In windowed mode format conversion can occur and this depends on the driver. When format
4507 * conversion is done, this function should nevertheless fail and applications need to use
4508 * CheckDeviceFormatConversion.
4509 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4511 /* There are only 4 display formats. */
4512 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
4513 || display_format == WINED3DFMT_B5G5R5X1_UNORM
4514 || display_format == WINED3DFMT_B8G8R8X8_UNORM
4515 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
4517 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
4518 return WINED3DERR_NOTAVAILABLE;
4521 /* If the requested display format is not available, don't continue. */
4522 mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
4523 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
4526 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
4527 return WINED3DERR_NOTAVAILABLE;
4530 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4531 * it means 'reuse' the display format for the backbuffer. */
4532 if (!windowed && backbuffer_format == WINED3DFMT_UNKNOWN)
4534 TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4535 return WINED3DERR_NOTAVAILABLE;
4538 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4539 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4540 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
4542 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4543 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4544 return WINED3DERR_NOTAVAILABLE;
4547 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4548 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4549 * WINED3DFMT_B5G5R5A1_UNORM. */
4550 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
4551 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
4553 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4554 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4555 return WINED3DERR_NOTAVAILABLE;
4558 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4559 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4560 * WINED3DFMT_B8G8R8A8_UNORM. */
4561 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
4562 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
4564 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4565 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4566 return WINED3DERR_NOTAVAILABLE;
4569 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4570 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4571 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
4572 && (backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM || windowed))
4574 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4575 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4576 return WINED3DERR_NOTAVAILABLE;
4579 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4580 hr = wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
4581 WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_SURFACE, backbuffer_format, WINED3D_SURFACE_TYPE_OPENGL);
4583 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4584 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4589 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
4590 enum wined3d_device_type device_type, WINED3DCAPS *caps)
4592 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
4593 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
4594 int vs_selected_mode;
4595 int ps_selected_mode;
4596 struct shader_caps shader_caps;
4597 struct fragment_caps fragment_caps;
4598 DWORD ckey_caps, blit_caps, fx_caps, pal_caps;
4600 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4601 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
4603 if (adapter_idx >= wined3d->adapter_count)
4604 return WINED3DERR_INVALIDCALL;
4606 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
4608 /* ------------------------------------------------
4609 The following fields apply to both d3d8 and d3d9
4610 ------------------------------------------------ */
4611 /* Not quite true, but use h/w supported by opengl I suppose */
4612 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
4613 caps->AdapterOrdinal = adapter_idx;
4616 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
4617 WINED3DCAPS2_FULLSCREENGAMMA |
4618 WINED3DCAPS2_DYNAMICTEXTURES;
4619 if (gl_info->supported[SGIS_GENERATE_MIPMAP])
4620 caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
4622 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
4623 WINED3DCAPS3_COPY_TO_VIDMEM |
4624 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
4626 caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
4627 WINED3DPRESENT_INTERVAL_ONE;
4629 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
4630 WINED3DCURSORCAPS_LOWRES;
4632 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
4633 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
4634 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
4635 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
4636 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
4637 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
4638 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
4639 WINED3DDEVCAPS_PUREDEVICE |
4640 WINED3DDEVCAPS_HWRASTERIZATION |
4641 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
4642 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
4643 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
4644 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
4645 WINED3DDEVCAPS_DRAWPRIMITIVES2EX |
4646 WINED3DDEVCAPS_RTPATCHES;
4648 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
4649 WINED3DPMISCCAPS_CULLCCW |
4650 WINED3DPMISCCAPS_CULLCW |
4651 WINED3DPMISCCAPS_COLORWRITEENABLE |
4652 WINED3DPMISCCAPS_CLIPTLVERTS |
4653 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
4654 WINED3DPMISCCAPS_MASKZ |
4655 WINED3DPMISCCAPS_BLENDOP |
4656 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
4658 WINED3DPMISCCAPS_NULLREFERENCE
4659 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4660 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4661 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4663 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
4664 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
4665 if (gl_info->supported[EXT_DRAW_BUFFERS2])
4666 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
4667 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
4668 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
4670 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
4671 WINED3DPRASTERCAPS_PAT |
4672 WINED3DPRASTERCAPS_WFOG |
4673 WINED3DPRASTERCAPS_ZFOG |
4674 WINED3DPRASTERCAPS_FOGVERTEX |
4675 WINED3DPRASTERCAPS_FOGTABLE |
4676 WINED3DPRASTERCAPS_STIPPLE |
4677 WINED3DPRASTERCAPS_SUBPIXEL |
4678 WINED3DPRASTERCAPS_ZTEST |
4679 WINED3DPRASTERCAPS_SCISSORTEST |
4680 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
4681 WINED3DPRASTERCAPS_DEPTHBIAS;
4683 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4685 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
4686 WINED3DPRASTERCAPS_ZBIAS |
4687 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
4689 if (gl_info->supported[NV_FOG_DISTANCE])
4691 caps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
4694 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4695 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4696 WINED3DPRASTERCAPS_ANTIALIASEDGES
4697 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4698 WINED3DPRASTERCAPS_WBUFFER */
4700 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
4701 WINED3DPCMPCAPS_EQUAL |
4702 WINED3DPCMPCAPS_GREATER |
4703 WINED3DPCMPCAPS_GREATEREQUAL |
4704 WINED3DPCMPCAPS_LESS |
4705 WINED3DPCMPCAPS_LESSEQUAL |
4706 WINED3DPCMPCAPS_NEVER |
4707 WINED3DPCMPCAPS_NOTEQUAL;
4709 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
4710 WINED3DPBLENDCAPS_BOTHSRCALPHA |
4711 WINED3DPBLENDCAPS_DESTALPHA |
4712 WINED3DPBLENDCAPS_DESTCOLOR |
4713 WINED3DPBLENDCAPS_INVDESTALPHA |
4714 WINED3DPBLENDCAPS_INVDESTCOLOR |
4715 WINED3DPBLENDCAPS_INVSRCALPHA |
4716 WINED3DPBLENDCAPS_INVSRCCOLOR |
4717 WINED3DPBLENDCAPS_ONE |
4718 WINED3DPBLENDCAPS_SRCALPHA |
4719 WINED3DPBLENDCAPS_SRCALPHASAT |
4720 WINED3DPBLENDCAPS_SRCCOLOR |
4721 WINED3DPBLENDCAPS_ZERO;
4723 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
4724 WINED3DPBLENDCAPS_DESTCOLOR |
4725 WINED3DPBLENDCAPS_INVDESTALPHA |
4726 WINED3DPBLENDCAPS_INVDESTCOLOR |
4727 WINED3DPBLENDCAPS_INVSRCALPHA |
4728 WINED3DPBLENDCAPS_INVSRCCOLOR |
4729 WINED3DPBLENDCAPS_ONE |
4730 WINED3DPBLENDCAPS_SRCALPHA |
4731 WINED3DPBLENDCAPS_SRCCOLOR |
4732 WINED3DPBLENDCAPS_ZERO;
4733 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4734 * according to the glBlendFunc manpage
4736 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4737 * legacy settings for srcblend only
4740 if (gl_info->supported[EXT_BLEND_COLOR])
4742 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
4743 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
4747 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
4748 WINED3DPCMPCAPS_EQUAL |
4749 WINED3DPCMPCAPS_GREATER |
4750 WINED3DPCMPCAPS_GREATEREQUAL |
4751 WINED3DPCMPCAPS_LESS |
4752 WINED3DPCMPCAPS_LESSEQUAL |
4753 WINED3DPCMPCAPS_NEVER |
4754 WINED3DPCMPCAPS_NOTEQUAL;
4756 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
4757 WINED3DPSHADECAPS_COLORGOURAUDRGB |
4758 WINED3DPSHADECAPS_ALPHAFLATBLEND |
4759 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
4760 WINED3DPSHADECAPS_COLORFLATRGB |
4761 WINED3DPSHADECAPS_FOGFLAT |
4762 WINED3DPSHADECAPS_FOGGOURAUD |
4763 WINED3DPSHADECAPS_SPECULARFLATRGB;
4765 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
4766 WINED3DPTEXTURECAPS_ALPHAPALETTE |
4767 WINED3DPTEXTURECAPS_TRANSPARENCY |
4768 WINED3DPTEXTURECAPS_BORDER |
4769 WINED3DPTEXTURECAPS_MIPMAP |
4770 WINED3DPTEXTURECAPS_PROJECTED |
4771 WINED3DPTEXTURECAPS_PERSPECTIVE;
4773 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4775 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
4776 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
4779 if (gl_info->supported[EXT_TEXTURE3D])
4781 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
4782 WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
4783 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4785 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
4789 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4791 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
4792 WINED3DPTEXTURECAPS_MIPCUBEMAP;
4793 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4795 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
4799 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4800 WINED3DPTFILTERCAPS_MAGFPOINT |
4801 WINED3DPTFILTERCAPS_MINFLINEAR |
4802 WINED3DPTFILTERCAPS_MINFPOINT |
4803 WINED3DPTFILTERCAPS_MIPFLINEAR |
4804 WINED3DPTFILTERCAPS_MIPFPOINT |
4805 WINED3DPTFILTERCAPS_LINEAR |
4806 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4807 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4808 WINED3DPTFILTERCAPS_MIPLINEAR |
4809 WINED3DPTFILTERCAPS_MIPNEAREST |
4810 WINED3DPTFILTERCAPS_NEAREST;
4812 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4814 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
4815 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
4818 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4820 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4821 WINED3DPTFILTERCAPS_MAGFPOINT |
4822 WINED3DPTFILTERCAPS_MINFLINEAR |
4823 WINED3DPTFILTERCAPS_MINFPOINT |
4824 WINED3DPTFILTERCAPS_MIPFLINEAR |
4825 WINED3DPTFILTERCAPS_MIPFPOINT |
4826 WINED3DPTFILTERCAPS_LINEAR |
4827 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4828 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4829 WINED3DPTFILTERCAPS_MIPLINEAR |
4830 WINED3DPTFILTERCAPS_MIPNEAREST |
4831 WINED3DPTFILTERCAPS_NEAREST;
4833 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4835 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
4836 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
4841 caps->CubeTextureFilterCaps = 0;
4844 if (gl_info->supported[EXT_TEXTURE3D])
4846 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4847 WINED3DPTFILTERCAPS_MAGFPOINT |
4848 WINED3DPTFILTERCAPS_MINFLINEAR |
4849 WINED3DPTFILTERCAPS_MINFPOINT |
4850 WINED3DPTFILTERCAPS_MIPFLINEAR |
4851 WINED3DPTFILTERCAPS_MIPFPOINT |
4852 WINED3DPTFILTERCAPS_LINEAR |
4853 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4854 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4855 WINED3DPTFILTERCAPS_MIPLINEAR |
4856 WINED3DPTFILTERCAPS_MIPNEAREST |
4857 WINED3DPTFILTERCAPS_NEAREST;
4861 caps->VolumeTextureFilterCaps = 0;
4864 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
4865 WINED3DPTADDRESSCAPS_CLAMP |
4866 WINED3DPTADDRESSCAPS_WRAP;
4868 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
4870 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
4872 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
4874 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
4876 if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4878 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
4881 if (gl_info->supported[EXT_TEXTURE3D])
4883 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
4884 WINED3DPTADDRESSCAPS_CLAMP |
4885 WINED3DPTADDRESSCAPS_WRAP;
4886 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
4888 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
4890 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
4892 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
4894 if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4896 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
4901 caps->VolumeTextureAddressCaps = 0;
4904 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
4905 WINED3DLINECAPS_ZTEST |
4906 WINED3DLINECAPS_BLEND |
4907 WINED3DLINECAPS_ALPHACMP |
4908 WINED3DLINECAPS_FOG;
4909 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4910 * idea how generating the smoothing alpha values works; the result is different
4913 caps->MaxTextureWidth = gl_info->limits.texture_size;
4914 caps->MaxTextureHeight = gl_info->limits.texture_size;
4916 if (gl_info->supported[EXT_TEXTURE3D])
4917 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
4919 caps->MaxVolumeExtent = 0;
4921 caps->MaxTextureRepeat = 32768;
4922 caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
4923 caps->MaxVertexW = 1.0f;
4925 caps->GuardBandLeft = 0.0f;
4926 caps->GuardBandTop = 0.0f;
4927 caps->GuardBandRight = 0.0f;
4928 caps->GuardBandBottom = 0.0f;
4930 caps->ExtentsAdjust = 0.0f;
4932 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
4933 WINED3DSTENCILCAPS_INCRSAT |
4934 WINED3DSTENCILCAPS_INVERT |
4935 WINED3DSTENCILCAPS_KEEP |
4936 WINED3DSTENCILCAPS_REPLACE |
4937 WINED3DSTENCILCAPS_ZERO;
4938 if (gl_info->supported[EXT_STENCIL_WRAP])
4940 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
4941 WINED3DSTENCILCAPS_INCR;
4943 if (gl_info->supported[EXT_STENCIL_TWO_SIDE] || gl_info->supported[ATI_SEPARATE_STENCIL])
4945 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
4948 caps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
4950 caps->MaxUserClipPlanes = gl_info->limits.clipplanes;
4951 caps->MaxActiveLights = gl_info->limits.lights;
4953 caps->MaxVertexBlendMatrices = gl_info->limits.blends;
4954 caps->MaxVertexBlendMatrixIndex = 0;
4956 caps->MaxAnisotropy = gl_info->limits.anisotropy;
4957 caps->MaxPointSize = gl_info->limits.pointsize_max;
4960 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4961 caps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
4962 WINED3DVTXPCAPS_MATERIALSOURCE7 |
4963 WINED3DVTXPCAPS_POSITIONALLIGHTS |
4964 WINED3DVTXPCAPS_LOCALVIEWER |
4965 WINED3DVTXPCAPS_VERTEXFOG |
4966 WINED3DVTXPCAPS_TEXGEN;
4968 caps->MaxPrimitiveCount = 0xfffff; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4969 caps->MaxVertexIndex = 0xfffff;
4970 caps->MaxStreams = MAX_STREAMS;
4971 caps->MaxStreamStride = 1024;
4973 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4974 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
4975 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
4976 caps->MaxNpatchTessellationLevel = 0;
4977 caps->MasterAdapterOrdinal = 0;
4978 caps->AdapterOrdinalInGroup = 0;
4979 caps->NumberOfAdaptersInGroup = 1;
4981 caps->NumSimultaneousRTs = gl_info->limits.buffers;
4983 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
4984 WINED3DPTFILTERCAPS_MAGFPOINT |
4985 WINED3DPTFILTERCAPS_MINFLINEAR |
4986 WINED3DPTFILTERCAPS_MAGFLINEAR;
4987 caps->VertexTextureFilterCaps = 0;
4989 adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
4990 adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
4992 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4993 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
4995 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4996 * Ignore shader model capabilities if disabled in config
4998 if (vs_selected_mode == SHADER_NONE)
5000 TRACE("Vertex shader disabled in config, reporting version 0.0.\n");
5001 caps->VertexShaderVersion = 0;
5002 caps->MaxVertexShaderConst = 0;
5006 caps->VertexShaderVersion = shader_caps.vs_version;
5007 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
5010 if (ps_selected_mode == SHADER_NONE)
5012 TRACE("Pixel shader disabled in config, reporting version 0.0.\n");
5013 caps->PixelShaderVersion = 0;
5014 caps->PixelShader1xMaxValue = 0.0f;
5016 caps->PixelShaderVersion = shader_caps.ps_version;
5017 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
5020 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
5021 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
5022 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
5024 /* The following caps are shader specific, but they are things we cannot detect, or which
5025 * are the same among all shader models. So to avoid code duplication set the shader version
5026 * specific, but otherwise constant caps here
5028 if (caps->VertexShaderVersion >= 3)
5030 /* Where possible set the caps based on OpenGL extensions and if they
5031 * aren't set (in case of software rendering) use the VS 3.0 from
5032 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5034 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
5035 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5036 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5037 caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
5038 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
5039 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
5041 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
5042 caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
5044 else if (caps->VertexShaderVersion == 2)
5046 caps->VS20Caps.caps = 0;
5047 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
5048 caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
5049 caps->VS20Caps.static_flow_control_depth = 1;
5051 caps->MaxVShaderInstructionsExecuted = 65535;
5052 caps->MaxVertexShader30InstructionSlots = 0;
5056 caps->VS20Caps.caps = 0;
5057 caps->VS20Caps.dynamic_flow_control_depth = 0;
5058 caps->VS20Caps.temp_count = 0;
5059 caps->VS20Caps.static_flow_control_depth = 0;
5061 caps->MaxVShaderInstructionsExecuted = 0;
5062 caps->MaxVertexShader30InstructionSlots = 0;
5065 if (caps->PixelShaderVersion >= 3)
5067 /* Where possible set the caps based on OpenGL extensions and if they
5068 * aren't set (in case of software rendering) use the PS 3.0 from
5069 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5072 /* Caps is more or less undocumented on MSDN but it appears to be
5073 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
5074 * cards from Windows */
5075 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
5076 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
5077 WINED3DPS20CAPS_PREDICATION |
5078 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
5079 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
5080 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5081 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5082 caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
5083 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
5084 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
5085 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
5086 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
5088 caps->MaxPShaderInstructionsExecuted = 65535;
5089 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
5090 adapter->gl_info.limits.arb_ps_instructions);
5092 else if(caps->PixelShaderVersion == 2)
5094 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
5095 caps->PS20Caps.caps = 0;
5096 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
5097 caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
5098 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
5099 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
5100 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
5102 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
5103 caps->MaxPixelShader30InstructionSlots = 0;
5107 caps->PS20Caps.caps = 0;
5108 caps->PS20Caps.dynamic_flow_control_depth = 0;
5109 caps->PS20Caps.temp_count = 0;
5110 caps->PS20Caps.static_flow_control_depth = 0;
5111 caps->PS20Caps.instruction_slot_count = 0;
5113 caps->MaxPShaderInstructionsExecuted = 0;
5114 caps->MaxPixelShader30InstructionSlots = 0;
5117 if (caps->VertexShaderVersion >= 2)
5119 /* OpenGL supports all the formats below, perhaps not always
5120 * without conversion, but it supports them.
5121 * Further GLSL doesn't seem to have an official unsigned type so
5122 * don't advertise it yet as I'm not sure how we handle it.
5123 * We might need to add some clamping in the shader engine to
5125 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
5126 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
5127 WINED3DDTCAPS_UBYTE4N |
5128 WINED3DDTCAPS_SHORT2N |
5129 WINED3DDTCAPS_SHORT4N;
5130 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
5132 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
5133 WINED3DDTCAPS_FLOAT16_4;
5138 caps->DeclTypes = 0;
5141 /* Set DirectDraw helper Caps */
5142 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
5143 WINEDDCKEYCAPS_SRCBLT;
5144 fx_caps = WINEDDFXCAPS_BLTALPHA |
5145 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
5146 WINEDDFXCAPS_BLTMIRRORUPDOWN |
5147 WINEDDFXCAPS_BLTROTATION90 |
5148 WINEDDFXCAPS_BLTSHRINKX |
5149 WINEDDFXCAPS_BLTSHRINKXN |
5150 WINEDDFXCAPS_BLTSHRINKY |
5151 WINEDDFXCAPS_BLTSHRINKXN |
5152 WINEDDFXCAPS_BLTSTRETCHX |
5153 WINEDDFXCAPS_BLTSTRETCHXN |
5154 WINEDDFXCAPS_BLTSTRETCHY |
5155 WINEDDFXCAPS_BLTSTRETCHYN;
5156 blit_caps = WINEDDCAPS_BLT |
5157 WINEDDCAPS_BLTCOLORFILL |
5158 WINEDDCAPS_BLTDEPTHFILL |
5159 WINEDDCAPS_BLTSTRETCH |
5160 WINEDDCAPS_CANBLTSYSMEM |
5161 WINEDDCAPS_CANCLIP |
5162 WINEDDCAPS_CANCLIPSTRETCHED |
5163 WINEDDCAPS_COLORKEY |
5164 WINEDDCAPS_COLORKEYHWASSIST |
5165 WINEDDCAPS_ALIGNBOUNDARYSRC;
5166 pal_caps = WINEDDPCAPS_8BIT |
5167 WINEDDPCAPS_PRIMARYSURFACE;
5169 /* Fill the ddraw caps structure */
5170 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
5171 WINEDDCAPS_PALETTE |
5173 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
5174 WINEDDCAPS2_NOPAGELOCKREQUIRED |
5175 WINEDDCAPS2_PRIMARYGAMMA |
5176 WINEDDCAPS2_WIDESURFACES |
5177 WINEDDCAPS2_CANRENDERWINDOWED;
5178 caps->ddraw_caps.color_key_caps = ckey_caps;
5179 caps->ddraw_caps.fx_caps = fx_caps;
5180 caps->ddraw_caps.pal_caps = pal_caps;
5181 caps->ddraw_caps.svb_caps = blit_caps;
5182 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
5183 caps->ddraw_caps.svb_fx_caps = fx_caps;
5184 caps->ddraw_caps.vsb_caps = blit_caps;
5185 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
5186 caps->ddraw_caps.vsb_fx_caps = fx_caps;
5187 caps->ddraw_caps.ssb_caps = blit_caps;
5188 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
5189 caps->ddraw_caps.ssb_fx_caps = fx_caps;
5191 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
5192 WINEDDSCAPS_BACKBUFFER |
5194 WINEDDSCAPS_FRONTBUFFER |
5195 WINEDDSCAPS_OFFSCREENPLAIN |
5196 WINEDDSCAPS_PALETTE |
5197 WINEDDSCAPS_PRIMARYSURFACE |
5198 WINEDDSCAPS_SYSTEMMEMORY |
5199 WINEDDSCAPS_VIDEOMEMORY |
5200 WINEDDSCAPS_VISIBLE;
5201 caps->ddraw_caps.stride_align = DDRAW_PITCH_ALIGNMENT;
5203 /* Set D3D caps if OpenGL is available. */
5204 if (adapter->opengl)
5206 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
5207 WINEDDSCAPS_MIPMAP |
5208 WINEDDSCAPS_TEXTURE |
5209 WINEDDSCAPS_ZBUFFER;
5210 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
5216 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
5217 HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
5218 struct wined3d_device **device)
5220 struct wined3d_device *object;
5223 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
5224 wined3d, adapter_idx, device_type, focus_window, flags, device_parent, device);
5226 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
5227 * number and create a device without a 3D adapter for 2D only operation. */
5228 if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
5229 return WINED3DERR_INVALIDCALL;
5231 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5234 ERR("Failed to allocate device memory.\n");
5235 return E_OUTOFMEMORY;
5238 hr = device_init(object, wined3d, adapter_idx, device_type,
5239 focus_window, flags, surface_alignment, device_parent);
5242 WARN("Failed to initialize device, hr %#x.\n", hr);
5243 HeapFree(GetProcessHeap(), 0, object);
5247 TRACE("Created device %p.\n", object);
5250 device_parent->ops->wined3d_device_created(device_parent, *device);
5255 static void WINE_GLAPI invalid_func(const void *data)
5257 ERR("Invalid vertex attribute function called\n");
5261 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
5263 ERR("Invalid texcoord function called\n");
5267 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
5268 * the extension detection and are used in drawStridedSlow
5270 static void WINE_GLAPI position_d3dcolor(const void *data)
5272 DWORD pos = *((const DWORD *)data);
5274 FIXME("Add a test for fixed function position from d3dcolor type\n");
5275 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
5281 static void WINE_GLAPI position_float4(const void *data)
5283 const GLfloat *pos = data;
5285 if (pos[3] != 0.0f && pos[3] != 1.0f)
5287 float w = 1.0f / pos[3];
5289 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
5293 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
5297 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
5299 DWORD diffuseColor = *((const DWORD *)data);
5301 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
5302 D3DCOLOR_B_G(diffuseColor),
5303 D3DCOLOR_B_B(diffuseColor),
5304 D3DCOLOR_B_A(diffuseColor));
5307 static void WINE_GLAPI specular_d3dcolor(const void *data)
5309 DWORD specularColor = *((const DWORD *)data);
5310 GLbyte d[] = {D3DCOLOR_B_R(specularColor),
5311 D3DCOLOR_B_G(specularColor),
5312 D3DCOLOR_B_B(specularColor)};
5314 specular_func_3ubv(d);
5317 static void WINE_GLAPI warn_no_specular_func(const void *data)
5319 WARN("GL_EXT_secondary_color not supported\n");
5322 static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
5324 position_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5325 position_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5326 position_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex3fv;
5327 position_funcs[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
5328 position_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
5329 position_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5330 position_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5331 position_funcs[WINED3D_FFP_EMIT_SHORT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex2sv;
5332 position_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5333 position_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5334 position_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5335 position_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5336 position_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5337 position_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5338 position_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5339 position_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5340 position_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5342 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5343 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5344 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor3fv;
5345 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4fv;
5346 diffuse_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
5347 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5348 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5349 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5350 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4ubv;
5351 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5352 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4sv;
5353 diffuse_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5354 diffuse_funcs[WINED3D_FFP_EMIT_USHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4usv;
5355 diffuse_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5356 diffuse_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5357 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5358 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5360 /* No 4 component entry points here */
5361 specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5362 specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5363 if (gl_info->supported[EXT_SECONDARY_COLOR])
5365 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
5369 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
5371 specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func;
5372 if (gl_info->supported[EXT_SECONDARY_COLOR])
5374 specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT);
5375 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
5379 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
5381 specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5382 specular_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5383 specular_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5384 specular_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5385 specular_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5386 specular_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5387 specular_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5388 specular_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5389 specular_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5390 specular_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5391 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5392 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5394 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5395 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5397 normal_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5398 normal_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5399 normal_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv;
5400 normal_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv; /* Just ignore the 4th value */
5401 normal_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_func;
5402 normal_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5403 normal_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5404 normal_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5405 normal_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5406 normal_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5407 normal_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5408 normal_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5409 normal_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5410 normal_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5411 normal_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5412 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5413 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5415 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
5416 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
5417 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
5418 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
5419 multi_texcoord_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_texcoord_func;
5420 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_texcoord_func;
5421 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
5422 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
5423 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_texcoord_func;
5424 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_texcoord_func;
5425 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_texcoord_func;
5426 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_texcoord_func;
5427 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func;
5428 multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func;
5429 multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func;
5430 if (gl_info->supported[NV_HALF_FLOAT])
5432 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5433 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
5434 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
5436 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_texcoord_func;
5437 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_texcoord_func;
5441 /* Do not call while under the GL lock. */
5442 static BOOL InitAdapters(struct wined3d *wined3d)
5444 struct wined3d_adapter *adapter = &wined3d->adapters[0];
5445 struct wined3d_gl_info *gl_info = &adapter->gl_info;
5447 int ps_selected_mode, vs_selected_mode;
5449 /* No need to hold any lock. The calling library makes sure only one thread calls
5450 * wined3d simultaneously
5453 TRACE("Initializing adapters\n");
5455 /* Dynamically load all GL core functions */
5456 #ifdef USE_WIN32_OPENGL
5458 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
5459 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5464 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
5466 HDC hdc = GetDC( 0 );
5467 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
5468 ReleaseDC( 0, hdc );
5469 if (!wgl_driver || wgl_driver == (void *)-1) goto nogl_adapter;
5470 gl_info->gl_ops.gl = wgl_driver->gl;
5474 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
5475 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
5477 /* For now only one default adapter */
5479 struct wined3d_fake_gl_ctx fake_gl_ctx = {0};
5480 struct wined3d_pixel_format *cfgs;
5483 DISPLAY_DEVICEW DisplayDevice;
5486 TRACE("Initializing default adapter\n");
5487 adapter->ordinal = 0;
5488 adapter->monitorPoint.x = -1;
5489 adapter->monitorPoint.y = -1;
5491 if (!AllocateLocallyUniqueId(&adapter->luid))
5493 DWORD err = GetLastError();
5494 ERR("Failed to set adapter LUID (%#x).\n", err);
5497 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5498 adapter->luid.HighPart, adapter->luid.LowPart);
5500 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx))
5502 ERR("Failed to get a gl context for default adapter\n");
5506 ret = wined3d_adapter_init_gl_caps(adapter);
5508 ERR("Failed to initialize gl caps for default adapter\n");
5509 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5512 ret = initPixelFormats(&adapter->gl_info, adapter->driver_info.vendor);
5514 ERR("Failed to init gl formats\n");
5515 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5519 hdc = fake_gl_ctx.dc;
5521 adapter->TextureRam = adapter->driver_info.vidmem;
5522 adapter->UsedTextureRam = 0;
5523 TRACE("Emulating %dMB of texture ram\n", adapter->TextureRam/(1024*1024));
5525 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5526 DisplayDevice.cb = sizeof(DisplayDevice);
5527 EnumDisplayDevicesW(NULL, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice, 0);
5528 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice.DeviceName));
5529 strcpyW(adapter->DeviceName, DisplayDevice.DeviceName);
5531 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
5539 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
5540 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, &attribute, &cfg_count));
5541 adapter->cfg_count = cfg_count;
5543 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, adapter->cfg_count * sizeof(*adapter->cfgs));
5544 cfgs = adapter->cfgs;
5545 attribs[nAttribs++] = WGL_RED_BITS_ARB;
5546 attribs[nAttribs++] = WGL_GREEN_BITS_ARB;
5547 attribs[nAttribs++] = WGL_BLUE_BITS_ARB;
5548 attribs[nAttribs++] = WGL_ALPHA_BITS_ARB;
5549 attribs[nAttribs++] = WGL_COLOR_BITS_ARB;
5550 attribs[nAttribs++] = WGL_DEPTH_BITS_ARB;
5551 attribs[nAttribs++] = WGL_STENCIL_BITS_ARB;
5552 attribs[nAttribs++] = WGL_DRAW_TO_WINDOW_ARB;
5553 attribs[nAttribs++] = WGL_PIXEL_TYPE_ARB;
5554 attribs[nAttribs++] = WGL_DOUBLE_BUFFER_ARB;
5555 attribs[nAttribs++] = WGL_AUX_BUFFERS_ARB;
5557 for (iPixelFormat=1; iPixelFormat <= adapter->cfg_count; ++iPixelFormat)
5559 res = GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, nAttribs, attribs, values));
5564 /* Cache the pixel format */
5565 cfgs->iPixelFormat = iPixelFormat;
5566 cfgs->redSize = values[0];
5567 cfgs->greenSize = values[1];
5568 cfgs->blueSize = values[2];
5569 cfgs->alphaSize = values[3];
5570 cfgs->colorSize = values[4];
5571 cfgs->depthSize = values[5];
5572 cfgs->stencilSize = values[6];
5573 cfgs->windowDrawable = values[7];
5574 cfgs->iPixelType = values[8];
5575 cfgs->doubleBuffer = values[9];
5576 cfgs->auxBuffers = values[10];
5578 cfgs->numSamples = 0;
5579 /* Check multisample support */
5580 if (gl_info->supported[ARB_MULTISAMPLE])
5582 int attrib[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
5584 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 2, attrib, value))) {
5585 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5586 * value[1] = number of multi sample buffers*/
5588 cfgs->numSamples = value[1];
5592 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5593 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5594 cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
5595 cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
5596 cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable);
5602 int nCfgs = DescribePixelFormat(hdc, 0, 0, 0);
5603 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs * sizeof(*adapter->cfgs));
5604 adapter->cfg_count = 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5606 cfgs = adapter->cfgs;
5607 for(iPixelFormat=1; iPixelFormat<=nCfgs; iPixelFormat++)
5609 PIXELFORMATDESCRIPTOR ppfd;
5611 res = DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &ppfd);
5615 /* We only want HW acceleration using an OpenGL ICD driver.
5616 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5617 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5619 if(ppfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
5621 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat);
5625 cfgs->iPixelFormat = iPixelFormat;
5626 cfgs->redSize = ppfd.cRedBits;
5627 cfgs->greenSize = ppfd.cGreenBits;
5628 cfgs->blueSize = ppfd.cBlueBits;
5629 cfgs->alphaSize = ppfd.cAlphaBits;
5630 cfgs->colorSize = ppfd.cColorBits;
5631 cfgs->depthSize = ppfd.cDepthBits;
5632 cfgs->stencilSize = ppfd.cStencilBits;
5633 cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
5634 cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
5635 cfgs->doubleBuffer = (ppfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
5636 cfgs->auxBuffers = ppfd.cAuxBuffers;
5637 cfgs->numSamples = 0;
5639 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5640 "depth=%d, stencil=%d, windowDrawable=%d\n",
5641 cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
5642 cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
5643 cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable);
5645 adapter->cfg_count++;
5648 /* We haven't found any suitable formats. This should only happen
5649 * in case of GDI software rendering, which is pretty useless
5651 if (!adapter->cfg_count)
5653 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5655 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5656 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
5661 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5663 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
5664 fillGLAttribFuncs(&adapter->gl_info);
5665 adapter->opengl = TRUE;
5667 wined3d->adapter_count = 1;
5668 TRACE("%u adapters successfully initialized.\n", wined3d->adapter_count);
5673 /* Initialize an adapter for ddraw-only memory counting */
5674 memset(wined3d->adapters, 0, sizeof(wined3d->adapters));
5675 wined3d->adapters[0].ordinal = 0;
5676 wined3d->adapters[0].opengl = FALSE;
5677 wined3d->adapters[0].monitorPoint.x = -1;
5678 wined3d->adapters[0].monitorPoint.y = -1;
5680 wined3d->adapters[0].driver_info.name = "Display";
5681 wined3d->adapters[0].driver_info.description = "WineD3D DirectDraw Emulation";
5682 if (wined3d_settings.emulated_textureram)
5683 wined3d->adapters[0].TextureRam = wined3d_settings.emulated_textureram;
5685 wined3d->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5687 initPixelFormatsNoGL(&wined3d->adapters[0].gl_info);
5689 wined3d->adapter_count = 1;
5693 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
5695 const struct wined3d_parent_ops wined3d_null_parent_ops =
5697 wined3d_null_wined3d_object_destroyed,
5700 /* Do not call while under the GL lock. */
5701 HRESULT wined3d_init(struct wined3d *wined3d, UINT version, DWORD flags)
5703 wined3d->dxVersion = version;
5705 wined3d->flags = flags;
5707 if (!InitAdapters(wined3d))
5709 WARN("Failed to initialize adapters.\n");
5712 MESSAGE("Direct3D%u is not available without OpenGL.\n", version);