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_instanced_arrays", ARB_INSTANCED_ARRAYS, },
109 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
110 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
111 {"GL_ARB_multisample", ARB_MULTISAMPLE }, /* needs GLX_ARB_MULTISAMPLE as well */
112 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
113 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
114 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
115 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
116 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
117 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
118 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
119 {"GL_ARB_shader_objects", ARB_SHADER_OBJECTS },
120 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
121 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
122 {"GL_ARB_shadow", ARB_SHADOW },
123 {"GL_ARB_sync", ARB_SYNC },
124 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
125 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
126 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
127 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
128 {"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD },
129 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
130 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
131 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
132 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
133 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
134 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
135 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
136 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
137 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
138 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
139 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
140 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
143 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
144 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
145 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
146 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
147 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
150 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
151 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
152 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
153 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
154 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
155 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
156 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
157 {"GL_EXT_fog_coord", EXT_FOG_COORD },
158 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
159 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
160 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
161 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
162 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
163 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
164 {"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE },
165 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
166 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
167 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
168 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
169 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
170 {"GL_EXT_texture3D", EXT_TEXTURE3D },
171 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
172 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
173 {"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD },
174 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
175 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
176 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
177 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
178 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
179 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
180 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
183 {"GL_NV_depth_clamp", NV_DEPTH_CLAMP },
184 {"GL_NV_fence", NV_FENCE },
185 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
186 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
187 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
188 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
189 {"GL_NV_half_float", NV_HALF_FLOAT },
190 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
191 {"GL_NV_point_sprite", NV_POINT_SPRITE },
192 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
193 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
194 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
195 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
196 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
197 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
198 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
199 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
200 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
201 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
202 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
205 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
208 static const struct wined3d_extension_map wgl_extension_map[] =
210 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
211 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
212 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
215 /**********************************************************
216 * Utility functions follow
217 **********************************************************/
219 const struct min_lookup minMipLookup[] =
221 /* NONE POINT LINEAR */
222 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
223 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
224 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
227 const struct min_lookup minMipLookup_noFilter[] =
229 /* NONE POINT LINEAR */
230 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
231 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
232 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
235 const struct min_lookup minMipLookup_noMip[] =
237 /* NONE POINT LINEAR */
238 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
239 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
240 {{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
243 const GLenum magLookup[] =
245 /* NONE POINT LINEAR */
246 GL_NEAREST, GL_NEAREST, GL_LINEAR,
249 const GLenum magLookup_noFilter[] =
251 /* NONE POINT LINEAR */
252 GL_NEAREST, GL_NEAREST, GL_NEAREST,
255 /* drawStridedSlow attributes */
256 glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
257 glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
258 glAttribFunc specular_func_3ubv;
259 glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
260 glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
261 glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
264 * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
265 * i.e., there is no GL Context - Get a default rendering context to enable the
266 * function query some info from GL.
269 struct wined3d_fake_gl_ctx
275 HGLRC restore_gl_ctx;
278 static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
280 TRACE("Destroying fake GL context.\n");
282 if (!wglMakeCurrent(NULL, NULL))
283 ERR("Failed to disable fake GL context.\n");
285 if (!wglDeleteContext(ctx->gl_ctx))
287 DWORD err = GetLastError();
288 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
291 ReleaseDC(ctx->wnd, ctx->dc);
292 DestroyWindow(ctx->wnd);
294 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
295 ERR("Failed to restore previous GL context.\n");
298 /* Do not call while under the GL lock. */
299 static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
301 PIXELFORMATDESCRIPTOR pfd;
304 TRACE("getting context...\n");
306 ctx->restore_dc = wglGetCurrentDC();
307 ctx->restore_gl_ctx = wglGetCurrentContext();
309 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
310 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
311 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
314 ERR("Failed to create a window.\n");
318 ctx->dc = GetDC(ctx->wnd);
321 ERR("Failed to get a DC.\n");
325 /* PixelFormat selection */
326 ZeroMemory(&pfd, sizeof(pfd));
327 pfd.nSize = sizeof(pfd);
329 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
330 pfd.iPixelType = PFD_TYPE_RGBA;
332 pfd.iLayerType = PFD_MAIN_PLANE;
334 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
336 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
337 ERR("Failed to find a suitable pixel format.\n");
340 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
341 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
343 /* Create a GL context. */
344 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
346 WARN("Failed to create default context for capabilities initialization.\n");
350 /* Make it the current GL context. */
351 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
353 ERR("Failed to make fake GL context current.\n");
360 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
362 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
364 if (ctx->wnd) DestroyWindow(ctx->wnd);
366 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
367 ERR("Failed to restore previous GL context.\n");
372 /* Adjust the amount of used texture memory */
373 unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount)
375 adapter->UsedTextureRam += amount;
376 TRACE("Adjusted adapter memory by %d to %d.\n", amount, adapter->UsedTextureRam);
377 return adapter->UsedTextureRam;
380 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
382 HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
383 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
386 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
388 ULONG refcount = InterlockedIncrement(&wined3d->ref);
390 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
395 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
397 ULONG refcount = InterlockedDecrement(&wined3d->ref);
399 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
405 for (i = 0; i < wined3d->adapter_count; ++i)
407 wined3d_adapter_cleanup(&wined3d->adapters[i]);
409 HeapFree(GetProcessHeap(), 0, wined3d);
415 /* Context activation is done by the caller. */
416 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
420 const char *testcode =
422 "PARAM C[66] = { program.env[0..65] };\n"
424 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
425 "ARL A0.x, zero.x;\n"
426 "MOV result.position, C[A0.x + 65];\n"
429 while (gl_info->gl_ops.gl.p_glGetError());
430 GL_EXTCALL(glGenProgramsARB(1, &prog));
432 ERR("Failed to create an ARB offset limit test program\n");
434 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
435 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
436 strlen(testcode), testcode));
437 if (gl_info->gl_ops.gl.p_glGetError())
439 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
440 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
442 } else TRACE("OpenGL implementation allows offsets > 63\n");
444 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
445 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
446 checkGLcall("ARB vp offset limit test cleanup");
451 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
452 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
454 if (card_vendor != HW_VENDOR_AMD) return FALSE;
455 if (device == CARD_AMD_RADEON_9500) return TRUE;
456 if (device == CARD_AMD_RADEON_X700) return TRUE;
457 if (device == CARD_AMD_RADEON_X1600) return TRUE;
461 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
462 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
464 if (card_vendor == HW_VENDOR_NVIDIA)
466 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
467 device == CARD_NVIDIA_GEFORCEFX_5600 ||
468 device == CARD_NVIDIA_GEFORCEFX_5800)
476 static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
477 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
479 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
480 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
481 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
483 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
484 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
485 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
486 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
487 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
488 * the chance that other implementations support them is rather small since Win32 QuickTime uses
489 * DirectDraw, not OpenGL.
491 * This test has been moved into wined3d_guess_gl_vendor()
493 if (gl_vendor == GL_VENDOR_APPLE)
500 /* Context activation is done by the caller. */
501 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
503 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
504 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
505 * all the texture. This function detects this bug by its symptom and disables PBOs
508 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
509 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
510 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
511 * read back is compared to the original. If they are equal PBOs are assumed to work,
512 * otherwise the PBO extension is disabled. */
514 static const unsigned int pattern[] =
516 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
517 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
518 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
519 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
521 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
523 /* No PBO -> No point in testing them. */
524 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
526 while (gl_info->gl_ops.gl.p_glGetError());
527 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
528 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
530 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
531 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);
532 checkGLcall("Specifying the PBO test texture");
534 GL_EXTCALL(glGenBuffersARB(1, &pbo));
535 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
536 GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
537 checkGLcall("Specifying the PBO test pbo");
539 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);
540 checkGLcall("Loading the PBO test texture");
542 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
544 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
546 memset(check, 0, sizeof(check));
547 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
548 checkGLcall("Reading back the PBO test texture");
550 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
551 GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
552 checkGLcall("PBO test cleanup");
554 if (memcmp(check, pattern, sizeof(check)))
556 WARN("PBO test failed, read back data doesn't match original.\n"
557 "Disabling PBOs. This may result in slower performance.\n");
558 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
562 TRACE("PBO test successful.\n");
566 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
567 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
569 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
572 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
573 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
575 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
576 if (card_vendor != HW_VENDOR_AMD) return FALSE;
577 if (device == CARD_AMD_RADEON_X1600) return FALSE;
581 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
582 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
584 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
585 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
586 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
587 * varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
590 * dx10 cards usually have 64 varyings */
591 return gl_info->limits.glsl_varyings > 44;
594 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
595 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
597 return !match_dx10_capable(gl_info, gl_renderer, gl_vendor, card_vendor, device);
600 /* A GL context is provided by the caller */
601 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
602 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
607 if (!gl_info->supported[EXT_SECONDARY_COLOR])
610 while (gl_info->gl_ops.gl.p_glGetError());
611 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
612 error = gl_info->gl_ops.gl.p_glGetError();
614 if (error == GL_NO_ERROR)
616 TRACE("GL Implementation accepts 4 component specular color pointers\n");
621 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
622 debug_glerror(error));
627 /* A GL context is provided by the caller */
628 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
629 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
634 const char *testcode =
636 "OPTION NV_vertex_program2;\n"
637 "MOV result.clip[0], 0.0;\n"
638 "MOV result.position, 0.0;\n"
641 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
643 while (gl_info->gl_ops.gl.p_glGetError());
645 GL_EXTCALL(glGenProgramsARB(1, &prog));
648 ERR("Failed to create the NVvp clip test program\n");
651 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
652 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
653 strlen(testcode), testcode));
654 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
657 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
658 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
660 while (gl_info->gl_ops.gl.p_glGetError());
662 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
664 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
665 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
666 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
671 /* Context activation is done by the caller. */
672 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
673 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
675 char data[4 * 4 * 4];
679 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
681 memset(data, 0xcc, sizeof(data));
683 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
684 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
685 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
686 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
687 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);
688 checkGLcall("glTexImage2D");
690 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
691 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
692 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
693 checkGLcall("glFramebufferTexture2D");
695 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
696 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
697 checkGLcall("glCheckFramebufferStatus");
699 memset(data, 0x11, sizeof(data));
700 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);
701 checkGLcall("glTexSubImage2D");
703 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
704 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
705 checkGLcall("glClear");
707 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
708 checkGLcall("glGetTexImage");
710 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
711 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
712 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
713 checkGLcall("glBindTexture");
715 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
716 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
717 checkGLcall("glDeleteTextures");
719 return *(DWORD *)data == 0x11111111;
722 /* Context activation is done by the caller. */
723 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
724 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
726 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
727 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
731 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
732 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
733 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
734 checkGLcall("glTexImage2D");
736 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
737 checkGLcall("glGetTexLevelParameteriv");
738 TRACE("Real color depth is %d\n", size);
740 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
741 checkGLcall("glBindTexture");
742 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
743 checkGLcall("glDeleteTextures");
748 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
749 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
751 return gl_vendor == GL_VENDOR_FGLRX;
754 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
756 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
757 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
758 * allow 48 different offsets or other helper immediate values. */
759 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
760 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
763 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
765 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
766 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
767 * If real NP2 textures are used, the driver falls back to software. We could just remove the
768 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
769 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
770 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
771 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
773 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
774 * has this extension promoted to core. The extension loading code sets this extension supported
775 * due to that, so this code works on fglrx as well. */
776 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
778 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
779 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
780 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
784 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
786 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
787 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
788 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
789 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
790 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
791 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
793 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
794 * triggering the software fallback. There is not much we can do here apart from disabling the
795 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
796 * in wined3d_adapter_init_gl_caps).
797 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
798 * post-processing effects in the game "Max Payne 2").
799 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
800 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
801 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
802 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
805 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
807 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
808 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
809 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
810 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
811 * according to the spec.
813 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
814 * makes the shader slower and eats instruction slots which should be available to the d3d app.
816 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
817 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
818 * this workaround is activated on cards that do not need it, it won't break things, just affect
819 * performance negatively. */
820 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
821 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
824 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
826 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
829 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
831 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
834 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
836 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
839 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
841 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
844 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
846 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
849 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
851 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
854 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
856 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
857 selected texture formats. They are apparently the only DX9 class GPUs
859 Also, DX9-era GPUs are somewhat limited with float textures
860 filtering and blending. */
861 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
866 BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
867 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
868 void (*apply)(struct wined3d_gl_info *gl_info);
869 const char *description;
872 static const struct driver_quirk quirk_table[] =
875 match_amd_r300_to_500,
877 "AMD normalized texrect quirk"
881 quirk_apple_glsl_constants,
882 "Apple GLSL uniform override"
887 "Geforce 5 NP2 disable"
892 "Init texcoord .w for Apple Intel GPU driver"
895 match_apple_nonr500ati,
897 "Init texcoord .w for Apple ATI >= r600 GPU driver"
902 "Reserved varying for gl_ClipPos"
905 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
906 * GL implementations accept it. The Mac GL is the only implementation known to
909 * If we can pass 4 component specular colors, do it, because (a) we don't have
910 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
911 * passes specular alpha to the pixel shader if any is used. Otherwise the
912 * specular alpha is used to pass the fog coordinate, which we pass to opengl
913 * via GL_EXT_fog_coord.
915 match_allows_spec_alpha,
916 quirk_allows_specular_alpha,
917 "Allow specular alpha quirk"
920 match_broken_nv_clip,
921 quirk_disable_nvvp_clip,
922 "Apple NV_vertex_program clip bug quirk"
925 match_fbo_tex_update,
926 quirk_fbo_tex_update,
927 "FBO rebind for attachment updates"
932 "True RGBA16 is not available"
937 "Not printing GLSL infolog"
940 match_not_dx10_capable,
941 quirk_limited_tex_filtering,
942 "Texture filtering, blending and VTF support is limited"
946 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
947 * reporting a driver version is moot because we are not the Windows driver, and we have different
948 * bugs, features, etc.
950 * The driver version has the form "x.y.z.w".
952 * "x" is the Windows version the driver is meant for:
959 * "y" is the maximum Direct3D version the driver supports.
960 * y -> d3d version mapping:
969 * "z" is the subversion number.
971 * "w" is the vendor specific driver build number.
974 struct driver_version_information
976 enum wined3d_display_driver driver;
977 enum wined3d_driver_model driver_model;
978 const char *driver_name; /* name of Windows driver */
979 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
980 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
981 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
984 /* The driver version table contains driver information for different devices on several OS versions. */
985 static const struct driver_version_information driver_version_table[] =
988 * - Radeon HD2x00 (R600) and up supported by current drivers.
989 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
990 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
991 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
992 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
993 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
994 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
995 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
996 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
997 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1000 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1001 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1002 * igxprd32.dll but the GMA800 driver was never updated. */
1003 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1004 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1005 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1006 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1007 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1008 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1011 * - Geforce6 and newer cards are supported by the current driver (197.x) on XP-Win7
1012 * - GeforceFX support is up to 173.x on <= XP
1013 * - Geforce2MX/3/4 up to 96.x on <= XP
1014 * - TNT/Geforce1/2 up to 71.x on <= XP
1015 * All version numbers used below are from the Linux nvidia drivers. */
1016 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1017 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1018 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1019 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 12, 6658},
1020 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 12, 6658},
1023 struct gpu_description
1025 WORD vendor; /* reported PCI card vendor ID */
1026 WORD card; /* reported PCI card device ID */
1027 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1028 enum wined3d_display_driver driver;
1029 unsigned int vidmem;
1032 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1033 * found on a board containing a specific GPU. */
1034 static const struct gpu_description gpu_description_table[] =
1037 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1038 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1039 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1040 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1041 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1042 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1043 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1044 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1045 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1046 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1047 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1048 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1049 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1050 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1051 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1052 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1053 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1054 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1055 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1056 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE6, 128 },
1057 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1058 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1059 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE6, 320 },
1060 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE6, 768 },
1061 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE6, 256 },
1062 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE6, 256 },
1063 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE6, 256 },
1064 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1065 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1066 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE6, 384 },
1067 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE6, 512 },
1068 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE6, 512 },
1069 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE6, 512 },
1070 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE6, 512 },
1071 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6, 1024},
1072 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6, 896 },
1073 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6, 1024},
1074 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE6, 256},
1075 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6, 1024},
1076 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6, 1024},
1077 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6, 1024},
1078 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6, 1024},
1079 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6, 2048},
1080 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6, 1024},
1081 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6, 1024},
1082 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6, 1024},
1083 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6, 768 },
1084 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE6, 1536},
1085 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6, 1024},
1086 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6, 1280},
1087 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6, 1536},
1088 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE6, 1024},
1089 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE6, 1024},
1090 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1091 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE6, 1024},
1092 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE6, 1024},
1093 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE6, 1024},
1094 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6, 1280},
1095 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6, 1536},
1096 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE6, 1024},
1097 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE6, 1024},
1098 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE6, 2048},
1099 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE6, 2048},
1100 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE6, 2048},
1103 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1104 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1105 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1106 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1107 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1108 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1109 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1110 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1111 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1112 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1113 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1114 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1115 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1116 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1117 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1118 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1119 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1120 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1121 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1122 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1123 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1124 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1125 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1126 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1127 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1128 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1129 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1130 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1131 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1132 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1133 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1134 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1136 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1137 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1138 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1139 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1140 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1141 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1142 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1143 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1144 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1145 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1146 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1147 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1148 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1149 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1150 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1151 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1152 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1153 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1154 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1155 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1156 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1157 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1158 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1159 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1160 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1161 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1162 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) Ironlake Desktop", DRIVER_INTEL_GMA3000, 1024},
1163 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) Ironlake Mobile", DRIVER_INTEL_GMA3000, 1024},
1164 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) Sandybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1165 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) Sandybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1166 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) Sandybridge Server", DRIVER_INTEL_GMA3000, 1024},
1167 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) Ivybridge Desktop", DRIVER_INTEL_GMA3000, 1024},
1168 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) Ivybridge Mobile", DRIVER_INTEL_GMA3000, 1024},
1169 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) Ivybridge Server", DRIVER_INTEL_GMA3000, 1024},
1172 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1173 enum wined3d_driver_model driver_model)
1177 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1178 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
1180 const struct driver_version_information *entry = &driver_version_table[i];
1182 if (entry->driver == driver && entry->driver_model == driver_model)
1184 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1185 entry->driver_name, entry->version, entry->subversion, entry->build);
1192 static void init_driver_info(struct wined3d_driver_info *driver_info,
1193 enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
1195 OSVERSIONINFOW os_version;
1196 WORD driver_os_version;
1198 enum wined3d_display_driver driver = DRIVER_UNKNOWN;
1199 enum wined3d_driver_model driver_model;
1200 const struct driver_version_information *version_info;
1202 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1204 TRACE("Overriding PCI vendor ID with 0x%04x.\n", wined3d_settings.pci_vendor_id);
1205 vendor = wined3d_settings.pci_vendor_id;
1207 driver_info->vendor = vendor;
1209 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1211 TRACE("Overriding PCI device ID with 0x%04x.\n", wined3d_settings.pci_device_id);
1212 device = wined3d_settings.pci_device_id;
1214 driver_info->device = device;
1216 /* Set a default amount of video memory (64MB). In general this code isn't used unless the user
1217 * overrides the pci ids to a card which is not in our database. */
1218 driver_info->vidmem = WINE_DEFAULT_VIDMEM;
1220 memset(&os_version, 0, sizeof(os_version));
1221 os_version.dwOSVersionInfoSize = sizeof(os_version);
1222 if (!GetVersionExW(&os_version))
1224 ERR("Failed to get OS version, reporting 2000/XP.\n");
1225 driver_os_version = 6;
1226 driver_model = DRIVER_MODEL_NT5X;
1230 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1231 switch (os_version.dwMajorVersion)
1234 /* If needed we could distinguish between 9x and NT4, but this code won't make
1235 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1237 driver_os_version = 4;
1238 driver_model = DRIVER_MODEL_WIN9X;
1242 driver_os_version = 6;
1243 driver_model = DRIVER_MODEL_NT5X;
1247 if (os_version.dwMinorVersion == 0)
1249 driver_os_version = 7;
1250 driver_model = DRIVER_MODEL_NT6X;
1254 if (os_version.dwMinorVersion > 1)
1256 FIXME("Unhandled OS version %u.%u, reporting Win 7.\n",
1257 os_version.dwMajorVersion, os_version.dwMinorVersion);
1259 driver_os_version = 8;
1260 driver_model = DRIVER_MODEL_NT6X;
1265 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1266 os_version.dwMajorVersion, os_version.dwMinorVersion);
1267 driver_os_version = 6;
1268 driver_model = DRIVER_MODEL_NT5X;
1273 /* When we reach this stage we always have a vendor or device id (it can be a default one).
1274 * This means that unless the ids are overridden, we will always find a GPU description. */
1275 for (i = 0; i < (sizeof(gpu_description_table) / sizeof(gpu_description_table[0])); i++)
1277 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1279 TRACE("Found card %04x:%04x in driver DB.\n", vendor, device);
1281 driver_info->description = gpu_description_table[i].description;
1282 driver_info->vidmem = gpu_description_table[i].vidmem * 1024*1024;
1283 driver = gpu_description_table[i].driver;
1288 if (wined3d_settings.emulated_textureram)
1290 TRACE("Overriding amount of video memory with %u bytes.\n", wined3d_settings.emulated_textureram);
1291 driver_info->vidmem = wined3d_settings.emulated_textureram;
1294 /* Try to obtain driver version information for the current Windows version. This fails in
1296 * - the gpu is not available on the currently selected OS version:
1297 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1298 * version information for the current Windows version is returned instead of faked info.
1299 * We do the same and assume the default Windows version to emulate is WinXP.
1301 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1302 * For now return the XP driver info. Perhaps later on we should return VESA.
1304 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1305 * This could be an indication that our database is not up to date, so this should be fixed.
1307 version_info = get_driver_version_info(driver, driver_model);
1310 driver_info->name = version_info->driver_name;
1311 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1312 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1316 version_info = get_driver_version_info(driver, DRIVER_MODEL_NT5X);
1319 driver_info->name = version_info->driver_name;
1320 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1321 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1325 driver_info->description = "Direct3D HAL";
1326 driver_info->name = "Display";
1327 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1328 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1330 FIXME("Unable to find a driver/device info for vendor_id=%#x device_id=%#x for driver_model=%d\n",
1331 vendor, device, driver_model);
1335 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1336 driver_info->version_high, driver_info->version_low);
1339 /* Context activation is done by the caller. */
1340 static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
1341 enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1345 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
1347 if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
1348 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1349 quirk_table[i].apply(gl_info);
1352 /* Find out if PBOs work as they are supposed to. */
1353 test_pbo_functionality(gl_info);
1356 static DWORD wined3d_parse_gl_version(const char *gl_version)
1358 const char *ptr = gl_version;
1363 ERR("Invalid OpenGL major version %d.\n", major);
1365 while (isdigit(*ptr)) ++ptr;
1367 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1371 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1373 return MAKEDWORD_VERSION(major, minor);
1376 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1377 const char *gl_vendor_string, const char *gl_renderer)
1380 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1381 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1382 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1384 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1385 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1386 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1387 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1388 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1389 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1390 * DirectDraw, not OpenGL. */
1391 if (gl_info->supported[APPLE_FENCE]
1392 && gl_info->supported[APPLE_CLIENT_STORAGE]
1393 && gl_info->supported[APPLE_YCBCR_422])
1394 return GL_VENDOR_APPLE;
1396 if (strstr(gl_vendor_string, "NVIDIA"))
1397 return GL_VENDOR_NVIDIA;
1399 if (strstr(gl_vendor_string, "ATI"))
1400 return GL_VENDOR_FGLRX;
1402 if (strstr(gl_vendor_string, "Intel(R)")
1403 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1404 || strstr(gl_renderer, "Intel")
1405 || strstr(gl_vendor_string, "Intel Inc."))
1406 return GL_VENDOR_INTEL;
1408 if (strstr(gl_vendor_string, "Mesa")
1409 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1410 || strstr(gl_vendor_string, "DRI R300 Project")
1411 || strstr(gl_vendor_string, "X.Org R300 Project")
1412 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1413 || strstr(gl_vendor_string, "VMware, Inc.")
1414 || strstr(gl_renderer, "Mesa")
1415 || strstr(gl_renderer, "Gallium"))
1416 return GL_VENDOR_MESA;
1418 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1419 debugstr_a(gl_vendor_string));
1421 return GL_VENDOR_UNKNOWN;
1424 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1426 if (strstr(gl_vendor_string, "NVIDIA")
1427 || strstr(gl_vendor_string, "Nouveau")
1428 || strstr(gl_vendor_string, "nouveau"))
1429 return HW_VENDOR_NVIDIA;
1431 if (strstr(gl_vendor_string, "ATI")
1432 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1433 || strstr(gl_vendor_string, "X.Org R300 Project")
1434 || strstr(gl_renderer, "AMD")
1435 || strstr(gl_renderer, "R100")
1436 || strstr(gl_renderer, "R200")
1437 || strstr(gl_renderer, "R300")
1438 || strstr(gl_renderer, "R600")
1439 || strstr(gl_renderer, "R700"))
1440 return HW_VENDOR_AMD;
1442 if (strstr(gl_vendor_string, "Intel(R)")
1443 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1444 || strstr(gl_renderer, "Intel")
1445 || strstr(gl_renderer, "i915")
1446 || strstr(gl_vendor_string, "Intel Inc."))
1447 return HW_VENDOR_INTEL;
1449 if (strstr(gl_vendor_string, "Mesa")
1450 || strstr(gl_vendor_string, "Brian Paul")
1451 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1452 || strstr(gl_vendor_string, "VMware, Inc."))
1453 return HW_VENDOR_SOFTWARE;
1455 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1457 return HW_VENDOR_NVIDIA;
1460 static UINT d3d_level_from_gl_info(const struct wined3d_gl_info *gl_info)
1464 if (gl_info->supported[ARB_MULTITEXTURE])
1466 if (gl_info->supported[ARB_TEXTURE_COMPRESSION]
1467 && gl_info->supported[ARB_TEXTURE_CUBE_MAP]
1468 && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
1470 if (level == 7 && gl_info->supported[ARB_MULTISAMPLE]
1471 && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
1473 if (level == 8 && gl_info->supported[ARB_FRAGMENT_PROGRAM]
1474 && gl_info->supported[ARB_VERTEX_SHADER])
1476 if (level == 9 && gl_info->supported[EXT_GPU_SHADER4])
1482 static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
1483 const char *gl_renderer)
1485 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1488 if (d3d_level >= 10)
1492 const char *renderer;
1493 enum wined3d_pci_device id;
1497 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1498 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1499 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1500 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1501 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1502 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1503 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1504 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1505 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1506 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1507 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1508 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1509 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1510 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1511 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1512 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1513 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1514 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1515 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1516 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1517 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1518 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1519 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1520 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1521 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1522 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1523 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1524 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1525 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1526 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1527 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1528 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1529 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1530 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1531 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1532 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1533 {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1534 {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1535 {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1536 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1537 {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1538 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1539 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1540 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1541 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1542 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1543 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1544 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1545 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1546 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1547 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1548 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1549 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1550 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1551 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1552 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1553 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1554 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1555 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1556 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1557 {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1558 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1559 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1560 {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1561 {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1564 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1566 if (strstr(gl_renderer, cards[i].renderer))
1569 return PCI_DEVICE_NONE;
1572 /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
1573 * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
1575 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
1579 const char *renderer;
1580 enum wined3d_pci_device id;
1584 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1585 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1586 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1587 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1588 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1589 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1590 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1591 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
1592 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
1593 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
1594 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1595 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1596 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1599 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1601 if (strstr(gl_renderer, cards[i].renderer))
1604 return PCI_DEVICE_NONE;
1609 /* GeforceFX - highend */
1610 if (strstr(gl_renderer, "5800")
1611 || strstr(gl_renderer, "5900")
1612 || strstr(gl_renderer, "5950")
1613 || strstr(gl_renderer, "Quadro FX"))
1615 return CARD_NVIDIA_GEFORCEFX_5800;
1618 /* GeforceFX - midend */
1619 if (strstr(gl_renderer, "5600")
1620 || strstr(gl_renderer, "5650")
1621 || strstr(gl_renderer, "5700")
1622 || strstr(gl_renderer, "5750"))
1624 return CARD_NVIDIA_GEFORCEFX_5600;
1627 /* GeforceFX - lowend */
1628 return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
1633 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
1635 return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
1638 return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
1643 if (strstr(gl_renderer, "GeForce4 MX"))
1645 return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
1648 if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
1650 return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
1653 if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
1655 return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
1658 return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
1661 if (strstr(gl_renderer, "TNT2"))
1663 return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
1666 return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
1669 static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info,
1670 const char *gl_renderer)
1672 UINT d3d_level = d3d_level_from_gl_info(gl_info);
1674 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1676 * Beware: renderer string do not match exact card model,
1677 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1678 if (d3d_level >= 10)
1684 const char *renderer;
1685 enum wined3d_pci_device id;
1689 /* Southern Islands */
1690 {"HD 7900", CARD_AMD_RADEON_HD7900},
1691 {"HD 7800", CARD_AMD_RADEON_HD7800},
1692 {"HD 7700", CARD_AMD_RADEON_HD7700},
1693 /* Northern Islands */
1694 {"HD 6970", CARD_AMD_RADEON_HD6900},
1695 {"HD 6900", CARD_AMD_RADEON_HD6900},
1696 {"HD 6800", CARD_AMD_RADEON_HD6800},
1697 {"HD 6770M",CARD_AMD_RADEON_HD6600M},
1698 {"HD 6750M",CARD_AMD_RADEON_HD6600M},
1699 {"HD 6700", CARD_AMD_RADEON_HD6700},
1700 {"HD 6670", CARD_AMD_RADEON_HD6600},
1701 {"HD 6630M",CARD_AMD_RADEON_HD6600M},
1702 {"HD 6600M",CARD_AMD_RADEON_HD6600M},
1703 {"HD 6600", CARD_AMD_RADEON_HD6600},
1704 {"HD 6500M",CARD_AMD_RADEON_HD6600M},
1705 {"HD 6500", CARD_AMD_RADEON_HD6600},
1706 {"HD 6400", CARD_AMD_RADEON_HD6400},
1707 {"HD 6300", CARD_AMD_RADEON_HD6300},
1708 {"HD 6200", CARD_AMD_RADEON_HD6300},
1710 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
1711 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
1712 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1713 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
1714 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
1715 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1716 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
1717 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1718 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1719 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
1720 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
1722 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
1723 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1724 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1725 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1726 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
1727 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
1728 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
1729 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1730 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1731 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1732 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1733 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1734 /* R600/R700 integrated */
1735 {"HD 3300", CARD_AMD_RADEON_HD3200},
1736 {"HD 3200", CARD_AMD_RADEON_HD3200},
1737 {"HD 3100", CARD_AMD_RADEON_HD3200},
1739 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1740 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1741 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1742 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
1743 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1744 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1745 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1746 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1747 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1748 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1749 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1750 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1751 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1754 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1756 if (strstr(gl_renderer, cards[i].renderer))
1759 return PCI_DEVICE_NONE;
1765 if (strstr(gl_renderer, "X1600")
1766 || strstr(gl_renderer, "X1650")
1767 || strstr(gl_renderer, "X1800")
1768 || strstr(gl_renderer, "X1900")
1769 || strstr(gl_renderer, "X1950"))
1771 return CARD_AMD_RADEON_X1600;
1774 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1775 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1776 if (strstr(gl_renderer, "X700")
1777 || strstr(gl_renderer, "X800")
1778 || strstr(gl_renderer, "X850")
1779 || strstr(gl_renderer, "X1300")
1780 || strstr(gl_renderer, "X1400")
1781 || strstr(gl_renderer, "X1450")
1782 || strstr(gl_renderer, "X1550")
1783 || strstr(gl_renderer, "X2300")
1784 || strstr(gl_renderer, "X2500")
1785 || strstr(gl_renderer, "HD 2300")
1788 return CARD_AMD_RADEON_X700;
1791 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
1792 if (strstr(gl_renderer, "Radeon Xpress"))
1794 return CARD_AMD_RADEON_XPRESS_200M;
1797 return PCI_DEVICE_NONE;
1800 static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info,
1801 const char *gl_renderer)
1807 const char *renderer;
1808 enum wined3d_pci_device id;
1813 {"Ivybridge Server", CARD_INTEL_IVBS},
1814 {"Ivybridge Mobile", CARD_INTEL_IVBM},
1815 {"Ivybridge Desktop", CARD_INTEL_IVBD},
1817 {"Sandybridge Server", CARD_INTEL_SNBS},
1818 {"Sandybridge Mobile", CARD_INTEL_SNBM},
1819 {"Sandybridge Desktop", CARD_INTEL_SNBD},
1821 {"Ironlake Mobile", CARD_INTEL_ILKM},
1822 {"Ironlake Desktop", CARD_INTEL_ILKD},
1824 {"B43", CARD_INTEL_B43},
1825 {"G41", CARD_INTEL_G41},
1826 {"G45", CARD_INTEL_G45},
1827 {"Q45", CARD_INTEL_Q45},
1828 {"Integrated Graphics Device", CARD_INTEL_IGD},
1829 {"GM45", CARD_INTEL_GM45},
1831 {"965GME", CARD_INTEL_965GME},
1832 {"965GM", CARD_INTEL_965GM},
1833 {"X3100", CARD_INTEL_965GM}, /* MacOS */
1834 {"946GZ", CARD_INTEL_946GZ},
1835 {"965G", CARD_INTEL_965G},
1836 {"965Q", CARD_INTEL_965Q},
1838 {"Pineview M", CARD_INTEL_PNVM},
1839 {"Pineview G", CARD_INTEL_PNVG},
1840 {"IGD", CARD_INTEL_PNVG},
1841 {"Q33", CARD_INTEL_Q33},
1842 {"G33", CARD_INTEL_G33},
1843 {"Q35", CARD_INTEL_Q35},
1844 {"945GME", CARD_INTEL_945GME},
1845 {"945GM", CARD_INTEL_945GM},
1846 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
1847 {"945G", CARD_INTEL_945G},
1849 {"915GM", CARD_INTEL_915GM},
1850 {"E7221G", CARD_INTEL_E7221G},
1851 {"915G", CARD_INTEL_915G},
1853 {"865G", CARD_INTEL_865G},
1854 {"845G", CARD_INTEL_845G},
1855 {"855GM", CARD_INTEL_855GM},
1856 {"830M", CARD_INTEL_830M},
1859 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1861 if (strstr(gl_renderer, cards[i].renderer))
1865 return PCI_DEVICE_NONE;
1868 static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info,
1869 const char *gl_renderer)
1874 /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
1876 * Beware: renderer string do not match exact card model,
1877 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
1878 if (strstr(gl_renderer, "Gallium"))
1880 /* 20101109 - These are never returned by current Gallium radeon
1881 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
1883 * These are returned but not handled: RC410, RV380. */
1886 const char *renderer;
1887 enum wined3d_pci_device id;
1891 /* Southern Islands */
1892 {"TAHITI", CARD_AMD_RADEON_HD7900},
1893 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
1894 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
1895 /* Northern Islands */
1896 {"CAYMAN", CARD_AMD_RADEON_HD6900},
1897 {"BARTS", CARD_AMD_RADEON_HD6800},
1898 {"TURKS", CARD_AMD_RADEON_HD6600},
1899 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
1900 {"SUMO", CARD_AMD_RADEON_HD6550D},
1901 {"CAICOS", CARD_AMD_RADEON_HD6400},
1902 {"PALM", CARD_AMD_RADEON_HD6300},
1904 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
1905 {"CYPRESS", CARD_AMD_RADEON_HD5800},
1906 {"JUNIPER", CARD_AMD_RADEON_HD5700},
1907 {"REDWOOD", CARD_AMD_RADEON_HD5600},
1908 {"CEDAR", CARD_AMD_RADEON_HD5400},
1910 {"R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
1911 {"RV790", CARD_AMD_RADEON_HD4800},
1912 {"RV770", CARD_AMD_RADEON_HD4800},
1913 {"RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
1914 {"RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
1915 {"RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
1916 /* R600/R700 integrated */
1917 {"RS880", CARD_AMD_RADEON_HD3200},
1918 {"RS780", CARD_AMD_RADEON_HD3200},
1920 {"R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1921 {"R600", CARD_AMD_RADEON_HD2900},
1922 {"RV670", CARD_AMD_RADEON_HD2900},
1923 {"RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1924 {"RV630", CARD_AMD_RADEON_HD2600},
1925 {"RV620", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1926 {"RV610", CARD_AMD_RADEON_HD2350},
1928 {"R580", CARD_AMD_RADEON_X1600},
1929 {"R520", CARD_AMD_RADEON_X1600},
1930 {"RV570", CARD_AMD_RADEON_X1600},
1931 {"RV560", CARD_AMD_RADEON_X1600},
1932 {"RV535", CARD_AMD_RADEON_X1600},
1933 {"RV530", CARD_AMD_RADEON_X1600},
1934 {"RV516", CARD_AMD_RADEON_X700}, /* X700 is actually R400. */
1935 {"RV515", CARD_AMD_RADEON_X700},
1937 {"R481", CARD_AMD_RADEON_X700},
1938 {"R480", CARD_AMD_RADEON_X700},
1939 {"R430", CARD_AMD_RADEON_X700},
1940 {"R423", CARD_AMD_RADEON_X700},
1941 {"R420", CARD_AMD_RADEON_X700},
1942 {"R410", CARD_AMD_RADEON_X700},
1943 {"RV410", CARD_AMD_RADEON_X700},
1944 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
1945 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
1946 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
1947 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
1948 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
1949 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
1950 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
1951 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
1953 {"R360", CARD_AMD_RADEON_9500},
1954 {"R350", CARD_AMD_RADEON_9500},
1955 {"R300", CARD_AMD_RADEON_9500},
1956 {"RV370", CARD_AMD_RADEON_9500},
1957 {"RV360", CARD_AMD_RADEON_9500},
1958 {"RV351", CARD_AMD_RADEON_9500},
1959 {"RV350", CARD_AMD_RADEON_9500},
1962 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
1964 if (strstr(gl_renderer, cards[i].renderer))
1967 return PCI_DEVICE_NONE;
1970 d3d_level = d3d_level_from_gl_info(gl_info);
1975 const char *renderer;
1976 enum wined3d_pci_device id;
1981 {"(R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
1982 {"(RV790", CARD_AMD_RADEON_HD4800},
1983 {"(RV770", CARD_AMD_RADEON_HD4800},
1984 {"(RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
1985 {"(RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
1986 {"(RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
1987 /* R600/R700 integrated */
1988 {"RS880", CARD_AMD_RADEON_HD3200},
1989 {"RS780", CARD_AMD_RADEON_HD3200},
1991 {"(R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1992 {"(R600", CARD_AMD_RADEON_HD2900},
1993 {"(RV670", CARD_AMD_RADEON_HD2900},
1994 {"(RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
1995 {"(RV630", CARD_AMD_RADEON_HD2600},
1996 {"(RV620", CARD_AMD_RADEON_HD2350}, /* HD2300/HD2400/HD3400 - lowend */
1997 {"(RV610", CARD_AMD_RADEON_HD2350},
2000 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2002 if (strstr(gl_renderer, cards[i].renderer))
2006 return PCI_DEVICE_NONE;
2009 static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
2010 const char *gl_renderer)
2016 const char *renderer;
2017 enum wined3d_pci_device id;
2022 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680},
2024 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
2025 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2026 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2027 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2028 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2029 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2030 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2031 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2033 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2034 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2035 {"NVAA", CARD_NVIDIA_GEFORCE_8200},
2036 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2037 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2038 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2039 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2040 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2041 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2042 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2043 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2044 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2045 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2046 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2048 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2049 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2050 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2051 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2052 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2053 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2054 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2055 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2056 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2057 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2058 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2059 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2060 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2061 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2062 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2063 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2065 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2066 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2067 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2068 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2069 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2070 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2072 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2073 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2074 {"nv20", CARD_NVIDIA_GEFORCE3},
2076 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2077 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2078 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2079 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2080 {"nv16", CARD_NVIDIA_GEFORCE2},
2081 {"nv15", CARD_NVIDIA_GEFORCE2},
2082 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2083 {"nv10", CARD_NVIDIA_GEFORCE},
2085 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2086 {"nv04", CARD_NVIDIA_RIVA_TNT},
2087 {"nv03", CARD_NVIDIA_RIVA_128},
2090 for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
2092 if (strstr(gl_renderer, cards[i].renderer))
2095 return PCI_DEVICE_NONE;
2098 static const struct gl_vendor_selection
2100 enum wined3d_gl_vendor gl_vendor;
2101 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2102 enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer);
2104 nvidia_gl_vendor_table[] =
2106 {GL_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
2107 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
2108 {GL_VENDOR_MESA, "Mesa Nouveau driver", select_card_nvidia_mesa},
2110 amd_gl_vendor_table[] =
2112 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", select_card_amd_binary},
2113 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", select_card_amd_binary},
2114 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", select_card_amd_mesa},
2116 intel_gl_vendor_table[] =
2118 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", select_card_intel},
2119 {GL_VENDOR_INTEL, "Mesa Intel driver", select_card_intel},
2120 {GL_VENDOR_MESA, "Mesa Intel driver", select_card_intel},
2123 static enum wined3d_pci_device select_card_fallback_nvidia(const struct wined3d_gl_info *gl_info)
2125 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2126 if (d3d_level >= 10)
2127 return CARD_NVIDIA_GEFORCE_8800GTX;
2128 if (d3d_level >= 9 && gl_info->supported[NV_VERTEX_PROGRAM3])
2129 return CARD_NVIDIA_GEFORCE_6800;
2131 return CARD_NVIDIA_GEFORCEFX_5800;
2133 return CARD_NVIDIA_GEFORCE3;
2135 return CARD_NVIDIA_GEFORCE;
2137 return CARD_NVIDIA_RIVA_TNT;
2138 return CARD_NVIDIA_RIVA_128;
2141 static enum wined3d_pci_device select_card_fallback_amd(const struct wined3d_gl_info *gl_info)
2143 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2144 if (d3d_level >= 10)
2145 return CARD_AMD_RADEON_HD2900;
2147 return CARD_AMD_RADEON_9500;
2149 return CARD_AMD_RADEON_8500;
2151 return CARD_AMD_RADEON_7200;
2152 return CARD_AMD_RAGE_128PRO;
2155 static enum wined3d_pci_device select_card_fallback_intel(const struct wined3d_gl_info *gl_info)
2157 UINT d3d_level = d3d_level_from_gl_info(gl_info);
2158 if (d3d_level >= 10)
2159 return CARD_INTEL_G45;
2160 return CARD_INTEL_915G;
2163 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2164 unsigned int table_size, enum wined3d_gl_vendor gl_vendor,
2165 const struct wined3d_gl_info *gl_info, const char *gl_renderer)
2169 for (i = 0; i < table_size; ++i)
2171 if (table[i].gl_vendor != gl_vendor)
2174 TRACE("Applying card selector \"%s\".\n", table[i].description);
2175 return table[i].select_card(gl_info, gl_renderer);
2177 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2178 gl_vendor, debugstr_a(gl_renderer));
2180 return PCI_DEVICE_NONE;
2185 enum wined3d_pci_vendor card_vendor;
2186 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2187 const struct gl_vendor_selection *gl_vendor_selection;
2188 unsigned int gl_vendor_count;
2189 enum wined3d_pci_device (*select_card_fallback)(const struct wined3d_gl_info *gl_info);
2191 card_vendor_table[] =
2193 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2194 sizeof(nvidia_gl_vendor_table) / sizeof(nvidia_gl_vendor_table[0]),
2195 select_card_fallback_nvidia},
2196 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2197 sizeof(amd_gl_vendor_table) / sizeof(amd_gl_vendor_table[0]),
2198 select_card_fallback_amd},
2199 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2200 sizeof(intel_gl_vendor_table) / sizeof(intel_gl_vendor_table[0]),
2201 select_card_fallback_intel},
2205 static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
2206 enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2208 /* A Direct3D device object contains the PCI id (vendor + device) of the
2209 * videocard which is used for rendering. Various applications use this
2210 * information to get a rough estimation of the features of the card and
2211 * some might use it for enabling 3d effects only on certain types of
2212 * videocards. In some cases games might even use it to work around bugs
2213 * which happen on certain videocards/driver combinations. The problem is
2214 * that OpenGL only exposes a rendering string containing the name of the
2215 * videocard and not the PCI id.
2217 * Various games depend on the PCI id, so somehow we need to provide one.
2218 * A simple option is to parse the renderer string and translate this to
2219 * the right PCI id. This is a lot of work because there are more than 200
2220 * GPUs just for Nvidia. Various cards share the same renderer string, so
2221 * the amount of code might be 'small' but there are quite a number of
2222 * exceptions which would make this a pain to maintain. Another way would
2223 * be to query the PCI id from the operating system (assuming this is the
2224 * videocard which is used for rendering which is not always the case).
2225 * This would work but it is not very portable. Second it would not work
2226 * well in, let's say, a remote X situation in which the amount of 3d
2227 * features which can be used is limited.
2229 * As said most games only use the PCI id to get an indication of the
2230 * capabilities of the card. It doesn't really matter if the given id is
2231 * the correct one if we return the id of a card with similar 3d features.
2233 * The code below checks the OpenGL capabilities of a videocard and matches
2234 * that to a certain level of Direct3D functionality. Once a card passes
2235 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2236 * least a GeforceFX. To give a better estimate we do a basic check on the
2237 * renderer string but if that won't pass we return a default card. This
2238 * way is better than maintaining a full card database as even without a
2239 * full database we can return a card with similar features. Second the
2240 * size of the database can be made quite small because when you know what
2241 * type of 3d functionality a card has, you know to which GPU family the
2242 * GPU must belong. Because of this you only have to check a small part of
2243 * the renderer string to distinguishes between different models from that
2246 * The code also selects a default amount of video memory which we will
2247 * use for an estimation of the amount of free texture memory. In case of
2248 * real D3D the amount of texture memory includes video memory and system
2249 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2250 * HyperMemory). We don't know how much system memory can be addressed by
2251 * the system but we can make a reasonable estimation about the amount of
2252 * video memory. If the value is slightly wrong it doesn't matter as we
2253 * didn't include AGP-like memory which makes the amount of addressable
2254 * memory higher and second OpenGL isn't that critical it moves to system
2255 * memory behind our backs if really needed. Note that the amount of video
2256 * memory can be overruled using a registry setting. */
2259 enum wined3d_pci_device device;
2261 for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
2263 if (card_vendor_table[i].card_vendor != *card_vendor)
2266 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2267 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2268 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_info, gl_renderer);
2269 if (device != PCI_DEVICE_NONE)
2272 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2273 return card_vendor_table[i].select_card_fallback(gl_info);
2276 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2277 *card_vendor, debugstr_a(gl_renderer));
2279 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2280 *card_vendor = HW_VENDOR_NVIDIA;
2281 return select_card_fallback_nvidia(gl_info);
2284 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info)
2286 int vs_selected_mode, ps_selected_mode;
2288 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2289 if (ps_selected_mode == SHADER_GLSL)
2290 return &glsl_fragment_pipe;
2291 if (ps_selected_mode == SHADER_ARB)
2292 return &arbfp_fragment_pipeline;
2293 if (ps_selected_mode == SHADER_ATI)
2294 return &atifs_fragment_pipeline;
2295 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2296 return &nvts_fragment_pipeline;
2297 if (gl_info->supported[NV_REGISTER_COMBINERS])
2298 return &nvrc_fragment_pipeline;
2299 return &ffp_fragment_pipeline;
2302 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2304 int vs_selected_mode, ps_selected_mode;
2306 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2307 if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
2308 if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
2309 return &none_shader_backend;
2312 static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info)
2314 int vs_selected_mode, ps_selected_mode;
2316 select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
2317 if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
2318 && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
2319 else return &ffp_blit;
2322 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2323 const struct wined3d_extension_map *map, UINT entry_count)
2331 while (isspace(*extensions))
2334 while (!isspace(*extensions) && *extensions)
2337 len = extensions - start;
2341 TRACE("- %s.\n", debugstr_an(start, len));
2343 for (i = 0; i < entry_count; ++i)
2345 if (len == strlen(map[i].extension_string)
2346 && !memcmp(start, map[i].extension_string, len))
2348 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2349 gl_info->supported[map[i].extension] = TRUE;
2356 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2358 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2362 #ifndef USE_WIN32_OPENGL
2363 /* hack: use the functions directly from the TEB table to bypass the thunks */
2364 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2365 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
2369 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
2371 GLfloat gl_floatv[2];
2374 gl_info->limits.blends = 1;
2375 gl_info->limits.buffers = 1;
2376 gl_info->limits.textures = 1;
2377 gl_info->limits.texture_coords = 1;
2378 gl_info->limits.fragment_samplers = 1;
2379 gl_info->limits.vertex_samplers = 0;
2380 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
2381 gl_info->limits.vertex_attribs = 16;
2382 gl_info->limits.glsl_vs_float_constants = 0;
2383 gl_info->limits.glsl_ps_float_constants = 0;
2384 gl_info->limits.arb_vs_float_constants = 0;
2385 gl_info->limits.arb_vs_native_constants = 0;
2386 gl_info->limits.arb_vs_instructions = 0;
2387 gl_info->limits.arb_vs_temps = 0;
2388 gl_info->limits.arb_ps_float_constants = 0;
2389 gl_info->limits.arb_ps_local_constants = 0;
2390 gl_info->limits.arb_ps_instructions = 0;
2391 gl_info->limits.arb_ps_temps = 0;
2393 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
2394 gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
2395 TRACE("Clip plane support - max planes %d.\n", gl_max);
2397 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
2398 gl_info->limits.lights = gl_max;
2399 TRACE("Light support - max lights %d.\n", gl_max);
2401 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
2402 gl_info->limits.texture_size = gl_max;
2403 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
2405 gl_info->gl_ops.gl.p_glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
2406 gl_info->limits.pointsize_min = gl_floatv[0];
2407 gl_info->limits.pointsize_max = gl_floatv[1];
2408 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
2410 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
2412 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
2413 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
2417 WARN("Driver doesn't guarantee a minimum buffer map alignment.\n");
2419 if (gl_info->supported[NV_REGISTER_COMBINERS])
2421 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
2422 gl_info->limits.general_combiners = gl_max;
2423 TRACE("Max general combiners: %d.\n", gl_max);
2425 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2427 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
2428 gl_info->limits.buffers = gl_max;
2429 TRACE("Max draw buffers: %u.\n", gl_max);
2431 if (gl_info->supported[ARB_MULTITEXTURE])
2433 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
2434 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
2435 TRACE("Max textures: %d.\n", gl_info->limits.textures);
2437 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2440 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
2441 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
2442 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2443 gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
2447 gl_info->limits.texture_coords = max(gl_info->limits.texture_coords, gl_max);
2448 gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, gl_max);
2450 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
2451 TRACE("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
2453 if (gl_info->supported[ARB_VERTEX_SHADER])
2456 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2457 gl_info->limits.vertex_samplers = tmp;
2458 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp);
2459 gl_info->limits.combined_samplers = tmp;
2460 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &tmp);
2461 gl_info->limits.vertex_attribs = tmp;
2463 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
2464 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
2465 * an issue because then the sampler setup only depends on the two shaders. If a pixel
2466 * shader is used with fixed function vertex processing we're fine too because fixed function
2467 * vertex processing doesn't use any samplers. If fixed function fragment processing is
2468 * used we have to make sure that all vertex sampler setups are valid together with all
2469 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
2470 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
2471 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
2472 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
2473 * a fixed function pipeline anymore.
2475 * So this is just a check to check that our assumption holds true. If not, write a warning
2476 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
2477 if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
2478 && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
2480 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2481 gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
2482 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2483 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
2484 gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
2486 gl_info->limits.vertex_samplers = 0;
2491 gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
2493 TRACE("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
2494 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
2496 if (gl_info->supported[ARB_VERTEX_BLEND])
2498 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
2499 gl_info->limits.blends = gl_max;
2500 TRACE("Max blends: %u.\n", gl_info->limits.blends);
2502 if (gl_info->supported[EXT_TEXTURE3D])
2504 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
2505 gl_info->limits.texture3d_size = gl_max;
2506 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
2508 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
2510 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
2511 gl_info->limits.anisotropy = gl_max;
2512 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
2514 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2516 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2517 gl_info->limits.arb_ps_float_constants = gl_max;
2518 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
2519 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2520 gl_info->limits.arb_ps_native_constants = gl_max;
2521 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
2522 gl_info->limits.arb_ps_native_constants);
2523 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2524 gl_info->limits.arb_ps_temps = gl_max;
2525 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
2526 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2527 gl_info->limits.arb_ps_instructions = gl_max;
2528 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
2529 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
2530 gl_info->limits.arb_ps_local_constants = gl_max;
2531 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
2533 if (gl_info->supported[ARB_VERTEX_PROGRAM])
2535 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
2536 gl_info->limits.arb_vs_float_constants = gl_max;
2537 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
2538 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
2539 gl_info->limits.arb_vs_native_constants = gl_max;
2540 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
2541 gl_info->limits.arb_vs_native_constants);
2542 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
2543 gl_info->limits.arb_vs_temps = gl_max;
2544 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
2545 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
2546 gl_info->limits.arb_vs_instructions = gl_max;
2547 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
2549 if (gl_info->supported[ARB_VERTEX_SHADER])
2551 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
2552 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
2553 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
2555 if (gl_info->supported[ARB_FRAGMENT_SHADER])
2557 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
2558 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
2559 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
2560 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
2561 gl_info->limits.glsl_varyings = gl_max;
2562 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
2565 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
2566 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
2568 gl_info->limits.shininess = 128.0f;
2570 if ((gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2571 && wined3d_settings.allow_multisampling)
2573 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
2574 gl_info->limits.samples = gl_max;
2578 /* Context activation is done by the caller. */
2579 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
2581 struct wined3d_driver_info *driver_info = &adapter->driver_info;
2582 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
2583 struct wined3d_gl_info *gl_info = &adapter->gl_info;
2584 enum wined3d_pci_vendor card_vendor;
2585 struct fragment_caps fragment_caps;
2586 const char *WGL_Extensions = NULL;
2587 const char *GL_Extensions = NULL;
2588 enum wined3d_gl_vendor gl_vendor;
2589 enum wined3d_pci_device device;
2593 TRACE("adapter %p.\n", adapter);
2595 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
2596 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
2597 if (!gl_renderer_str)
2599 ERR("Received a NULL GL_RENDERER.\n");
2603 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
2604 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
2607 ERR("Received a NULL GL_VENDOR.\n");
2611 /* Parse the GL_VERSION field into major and minor information */
2612 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
2613 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
2614 if (!gl_version_str)
2616 ERR("Received a NULL GL_VERSION.\n");
2619 gl_version = wined3d_parse_gl_version(gl_version_str);
2621 /* Parse the gl supported features, in theory enabling parts of our code appropriately. */
2622 GL_Extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
2625 ERR("Received a NULL GL_EXTENSIONS.\n");
2629 memset(gl_info->supported, 0, sizeof(gl_info->supported));
2630 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
2632 TRACE("GL extensions reported:\n");
2633 parse_extension_string(gl_info, GL_Extensions, gl_extension_map,
2634 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
2636 /* Now work out what GL support this card really has. */
2637 load_gl_funcs( gl_info );
2639 hdc = wglGetCurrentDC();
2640 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
2641 if (GL_EXTCALL(wglGetExtensionsStringARB))
2642 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
2643 if (!WGL_Extensions)
2644 WARN("WGL extensions not supported.\n");
2646 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
2647 sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
2649 if (!gl_info->supported[EXT_TEXTURE3D] && gl_version >= MAKEDWORD_VERSION(1, 2))
2651 TRACE("GL CORE: GL_EXT_texture3D support.\n");
2652 gl_info->gl_ops.ext.p_glTexImage3DEXT = (void *)gl_info->gl_ops.ext.p_glTexImage3D;
2653 gl_info->gl_ops.ext.p_glTexSubImage3DEXT = gl_info->gl_ops.ext.p_glTexSubImage3D;
2654 gl_info->supported[EXT_TEXTURE3D] = TRUE;
2657 if (!gl_info->supported[NV_POINT_SPRITE] && gl_version >= MAKEDWORD_VERSION(1, 4))
2659 TRACE("GL CORE: GL_NV_point_sprite support.\n");
2660 gl_info->gl_ops.ext.p_glPointParameterivNV = gl_info->gl_ops.ext.p_glPointParameteriv;
2661 gl_info->gl_ops.ext.p_glPointParameteriNV = gl_info->gl_ops.ext.p_glPointParameteri;
2662 gl_info->supported[NV_POINT_SPRITE] = TRUE;
2665 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && gl_version >= MAKEDWORD_VERSION(2, 0))
2667 TRACE("GL CORE: GL_ARB_texture_non_power_of_two support.\n");
2668 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = TRUE;
2671 if (gl_version >= MAKEDWORD_VERSION(2, 0)) gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
2673 if (gl_info->supported[APPLE_FENCE])
2675 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
2676 * The apple extension interacts with some other apple exts. Disable the NV
2677 * extension if the apple one is support to prevent confusion in other parts
2679 gl_info->supported[NV_FENCE] = FALSE;
2681 if (gl_info->supported[APPLE_FLOAT_PIXELS])
2683 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
2685 * The enums are the same:
2686 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
2687 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
2688 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
2689 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
2690 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
2692 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
2694 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
2695 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
2697 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
2699 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
2700 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
2703 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
2705 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
2706 * functionality. Prefer the ARB extension */
2707 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
2709 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
2711 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
2712 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
2714 if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
2716 TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
2717 gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
2719 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
2721 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
2722 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
2724 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
2726 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
2727 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
2729 if (gl_info->supported[NV_TEXTURE_SHADER2])
2731 if (gl_info->supported[NV_REGISTER_COMBINERS])
2733 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
2734 * are supported. The nv extensions provide the same functionality as the
2735 * ATI one, and a bit more(signed pixelformats). */
2736 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
2739 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
2741 /* If we have full NP2 texture support, disable
2742 * GL_ARB_texture_rectangle because we will never use it.
2743 * This saves a few redundant glDisable calls. */
2744 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
2746 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2748 /* Disable NV_register_combiners and fragment shader if this is supported.
2749 * generally the NV extensions are preferred over the ATI ones, and this
2750 * extension is disabled if register_combiners and texture_shader2 are both
2751 * supported. So we reach this place only if we have incomplete NV dxlevel 8
2752 * fragment processing support. */
2753 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
2754 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
2755 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
2756 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
2758 if (gl_info->supported[NV_HALF_FLOAT])
2760 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
2761 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
2763 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
2765 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
2766 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
2767 * we never render to sRGB surfaces). */
2768 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
2771 wined3d_adapter_init_limits(gl_info);
2773 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
2774 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
2776 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
2778 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
2779 unsigned int major, minor;
2781 TRACE("GLSL version string: %s.\n", debugstr_a(str));
2783 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
2784 sscanf(str, "%u.%u", &major, &minor);
2785 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
2788 checkGLcall("extension detection");
2790 adapter->fragment_pipe = select_fragment_implementation(gl_info);
2791 adapter->shader_backend = select_shader_backend(gl_info);
2792 adapter->blitter = select_blit_implementation(gl_info);
2794 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
2795 gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
2796 TRACE("Max texture stages: %u.\n", gl_info->limits.texture_stages);
2798 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
2800 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
2801 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
2802 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
2803 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
2804 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
2805 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
2806 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
2807 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
2808 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
2809 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
2810 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
2811 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
2812 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
2813 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
2814 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
2815 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
2816 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
2817 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
2818 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
2819 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
2823 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
2825 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
2826 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
2827 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
2828 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
2829 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
2830 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
2831 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
2832 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
2833 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
2834 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
2835 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
2836 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
2837 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
2838 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
2839 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
2840 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
2841 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
2842 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
2844 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2846 WARN("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
2847 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
2849 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
2851 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
2853 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
2855 gl_info->fbo_ops.glRenderbufferStorageMultisample
2856 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
2860 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
2861 card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
2862 TRACE("Found GL_VENDOR (%s)->(0x%04x/0x%04x).\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
2864 device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor);
2865 TRACE("Found (fake) card: 0x%x (vendor id), 0x%x (device id).\n", card_vendor, device);
2867 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
2868 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
2869 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
2870 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
2871 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
2872 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
2873 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
2874 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
2876 fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
2877 init_driver_info(driver_info, card_vendor, device);
2878 add_gl_compat_wrappers(gl_info);
2883 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
2885 TRACE("wined3d %p, reporting %u adapters.\n",
2886 wined3d, wined3d->adapter_count);
2888 return wined3d->adapter_count;
2891 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
2893 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
2898 HMONITOR CDECL wined3d_get_adapter_monitor(const struct wined3d *wined3d, UINT adapter_idx)
2900 TRACE("wined3d %p, adapter_idx %u.\n", wined3d, adapter_idx);
2902 if (adapter_idx >= wined3d->adapter_count)
2905 return MonitorFromPoint(wined3d->adapters[adapter_idx].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
2908 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
2909 of the same bpp but different resolutions */
2911 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2912 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
2913 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
2915 const struct wined3d_adapter *adapter;
2916 const struct wined3d_format *format;
2922 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
2923 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
2925 if (adapter_idx >= wined3d->adapter_count)
2928 adapter = &wined3d->adapters[adapter_idx];
2929 format = wined3d_get_format(&adapter->gl_info, format_id);
2930 format_bits = format->byte_count * CHAR_BIT;
2932 memset(&mode, 0, sizeof(mode));
2933 mode.dmSize = sizeof(mode);
2935 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
2937 if (mode.dmFields & DM_DISPLAYFLAGS)
2939 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
2940 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
2943 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
2944 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
2948 if (format_id == WINED3DFMT_UNKNOWN)
2950 /* This is for d3d8, do not enumerate P8 here. */
2951 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
2953 else if (mode.dmBitsPerPel == format_bits)
2959 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
2964 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
2965 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
2966 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
2967 UINT mode_idx, struct wined3d_display_mode *mode)
2969 const struct wined3d_adapter *adapter;
2970 const struct wined3d_format *format;
2976 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
2977 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
2979 if (!mode || adapter_idx >= wined3d->adapter_count)
2980 return WINED3DERR_INVALIDCALL;
2982 adapter = &wined3d->adapters[adapter_idx];
2983 format = wined3d_get_format(&adapter->gl_info, format_id);
2984 format_bits = format->byte_count * CHAR_BIT;
2986 memset(&m, 0, sizeof(m));
2987 m.dmSize = sizeof(m);
2989 while (i <= mode_idx)
2991 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
2993 WARN("Invalid mode_idx %u.\n", mode_idx);
2994 return WINED3DERR_INVALIDCALL;
2997 if (m.dmFields & DM_DISPLAYFLAGS)
2999 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
3000 && (m.u2.dmDisplayFlags & DM_INTERLACED))
3003 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
3004 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
3008 if (format_id == WINED3DFMT_UNKNOWN)
3010 /* This is for d3d8, do not enumerate P8 here. */
3011 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
3013 else if (m.dmBitsPerPel == format_bits)
3019 mode->width = m.dmPelsWidth;
3020 mode->height = m.dmPelsHeight;
3021 mode->refresh_rate = DEFAULT_REFRESH_RATE;
3022 if (m.dmFields & DM_DISPLAYFREQUENCY)
3023 mode->refresh_rate = m.dmDisplayFrequency;
3025 if (format_id == WINED3DFMT_UNKNOWN)
3026 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
3028 mode->format_id = format_id;
3030 if (!(m.dmFields & DM_DISPLAYFLAGS))
3031 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
3032 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
3033 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
3035 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
3037 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
3038 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
3043 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
3044 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
3046 const struct wined3d_adapter *adapter;
3049 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
3050 wined3d, adapter_idx, mode, rotation);
3052 if (!mode || adapter_idx >= wined3d->adapter_count)
3053 return WINED3DERR_INVALIDCALL;
3055 adapter = &wined3d->adapters[adapter_idx];
3057 memset(&m, 0, sizeof(m));
3058 m.dmSize = sizeof(m);
3060 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
3061 mode->width = m.dmPelsWidth;
3062 mode->height = m.dmPelsHeight;
3063 mode->refresh_rate = DEFAULT_REFRESH_RATE;
3064 if (m.dmFields & DM_DISPLAYFREQUENCY)
3065 mode->refresh_rate = m.dmDisplayFrequency;
3066 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
3068 /* Lie about the format. X11 can't change the color depth, and some apps
3069 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
3070 * that GetDisplayMode still returns 24 bpp. This should probably be
3071 * handled in winex11 instead. */
3072 if (adapter->screen_format && adapter->screen_format != mode->format_id)
3074 WARN("Overriding format %s with stored format %s.\n",
3075 debug_d3dformat(mode->format_id),
3076 debug_d3dformat(adapter->screen_format));
3077 mode->format_id = adapter->screen_format;
3080 if (!(m.dmFields & DM_DISPLAYFLAGS))
3081 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
3082 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
3083 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
3085 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
3089 switch (m.u1.s2.dmDisplayOrientation)
3092 *rotation = WINED3D_DISPLAY_ROTATION_0;
3095 *rotation = WINED3D_DISPLAY_ROTATION_90;
3098 *rotation = WINED3D_DISPLAY_ROTATION_180;
3101 *rotation = WINED3D_DISPLAY_ROTATION_270;
3104 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
3105 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
3110 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
3111 mode->refresh_rate, debug_d3dformat(mode->format_id),
3112 mode->scanline_ordering);
3116 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
3117 UINT adapter_idx, const struct wined3d_display_mode *mode)
3119 struct wined3d_display_mode current_mode;
3120 const struct wined3d_format *format;
3121 struct wined3d_adapter *adapter;
3127 TRACE("wined3d %p, adapter_idx %u, mode %p (%ux%u@%u %s %#x).\n", wined3d, adapter_idx, mode,
3128 mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id),
3129 mode->scanline_ordering);
3131 if (adapter_idx >= wined3d->adapter_count)
3132 return WINED3DERR_INVALIDCALL;
3134 adapter = &wined3d->adapters[adapter_idx];
3135 format = wined3d_get_format(&adapter->gl_info, mode->format_id);
3137 memset(&devmode, 0, sizeof(devmode));
3138 devmode.dmSize = sizeof(devmode);
3139 devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
3140 devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
3141 devmode.dmPelsWidth = mode->width;
3142 devmode.dmPelsHeight = mode->height;
3144 devmode.dmDisplayFrequency = mode->refresh_rate;
3145 if (mode->refresh_rate)
3146 devmode.dmFields |= DM_DISPLAYFREQUENCY;
3148 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
3150 devmode.dmFields |= DM_DISPLAYFLAGS;
3151 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
3152 devmode.u2.dmDisplayFlags |= DM_INTERLACED;
3155 /* Only change the mode if necessary. */
3156 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, ¤t_mode, NULL)))
3158 ERR("Failed to get current display mode, hr %#x.\n", hr);
3160 else if (current_mode.width == mode->width
3161 && current_mode.height == mode->height
3162 && current_mode.format_id == mode->format_id
3163 && (current_mode.refresh_rate == mode->refresh_rate
3164 || !mode->refresh_rate)
3165 && (current_mode.scanline_ordering == mode->scanline_ordering
3166 || mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_UNKNOWN))
3168 TRACE("Skipping redundant mode setting call.\n");
3172 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
3173 if (ret != DISP_CHANGE_SUCCESSFUL)
3175 if (devmode.dmDisplayFrequency)
3177 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
3178 devmode.dmFields &= ~DM_DISPLAYFREQUENCY;
3179 devmode.dmDisplayFrequency = 0;
3180 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
3182 if (ret != DISP_CHANGE_SUCCESSFUL)
3183 return WINED3DERR_NOTAVAILABLE;
3186 /* Store the new values. */
3187 adapter->screen_format = mode->format_id;
3189 /* And finally clip mouse to our screen. */
3190 SetRect(&clip_rc, 0, 0, mode->width, mode->height);
3191 ClipCursor(&clip_rc);
3196 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
3197 and fields being inserted in the middle, a new structure is used in place */
3198 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
3199 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
3201 const struct wined3d_adapter *adapter;
3204 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
3205 wined3d, adapter_idx, flags, identifier);
3207 if (adapter_idx >= wined3d->adapter_count)
3208 return WINED3DERR_INVALIDCALL;
3210 adapter = &wined3d->adapters[adapter_idx];
3212 if (identifier->driver_size)
3214 const char *name = adapter->driver_info.name;
3215 len = min(strlen(name), identifier->driver_size - 1);
3216 memcpy(identifier->driver, name, len);
3217 identifier->driver[len] = '\0';
3220 if (identifier->description_size)
3222 const char *description = adapter->driver_info.description;
3223 len = min(strlen(description), identifier->description_size - 1);
3224 memcpy(identifier->description, description, len);
3225 identifier->description[len] = '\0';
3228 /* Note that d3d8 doesn't supply a device name. */
3229 if (identifier->device_name_size)
3231 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
3232 identifier->device_name_size, NULL, NULL))
3234 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
3235 return WINED3DERR_INVALIDCALL;
3239 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
3240 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
3241 identifier->vendor_id = adapter->driver_info.vendor;
3242 identifier->device_id = adapter->driver_info.device;
3243 identifier->subsystem_id = 0;
3244 identifier->revision = 0;
3245 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
3246 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
3247 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
3248 identifier->video_memory = adapter->TextureRam;
3253 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
3254 struct wined3d_raster_status *raster_status)
3256 LONGLONG freq_per_frame, freq_per_line;
3257 LARGE_INTEGER counter, freq_per_sec;
3258 struct wined3d_display_mode mode;
3262 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3263 wined3d, adapter_idx, raster_status);
3265 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
3266 wined3d, adapter_idx, raster_status);
3268 /* Obtaining the raster status is a widely implemented but optional
3269 * feature. When this method returns OK StarCraft 2 expects the
3270 * raster_status->InVBlank value to actually change over time.
3271 * And Endless Alice Crysis doesn't care even if this method fails.
3272 * Thus this method returns OK and fakes raster_status by
3273 * QueryPerformanceCounter. */
3275 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
3276 return WINED3DERR_INVALIDCALL;
3277 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
3278 return WINED3DERR_INVALIDCALL;
3279 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
3280 mode.refresh_rate = 60;
3282 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
3283 /* Assume 20 scan lines in the vertical blank. */
3284 freq_per_line = freq_per_frame / (mode.height + 20);
3285 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
3286 if (raster_status->scan_line < mode.height)
3287 raster_status->in_vblank = FALSE;
3290 raster_status->scan_line = 0;
3291 raster_status->in_vblank = TRUE;
3294 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
3295 raster_status->in_vblank, raster_status->scan_line);
3300 static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
3301 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
3303 BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
3305 /* Float formats need FBOs. If FBOs are used this function isn't called */
3306 if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
3308 if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
3309 if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
3311 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
3315 if(cfg->redSize < redSize)
3318 if(cfg->greenSize < greenSize)
3321 if(cfg->blueSize < blueSize)
3324 if(cfg->alphaSize < alphaSize)
3330 /* Probably a RGBA_float or color index mode */
3334 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
3335 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
3337 BYTE depthSize, stencilSize;
3338 BOOL lockable = FALSE;
3340 if (!getDepthStencilBits(format, &depthSize, &stencilSize))
3342 ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
3346 /* Float formats need FBOs. If FBOs are used this function isn't called */
3347 if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
3349 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
3352 /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports.
3353 * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with
3354 * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */
3355 if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize)))
3358 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so
3359 * allow more stencil bits than requested. */
3360 if(cfg->stencilSize < stencilSize)
3366 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
3367 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
3368 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
3370 const struct wined3d_format *rt_format;
3371 const struct wined3d_format *ds_format;
3372 const struct wined3d_adapter *adapter;
3374 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
3375 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
3376 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
3377 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
3379 if (adapter_idx >= wined3d->adapter_count)
3380 return WINED3DERR_INVALIDCALL;
3382 adapter = &wined3d->adapters[adapter_idx];
3383 rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id);
3384 ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id);
3385 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3387 if ((rt_format->flags & WINED3DFMT_FLAG_RENDERTARGET)
3388 && (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
3390 TRACE("Formats match.\n");
3396 const struct wined3d_pixel_format *cfgs;
3397 unsigned int cfg_count;
3400 cfgs = adapter->cfgs;
3401 cfg_count = adapter->cfg_count;
3402 for (i = 0; i < cfg_count; ++i)
3404 if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
3405 && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
3407 TRACE("Formats match.\n");
3413 TRACE("Unsupported format pair: %s and %s.\n",
3414 debug_d3dformat(render_target_format_id),
3415 debug_d3dformat(depth_stencil_format_id));
3417 return WINED3DERR_NOTAVAILABLE;
3420 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
3421 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
3422 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
3424 const struct wined3d_gl_info *gl_info;
3426 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
3427 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
3428 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
3429 windowed, multisample_type, quality_levels);
3431 if (adapter_idx >= wined3d->adapter_count)
3432 return WINED3DERR_INVALIDCALL;
3434 gl_info = &wined3d->adapters[adapter_idx].gl_info;
3436 if (multisample_type > gl_info->limits.samples)
3438 TRACE("Returning not supported.\n");
3440 *quality_levels = 0;
3442 return WINED3DERR_NOTAVAILABLE;
3447 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
3448 /* FIXME: This is probably wrong. */
3449 *quality_levels = gl_info->limits.samples;
3451 *quality_levels = 1;
3457 /* Check if we support bumpmapping for a format */
3458 static BOOL CheckBumpMapCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3460 /* Ask the fixed function pipeline implementation if it can deal
3461 * with the conversion. If we've got a GL extension giving native
3462 * support this will be an identity conversion. */
3463 return (format->flags & WINED3DFMT_FLAG_BUMPMAP)
3464 && adapter->fragment_pipe->color_fixup_supported(format->color_fixup);
3467 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
3468 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
3469 const struct wined3d_format *display_format, const struct wined3d_format *ds_format)
3471 /* Only allow depth/stencil formats */
3472 if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
3474 /* Blacklist formats not supported on Windows */
3475 switch (ds_format->id)
3477 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
3478 case WINED3DFMT_S4X4_UINT_D24_UNORM:
3479 TRACE("[FAILED] - not supported on windows.\n");
3486 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3488 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
3489 if (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
3495 /* Walk through all WGL pixel formats to find a match */
3496 for (i = 0; i < adapter->cfg_count; ++i)
3498 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
3499 if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
3500 && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
3508 static BOOL CheckFilterCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3510 /* The flags entry of a format contains the filtering capability */
3511 if ((format->flags & WINED3DFMT_FLAG_FILTERING)
3512 || !(adapter->gl_info.quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING))
3518 /* Check the render target capabilities of a format */
3519 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
3520 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format)
3522 /* Filter out non-RT formats */
3523 if (!(check_format->flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
3524 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
3526 BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
3527 BYTE CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
3528 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
3531 getColorBits(adapter_format, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
3532 getColorBits(check_format, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
3534 /* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
3535 * The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
3536 if (!((AdapterRed == CheckRed) && (AdapterGreen == CheckGreen) && (AdapterBlue == CheckBlue)))
3538 TRACE("[FAILED]\n");
3542 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
3543 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
3544 for (i = 0; i < adapter->cfg_count; ++i)
3546 if (cfgs[i].windowDrawable
3547 && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
3549 TRACE("Pixel format %d is compatible with format %s.\n",
3550 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
3555 else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3557 /* For now return TRUE for FBOs until we have some proper checks.
3558 * Note that this function will only be called when the format is around for texturing. */
3564 static BOOL CheckSrgbReadCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3566 return format->flags & WINED3DFMT_FLAG_SRGB_READ;
3569 static BOOL CheckSrgbWriteCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3571 /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
3572 * doing the color fixup in shaders.
3573 * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
3574 if (format->flags & WINED3DFMT_FLAG_SRGB_WRITE)
3576 int vs_selected_mode;
3577 int ps_selected_mode;
3578 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
3580 if ((ps_selected_mode == SHADER_ARB) || (ps_selected_mode == SHADER_GLSL))
3587 TRACE("[FAILED] - sRGB writes not supported by format %s.\n", debug_d3dformat(format->id));
3591 /* Check if a format support blending in combination with pixel shaders */
3592 static BOOL CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter *adapter,
3593 const struct wined3d_format *format)
3595 /* The flags entry of a format contains the post pixel shader blending capability */
3596 if (format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) return TRUE;
3601 static BOOL CheckWrapAndMipCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3603 /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
3604 * but we have to report mipmapping so we cannot reject this flag. Tests show that
3605 * windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to show
3606 * that wrapping is supported. The lack of filtering will sort out the mipmapping
3607 * capability anyway.
3609 * For now lets report this on all formats, but in the future we may want to
3610 * restrict it to some should games need that
3615 /* Check if a texture format is supported on the given adapter */
3616 static BOOL CheckTextureCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
3618 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3623 * supported: RGB(A) formats
3625 case WINED3DFMT_B8G8R8_UNORM:
3626 TRACE("[FAILED] - Not enumerated on Windows.\n");
3628 case WINED3DFMT_B8G8R8A8_UNORM:
3629 case WINED3DFMT_B8G8R8X8_UNORM:
3630 case WINED3DFMT_B5G6R5_UNORM:
3631 case WINED3DFMT_B5G5R5X1_UNORM:
3632 case WINED3DFMT_B5G5R5A1_UNORM:
3633 case WINED3DFMT_B4G4R4A4_UNORM:
3634 case WINED3DFMT_A8_UNORM:
3635 case WINED3DFMT_B4G4R4X4_UNORM:
3636 case WINED3DFMT_R8G8B8A8_UNORM:
3637 case WINED3DFMT_R8G8B8X8_UNORM:
3638 case WINED3DFMT_B10G10R10A2_UNORM:
3639 case WINED3DFMT_R10G10B10A2_UNORM:
3640 case WINED3DFMT_R16G16_UNORM:
3644 case WINED3DFMT_B2G3R3_UNORM:
3645 TRACE("[FAILED] - Not supported on Windows.\n");
3649 * Not supported: Palettized
3650 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
3651 * Since it is not widely available, don't offer it. Further no Windows driver offers
3652 * WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
3654 case WINED3DFMT_P8_UINT:
3655 case WINED3DFMT_P8_UINT_A8_UNORM:
3659 * Supported: (Alpha)-Luminance
3661 case WINED3DFMT_L8_UNORM:
3662 case WINED3DFMT_L8A8_UNORM:
3663 case WINED3DFMT_L16_UNORM:
3667 /* Not supported on Windows, thus disabled */
3668 case WINED3DFMT_L4A4_UNORM:
3669 TRACE("[FAILED] - not supported on windows\n");
3673 * Supported: Depth/Stencil formats
3675 case WINED3DFMT_D16_LOCKABLE:
3676 case WINED3DFMT_D16_UNORM:
3677 case WINED3DFMT_X8D24_UNORM:
3678 case WINED3DFMT_D24_UNORM_S8_UINT:
3679 case WINED3DFMT_S8_UINT_D24_FLOAT:
3680 case WINED3DFMT_D32_UNORM:
3681 case WINED3DFMT_D32_FLOAT:
3684 case WINED3DFMT_INTZ:
3685 if (gl_info->supported[EXT_PACKED_DEPTH_STENCIL]
3686 || gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3690 /* Not supported on Windows */
3691 case WINED3DFMT_S1_UINT_D15_UNORM:
3692 case WINED3DFMT_S4X4_UINT_D24_UNORM:
3693 TRACE("[FAILED] - not supported on windows\n");
3697 * Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
3698 * GL_NV_texture_shader). Emulated by shaders
3700 case WINED3DFMT_R8G8_SNORM:
3701 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
3702 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
3703 case WINED3DFMT_R8G8B8A8_SNORM:
3704 case WINED3DFMT_R16G16_SNORM:
3705 /* Ask the shader backend if it can deal with the conversion. If
3706 * we've got a GL extension giving native support this will be an
3707 * identity conversion. */
3708 if (adapter->shader_backend->shader_color_fixup_supported(format->color_fixup))
3713 TRACE("[FAILED]\n");
3716 case WINED3DFMT_DXT1:
3717 case WINED3DFMT_DXT2:
3718 case WINED3DFMT_DXT3:
3719 case WINED3DFMT_DXT4:
3720 case WINED3DFMT_DXT5:
3721 if (gl_info->supported[EXT_TEXTURE_COMPRESSION_S3TC])
3726 TRACE("[FAILED]\n");
3731 * Odd formats - not supported
3733 case WINED3DFMT_VERTEXDATA:
3734 case WINED3DFMT_R16_UINT:
3735 case WINED3DFMT_R32_UINT:
3736 case WINED3DFMT_R16G16B16A16_SNORM:
3737 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM:
3738 case WINED3DFMT_R10G11B11_SNORM:
3739 case WINED3DFMT_R16:
3740 case WINED3DFMT_AL16:
3741 TRACE("[FAILED]\n"); /* Enable when implemented */
3745 * WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
3747 case WINED3DFMT_R8G8_SNORM_Cx:
3748 TRACE("[FAILED]\n"); /* Enable when implemented */
3752 case WINED3DFMT_UYVY:
3753 case WINED3DFMT_YUY2:
3754 if (gl_info->supported[APPLE_YCBCR_422])
3759 TRACE("[FAILED]\n");
3761 case WINED3DFMT_YV12:
3762 TRACE("[FAILED]\n");
3765 case WINED3DFMT_R16G16B16A16_UNORM:
3766 if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
3768 TRACE("[FAILED]\n");
3775 case WINED3DFMT_B2G3R3A8_UNORM:
3776 TRACE("[FAILED]\n"); /* Enable when implemented */
3779 /* Floating point formats */
3780 case WINED3DFMT_R16_FLOAT:
3781 case WINED3DFMT_R16G16_FLOAT:
3782 case WINED3DFMT_R16G16B16A16_FLOAT:
3783 if (gl_info->supported[ARB_TEXTURE_FLOAT] && gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3788 TRACE("[FAILED]\n");
3791 case WINED3DFMT_R32_FLOAT:
3792 case WINED3DFMT_R32G32_FLOAT:
3793 case WINED3DFMT_R32G32B32A32_FLOAT:
3794 if (gl_info->supported[ARB_TEXTURE_FLOAT])
3799 TRACE("[FAILED]\n");
3802 /* ATI instancing hack: Although ATI cards do not support Shader Model 3.0, they support
3803 * instancing. To query if the card supports instancing CheckDeviceFormat with the special format
3804 * MAKEFOURCC('I','N','S','T') is used. Should a (broken) app check for this provide a proper return value.
3805 * We can do instancing with all shader versions, but we need vertex shaders.
3807 * Additionally applications have to set the D3DRS_POINTSIZE render state to MAKEFOURCC('I','N','S','T') once
3808 * to enable instancing. WineD3D doesn't need that and just ignores it.
3810 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows.
3812 case WINED3DFMT_INST:
3813 TRACE("ATI Instancing check hack\n");
3814 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
3819 TRACE("[FAILED]\n");
3822 /* Some weird FOURCC formats */
3823 case WINED3DFMT_R8G8_B8G8:
3824 case WINED3DFMT_G8R8_G8B8:
3825 case WINED3DFMT_MULTI2_ARGB8:
3826 TRACE("[FAILED]\n");
3829 /* Vendor specific formats */
3830 case WINED3DFMT_ATI2N:
3831 if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC]
3832 || gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
3834 if (adapter->shader_backend->shader_color_fixup_supported(format->color_fixup)
3835 && adapter->fragment_pipe->color_fixup_supported(format->color_fixup))
3841 TRACE("[FAILED]\n");
3844 /* Depth bound test. To query if the card supports it CheckDeviceFormat with the special
3845 * format MAKEFOURCC('N','V','D','B') is used.
3846 * It is enabled by setting D3DRS_ADAPTIVETESS_X render state to MAKEFOURCC('N','V','D','B') and
3847 * then controlled by setting D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax)
3850 case WINED3DFMT_NVDB:
3851 if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
3856 TRACE("[FAILED]\n");
3859 case WINED3DFMT_NVHU:
3860 case WINED3DFMT_NVHS:
3861 /* These formats seem to be similar to the HILO formats in GL_NV_texture_shader. NVHU
3862 * is said to be GL_UNSIGNED_HILO16, NVHS GL_SIGNED_HILO16. Rumours say that d3d computes
3863 * a 3rd channel similarly to D3DFMT_CxV8U8(So NVHS could be called D3DFMT_CxV16U16).
3864 * ATI refused to support formats which can easily be emulated with pixel shaders, so
3865 * Applications have to deal with not having NVHS and NVHU.
3867 TRACE("[FAILED]\n");
3870 case WINED3DFMT_NULL:
3871 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3875 case WINED3DFMT_UNKNOWN:
3879 ERR("Unhandled format %s.\n", debug_d3dformat(format->id));
3885 static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
3886 const struct wined3d_format *adapter_format,
3887 const struct wined3d_format *check_format,
3888 enum wined3d_surface_type surface_type)
3890 if (surface_type == WINED3D_SURFACE_TYPE_GDI)
3892 switch (check_format->id)
3894 case WINED3DFMT_B8G8R8_UNORM:
3895 TRACE("[FAILED] - Not enumerated on Windows.\n");
3897 case WINED3DFMT_B8G8R8A8_UNORM:
3898 case WINED3DFMT_B8G8R8X8_UNORM:
3899 case WINED3DFMT_B5G6R5_UNORM:
3900 case WINED3DFMT_B5G5R5X1_UNORM:
3901 case WINED3DFMT_B5G5R5A1_UNORM:
3902 case WINED3DFMT_B4G4R4A4_UNORM:
3903 case WINED3DFMT_B2G3R3_UNORM:
3904 case WINED3DFMT_A8_UNORM:
3905 case WINED3DFMT_B2G3R3A8_UNORM:
3906 case WINED3DFMT_B4G4R4X4_UNORM:
3907 case WINED3DFMT_R10G10B10A2_UNORM:
3908 case WINED3DFMT_R8G8B8A8_UNORM:
3909 case WINED3DFMT_R8G8B8X8_UNORM:
3910 case WINED3DFMT_R16G16_UNORM:
3911 case WINED3DFMT_B10G10R10A2_UNORM:
3912 case WINED3DFMT_R16G16B16A16_UNORM:
3913 case WINED3DFMT_P8_UINT:
3917 TRACE("[FAILED] - Not available on GDI surfaces.\n");
3922 /* All format that are supported for textures are supported for surfaces as well */
3923 if (CheckTextureCapability(adapter, check_format)) return TRUE;
3924 /* All depth stencil formats are supported on surfaces */
3925 if (CheckDepthStencilCapability(adapter, adapter_format, check_format)) return TRUE;
3927 /* If opengl can't process the format natively, the blitter may be able to convert it */
3928 if (adapter->blitter->blit_supported(&adapter->gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
3929 NULL, WINED3D_POOL_DEFAULT, 0, check_format,
3930 NULL, WINED3D_POOL_DEFAULT, 0, adapter_format))
3936 /* Reject other formats */
3937 TRACE("[FAILED]\n");
3941 static BOOL CheckVertexTextureCapability(const struct wined3d_adapter *adapter,
3942 const struct wined3d_format *format)
3944 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3946 if (!gl_info->limits.vertex_samplers || !(format->flags & WINED3DFMT_FLAG_VTF))
3951 case WINED3DFMT_R32G32B32A32_FLOAT:
3952 case WINED3DFMT_R32_FLOAT:
3955 return !(gl_info->quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING);
3959 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
3960 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
3961 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id,
3962 enum wined3d_surface_type surface_type)
3964 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
3965 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3966 const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id);
3967 const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id);
3968 DWORD usage_caps = 0;
3970 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
3971 "resource_type %s, check_format %s, surface_type %#x.\n",
3972 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
3973 debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
3974 debug_d3dformat(check_format_id), surface_type);
3976 if (adapter_idx >= wined3d->adapter_count)
3977 return WINED3DERR_INVALIDCALL;
3979 switch (resource_type)
3981 case WINED3D_RTYPE_CUBE_TEXTURE:
3982 /* Cubetexture allows:
3983 * - WINED3DUSAGE_AUTOGENMIPMAP
3984 * - WINED3DUSAGE_DEPTHSTENCIL
3985 * - WINED3DUSAGE_DYNAMIC
3986 * - WINED3DUSAGE_NONSECURE (d3d9ex)
3987 * - WINED3DUSAGE_RENDERTARGET
3988 * - WINED3DUSAGE_SOFTWAREPROCESSING
3989 * - WINED3DUSAGE_QUERY_WRAPANDMIP
3991 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
3993 TRACE("[FAILED]\n");
3994 return WINED3DERR_NOTAVAILABLE;
3997 if (!gl_info->supported[ARB_TEXTURE_CUBE_MAP])
3999 TRACE("[FAILED] - No cube texture support.\n");
4000 return WINED3DERR_NOTAVAILABLE;
4003 if (!CheckTextureCapability(adapter, format))
4005 TRACE("[FAILED] - Cube texture format not supported.\n");
4006 return WINED3DERR_NOTAVAILABLE;
4009 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
4011 if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
4012 /* When autogenmipmap isn't around continue and return
4013 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
4014 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
4016 usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
4019 /* Always report dynamic locking. */
4020 if (usage & WINED3DUSAGE_DYNAMIC)
4021 usage_caps |= WINED3DUSAGE_DYNAMIC;
4023 if (usage & WINED3DUSAGE_RENDERTARGET)
4025 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4027 TRACE("[FAILED] - No render target support.\n");
4028 return WINED3DERR_NOTAVAILABLE;
4030 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4033 /* Always report software processing. */
4034 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4035 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4037 if (usage & WINED3DUSAGE_QUERY_FILTER)
4039 if (!CheckFilterCapability(adapter, format))
4041 TRACE("[FAILED] - No filter support.\n");
4042 return WINED3DERR_NOTAVAILABLE;
4044 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4047 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4049 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4051 TRACE("[FAILED] - No post pixelshader blending support.\n");
4052 return WINED3DERR_NOTAVAILABLE;
4054 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4057 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4059 if (!CheckSrgbReadCapability(adapter, format))
4061 TRACE("[FAILED] - No sRGB read support.\n");
4062 return WINED3DERR_NOTAVAILABLE;
4064 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4067 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4069 if (!CheckSrgbWriteCapability(adapter, format))
4071 TRACE("[FAILED] - No sRGB write support.\n");
4072 return WINED3DERR_NOTAVAILABLE;
4074 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4077 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4079 if (!CheckVertexTextureCapability(adapter, format))
4081 TRACE("[FAILED] - No vertex texture support.\n");
4082 return WINED3DERR_NOTAVAILABLE;
4084 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4087 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4089 if (!CheckWrapAndMipCapability(adapter, format))
4091 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4092 return WINED3DERR_NOTAVAILABLE;
4094 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4098 case WINED3D_RTYPE_SURFACE:
4100 * - WINED3DUSAGE_DEPTHSTENCIL
4101 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4102 * - WINED3DUSAGE_RENDERTARGET
4104 if (!CheckSurfaceCapability(adapter, adapter_format, format, surface_type))
4106 TRACE("[FAILED] - Not supported for plain surfaces.\n");
4107 return WINED3DERR_NOTAVAILABLE;
4110 if (usage & WINED3DUSAGE_DEPTHSTENCIL)
4112 if (!CheckDepthStencilCapability(adapter, adapter_format, format))
4114 TRACE("[FAILED] - No depth/stencil support.\n");
4115 return WINED3DERR_NOTAVAILABLE;
4117 usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
4120 if (usage & WINED3DUSAGE_RENDERTARGET)
4122 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4124 TRACE("[FAILED] - No render target support.\n");
4125 return WINED3DERR_NOTAVAILABLE;
4127 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4130 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4132 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4134 TRACE("[FAILED] - No post pixelshader blending support.\n");
4135 return WINED3DERR_NOTAVAILABLE;
4137 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4141 case WINED3D_RTYPE_TEXTURE:
4143 * - WINED3DUSAGE_AUTOGENMIPMAP
4144 * - WINED3DUSAGE_DEPTHSTENCIL
4145 * - WINED3DUSAGE_DMAP
4146 * - WINED3DUSAGE_DYNAMIC
4147 * - WINED3DUSAGE_NONSECURE (d3d9ex)
4148 * - WINED3DUSAGE_RENDERTARGET
4149 * - WINED3DUSAGE_SOFTWAREPROCESSING
4150 * - WINED3DUSAGE_TEXTAPI (d3d9ex)
4151 * - WINED3DUSAGE_QUERY_WRAPANDMIP
4153 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
4155 TRACE("[FAILED]\n");
4156 return WINED3DERR_NOTAVAILABLE;
4159 if (!CheckTextureCapability(adapter, format))
4161 TRACE("[FAILED] - Texture format not supported.\n");
4162 return WINED3DERR_NOTAVAILABLE;
4165 if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
4167 if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
4168 /* When autogenmipmap isn't around continue and return
4169 * WINED3DOK_NOAUTOGEN instead of D3D_OK. */
4170 TRACE("[FAILED] - No autogenmipmap support, but continuing.\n");
4172 usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
4175 /* Always report dynamic locking. */
4176 if (usage & WINED3DUSAGE_DYNAMIC)
4177 usage_caps |= WINED3DUSAGE_DYNAMIC;
4179 if (usage & WINED3DUSAGE_RENDERTARGET)
4181 if (!CheckRenderTargetCapability(adapter, adapter_format, format))
4183 TRACE("[FAILED] - No render target support.\n");
4184 return WINED3DERR_NOTAVAILABLE;
4186 usage_caps |= WINED3DUSAGE_RENDERTARGET;
4189 /* Always report software processing. */
4190 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4191 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4193 if (usage & WINED3DUSAGE_QUERY_FILTER)
4195 if (!CheckFilterCapability(adapter, format))
4197 TRACE("[FAILED] - No filter support.\n");
4198 return WINED3DERR_NOTAVAILABLE;
4200 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4203 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
4205 if (!CheckBumpMapCapability(adapter, format))
4207 TRACE("[FAILED] - No legacy bumpmap support.\n");
4208 return WINED3DERR_NOTAVAILABLE;
4210 usage_caps |= WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
4213 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4215 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4217 TRACE("[FAILED] - No post pixelshader blending support.\n");
4218 return WINED3DERR_NOTAVAILABLE;
4220 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4223 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4225 if (!CheckSrgbReadCapability(adapter, format))
4227 TRACE("[FAILED] - No sRGB read support.\n");
4228 return WINED3DERR_NOTAVAILABLE;
4230 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4233 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4235 if (!CheckSrgbWriteCapability(adapter, format))
4237 TRACE("[FAILED] - No sRGB write support.\n");
4238 return WINED3DERR_NOTAVAILABLE;
4240 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4243 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4245 if (!CheckVertexTextureCapability(adapter, format))
4247 TRACE("[FAILED] - No vertex texture support.\n");
4248 return WINED3DERR_NOTAVAILABLE;
4250 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4253 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4255 if (!CheckWrapAndMipCapability(adapter, format))
4257 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4258 return WINED3DERR_NOTAVAILABLE;
4260 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4263 if (usage & WINED3DUSAGE_DEPTHSTENCIL)
4265 if (!CheckDepthStencilCapability(adapter, adapter_format, format))
4267 TRACE("[FAILED] - No depth/stencil support.\n");
4268 return WINED3DERR_NOTAVAILABLE;
4270 if ((format->flags & WINED3DFMT_FLAG_SHADOW) && !gl_info->supported[ARB_SHADOW])
4272 TRACE("[FAILED] - No shadow sampler support.\n");
4273 return WINED3DERR_NOTAVAILABLE;
4275 usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
4279 case WINED3D_RTYPE_VOLUME_TEXTURE:
4280 case WINED3D_RTYPE_VOLUME:
4281 /* Volume is to VolumeTexture what Surface is to Texture, but its
4282 * usage caps are not documented. Most driver seem to offer
4283 * (nearly) the same on Volume and VolumeTexture, so do that too.
4285 * Volumetexture allows:
4286 * - D3DUSAGE_DYNAMIC
4287 * - D3DUSAGE_NONSECURE (d3d9ex)
4288 * - D3DUSAGE_SOFTWAREPROCESSING
4289 * - D3DUSAGE_QUERY_WRAPANDMIP
4291 if (surface_type != WINED3D_SURFACE_TYPE_OPENGL)
4293 TRACE("[FAILED]\n");
4294 return WINED3DERR_NOTAVAILABLE;
4297 if (!gl_info->supported[EXT_TEXTURE3D])
4299 TRACE("[FAILED] - No volume texture support.\n");
4300 return WINED3DERR_NOTAVAILABLE;
4303 if (!CheckTextureCapability(adapter, format))
4305 TRACE("[FAILED] - Format not supported.\n");
4306 return WINED3DERR_NOTAVAILABLE;
4309 /* Filter formats that need conversion; For one part, this
4310 * conversion is unimplemented, and volume textures are huge, so
4311 * it would be a big performance hit. Unless we hit an application
4312 * needing one of those formats, don't advertize them to avoid
4313 * leading applications into temptation. The windows drivers don't
4314 * support most of those formats on volumes anyway, except for
4315 * WINED3DFMT_R32_FLOAT. */
4316 switch (check_format_id)
4318 case WINED3DFMT_P8_UINT:
4319 case WINED3DFMT_L4A4_UNORM:
4320 case WINED3DFMT_R32_FLOAT:
4321 case WINED3DFMT_R16_FLOAT:
4322 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
4323 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
4324 case WINED3DFMT_R16G16_UNORM:
4325 TRACE("[FAILED] - No converted formats on volumes.\n");
4326 return WINED3DERR_NOTAVAILABLE;
4328 case WINED3DFMT_R8G8B8A8_SNORM:
4329 case WINED3DFMT_R16G16_SNORM:
4330 if (!gl_info->supported[NV_TEXTURE_SHADER])
4332 TRACE("[FAILED] - No converted formats on volumes.\n");
4333 return WINED3DERR_NOTAVAILABLE;
4337 case WINED3DFMT_R8G8_SNORM:
4338 if (!gl_info->supported[NV_TEXTURE_SHADER])
4340 TRACE("[FAILED] - No converted formats on volumes.\n");
4341 return WINED3DERR_NOTAVAILABLE;
4345 case WINED3DFMT_DXT1:
4346 case WINED3DFMT_DXT2:
4347 case WINED3DFMT_DXT3:
4348 case WINED3DFMT_DXT4:
4349 case WINED3DFMT_DXT5:
4350 /* The GL_EXT_texture_compression_s3tc spec requires that
4351 * loading an s3tc compressed texture results in an error.
4352 * While the D3D refrast does support s3tc volumes, at
4353 * least the nvidia windows driver does not, so we're free
4354 * not to support this format. */
4355 TRACE("[FAILED] - DXTn does not support 3D textures.\n");
4356 return WINED3DERR_NOTAVAILABLE;
4359 /* Do nothing, continue with checking the format below */
4363 /* Always report dynamic locking. */
4364 if (usage & WINED3DUSAGE_DYNAMIC)
4365 usage_caps |= WINED3DUSAGE_DYNAMIC;
4367 /* Always report software processing. */
4368 if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
4369 usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
4371 if (usage & WINED3DUSAGE_QUERY_FILTER)
4373 if (!CheckFilterCapability(adapter, format))
4375 TRACE("[FAILED] - No filter support.\n");
4376 return WINED3DERR_NOTAVAILABLE;
4378 usage_caps |= WINED3DUSAGE_QUERY_FILTER;
4381 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
4383 if (!CheckPostPixelShaderBlendingCapability(adapter, format))
4385 TRACE("[FAILED] - No post pixelshader blending support.\n");
4386 return WINED3DERR_NOTAVAILABLE;
4388 usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
4391 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
4393 if (!CheckSrgbReadCapability(adapter, format))
4395 TRACE("[FAILED] - No sRGB read support.\n");
4396 return WINED3DERR_NOTAVAILABLE;
4398 usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
4401 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
4403 if (!CheckSrgbWriteCapability(adapter, format))
4405 TRACE("[FAILED] - No sRGB write support.\n");
4406 return WINED3DERR_NOTAVAILABLE;
4408 usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
4411 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
4413 if (!CheckVertexTextureCapability(adapter, format))
4415 TRACE("[FAILED] - No vertex texture support.\n");
4416 return WINED3DERR_NOTAVAILABLE;
4418 usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
4421 if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
4423 if (!CheckWrapAndMipCapability(adapter, format))
4425 TRACE("[FAILED] - No wrapping and mipmapping support.\n");
4426 return WINED3DERR_NOTAVAILABLE;
4428 usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
4433 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
4434 return WINED3DERR_NOTAVAILABLE;
4437 /* When the usage_caps exactly matches usage return WINED3D_OK except for
4438 * the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
4439 * WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
4440 if (usage_caps == usage)
4442 if (usage_caps == (usage & ~WINED3DUSAGE_AUTOGENMIPMAP))
4443 return WINED3DOK_NOAUTOGEN;
4445 TRACE("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
4446 usage, debug_d3dformat(check_format_id), debug_d3dresourcetype(resource_type), usage_caps);
4448 return WINED3DERR_NOTAVAILABLE;
4451 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
4452 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
4454 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
4455 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
4456 debug_d3dformat(dst_format));
4461 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
4462 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
4463 enum wined3d_format_id backbuffer_format, BOOL windowed)
4468 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
4469 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
4470 debug_d3dformat(backbuffer_format), windowed);
4472 if (adapter_idx >= wined3d->adapter_count)
4473 return WINED3DERR_INVALIDCALL;
4475 /* The task of this function is to check whether a certain display / backbuffer format
4476 * combination is available on the given adapter. In fullscreen mode microsoft specified
4477 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
4478 * and display format should match exactly.
4479 * In windowed mode format conversion can occur and this depends on the driver. When format
4480 * conversion is done, this function should nevertheless fail and applications need to use
4481 * CheckDeviceFormatConversion.
4482 * At the moment we assume that fullscreen and windowed have the same capabilities. */
4484 /* There are only 4 display formats. */
4485 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
4486 || display_format == WINED3DFMT_B5G5R5X1_UNORM
4487 || display_format == WINED3DFMT_B8G8R8X8_UNORM
4488 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
4490 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
4491 return WINED3DERR_NOTAVAILABLE;
4494 /* If the requested display format is not available, don't continue. */
4495 mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
4496 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
4499 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
4500 return WINED3DERR_NOTAVAILABLE;
4503 /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format,
4504 * it means 'reuse' the display format for the backbuffer. */
4505 if (!windowed && backbuffer_format == WINED3DFMT_UNKNOWN)
4507 TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n");
4508 return WINED3DERR_NOTAVAILABLE;
4511 /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with
4512 * backbuffer format WINED3DFMT_B5G6R5_UNORM. */
4513 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
4515 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4516 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4517 return WINED3DERR_NOTAVAILABLE;
4520 /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with
4521 * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and
4522 * WINED3DFMT_B5G5R5A1_UNORM. */
4523 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
4524 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
4526 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4527 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4528 return WINED3DERR_NOTAVAILABLE;
4531 /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with
4532 * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and
4533 * WINED3DFMT_B8G8R8A8_UNORM. */
4534 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
4535 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
4537 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4538 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4539 return WINED3DERR_NOTAVAILABLE;
4542 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it
4543 * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */
4544 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
4545 && (backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM || windowed))
4547 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4548 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4549 return WINED3DERR_NOTAVAILABLE;
4552 /* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
4553 hr = wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
4554 WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_SURFACE, backbuffer_format, WINED3D_SURFACE_TYPE_OPENGL);
4556 TRACE("Unsupported display/backbuffer format combination %s / %s.\n",
4557 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
4562 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
4563 enum wined3d_device_type device_type, WINED3DCAPS *caps)
4565 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
4566 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
4567 int vs_selected_mode;
4568 int ps_selected_mode;
4569 struct shader_caps shader_caps;
4570 struct fragment_caps fragment_caps;
4571 DWORD ckey_caps, blit_caps, fx_caps, pal_caps;
4573 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
4574 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
4576 if (adapter_idx >= wined3d->adapter_count)
4577 return WINED3DERR_INVALIDCALL;
4579 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
4581 /* ------------------------------------------------
4582 The following fields apply to both d3d8 and d3d9
4583 ------------------------------------------------ */
4584 /* Not quite true, but use h/w supported by opengl I suppose */
4585 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
4586 caps->AdapterOrdinal = adapter_idx;
4589 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
4590 WINED3DCAPS2_FULLSCREENGAMMA |
4591 WINED3DCAPS2_DYNAMICTEXTURES;
4592 if (gl_info->supported[SGIS_GENERATE_MIPMAP])
4593 caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
4595 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
4596 WINED3DCAPS3_COPY_TO_VIDMEM |
4597 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
4599 caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
4600 WINED3DPRESENT_INTERVAL_ONE;
4602 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
4603 WINED3DCURSORCAPS_LOWRES;
4605 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
4606 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
4607 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
4608 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
4609 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
4610 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
4611 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
4612 WINED3DDEVCAPS_PUREDEVICE |
4613 WINED3DDEVCAPS_HWRASTERIZATION |
4614 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
4615 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
4616 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
4617 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
4618 WINED3DDEVCAPS_DRAWPRIMITIVES2EX |
4619 WINED3DDEVCAPS_RTPATCHES;
4621 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
4622 WINED3DPMISCCAPS_CULLCCW |
4623 WINED3DPMISCCAPS_CULLCW |
4624 WINED3DPMISCCAPS_COLORWRITEENABLE |
4625 WINED3DPMISCCAPS_CLIPTLVERTS |
4626 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
4627 WINED3DPMISCCAPS_MASKZ |
4628 WINED3DPMISCCAPS_BLENDOP |
4629 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
4631 WINED3DPMISCCAPS_NULLREFERENCE
4632 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
4633 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
4634 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
4636 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
4637 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
4638 if (gl_info->supported[EXT_DRAW_BUFFERS2])
4639 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
4640 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
4641 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
4643 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
4644 WINED3DPRASTERCAPS_PAT |
4645 WINED3DPRASTERCAPS_WFOG |
4646 WINED3DPRASTERCAPS_ZFOG |
4647 WINED3DPRASTERCAPS_FOGVERTEX |
4648 WINED3DPRASTERCAPS_FOGTABLE |
4649 WINED3DPRASTERCAPS_STIPPLE |
4650 WINED3DPRASTERCAPS_SUBPIXEL |
4651 WINED3DPRASTERCAPS_ZTEST |
4652 WINED3DPRASTERCAPS_SCISSORTEST |
4653 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
4654 WINED3DPRASTERCAPS_DEPTHBIAS;
4656 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4658 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
4659 WINED3DPRASTERCAPS_ZBIAS |
4660 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
4662 if (gl_info->supported[NV_FOG_DISTANCE])
4664 caps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
4667 WINED3DPRASTERCAPS_COLORPERSPECTIVE
4668 WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
4669 WINED3DPRASTERCAPS_ANTIALIASEDGES
4670 WINED3DPRASTERCAPS_ZBUFFERLESSHSR
4671 WINED3DPRASTERCAPS_WBUFFER */
4673 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
4674 WINED3DPCMPCAPS_EQUAL |
4675 WINED3DPCMPCAPS_GREATER |
4676 WINED3DPCMPCAPS_GREATEREQUAL |
4677 WINED3DPCMPCAPS_LESS |
4678 WINED3DPCMPCAPS_LESSEQUAL |
4679 WINED3DPCMPCAPS_NEVER |
4680 WINED3DPCMPCAPS_NOTEQUAL;
4682 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
4683 WINED3DPBLENDCAPS_BOTHSRCALPHA |
4684 WINED3DPBLENDCAPS_DESTALPHA |
4685 WINED3DPBLENDCAPS_DESTCOLOR |
4686 WINED3DPBLENDCAPS_INVDESTALPHA |
4687 WINED3DPBLENDCAPS_INVDESTCOLOR |
4688 WINED3DPBLENDCAPS_INVSRCALPHA |
4689 WINED3DPBLENDCAPS_INVSRCCOLOR |
4690 WINED3DPBLENDCAPS_ONE |
4691 WINED3DPBLENDCAPS_SRCALPHA |
4692 WINED3DPBLENDCAPS_SRCALPHASAT |
4693 WINED3DPBLENDCAPS_SRCCOLOR |
4694 WINED3DPBLENDCAPS_ZERO;
4696 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
4697 WINED3DPBLENDCAPS_DESTCOLOR |
4698 WINED3DPBLENDCAPS_INVDESTALPHA |
4699 WINED3DPBLENDCAPS_INVDESTCOLOR |
4700 WINED3DPBLENDCAPS_INVSRCALPHA |
4701 WINED3DPBLENDCAPS_INVSRCCOLOR |
4702 WINED3DPBLENDCAPS_ONE |
4703 WINED3DPBLENDCAPS_SRCALPHA |
4704 WINED3DPBLENDCAPS_SRCCOLOR |
4705 WINED3DPBLENDCAPS_ZERO;
4706 /* NOTE: WINED3DPBLENDCAPS_SRCALPHASAT is not supported as dest blend factor,
4707 * according to the glBlendFunc manpage
4709 * WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA are
4710 * legacy settings for srcblend only
4713 if (gl_info->supported[EXT_BLEND_COLOR])
4715 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
4716 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
4720 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
4721 WINED3DPCMPCAPS_EQUAL |
4722 WINED3DPCMPCAPS_GREATER |
4723 WINED3DPCMPCAPS_GREATEREQUAL |
4724 WINED3DPCMPCAPS_LESS |
4725 WINED3DPCMPCAPS_LESSEQUAL |
4726 WINED3DPCMPCAPS_NEVER |
4727 WINED3DPCMPCAPS_NOTEQUAL;
4729 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
4730 WINED3DPSHADECAPS_COLORGOURAUDRGB |
4731 WINED3DPSHADECAPS_ALPHAFLATBLEND |
4732 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
4733 WINED3DPSHADECAPS_COLORFLATRGB |
4734 WINED3DPSHADECAPS_FOGFLAT |
4735 WINED3DPSHADECAPS_FOGGOURAUD |
4736 WINED3DPSHADECAPS_SPECULARFLATRGB;
4738 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
4739 WINED3DPTEXTURECAPS_ALPHAPALETTE |
4740 WINED3DPTEXTURECAPS_TRANSPARENCY |
4741 WINED3DPTEXTURECAPS_BORDER |
4742 WINED3DPTEXTURECAPS_MIPMAP |
4743 WINED3DPTEXTURECAPS_PROJECTED |
4744 WINED3DPTEXTURECAPS_PERSPECTIVE;
4746 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4748 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
4749 WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
4752 if (gl_info->supported[EXT_TEXTURE3D])
4754 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
4755 WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
4756 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4758 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
4762 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4764 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
4765 WINED3DPTEXTURECAPS_MIPCUBEMAP;
4766 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4768 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
4772 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4773 WINED3DPTFILTERCAPS_MAGFPOINT |
4774 WINED3DPTFILTERCAPS_MINFLINEAR |
4775 WINED3DPTFILTERCAPS_MINFPOINT |
4776 WINED3DPTFILTERCAPS_MIPFLINEAR |
4777 WINED3DPTFILTERCAPS_MIPFPOINT |
4778 WINED3DPTFILTERCAPS_LINEAR |
4779 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4780 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4781 WINED3DPTFILTERCAPS_MIPLINEAR |
4782 WINED3DPTFILTERCAPS_MIPNEAREST |
4783 WINED3DPTFILTERCAPS_NEAREST;
4785 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4787 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
4788 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
4791 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4793 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4794 WINED3DPTFILTERCAPS_MAGFPOINT |
4795 WINED3DPTFILTERCAPS_MINFLINEAR |
4796 WINED3DPTFILTERCAPS_MINFPOINT |
4797 WINED3DPTFILTERCAPS_MIPFLINEAR |
4798 WINED3DPTFILTERCAPS_MIPFPOINT |
4799 WINED3DPTFILTERCAPS_LINEAR |
4800 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4801 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4802 WINED3DPTFILTERCAPS_MIPLINEAR |
4803 WINED3DPTFILTERCAPS_MIPNEAREST |
4804 WINED3DPTFILTERCAPS_NEAREST;
4806 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
4808 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
4809 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
4814 caps->CubeTextureFilterCaps = 0;
4817 if (gl_info->supported[EXT_TEXTURE3D])
4819 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
4820 WINED3DPTFILTERCAPS_MAGFPOINT |
4821 WINED3DPTFILTERCAPS_MINFLINEAR |
4822 WINED3DPTFILTERCAPS_MINFPOINT |
4823 WINED3DPTFILTERCAPS_MIPFLINEAR |
4824 WINED3DPTFILTERCAPS_MIPFPOINT |
4825 WINED3DPTFILTERCAPS_LINEAR |
4826 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
4827 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
4828 WINED3DPTFILTERCAPS_MIPLINEAR |
4829 WINED3DPTFILTERCAPS_MIPNEAREST |
4830 WINED3DPTFILTERCAPS_NEAREST;
4834 caps->VolumeTextureFilterCaps = 0;
4837 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
4838 WINED3DPTADDRESSCAPS_CLAMP |
4839 WINED3DPTADDRESSCAPS_WRAP;
4841 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
4843 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
4845 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
4847 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
4849 if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4851 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
4854 if (gl_info->supported[EXT_TEXTURE3D])
4856 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
4857 WINED3DPTADDRESSCAPS_CLAMP |
4858 WINED3DPTADDRESSCAPS_WRAP;
4859 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
4861 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
4863 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
4865 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
4867 if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4869 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
4874 caps->VolumeTextureAddressCaps = 0;
4877 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
4878 WINED3DLINECAPS_ZTEST |
4879 WINED3DLINECAPS_BLEND |
4880 WINED3DLINECAPS_ALPHACMP |
4881 WINED3DLINECAPS_FOG;
4882 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
4883 * idea how generating the smoothing alpha values works; the result is different
4886 caps->MaxTextureWidth = gl_info->limits.texture_size;
4887 caps->MaxTextureHeight = gl_info->limits.texture_size;
4889 if (gl_info->supported[EXT_TEXTURE3D])
4890 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
4892 caps->MaxVolumeExtent = 0;
4894 caps->MaxTextureRepeat = 32768;
4895 caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
4896 caps->MaxVertexW = 1.0f;
4898 caps->GuardBandLeft = 0.0f;
4899 caps->GuardBandTop = 0.0f;
4900 caps->GuardBandRight = 0.0f;
4901 caps->GuardBandBottom = 0.0f;
4903 caps->ExtentsAdjust = 0.0f;
4905 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
4906 WINED3DSTENCILCAPS_INCRSAT |
4907 WINED3DSTENCILCAPS_INVERT |
4908 WINED3DSTENCILCAPS_KEEP |
4909 WINED3DSTENCILCAPS_REPLACE |
4910 WINED3DSTENCILCAPS_ZERO;
4911 if (gl_info->supported[EXT_STENCIL_WRAP])
4913 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
4914 WINED3DSTENCILCAPS_INCR;
4916 if (gl_info->supported[EXT_STENCIL_TWO_SIDE] || gl_info->supported[ATI_SEPARATE_STENCIL])
4918 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
4921 caps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
4923 caps->MaxUserClipPlanes = gl_info->limits.clipplanes;
4924 caps->MaxActiveLights = gl_info->limits.lights;
4926 caps->MaxVertexBlendMatrices = gl_info->limits.blends;
4927 caps->MaxVertexBlendMatrixIndex = 0;
4929 caps->MaxAnisotropy = gl_info->limits.anisotropy;
4930 caps->MaxPointSize = gl_info->limits.pointsize_max;
4933 /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
4934 caps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
4935 WINED3DVTXPCAPS_MATERIALSOURCE7 |
4936 WINED3DVTXPCAPS_POSITIONALLIGHTS |
4937 WINED3DVTXPCAPS_LOCALVIEWER |
4938 WINED3DVTXPCAPS_VERTEXFOG |
4939 WINED3DVTXPCAPS_TEXGEN;
4941 caps->MaxPrimitiveCount = 0xfffff; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
4942 caps->MaxVertexIndex = 0xfffff;
4943 caps->MaxStreams = MAX_STREAMS;
4944 caps->MaxStreamStride = 1024;
4946 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
4947 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
4948 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
4949 caps->MaxNpatchTessellationLevel = 0;
4950 caps->MasterAdapterOrdinal = 0;
4951 caps->AdapterOrdinalInGroup = 0;
4952 caps->NumberOfAdaptersInGroup = 1;
4954 caps->NumSimultaneousRTs = gl_info->limits.buffers;
4956 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
4957 WINED3DPTFILTERCAPS_MAGFPOINT |
4958 WINED3DPTFILTERCAPS_MINFLINEAR |
4959 WINED3DPTFILTERCAPS_MAGFLINEAR;
4960 caps->VertexTextureFilterCaps = 0;
4962 adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
4963 adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
4965 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
4966 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
4968 /* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
4969 * Ignore shader model capabilities if disabled in config
4971 if (vs_selected_mode == SHADER_NONE)
4973 TRACE("Vertex shader disabled in config, reporting version 0.0.\n");
4974 caps->VertexShaderVersion = 0;
4975 caps->MaxVertexShaderConst = 0;
4979 caps->VertexShaderVersion = shader_caps.vs_version;
4980 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
4983 if (ps_selected_mode == SHADER_NONE)
4985 TRACE("Pixel shader disabled in config, reporting version 0.0.\n");
4986 caps->PixelShaderVersion = 0;
4987 caps->PixelShader1xMaxValue = 0.0f;
4989 caps->PixelShaderVersion = shader_caps.ps_version;
4990 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
4993 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
4994 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
4995 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
4997 /* The following caps are shader specific, but they are things we cannot detect, or which
4998 * are the same among all shader models. So to avoid code duplication set the shader version
4999 * specific, but otherwise constant caps here
5001 if (caps->VertexShaderVersion >= 3)
5003 /* Where possible set the caps based on OpenGL extensions and if they
5004 * aren't set (in case of software rendering) use the VS 3.0 from
5005 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5007 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
5008 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5009 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5010 caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
5011 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
5012 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
5014 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
5015 caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
5017 else if (caps->VertexShaderVersion == 2)
5019 caps->VS20Caps.caps = 0;
5020 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
5021 caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
5022 caps->VS20Caps.static_flow_control_depth = 1;
5024 caps->MaxVShaderInstructionsExecuted = 65535;
5025 caps->MaxVertexShader30InstructionSlots = 0;
5029 caps->VS20Caps.caps = 0;
5030 caps->VS20Caps.dynamic_flow_control_depth = 0;
5031 caps->VS20Caps.temp_count = 0;
5032 caps->VS20Caps.static_flow_control_depth = 0;
5034 caps->MaxVShaderInstructionsExecuted = 0;
5035 caps->MaxVertexShader30InstructionSlots = 0;
5038 if (caps->PixelShaderVersion >= 3)
5040 /* Where possible set the caps based on OpenGL extensions and if they
5041 * aren't set (in case of software rendering) use the PS 3.0 from
5042 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5045 /* Caps is more or less undocumented on MSDN but it appears to be
5046 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
5047 * cards from Windows */
5048 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
5049 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
5050 WINED3DPS20CAPS_PREDICATION |
5051 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
5052 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
5053 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5054 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5055 caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
5056 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
5057 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
5058 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
5059 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
5061 caps->MaxPShaderInstructionsExecuted = 65535;
5062 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
5063 adapter->gl_info.limits.arb_ps_instructions);
5065 else if(caps->PixelShaderVersion == 2)
5067 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
5068 caps->PS20Caps.caps = 0;
5069 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
5070 caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
5071 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
5072 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
5073 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
5075 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
5076 caps->MaxPixelShader30InstructionSlots = 0;
5080 caps->PS20Caps.caps = 0;
5081 caps->PS20Caps.dynamic_flow_control_depth = 0;
5082 caps->PS20Caps.temp_count = 0;
5083 caps->PS20Caps.static_flow_control_depth = 0;
5084 caps->PS20Caps.instruction_slot_count = 0;
5086 caps->MaxPShaderInstructionsExecuted = 0;
5087 caps->MaxPixelShader30InstructionSlots = 0;
5090 if (caps->VertexShaderVersion >= 2)
5092 /* OpenGL supports all the formats below, perhaps not always
5093 * without conversion, but it supports them.
5094 * Further GLSL doesn't seem to have an official unsigned type so
5095 * don't advertise it yet as I'm not sure how we handle it.
5096 * We might need to add some clamping in the shader engine to
5098 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
5099 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
5100 WINED3DDTCAPS_UBYTE4N |
5101 WINED3DDTCAPS_SHORT2N |
5102 WINED3DDTCAPS_SHORT4N;
5103 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
5105 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
5106 WINED3DDTCAPS_FLOAT16_4;
5111 caps->DeclTypes = 0;
5114 /* Set DirectDraw helper Caps */
5115 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
5116 WINEDDCKEYCAPS_SRCBLT;
5117 fx_caps = WINEDDFXCAPS_BLTALPHA |
5118 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
5119 WINEDDFXCAPS_BLTMIRRORUPDOWN |
5120 WINEDDFXCAPS_BLTROTATION90 |
5121 WINEDDFXCAPS_BLTSHRINKX |
5122 WINEDDFXCAPS_BLTSHRINKXN |
5123 WINEDDFXCAPS_BLTSHRINKY |
5124 WINEDDFXCAPS_BLTSHRINKXN |
5125 WINEDDFXCAPS_BLTSTRETCHX |
5126 WINEDDFXCAPS_BLTSTRETCHXN |
5127 WINEDDFXCAPS_BLTSTRETCHY |
5128 WINEDDFXCAPS_BLTSTRETCHYN;
5129 blit_caps = WINEDDCAPS_BLT |
5130 WINEDDCAPS_BLTCOLORFILL |
5131 WINEDDCAPS_BLTDEPTHFILL |
5132 WINEDDCAPS_BLTSTRETCH |
5133 WINEDDCAPS_CANBLTSYSMEM |
5134 WINEDDCAPS_CANCLIP |
5135 WINEDDCAPS_CANCLIPSTRETCHED |
5136 WINEDDCAPS_COLORKEY |
5137 WINEDDCAPS_COLORKEYHWASSIST |
5138 WINEDDCAPS_ALIGNBOUNDARYSRC;
5139 pal_caps = WINEDDPCAPS_8BIT |
5140 WINEDDPCAPS_PRIMARYSURFACE;
5142 /* Fill the ddraw caps structure */
5143 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
5144 WINEDDCAPS_PALETTE |
5146 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
5147 WINEDDCAPS2_NOPAGELOCKREQUIRED |
5148 WINEDDCAPS2_PRIMARYGAMMA |
5149 WINEDDCAPS2_WIDESURFACES |
5150 WINEDDCAPS2_CANRENDERWINDOWED;
5151 caps->ddraw_caps.color_key_caps = ckey_caps;
5152 caps->ddraw_caps.fx_caps = fx_caps;
5153 caps->ddraw_caps.pal_caps = pal_caps;
5154 caps->ddraw_caps.svb_caps = blit_caps;
5155 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
5156 caps->ddraw_caps.svb_fx_caps = fx_caps;
5157 caps->ddraw_caps.vsb_caps = blit_caps;
5158 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
5159 caps->ddraw_caps.vsb_fx_caps = fx_caps;
5160 caps->ddraw_caps.ssb_caps = blit_caps;
5161 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
5162 caps->ddraw_caps.ssb_fx_caps = fx_caps;
5164 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
5165 WINEDDSCAPS_BACKBUFFER |
5167 WINEDDSCAPS_FRONTBUFFER |
5168 WINEDDSCAPS_OFFSCREENPLAIN |
5169 WINEDDSCAPS_PALETTE |
5170 WINEDDSCAPS_PRIMARYSURFACE |
5171 WINEDDSCAPS_SYSTEMMEMORY |
5172 WINEDDSCAPS_VIDEOMEMORY |
5173 WINEDDSCAPS_VISIBLE;
5174 caps->ddraw_caps.stride_align = DDRAW_PITCH_ALIGNMENT;
5176 /* Set D3D caps if OpenGL is available. */
5177 if (adapter->opengl)
5179 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
5180 WINEDDSCAPS_MIPMAP |
5181 WINEDDSCAPS_TEXTURE |
5182 WINEDDSCAPS_ZBUFFER;
5183 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
5189 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
5190 HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
5191 struct wined3d_device **device)
5193 struct wined3d_device *object;
5196 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
5197 wined3d, adapter_idx, device_type, focus_window, flags, device_parent, device);
5199 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
5200 * number and create a device without a 3D adapter for 2D only operation. */
5201 if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
5202 return WINED3DERR_INVALIDCALL;
5204 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5207 ERR("Failed to allocate device memory.\n");
5208 return E_OUTOFMEMORY;
5211 hr = device_init(object, wined3d, adapter_idx, device_type,
5212 focus_window, flags, surface_alignment, device_parent);
5215 WARN("Failed to initialize device, hr %#x.\n", hr);
5216 HeapFree(GetProcessHeap(), 0, object);
5220 TRACE("Created device %p.\n", object);
5223 device_parent->ops->wined3d_device_created(device_parent, *device);
5228 static void WINE_GLAPI invalid_func(const void *data)
5230 ERR("Invalid vertex attribute function called\n");
5234 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
5236 ERR("Invalid texcoord function called\n");
5240 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
5241 * the extension detection and are used in drawStridedSlow
5243 static void WINE_GLAPI position_d3dcolor(const void *data)
5245 DWORD pos = *((const DWORD *)data);
5247 FIXME("Add a test for fixed function position from d3dcolor type\n");
5248 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
5254 static void WINE_GLAPI position_float4(const void *data)
5256 const GLfloat *pos = data;
5258 if (pos[3] != 0.0f && pos[3] != 1.0f)
5260 float w = 1.0f / pos[3];
5262 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
5266 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
5270 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
5272 DWORD diffuseColor = *((const DWORD *)data);
5274 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
5275 D3DCOLOR_B_G(diffuseColor),
5276 D3DCOLOR_B_B(diffuseColor),
5277 D3DCOLOR_B_A(diffuseColor));
5280 static void WINE_GLAPI specular_d3dcolor(const void *data)
5282 DWORD specularColor = *((const DWORD *)data);
5283 GLbyte d[] = {D3DCOLOR_B_R(specularColor),
5284 D3DCOLOR_B_G(specularColor),
5285 D3DCOLOR_B_B(specularColor)};
5287 specular_func_3ubv(d);
5290 static void WINE_GLAPI warn_no_specular_func(const void *data)
5292 WARN("GL_EXT_secondary_color not supported\n");
5295 static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
5297 position_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5298 position_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5299 position_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex3fv;
5300 position_funcs[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
5301 position_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
5302 position_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5303 position_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5304 position_funcs[WINED3D_FFP_EMIT_SHORT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glVertex2sv;
5305 position_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5306 position_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5307 position_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5308 position_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5309 position_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5310 position_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5311 position_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5312 position_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5313 position_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5315 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5316 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5317 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor3fv;
5318 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4fv;
5319 diffuse_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
5320 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5321 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5322 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5323 diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4ubv;
5324 diffuse_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5325 diffuse_funcs[WINED3D_FFP_EMIT_SHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4sv;
5326 diffuse_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5327 diffuse_funcs[WINED3D_FFP_EMIT_USHORT4N] = (glAttribFunc)gl_info->gl_ops.gl.p_glColor4usv;
5328 diffuse_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5329 diffuse_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5330 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5331 diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5333 /* No 4 component entry points here */
5334 specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5335 specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5336 if (gl_info->supported[EXT_SECONDARY_COLOR])
5338 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
5342 specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
5344 specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func;
5345 if (gl_info->supported[EXT_SECONDARY_COLOR])
5347 specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT);
5348 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
5352 specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
5354 specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5355 specular_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5356 specular_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5357 specular_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5358 specular_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5359 specular_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5360 specular_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5361 specular_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5362 specular_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5363 specular_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5364 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5365 specular_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5367 /* Only 3 component entry points here. Test how others behave. Float4 normals are used
5368 * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
5370 normal_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
5371 normal_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
5372 normal_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv;
5373 normal_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)gl_info->gl_ops.gl.p_glNormal3fv; /* Just ignore the 4th value */
5374 normal_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_func;
5375 normal_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
5376 normal_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
5377 normal_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
5378 normal_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
5379 normal_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
5380 normal_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
5381 normal_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
5382 normal_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
5383 normal_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
5384 normal_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
5385 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
5386 normal_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
5388 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
5389 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
5390 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
5391 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
5392 multi_texcoord_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_texcoord_func;
5393 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_texcoord_func;
5394 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
5395 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
5396 multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_texcoord_func;
5397 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_texcoord_func;
5398 multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_texcoord_func;
5399 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_texcoord_func;
5400 multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func;
5401 multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func;
5402 multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func;
5403 if (gl_info->supported[NV_HALF_FLOAT])
5405 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */
5406 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
5407 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
5409 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_texcoord_func;
5410 multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_texcoord_func;
5414 /* Do not call while under the GL lock. */
5415 static BOOL InitAdapters(struct wined3d *wined3d)
5417 struct wined3d_adapter *adapter = &wined3d->adapters[0];
5418 struct wined3d_gl_info *gl_info = &adapter->gl_info;
5420 int ps_selected_mode, vs_selected_mode;
5422 /* No need to hold any lock. The calling library makes sure only one thread calls
5423 * wined3d simultaneously
5426 TRACE("Initializing adapters\n");
5428 /* Dynamically load all GL core functions */
5429 #ifdef USE_WIN32_OPENGL
5431 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
5432 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5435 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
5438 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
5440 HDC hdc = GetDC( 0 );
5441 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
5442 ReleaseDC( 0, hdc );
5443 if (!wgl_driver || wgl_driver == (void *)-1) goto nogl_adapter;
5444 gl_info->gl_ops.wgl = wgl_driver->wgl;
5445 gl_info->gl_ops.gl = wgl_driver->gl;
5449 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
5450 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
5452 /* For now only one default adapter */
5454 struct wined3d_fake_gl_ctx fake_gl_ctx = {0};
5455 struct wined3d_pixel_format *cfgs;
5458 DISPLAY_DEVICEW DisplayDevice;
5461 TRACE("Initializing default adapter\n");
5462 adapter->ordinal = 0;
5463 adapter->monitorPoint.x = -1;
5464 adapter->monitorPoint.y = -1;
5466 if (!AllocateLocallyUniqueId(&adapter->luid))
5468 DWORD err = GetLastError();
5469 ERR("Failed to set adapter LUID (%#x).\n", err);
5472 TRACE("Allocated LUID %08x:%08x for adapter.\n",
5473 adapter->luid.HighPart, adapter->luid.LowPart);
5475 if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx))
5477 ERR("Failed to get a gl context for default adapter\n");
5481 ret = wined3d_adapter_init_gl_caps(adapter);
5483 ERR("Failed to initialize gl caps for default adapter\n");
5484 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5487 ret = initPixelFormats(&adapter->gl_info, adapter->driver_info.vendor);
5489 ERR("Failed to init gl formats\n");
5490 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5494 hdc = fake_gl_ctx.dc;
5496 adapter->TextureRam = adapter->driver_info.vidmem;
5497 adapter->UsedTextureRam = 0;
5498 TRACE("Emulating %dMB of texture ram\n", adapter->TextureRam/(1024*1024));
5500 /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
5501 DisplayDevice.cb = sizeof(DisplayDevice);
5502 EnumDisplayDevicesW(NULL, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice, 0);
5503 TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice.DeviceName));
5504 strcpyW(adapter->DeviceName, DisplayDevice.DeviceName);
5506 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
5514 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
5515 GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, &attribute, &cfg_count));
5516 adapter->cfg_count = cfg_count;
5518 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, adapter->cfg_count * sizeof(*adapter->cfgs));
5519 cfgs = adapter->cfgs;
5520 attribs[nAttribs++] = WGL_RED_BITS_ARB;
5521 attribs[nAttribs++] = WGL_GREEN_BITS_ARB;
5522 attribs[nAttribs++] = WGL_BLUE_BITS_ARB;
5523 attribs[nAttribs++] = WGL_ALPHA_BITS_ARB;
5524 attribs[nAttribs++] = WGL_COLOR_BITS_ARB;
5525 attribs[nAttribs++] = WGL_DEPTH_BITS_ARB;
5526 attribs[nAttribs++] = WGL_STENCIL_BITS_ARB;
5527 attribs[nAttribs++] = WGL_DRAW_TO_WINDOW_ARB;
5528 attribs[nAttribs++] = WGL_PIXEL_TYPE_ARB;
5529 attribs[nAttribs++] = WGL_DOUBLE_BUFFER_ARB;
5530 attribs[nAttribs++] = WGL_AUX_BUFFERS_ARB;
5532 for (iPixelFormat=1; iPixelFormat <= adapter->cfg_count; ++iPixelFormat)
5534 res = GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, nAttribs, attribs, values));
5539 /* Cache the pixel format */
5540 cfgs->iPixelFormat = iPixelFormat;
5541 cfgs->redSize = values[0];
5542 cfgs->greenSize = values[1];
5543 cfgs->blueSize = values[2];
5544 cfgs->alphaSize = values[3];
5545 cfgs->colorSize = values[4];
5546 cfgs->depthSize = values[5];
5547 cfgs->stencilSize = values[6];
5548 cfgs->windowDrawable = values[7];
5549 cfgs->iPixelType = values[8];
5550 cfgs->doubleBuffer = values[9];
5551 cfgs->auxBuffers = values[10];
5553 cfgs->numSamples = 0;
5554 /* Check multisample support */
5555 if (gl_info->supported[ARB_MULTISAMPLE])
5557 int attrib[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
5559 if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 2, attrib, value))) {
5560 /* value[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether multisampling is supported.
5561 * value[1] = number of multi sample buffers*/
5563 cfgs->numSamples = value[1];
5567 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5568 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
5569 cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
5570 cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
5571 cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable);
5577 int nCfgs = DescribePixelFormat(hdc, 0, 0, 0);
5578 adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs * sizeof(*adapter->cfgs));
5579 adapter->cfg_count = 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
5581 cfgs = adapter->cfgs;
5582 for(iPixelFormat=1; iPixelFormat<=nCfgs; iPixelFormat++)
5584 PIXELFORMATDESCRIPTOR ppfd;
5586 res = DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &ppfd);
5590 /* We only want HW acceleration using an OpenGL ICD driver.
5591 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering
5592 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD driver (e.g. 3dfx minigl)
5594 if(ppfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
5596 TRACE("Skipping iPixelFormat=%d because it isn't ICD accelerated\n", iPixelFormat);
5600 cfgs->iPixelFormat = iPixelFormat;
5601 cfgs->redSize = ppfd.cRedBits;
5602 cfgs->greenSize = ppfd.cGreenBits;
5603 cfgs->blueSize = ppfd.cBlueBits;
5604 cfgs->alphaSize = ppfd.cAlphaBits;
5605 cfgs->colorSize = ppfd.cColorBits;
5606 cfgs->depthSize = ppfd.cDepthBits;
5607 cfgs->stencilSize = ppfd.cStencilBits;
5608 cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
5609 cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
5610 cfgs->doubleBuffer = (ppfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
5611 cfgs->auxBuffers = ppfd.cAuxBuffers;
5612 cfgs->numSamples = 0;
5614 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
5615 "depth=%d, stencil=%d, windowDrawable=%d\n",
5616 cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
5617 cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
5618 cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable);
5620 adapter->cfg_count++;
5623 /* We haven't found any suitable formats. This should only happen
5624 * in case of GDI software rendering, which is pretty useless
5626 if (!adapter->cfg_count)
5628 ERR("Disabling Direct3D because no hardware accelerated pixel formats have been found!\n");
5630 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5631 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
5636 WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
5638 select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
5639 fillGLAttribFuncs(&adapter->gl_info);
5640 adapter->opengl = TRUE;
5642 wined3d->adapter_count = 1;
5643 TRACE("%u adapters successfully initialized.\n", wined3d->adapter_count);
5648 /* Initialize an adapter for ddraw-only memory counting */
5649 memset(wined3d->adapters, 0, sizeof(wined3d->adapters));
5650 wined3d->adapters[0].ordinal = 0;
5651 wined3d->adapters[0].opengl = FALSE;
5652 wined3d->adapters[0].monitorPoint.x = -1;
5653 wined3d->adapters[0].monitorPoint.y = -1;
5655 wined3d->adapters[0].driver_info.name = "Display";
5656 wined3d->adapters[0].driver_info.description = "WineD3D DirectDraw Emulation";
5657 if (wined3d_settings.emulated_textureram)
5658 wined3d->adapters[0].TextureRam = wined3d_settings.emulated_textureram;
5660 wined3d->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
5662 initPixelFormatsNoGL(&wined3d->adapters[0].gl_info);
5664 wined3d->adapter_count = 1;
5668 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
5670 const struct wined3d_parent_ops wined3d_null_parent_ops =
5672 wined3d_null_wined3d_object_destroyed,
5675 /* Do not call while under the GL lock. */
5676 HRESULT wined3d_init(struct wined3d *wined3d, UINT version, DWORD flags)
5678 wined3d->dxVersion = version;
5680 wined3d->flags = flags;
5682 if (!InitAdapters(wined3d))
5684 WARN("Failed to initialize adapters.\n");
5687 MESSAGE("Direct3D%u is not available without OpenGL.\n", version);