devenum: Implement IMoniker::GetClassID().
[wine.git] / dlls / wined3d / directx.c
blob53255dee01b90ecd527ded85fb116e1ed305ca73
1 /*
2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
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
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdio.h>
29 #include "wined3d_private.h"
30 #include "winternl.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
33 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
34 WINE_DECLARE_DEBUG_CHANNEL(winediag);
36 #define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
37 #define DEFAULT_REFRESH_RATE 0
39 /* The driver names reflect the lowest GPU supported
40 * by a certain driver, so DRIVER_AMD_R300 supports
41 * R3xx, R4xx and R5xx GPUs. */
42 enum wined3d_display_driver
44 DRIVER_AMD_RAGE_128PRO,
45 DRIVER_AMD_R100,
46 DRIVER_AMD_R300,
47 DRIVER_AMD_R600,
48 DRIVER_AMD_RX,
49 DRIVER_INTEL_GMA800,
50 DRIVER_INTEL_GMA900,
51 DRIVER_INTEL_GMA950,
52 DRIVER_INTEL_GMA3000,
53 DRIVER_INTEL_HD4000,
54 DRIVER_NVIDIA_TNT,
55 DRIVER_NVIDIA_GEFORCE2MX,
56 DRIVER_NVIDIA_GEFORCEFX,
57 DRIVER_NVIDIA_GEFORCE6,
58 DRIVER_NVIDIA_GEFORCE8,
59 DRIVER_VMWARE,
60 DRIVER_UNKNOWN
63 enum wined3d_driver_model
65 DRIVER_MODEL_GENERIC,
66 DRIVER_MODEL_WIN9X,
67 DRIVER_MODEL_NT40,
68 DRIVER_MODEL_NT5X,
69 DRIVER_MODEL_NT6X
72 enum wined3d_gl_vendor
74 GL_VENDOR_UNKNOWN,
75 GL_VENDOR_APPLE,
76 GL_VENDOR_FGLRX,
77 GL_VENDOR_MESA,
78 GL_VENDOR_NVIDIA,
81 enum wined3d_d3d_level
83 WINED3D_D3D_LEVEL_5,
84 WINED3D_D3D_LEVEL_6,
85 WINED3D_D3D_LEVEL_7,
86 WINED3D_D3D_LEVEL_8,
87 WINED3D_D3D_LEVEL_9_SM2,
88 WINED3D_D3D_LEVEL_9_SM3,
89 WINED3D_D3D_LEVEL_10,
90 WINED3D_D3D_LEVEL_11,
91 WINED3D_D3D_LEVEL_COUNT
94 /* The d3d device ID */
95 static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
97 /* Extension detection */
98 struct wined3d_extension_map
100 const char *extension_string;
101 enum wined3d_gl_extension extension;
104 static const struct wined3d_extension_map gl_extension_map[] =
106 /* APPLE */
107 {"GL_APPLE_fence", APPLE_FENCE },
108 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
109 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
110 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
112 /* ARB */
113 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED },
114 {"GL_ARB_clip_control", ARB_CLIP_CONTROL },
115 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
116 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER },
117 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
118 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
119 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
120 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
121 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
122 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
123 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
124 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
125 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY },
126 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY },
127 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION },
128 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS},
129 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
130 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
131 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
132 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
133 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
134 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5 },
135 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
136 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
137 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS },
138 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY },
139 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2 },
140 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
141 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
142 {"GL_ARB_multisample", ARB_MULTISAMPLE },
143 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
144 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
145 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
146 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
147 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
148 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
149 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS },
150 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP },
151 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS },
152 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
153 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE },
154 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE },
155 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT},
156 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
157 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
158 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK },
159 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING },
160 {"GL_ARB_shadow", ARB_SHADOW },
161 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING },
162 {"GL_ARB_sync", ARB_SYNC },
163 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
164 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT },
165 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE },
166 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
167 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC },
168 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
169 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
170 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY },
171 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
172 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
173 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
174 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
175 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE},
176 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
177 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS },
178 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
179 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
180 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI },
181 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE },
182 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE },
183 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW },
184 {"GL_ARB_timer_query", ARB_TIMER_QUERY },
185 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT },
186 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
187 {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND },
188 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
189 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
190 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
191 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV},
192 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY },
194 /* ATI */
195 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
196 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
197 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
198 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
199 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
201 /* EXT */
202 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
203 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
204 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
205 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
206 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
207 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
208 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
209 {"GL_EXT_fog_coord", EXT_FOG_COORD },
210 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
211 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
212 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
213 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
214 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
215 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
216 {"GL_EXT_packed_float", EXT_PACKED_FLOAT },
217 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
218 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
219 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
220 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
221 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
222 {"GL_EXT_texture3D", EXT_TEXTURE3D },
223 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY },
224 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
225 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
226 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
227 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
228 {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
229 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER },
230 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
231 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP },
232 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM },
233 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
234 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
235 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
237 /* NV */
238 {"GL_NV_fence", NV_FENCE },
239 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
240 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
241 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
242 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
243 {"GL_NV_half_float", NV_HALF_FLOAT },
244 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
245 {"GL_NV_point_sprite", NV_POINT_SPRITE },
246 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
247 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
248 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
249 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
250 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
251 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
252 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
253 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
254 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
255 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
256 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
258 /* SGI */
259 {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
262 static const struct wined3d_extension_map wgl_extension_map[] =
264 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
265 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
266 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
267 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER },
270 /**********************************************************
271 * Utility functions follow
272 **********************************************************/
274 const struct min_lookup minMipLookup[] =
276 /* NONE POINT LINEAR */
277 {{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
278 {{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
279 {{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
282 const GLenum magLookup[] =
284 /* NONE POINT LINEAR */
285 GL_NEAREST, GL_NEAREST, GL_LINEAR,
288 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx *ctx)
290 const struct wined3d_gl_info *gl_info = ctx->gl_info;
292 TRACE("Destroying caps GL context.\n");
294 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
295 * this function might be called before the relevant function pointers
296 * in gl_info are initialized. */
297 if (ctx->test_program_id || ctx->test_vbo)
299 GL_EXTCALL(glDeleteProgram(ctx->test_program_id));
300 GL_EXTCALL(glDeleteBuffers(1, &ctx->test_vbo));
303 if (!wglMakeCurrent(NULL, NULL))
304 ERR("Failed to disable caps GL context.\n");
306 if (!wglDeleteContext(ctx->gl_ctx))
308 DWORD err = GetLastError();
309 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
312 wined3d_release_dc(ctx->wnd, ctx->dc);
313 DestroyWindow(ctx->wnd);
315 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
316 ERR("Failed to restore previous GL context.\n");
319 static BOOL wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx *caps_gl_ctx,
320 struct wined3d_gl_info *gl_info)
322 HGLRC new_ctx;
324 if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
325 return TRUE;
327 if (!(new_ctx = context_create_wgl_attribs(gl_info, caps_gl_ctx->dc, NULL)))
329 gl_info->p_wglCreateContextAttribsARB = NULL;
330 return FALSE;
333 if (!wglMakeCurrent(caps_gl_ctx->dc, new_ctx))
335 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
336 if (!wglDeleteContext(new_ctx))
337 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
338 gl_info->p_wglCreateContextAttribsARB = NULL;
339 return TRUE;
342 if (!wglDeleteContext(caps_gl_ctx->gl_ctx))
343 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
344 caps_gl_ctx->gl_ctx = new_ctx;
346 return TRUE;
349 static BOOL wined3d_caps_gl_ctx_create(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
351 PIXELFORMATDESCRIPTOR pfd;
352 int iPixelFormat;
354 TRACE("getting context...\n");
356 ctx->restore_dc = wglGetCurrentDC();
357 ctx->restore_gl_ctx = wglGetCurrentContext();
359 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
360 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
361 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
362 if (!ctx->wnd)
364 ERR("Failed to create a window.\n");
365 goto fail;
368 ctx->dc = GetDC(ctx->wnd);
369 if (!ctx->dc)
371 ERR("Failed to get a DC.\n");
372 goto fail;
375 /* PixelFormat selection */
376 ZeroMemory(&pfd, sizeof(pfd));
377 pfd.nSize = sizeof(pfd);
378 pfd.nVersion = 1;
379 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
380 pfd.iPixelType = PFD_TYPE_RGBA;
381 pfd.cColorBits = 32;
382 pfd.iLayerType = PFD_MAIN_PLANE;
384 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
386 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
387 ERR("Failed to find a suitable pixel format.\n");
388 goto fail;
390 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
391 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
393 /* Create a GL context. */
394 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
396 WARN("Failed to create default context for capabilities initialization.\n");
397 goto fail;
400 /* Make it the current GL context. */
401 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
403 ERR("Failed to make caps GL context current.\n");
404 goto fail;
407 ctx->gl_info = &adapter->gl_info;
408 return TRUE;
410 fail:
411 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
412 ctx->gl_ctx = NULL;
413 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
414 ctx->dc = NULL;
415 if (ctx->wnd) DestroyWindow(ctx->wnd);
416 ctx->wnd = NULL;
417 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
418 ERR("Failed to restore previous GL context.\n");
420 return FALSE;
423 /* Adjust the amount of used texture memory */
424 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
426 adapter->vram_bytes_used += amount;
427 TRACE("Adjusted used adapter memory by 0x%s to 0x%s.\n",
428 wine_dbgstr_longlong(amount),
429 wine_dbgstr_longlong(adapter->vram_bytes_used));
430 return adapter->vram_bytes_used;
433 static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
435 HeapFree(GetProcessHeap(), 0, adapter->gl_info.formats);
436 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
439 ULONG CDECL wined3d_incref(struct wined3d *wined3d)
441 ULONG refcount = InterlockedIncrement(&wined3d->ref);
443 TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
445 return refcount;
448 ULONG CDECL wined3d_decref(struct wined3d *wined3d)
450 ULONG refcount = InterlockedDecrement(&wined3d->ref);
452 TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
454 if (!refcount)
456 unsigned int i;
458 for (i = 0; i < wined3d->adapter_count; ++i)
460 wined3d_adapter_cleanup(&wined3d->adapters[i]);
462 HeapFree(GetProcessHeap(), 0, wined3d);
465 return refcount;
468 /* Context activation is done by the caller. */
469 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
471 GLuint prog;
472 BOOL ret = FALSE;
473 static const char testcode[] =
474 "!!ARBvp1.0\n"
475 "PARAM C[66] = { program.env[0..65] };\n"
476 "ADDRESS A0;"
477 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
478 "ARL A0.x, zero.x;\n"
479 "MOV result.position, C[A0.x + 65];\n"
480 "END\n";
482 while (gl_info->gl_ops.gl.p_glGetError());
483 GL_EXTCALL(glGenProgramsARB(1, &prog));
484 if(!prog) {
485 ERR("Failed to create an ARB offset limit test program\n");
487 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
488 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
489 strlen(testcode), testcode));
490 if (gl_info->gl_ops.gl.p_glGetError())
492 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
493 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
494 ret = TRUE;
495 } else TRACE("OpenGL implementation allows offsets > 63\n");
497 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
498 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
499 checkGLcall("ARB vp offset limit test cleanup");
501 return ret;
504 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
505 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
506 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
508 if (card_vendor != HW_VENDOR_AMD) return FALSE;
509 if (device == CARD_AMD_RADEON_9500) return TRUE;
510 if (device == CARD_AMD_RADEON_X700) return TRUE;
511 if (device == CARD_AMD_RADEON_X1600) return TRUE;
512 return FALSE;
515 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
516 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
517 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
519 if (card_vendor == HW_VENDOR_NVIDIA)
521 if (device == CARD_NVIDIA_GEFORCEFX_5200 ||
522 device == CARD_NVIDIA_GEFORCEFX_5600 ||
523 device == CARD_NVIDIA_GEFORCEFX_5800)
525 return TRUE;
528 return FALSE;
531 static BOOL match_apple(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
532 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
533 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
535 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
536 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
537 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
539 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
540 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
541 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
542 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
543 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
544 * the chance that other implementations support them is rather small since Win32 QuickTime uses
545 * DirectDraw, not OpenGL.
547 * This test has been moved into wined3d_guess_gl_vendor()
549 return gl_vendor == GL_VENDOR_APPLE;
552 /* Context activation is done by the caller. */
553 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
555 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
556 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
557 * all the texture. This function detects this bug by its symptom and disables PBOs
558 * if the test fails.
560 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
561 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
562 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
563 * read back is compared to the original. If they are equal PBOs are assumed to work,
564 * otherwise the PBO extension is disabled. */
565 GLuint texture, pbo;
566 static const unsigned int pattern[] =
568 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
569 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
570 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
571 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
573 unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
575 /* No PBO -> No point in testing them. */
576 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
578 while (gl_info->gl_ops.gl.p_glGetError());
579 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
580 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
582 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
583 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);
584 checkGLcall("Specifying the PBO test texture");
586 GL_EXTCALL(glGenBuffers(1, &pbo));
587 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo));
588 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pattern), pattern, GL_STREAM_DRAW));
589 checkGLcall("Specifying the PBO test pbo");
591 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);
592 checkGLcall("Loading the PBO test texture");
594 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
596 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
598 memset(check, 0, sizeof(check));
599 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
600 checkGLcall("Reading back the PBO test texture");
602 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
603 GL_EXTCALL(glDeleteBuffers(1, &pbo));
604 checkGLcall("PBO test cleanup");
606 if (memcmp(check, pattern, sizeof(check)))
608 WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
609 "Disabling PBOs. This may result in slower performance.\n");
610 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
612 else
614 TRACE("PBO test successful.\n");
618 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
619 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
620 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
622 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
625 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
626 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
627 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
629 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
630 if (card_vendor != HW_VENDOR_AMD) return FALSE;
631 if (device == CARD_AMD_RADEON_X1600) return FALSE;
632 return TRUE;
635 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
636 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
637 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
639 /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
640 * 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
641 * This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
642 * varyings and we subtract one in dx9 shaders it's not going to hurt us because the dx9 limit is
643 * hardcoded
645 * dx10 cards usually have 64 varyings */
646 return gl_info->limits.glsl_varyings > 44;
649 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
650 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
651 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
653 return !match_dx10_capable(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device);
656 /* A GL context is provided by the caller */
657 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
658 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
659 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
661 GLenum error;
662 DWORD data[16];
664 if (!gl_info->supported[EXT_SECONDARY_COLOR])
665 return FALSE;
667 while (gl_info->gl_ops.gl.p_glGetError());
668 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
669 error = gl_info->gl_ops.gl.p_glGetError();
671 if (error == GL_NO_ERROR)
673 TRACE("GL Implementation accepts 4 component specular color pointers\n");
674 return TRUE;
676 else
678 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
679 debug_glerror(error));
680 return FALSE;
684 /* A GL context is provided by the caller */
685 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
686 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
687 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
689 GLuint prog;
690 BOOL ret = FALSE;
691 GLint pos;
692 static const char testcode[] =
693 "!!ARBvp1.0\n"
694 "OPTION NV_vertex_program2;\n"
695 "MOV result.clip[0], 0.0;\n"
696 "MOV result.position, 0.0;\n"
697 "END\n";
699 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
701 while (gl_info->gl_ops.gl.p_glGetError());
703 GL_EXTCALL(glGenProgramsARB(1, &prog));
704 if(!prog)
706 ERR("Failed to create the NVvp clip test program\n");
707 return FALSE;
709 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
710 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
711 strlen(testcode), testcode));
712 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
713 if(pos != -1)
715 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
716 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
717 ret = TRUE;
718 while (gl_info->gl_ops.gl.p_glGetError());
720 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
722 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
723 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
724 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
726 return ret;
729 /* Context activation is done by the caller. */
730 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
731 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
732 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
734 char data[4 * 4 * 4];
735 GLuint tex, fbo;
736 GLenum status;
738 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
740 memset(data, 0xcc, sizeof(data));
742 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
743 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
744 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
745 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
746 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);
747 checkGLcall("glTexImage2D");
749 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
750 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
751 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
752 checkGLcall("glFramebufferTexture2D");
754 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
755 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
756 checkGLcall("glCheckFramebufferStatus");
758 memset(data, 0x11, sizeof(data));
759 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);
760 checkGLcall("glTexSubImage2D");
762 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
763 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
764 checkGLcall("glClear");
766 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
767 checkGLcall("glGetTexImage");
769 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
770 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
771 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
772 checkGLcall("glBindTexture");
774 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
775 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
776 checkGLcall("glDeleteTextures");
778 return *(DWORD *)data == 0x11111111;
781 /* Context activation is done by the caller. */
782 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
783 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
784 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
786 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
787 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
788 GLuint tex;
789 GLint size;
791 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
792 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
793 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
794 checkGLcall("glTexImage2D");
796 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
797 checkGLcall("glGetTexLevelParameteriv");
798 TRACE("Real color depth is %d\n", size);
800 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
801 checkGLcall("glBindTexture");
802 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
803 checkGLcall("glDeleteTextures");
805 return size < 16;
808 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
809 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
810 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
812 return gl_vendor == GL_VENDOR_FGLRX;
815 static BOOL match_r200(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
816 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
817 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
819 if (card_vendor != HW_VENDOR_AMD) return FALSE;
820 if (device == CARD_AMD_RADEON_8500) return TRUE;
821 return FALSE;
824 static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
825 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
826 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
828 DWORD data[4];
829 GLuint tex, fbo;
830 GLenum status;
831 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
832 GLuint prog;
833 GLint err_pos;
834 static const char program_code[] =
835 "!!ARBfp1.0\n"
836 "OPTION ARB_fog_linear;\n"
837 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
838 "END\n";
840 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
841 return FALSE;
842 if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
843 return FALSE;
845 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
846 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
847 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
848 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
849 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 4, 1, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
850 checkGLcall("glTexImage2D");
852 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
853 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
854 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
855 checkGLcall("glFramebufferTexture2D");
857 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
858 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
859 checkGLcall("glCheckFramebufferStatus");
861 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
862 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
863 checkGLcall("glClear");
864 gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
865 checkGLcall("glViewport");
867 gl_info->gl_ops.gl.p_glEnable(GL_FOG);
868 gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
869 gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
870 gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
871 gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
872 gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
873 checkGLcall("fog setup");
875 GL_EXTCALL(glGenProgramsARB(1, &prog));
876 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
877 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
878 strlen(program_code), program_code));
879 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
880 checkGLcall("Test fragment program setup");
882 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
883 if (err_pos != -1)
885 const char *error_str;
886 error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
887 FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
890 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
891 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
892 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
893 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
894 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
895 gl_info->gl_ops.gl.p_glEnd();
896 checkGLcall("ARBfp fog test draw");
898 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
899 checkGLcall("glGetTexImage");
900 data[0] &= 0x00ffffff;
901 data[1] &= 0x00ffffff;
902 data[2] &= 0x00ffffff;
903 data[3] &= 0x00ffffff;
905 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
906 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
908 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
909 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
910 gl_info->gl_ops.gl.p_glDisable(GL_FOG);
911 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
912 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
913 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
914 checkGLcall("ARBfp fog test teardown");
916 TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
917 return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
920 static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl_info,
921 struct wined3d_caps_gl_ctx *ctx, const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
922 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
924 if (!gl_info->supported[ARB_VIEWPORT_ARRAY])
925 return FALSE;
926 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
927 return FALSE;
928 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx);
931 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
933 /* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
934 * Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
935 * allow 48 different offsets or other helper immediate values. */
936 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
937 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
940 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
942 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
943 * these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
944 * If real NP2 textures are used, the driver falls back to software. We could just remove the
945 * extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconvenient
946 * due to the non-normalized texture coordinates. Thus set an internal extension flag,
947 * GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
948 * as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
950 * fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
951 * has this extension promoted to core. The extension loading code sets this extension supported
952 * due to that, so this code works on fglrx as well. */
953 if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
955 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
956 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
957 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
961 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
963 /* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
964 * doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
965 * This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
966 * within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
967 * FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
968 * We therefore completely remove ARB_tex_npot from the list of supported extensions.
970 * Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
971 * triggering the software fallback. There is not much we can do here apart from disabling the
972 * software-emulated extension and re-enable ARB_tex_rect (which was previously disabled
973 * in wined3d_adapter_init_gl_caps).
974 * This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
975 * post-processing effects in the game "Max Payne 2").
976 * The behaviour can be verified through a simple test app attached in bugreport #14724. */
977 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
978 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
979 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
982 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
984 /* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
985 * with fixed function fragment processing. Ideally this flag should be detected with a test shader
986 * and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
987 * do not like vertex shaders in feedback mode and return an error, even though it should be valid
988 * according to the spec.
990 * We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
991 * makes the shader slower and eats instruction slots which should be available to the d3d app.
993 * ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
994 * all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
995 * this workaround is activated on cards that do not need it, it won't break things, just affect
996 * performance negatively. */
997 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
998 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
1001 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
1003 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
1006 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
1008 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
1011 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
1013 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
1016 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
1018 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
1021 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
1023 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
1026 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
1028 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
1031 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
1033 /* Nvidia GeForce 6xxx and 7xxx support accelerated VTF only on a few
1034 selected texture formats. They are apparently the only DX9 class GPUs
1035 supporting VTF.
1036 Also, DX9-era GPUs are somewhat limited with float textures
1037 filtering and blending. */
1038 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
1041 static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
1043 /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
1044 * loads some fog parameters (start, end, exponent, but not the color) into the
1045 * program.
1047 * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
1048 * and it is the responsibility of the vertex pipeline to handle non-linear fog and
1049 * linear fog with start and end other than 0.0 and 1.0. */
1050 TRACE("Reserving 1 ARB constant for compiler private use.\n");
1051 gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
1054 static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
1056 gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
1059 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info *gl_info)
1061 TRACE("Disabling ARB_viewport_array.\n");
1062 gl_info->supported[ARB_VIEWPORT_ARRAY] = FALSE;
1063 if (gl_info->supported[ARB_CLIP_CONTROL])
1065 TRACE("Disabling ARB_clip_control.\n");
1066 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
1070 struct driver_quirk
1072 BOOL (*match)(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1073 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1074 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
1075 void (*apply)(struct wined3d_gl_info *gl_info);
1076 const char *description;
1079 static const struct driver_quirk quirk_table[] =
1082 match_amd_r300_to_500,
1083 quirk_amd_dx9,
1084 "AMD normalized texrect quirk"
1087 match_apple,
1088 quirk_apple_glsl_constants,
1089 "Apple GLSL uniform override"
1092 match_geforce5,
1093 quirk_no_np2,
1094 "Geforce 5 NP2 disable"
1097 match_apple_intel,
1098 quirk_texcoord_w,
1099 "Init texcoord .w for Apple Intel GPU driver"
1102 match_apple_nonr500ati,
1103 quirk_texcoord_w,
1104 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1107 match_dx10_capable,
1108 quirk_clip_varying,
1109 "Reserved varying for gl_ClipPos"
1112 /* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
1113 * GL implementations accept it. The Mac GL is the only implementation known to
1114 * reject it.
1116 * If we can pass 4 component specular colors, do it, because (a) we don't have
1117 * to screw around with the data, and (b) the D3D fixed function vertex pipeline
1118 * passes specular alpha to the pixel shader if any is used. Otherwise the
1119 * specular alpha is used to pass the fog coordinate, which we pass to opengl
1120 * via GL_EXT_fog_coord.
1122 match_allows_spec_alpha,
1123 quirk_allows_specular_alpha,
1124 "Allow specular alpha quirk"
1127 match_broken_nv_clip,
1128 quirk_disable_nvvp_clip,
1129 "Apple NV_vertex_program clip bug quirk"
1132 match_fbo_tex_update,
1133 quirk_fbo_tex_update,
1134 "FBO rebind for attachment updates"
1137 match_broken_rgba16,
1138 quirk_broken_rgba16,
1139 "True RGBA16 is not available"
1142 match_fglrx,
1143 quirk_infolog_spam,
1144 "Not printing GLSL infolog"
1147 match_not_dx10_capable,
1148 quirk_limited_tex_filtering,
1149 "Texture filtering, blending and VTF support is limited"
1152 match_r200,
1153 quirk_r200_constants,
1154 "r200 vertex shader constants"
1157 match_broken_arb_fog,
1158 quirk_broken_arb_fog,
1159 "ARBfp fogstart == fogend workaround"
1162 match_broken_viewport_subpixel_bits,
1163 quirk_broken_viewport_subpixel_bits,
1164 "Nvidia viewport subpixel bits bug"
1168 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
1169 * reporting a driver version is moot because we are not the Windows driver, and we have different
1170 * bugs, features, etc.
1172 * The driver version has the form "x.y.z.w".
1174 * "x" is the Windows version the driver is meant for:
1175 * 4 -> 95/98/NT4
1176 * 5 -> 2000
1177 * 6 -> 2000/XP
1178 * 7 -> Vista
1179 * 8 -> Win 7
1181 * "y" is the maximum Direct3D version the driver supports.
1182 * y -> d3d version mapping:
1183 * 11 -> d3d6
1184 * 12 -> d3d7
1185 * 13 -> d3d8
1186 * 14 -> d3d9
1187 * 15 -> d3d10
1188 * 16 -> d3d10.1
1189 * 17 -> d3d11
1191 * "z" is the subversion number.
1193 * "w" is the vendor specific driver build number.
1196 struct driver_version_information
1198 enum wined3d_display_driver driver;
1199 enum wined3d_driver_model driver_model;
1200 const char *driver_name; /* name of Windows driver */
1201 WORD version; /* version word ('y'), contained in low word of DriverVersion.HighPart */
1202 WORD subversion; /* subversion word ('z'), contained in high word of DriverVersion.LowPart */
1203 WORD build; /* build number ('w'), contained in low word of DriverVersion.LowPart */
1206 /* The driver version table contains driver information for different devices on several OS versions. */
1207 static const struct driver_version_information driver_version_table[] =
1209 /* AMD
1210 * - Radeon HD2x00 (R600) and up supported by current drivers.
1211 * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
1212 * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
1213 * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
1214 {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
1215 {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
1216 {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
1217 {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 17, 10, 1280},
1218 {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
1219 {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 17, 10, 1280},
1220 {DRIVER_AMD_RX, DRIVER_MODEL_NT6X, "aticfx32.dll", 17, 10, 1474},
1222 /* Intel
1223 * The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
1224 * drivers used ialmrnt5.dll for GMA800/GMA900 but at some point the file was renamed to
1225 * igxprd32.dll but the GMA800 driver was never updated. */
1226 {DRIVER_INTEL_GMA800, DRIVER_MODEL_NT5X, "ialmrnt5.dll", 14, 10, 3889},
1227 {DRIVER_INTEL_GMA900, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4764},
1228 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 4926},
1229 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT5X, "igxprd32.dll", 14, 10, 5218},
1230 {DRIVER_INTEL_GMA950, DRIVER_MODEL_NT6X, "igdumd32.dll", 14, 10, 1504},
1231 {DRIVER_INTEL_GMA3000, DRIVER_MODEL_NT6X, "igdumd32.dll", 15, 10, 1666},
1232 {DRIVER_INTEL_HD4000, DRIVER_MODEL_NT6X, "igdumdim32.dll", 19, 15, 4352},
1234 /* Nvidia
1235 * - Geforce8 and newer is supported by the current 340.52 driver on XP-Win8
1236 * - Geforce6 and 7 support is up to 307.83 on XP-Win8
1237 * - GeforceFX support is up to 173.x on <= XP
1238 * - Geforce2MX/3/4 up to 96.x on <= XP
1239 * - TNT/Geforce1/2 up to 71.x on <= XP
1240 * All version numbers used below are from the Linux nvidia drivers. */
1241 {DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
1242 {DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
1243 {DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
1244 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 783},
1245 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT5X, "nv4_disp.dll", 18, 13, 4052},
1246 {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 783},
1247 {DRIVER_NVIDIA_GEFORCE8, DRIVER_MODEL_NT6X, "nvd3dum.dll", 18, 13, 4052},
1249 /* VMware */
1250 {DRIVER_VMWARE, DRIVER_MODEL_NT5X, "vm3dum.dll", 14, 1, 1134},
1253 struct gpu_description
1255 WORD vendor; /* reported PCI card vendor ID */
1256 WORD card; /* reported PCI card device ID */
1257 const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
1258 enum wined3d_display_driver driver;
1259 unsigned int vidmem;
1262 /* The amount of video memory stored in the gpu description table is the minimum amount of video memory
1263 * found on a board containing a specific GPU. */
1264 static const struct gpu_description gpu_description_table[] =
1266 /* Nvidia cards */
1267 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "NVIDIA RIVA 128", DRIVER_NVIDIA_TNT, 4 },
1268 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", DRIVER_NVIDIA_TNT, 16 },
1269 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", DRIVER_NVIDIA_TNT, 32 },
1270 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", DRIVER_NVIDIA_TNT, 32 },
1271 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", DRIVER_NVIDIA_TNT, 32 },
1272 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", DRIVER_NVIDIA_GEFORCE2MX,32 },
1273 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", DRIVER_NVIDIA_GEFORCE2MX,64 },
1274 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", DRIVER_NVIDIA_GEFORCE2MX,64 },
1275 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", DRIVER_NVIDIA_GEFORCE2MX,64, },
1276 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", DRIVER_NVIDIA_GEFORCEFX, 64 },
1277 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", DRIVER_NVIDIA_GEFORCEFX, 128 },
1278 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", DRIVER_NVIDIA_GEFORCEFX, 256 },
1279 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", DRIVER_NVIDIA_GEFORCE6, 64 },
1280 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", DRIVER_NVIDIA_GEFORCE6, 128 },
1281 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", DRIVER_NVIDIA_GEFORCE6, 128 },
1282 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", DRIVER_NVIDIA_GEFORCE6, 256 },
1283 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", DRIVER_NVIDIA_GEFORCE6, 256 },
1284 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1285 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", DRIVER_NVIDIA_GEFORCE6, 256 },
1286 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8200, "NVIDIA GeForce 8200", DRIVER_NVIDIA_GEFORCE8, 512 },
1287 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1288 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8400GS, "NVIDIA GeForce 8400 GS", DRIVER_NVIDIA_GEFORCE8, 128 },
1289 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8500GT, "NVIDIA GeForce 8500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1290 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1291 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1292 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", DRIVER_NVIDIA_GEFORCE8, 320 },
1293 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTX, "NVIDIA GeForce 8800 GTX", DRIVER_NVIDIA_GEFORCE8, 768 },
1294 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", DRIVER_NVIDIA_GEFORCE8, 256 },
1295 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9300, "NVIDIA GeForce 9300", DRIVER_NVIDIA_GEFORCE8, 256 },
1296 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400M, "NVIDIA GeForce 9400M", DRIVER_NVIDIA_GEFORCE8, 256 },
1297 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1298 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", DRIVER_NVIDIA_GEFORCE8, 256 },
1299 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1300 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9700MGT, "NVIDIA GeForce 9700M GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1301 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", DRIVER_NVIDIA_GEFORCE8, 512 },
1302 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_210, "NVIDIA GeForce 210", DRIVER_NVIDIA_GEFORCE8, 512 },
1303 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT220, "NVIDIA GeForce GT 220", DRIVER_NVIDIA_GEFORCE8, 512 },
1304 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", DRIVER_NVIDIA_GEFORCE8, 512 },
1305 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS250, "NVIDIA GeForce GTS 250", DRIVER_NVIDIA_GEFORCE8, 1024},
1306 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE8, 1024},
1307 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE8, 896 },
1308 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE8, 1024},
1309 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_315M, "NVIDIA GeForce 315M", DRIVER_NVIDIA_GEFORCE8, 512 },
1310 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_320M, "NVIDIA GeForce 320M", DRIVER_NVIDIA_GEFORCE8, 256},
1311 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE8, 1024},
1312 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE8, 1024},
1313 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE8, 1024},
1314 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE8, 1024},
1315 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_410M, "NVIDIA GeForce 410M", DRIVER_NVIDIA_GEFORCE8, 512},
1316 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE8, 2048},
1317 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT425M, "NVIDIA GeForce GT 425M", DRIVER_NVIDIA_GEFORCE8, 1024},
1318 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE8, 1024},
1319 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE8, 1024},
1320 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE8, 1024},
1321 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE8, 768 },
1322 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460M, "NVIDIA GeForce GTX 460M", DRIVER_NVIDIA_GEFORCE8, 1536},
1323 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE8, 1024},
1324 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE8, 1280},
1325 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE8, 1536},
1326 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT520, "NVIDIA GeForce GT 520", DRIVER_NVIDIA_GEFORCE8, 1024},
1327 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT525M, "NVIDIA GeForce GT 525M", DRIVER_NVIDIA_GEFORCE8, 1024},
1328 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT540M, "NVIDIA GeForce GT 540M", DRIVER_NVIDIA_GEFORCE8, 1024},
1329 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1330 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024},
1331 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1332 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024},
1333 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280},
1334 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536},
1335 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT610, "NVIDIA GeForce GT 610", DRIVER_NVIDIA_GEFORCE8, 1024},
1336 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630, "NVIDIA GeForce GT 630", DRIVER_NVIDIA_GEFORCE8, 1024},
1337 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT630M, "NVIDIA GeForce GT 630M", DRIVER_NVIDIA_GEFORCE8, 1024},
1338 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT640M, "NVIDIA GeForce GT 640M", DRIVER_NVIDIA_GEFORCE8, 1024},
1339 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT650M, "NVIDIA GeForce GT 650M", DRIVER_NVIDIA_GEFORCE8, 2048},
1340 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650, "NVIDIA GeForce GTX 650", DRIVER_NVIDIA_GEFORCE8, 1024},
1341 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX650TI, "NVIDIA GeForce GTX 650 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
1342 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660, "NVIDIA GeForce GTX 660", DRIVER_NVIDIA_GEFORCE8, 2048},
1343 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660M, "NVIDIA GeForce GTX 660M", DRIVER_NVIDIA_GEFORCE8, 2048},
1344 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX660TI, "NVIDIA GeForce GTX 660 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1345 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE8, 2048},
1346 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE8, 3072},
1347 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX675MX, "NVIDIA GeForce GTX 675MX", DRIVER_NVIDIA_GEFORCE8, 4096},
1348 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE8, 2048},
1349 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX690, "NVIDIA GeForce GTX 690", DRIVER_NVIDIA_GEFORCE8, 2048},
1350 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730, "NVIDIA GeForce GT 730", DRIVER_NVIDIA_GEFORCE8, 2048},
1351 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT730M, "NVIDIA GeForce GT 730M", DRIVER_NVIDIA_GEFORCE8, 1024},
1352 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT740M, "NVIDIA GeForce GT 740M", DRIVER_NVIDIA_GEFORCE8, 2048},
1353 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_GEFORCE8, 1024},
1354 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_GEFORCE8, 1024},
1355 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1356 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA GeForce GTX 760", DRIVER_NVIDIA_GEFORCE8, 2048},
1357 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760TI, "NVIDIA GeForce GTX 760 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
1358 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX765M, "NVIDIA GeForce GTX 765M", DRIVER_NVIDIA_GEFORCE8, 2048},
1359 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770M, "NVIDIA GeForce GTX 770M", DRIVER_NVIDIA_GEFORCE8, 3072},
1360 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX770, "NVIDIA GeForce GTX 770", DRIVER_NVIDIA_GEFORCE8, 2048},
1361 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780, "NVIDIA GeForce GTX 780", DRIVER_NVIDIA_GEFORCE8, 3072},
1362 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX780TI, "NVIDIA GeForce GTX 780 Ti", DRIVER_NVIDIA_GEFORCE8, 3072},
1363 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITAN, "NVIDIA GeForce GTX TITAN", DRIVER_NVIDIA_GEFORCE8, 6144},
1364 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANB, "NVIDIA GeForce GTX TITAN Black", DRIVER_NVIDIA_GEFORCE8, 6144},
1365 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANX, "NVIDIA GeForce GTX TITAN X", DRIVER_NVIDIA_GEFORCE8, 12288},
1366 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTXTITANZ, "NVIDIA GeForce GTX TITAN Z", DRIVER_NVIDIA_GEFORCE8, 12288},
1367 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_820M, "NVIDIA GeForce 820M", DRIVER_NVIDIA_GEFORCE8, 2048},
1368 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_830M, "NVIDIA GeForce 830M", DRIVER_NVIDIA_GEFORCE8, 2048},
1369 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_840M, "NVIDIA GeForce 840M", DRIVER_NVIDIA_GEFORCE8, 2048},
1370 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_845M, "NVIDIA GeForce 845M", DRIVER_NVIDIA_GEFORCE8, 2048},
1371 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX850M, "NVIDIA GeForce GTX 850M", DRIVER_NVIDIA_GEFORCE8, 2048},
1372 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX860M, "NVIDIA GeForce GTX 860M", DRIVER_NVIDIA_GEFORCE8, 2048},
1373 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX870M, "NVIDIA GeForce GTX 870M", DRIVER_NVIDIA_GEFORCE8, 3072},
1374 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX880M, "NVIDIA GeForce GTX 880M", DRIVER_NVIDIA_GEFORCE8, 4096},
1375 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_940M, "NVIDIA GeForce 940M", DRIVER_NVIDIA_GEFORCE8, 4096},
1376 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950, "NVIDIA GeForce GTX 950", DRIVER_NVIDIA_GEFORCE8, 2048},
1377 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX950M, "NVIDIA GeForce GTX 950M", DRIVER_NVIDIA_GEFORCE8, 4096},
1378 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960, "NVIDIA GeForce GTX 960", DRIVER_NVIDIA_GEFORCE8, 4096},
1379 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX960M, "NVIDIA GeForce GTX 960M", DRIVER_NVIDIA_GEFORCE8, 2048},
1380 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970, "NVIDIA GeForce GTX 970", DRIVER_NVIDIA_GEFORCE8, 4096},
1381 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX970M, "NVIDIA GeForce GTX 970M", DRIVER_NVIDIA_GEFORCE8, 3072},
1382 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980, "NVIDIA GeForce GTX 980", DRIVER_NVIDIA_GEFORCE8, 4096},
1383 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX980TI, "NVIDIA GeForce GTX 980 Ti", DRIVER_NVIDIA_GEFORCE8, 6144},
1384 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1050, "NVIDIA GeForce GTX 1050", DRIVER_NVIDIA_GEFORCE8, 2048},
1385 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1060, "NVIDIA GeForce GTX 1060", DRIVER_NVIDIA_GEFORCE8, 6144},
1386 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1070, "NVIDIA GeForce GTX 1070", DRIVER_NVIDIA_GEFORCE8, 8192},
1387 {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX1080, "NVIDIA GeForce GTX 1080", DRIVER_NVIDIA_GEFORCE8, 8192},
1389 /* AMD cards */
1390 {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
1391 {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
1392 {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
1393 {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
1394 {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
1395 {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
1396 {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
1397 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
1398 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
1399 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
1400 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
1401 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3850, "ATI Radeon HD 3850 AGP", DRIVER_AMD_R600, 512 },
1402 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4200M, "ATI Mobility Radeon HD 4200", DRIVER_AMD_R600, 256 },
1403 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
1404 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
1405 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
1406 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
1407 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
1408 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
1409 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
1410 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
1411 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
1412 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6300, "AMD Radeon HD 6300 series Graphics", DRIVER_AMD_R600, 1024},
1413 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6400, "AMD Radeon HD 6400 Series", DRIVER_AMD_R600, 1024},
1414 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6410D, "AMD Radeon HD 6410D", DRIVER_AMD_R600, 1024},
1415 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6480G, "AMD Radeon HD 6480G", DRIVER_AMD_R600, 512 },
1416 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6550D, "AMD Radeon HD 6550D", DRIVER_AMD_R600, 1024},
1417 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600, "AMD Radeon HD 6600 Series", DRIVER_AMD_R600, 1024},
1418 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6600M, "AMD Radeon HD 6600M Series", DRIVER_AMD_R600, 512 },
1419 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6700, "AMD Radeon HD 6700 Series", DRIVER_AMD_R600, 1024},
1420 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
1421 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
1422 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7660D, "AMD Radeon HD 7660D", DRIVER_AMD_R600, 2048},
1423 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7700, "AMD Radeon HD 7700 Series", DRIVER_AMD_R600, 1024},
1424 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7800, "AMD Radeon HD 7800 Series", DRIVER_AMD_R600, 2048},
1425 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD7900, "AMD Radeon HD 7900 Series", DRIVER_AMD_R600, 2048},
1426 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8600M, "AMD Radeon HD 8600M Series", DRIVER_AMD_R600, 1024},
1427 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8670, "AMD Radeon HD 8670", DRIVER_AMD_R600, 2048},
1428 {HW_VENDOR_AMD, CARD_AMD_RADEON_HD8770, "AMD Radeon HD 8770", DRIVER_AMD_R600, 2048},
1429 {HW_VENDOR_AMD, CARD_AMD_RADEON_R3, "AMD Radeon HD 8400 / R3 Series", DRIVER_AMD_R600, 2048},
1430 {HW_VENDOR_AMD, CARD_AMD_RADEON_R7, "AMD Radeon(TM) R7 Graphics", DRIVER_AMD_R600, 2048},
1431 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_285, "AMD Radeon R9 285", DRIVER_AMD_RX, 2048},
1432 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_290, "AMD Radeon R9 290", DRIVER_AMD_RX, 4096},
1433 {HW_VENDOR_AMD, CARD_AMD_RADEON_R9_FURY, "AMD Radeon (TM) R9 Fury Series", DRIVER_AMD_RX, 4096},
1434 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_460, "Radeon(TM) RX 460 Graphics", DRIVER_AMD_RX, 4096},
1435 {HW_VENDOR_AMD, CARD_AMD_RADEON_RX_480, "Radeon (TM) RX 480 Graphics", DRIVER_AMD_RX, 4096},
1437 /* VMware */
1438 {HW_VENDOR_VMWARE, CARD_VMWARE_SVGA3D, "VMware SVGA 3D (Microsoft Corporation - WDDM)", DRIVER_VMWARE, 1024},
1440 /* Intel cards */
1441 {HW_VENDOR_INTEL, CARD_INTEL_830M, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1442 {HW_VENDOR_INTEL, CARD_INTEL_855GM, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1443 {HW_VENDOR_INTEL, CARD_INTEL_845G, "Intel(R) 845G", DRIVER_INTEL_GMA800, 32 },
1444 {HW_VENDOR_INTEL, CARD_INTEL_865G, "Intel(R) 82865G Graphics Controller", DRIVER_INTEL_GMA800, 32 },
1445 {HW_VENDOR_INTEL, CARD_INTEL_915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1446 {HW_VENDOR_INTEL, CARD_INTEL_E7221G, "Intel(R) E7221G", DRIVER_INTEL_GMA900, 64 },
1447 {HW_VENDOR_INTEL, CARD_INTEL_915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
1448 {HW_VENDOR_INTEL, CARD_INTEL_945G, "Intel(R) 945G", DRIVER_INTEL_GMA950, 64 },
1449 {HW_VENDOR_INTEL, CARD_INTEL_945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
1450 {HW_VENDOR_INTEL, CARD_INTEL_945GME, "Intel(R) 945GME", DRIVER_INTEL_GMA950, 64 },
1451 {HW_VENDOR_INTEL, CARD_INTEL_Q35, "Intel(R) Q35", DRIVER_INTEL_GMA950, 64 },
1452 {HW_VENDOR_INTEL, CARD_INTEL_G33, "Intel(R) G33", DRIVER_INTEL_GMA950, 64 },
1453 {HW_VENDOR_INTEL, CARD_INTEL_Q33, "Intel(R) Q33", DRIVER_INTEL_GMA950, 64 },
1454 {HW_VENDOR_INTEL, CARD_INTEL_PNVG, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1455 {HW_VENDOR_INTEL, CARD_INTEL_PNVM, "Intel(R) IGD", DRIVER_INTEL_GMA950, 64 },
1456 {HW_VENDOR_INTEL, CARD_INTEL_965Q, "Intel(R) 965Q", DRIVER_INTEL_GMA3000, 128},
1457 {HW_VENDOR_INTEL, CARD_INTEL_965G, "Intel(R) 965G", DRIVER_INTEL_GMA3000, 128},
1458 {HW_VENDOR_INTEL, CARD_INTEL_946GZ, "Intel(R) 946GZ", DRIVER_INTEL_GMA3000, 128},
1459 {HW_VENDOR_INTEL, CARD_INTEL_965GM, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
1460 {HW_VENDOR_INTEL, CARD_INTEL_965GME, "Intel(R) 965GME", DRIVER_INTEL_GMA3000, 128},
1461 {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512},
1462 {HW_VENDOR_INTEL, CARD_INTEL_IGD, "Intel(R) Integrated Graphics Device", DRIVER_INTEL_GMA3000, 512},
1463 {HW_VENDOR_INTEL, CARD_INTEL_G45, "Intel(R) G45/G43", DRIVER_INTEL_GMA3000, 512},
1464 {HW_VENDOR_INTEL, CARD_INTEL_Q45, "Intel(R) Q45/Q43", DRIVER_INTEL_GMA3000, 512},
1465 {HW_VENDOR_INTEL, CARD_INTEL_G41, "Intel(R) G41", DRIVER_INTEL_GMA3000, 512},
1466 {HW_VENDOR_INTEL, CARD_INTEL_B43, "Intel(R) B43", DRIVER_INTEL_GMA3000, 512},
1467 {HW_VENDOR_INTEL, CARD_INTEL_ILKD, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1468 {HW_VENDOR_INTEL, CARD_INTEL_ILKM, "Intel(R) HD Graphics", DRIVER_INTEL_GMA3000, 1536},
1469 {HW_VENDOR_INTEL, CARD_INTEL_SNBD, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1470 {HW_VENDOR_INTEL, CARD_INTEL_SNBM, "Intel(R) HD Graphics 3000", DRIVER_INTEL_GMA3000, 1536},
1471 {HW_VENDOR_INTEL, CARD_INTEL_SNBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_GMA3000, 1536},
1472 {HW_VENDOR_INTEL, CARD_INTEL_IVBD, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1473 {HW_VENDOR_INTEL, CARD_INTEL_IVBM, "Intel(R) HD Graphics 4000", DRIVER_INTEL_HD4000, 1536},
1474 {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
1475 {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1476 {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
1477 {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1478 {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1479 {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1480 {HW_VENDOR_INTEL, CARD_INTEL_I5100_4, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
1481 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_1, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1482 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_2, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1483 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_3, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1484 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_4, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1485 {HW_VENDOR_INTEL, CARD_INTEL_IP5200_5, "Intel(R) Iris(TM) Pro Graphics 5200", DRIVER_INTEL_HD4000, 1536},
1486 {HW_VENDOR_INTEL, CARD_INTEL_HD5300, "Intel(R) HD Graphics 5300", DRIVER_INTEL_HD4000, 2048},
1487 {HW_VENDOR_INTEL, CARD_INTEL_HD5500, "Intel(R) HD Graphics 5500", DRIVER_INTEL_HD4000, 2048},
1488 {HW_VENDOR_INTEL, CARD_INTEL_HD5600, "Intel(R) HD Graphics 5600", DRIVER_INTEL_HD4000, 2048},
1489 {HW_VENDOR_INTEL, CARD_INTEL_HD6000, "Intel(R) HD Graphics 6000", DRIVER_INTEL_HD4000, 2048},
1490 {HW_VENDOR_INTEL, CARD_INTEL_I6100, "Intel(R) Iris(TM) Graphics 6100", DRIVER_INTEL_HD4000, 2048},
1491 {HW_VENDOR_INTEL, CARD_INTEL_IP6200, "Intel(R) Iris(TM) Pro Graphics 6200", DRIVER_INTEL_HD4000, 2048},
1492 {HW_VENDOR_INTEL, CARD_INTEL_IPP6300, "Intel(R) Iris(TM) Pro Graphics P6300", DRIVER_INTEL_HD4000, 2048},
1493 {HW_VENDOR_INTEL, CARD_INTEL_HD510_1, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1494 {HW_VENDOR_INTEL, CARD_INTEL_HD510_2, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1495 {HW_VENDOR_INTEL, CARD_INTEL_HD510_3, "Intel(R) HD Graphics 510", DRIVER_INTEL_HD4000, 2048},
1496 {HW_VENDOR_INTEL, CARD_INTEL_HD515, "Intel(R) HD Graphics 515", DRIVER_INTEL_HD4000, 2048},
1497 {HW_VENDOR_INTEL, CARD_INTEL_HD520_1, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1498 {HW_VENDOR_INTEL, CARD_INTEL_HD520_2, "Intel(R) HD Graphics 520", DRIVER_INTEL_HD4000, 2048},
1499 {HW_VENDOR_INTEL, CARD_INTEL_HD530_1, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1500 {HW_VENDOR_INTEL, CARD_INTEL_HD530_2, "Intel(R) HD Graphics 530", DRIVER_INTEL_HD4000, 2048},
1501 {HW_VENDOR_INTEL, CARD_INTEL_HDP530, "Intel(R) HD Graphics P530", DRIVER_INTEL_HD4000, 2048},
1502 {HW_VENDOR_INTEL, CARD_INTEL_I540, "Intel(R) Iris(TM) Graphics 540", DRIVER_INTEL_HD4000, 2048},
1503 {HW_VENDOR_INTEL, CARD_INTEL_I550, "Intel(R) Iris(TM) Graphics 550", DRIVER_INTEL_HD4000, 2048},
1504 {HW_VENDOR_INTEL, CARD_INTEL_I555, "Intel(R) Iris(TM) Graphics 555", DRIVER_INTEL_HD4000, 2048},
1505 {HW_VENDOR_INTEL, CARD_INTEL_IP555, "Intel(R) Iris(TM) Graphics P555", DRIVER_INTEL_HD4000, 2048},
1506 {HW_VENDOR_INTEL, CARD_INTEL_IP580_1, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1507 {HW_VENDOR_INTEL, CARD_INTEL_IP580_2, "Intel(R) Iris(TM) Pro Graphics 580", DRIVER_INTEL_HD4000, 2048},
1508 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_1, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1509 {HW_VENDOR_INTEL, CARD_INTEL_IPP580_2, "Intel(R) Iris(TM) Pro Graphics P580", DRIVER_INTEL_HD4000, 2048},
1512 static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
1513 enum wined3d_driver_model driver_model)
1515 unsigned int i;
1517 TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
1518 for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
1520 const struct driver_version_information *entry = &driver_version_table[i];
1522 if (entry->driver == driver && (driver_model == DRIVER_MODEL_GENERIC
1523 || entry->driver_model == driver_model))
1525 TRACE("Found driver \"%s\", version %u, subversion %u, build %u.\n",
1526 entry->driver_name, entry->version, entry->subversion, entry->build);
1527 return entry;
1530 return NULL;
1533 static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor vendor,
1534 enum wined3d_pci_device device)
1536 unsigned int i;
1538 for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i)
1540 if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
1541 return &gpu_description_table[i];
1544 return NULL;
1547 static const struct gpu_description *query_gpu_description(const struct wined3d_gl_info *gl_info, UINT64 *vram_bytes)
1549 enum wined3d_pci_vendor vendor = PCI_VENDOR_NONE;
1550 enum wined3d_pci_device device = PCI_DEVICE_NONE;
1551 const struct gpu_description *gpu_description;
1552 static unsigned int once;
1554 if (gl_info->supported[WGL_WINE_QUERY_RENDERER])
1556 GLuint value;
1558 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE, &value)))
1559 vendor = value;
1560 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE, &value)))
1561 device = value;
1562 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE, &value)))
1563 *vram_bytes = (UINT64)value * 1024 * 1024;
1564 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1565 vendor, device, wine_dbgstr_longlong(*vram_bytes));
1568 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1570 vendor = wined3d_settings.pci_vendor_id;
1571 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor);
1574 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1576 device = wined3d_settings.pci_device_id;
1577 TRACE("Overriding device PCI ID with 0x%04x.\n", device);
1580 if (wined3d_settings.emulated_textureram)
1582 *vram_bytes = wined3d_settings.emulated_textureram;
1583 TRACE("Overriding amount of video memory with 0x%s bytes.\n",
1584 wine_dbgstr_longlong(*vram_bytes));
1587 if (!(gpu_description = get_gpu_description(vendor, device))
1588 && (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE
1589 || wined3d_settings.pci_device_id != PCI_DEVICE_NONE) && !once++)
1590 ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor, device);
1592 return gpu_description;
1595 static void init_driver_info(struct wined3d_driver_info *driver_info,
1596 const struct gpu_description *gpu_desc, UINT64 vram_bytes)
1598 OSVERSIONINFOW os_version;
1599 WORD driver_os_version;
1600 enum wined3d_display_driver driver;
1601 enum wined3d_driver_model driver_model;
1602 const struct driver_version_information *version_info;
1604 memset(&os_version, 0, sizeof(os_version));
1605 os_version.dwOSVersionInfoSize = sizeof(os_version);
1606 if (!GetVersionExW(&os_version))
1608 ERR("Failed to get OS version, reporting 2000/XP.\n");
1609 driver_os_version = 6;
1610 driver_model = DRIVER_MODEL_NT5X;
1612 else
1614 TRACE("OS version %u.%u.\n", os_version.dwMajorVersion, os_version.dwMinorVersion);
1615 switch (os_version.dwMajorVersion)
1617 case 4:
1618 /* If needed we could distinguish between 9x and NT4, but this code won't make
1619 * sense for NT4 since it had no way to obtain this info through DirectDraw 3.0.
1621 driver_os_version = 4;
1622 driver_model = DRIVER_MODEL_WIN9X;
1623 break;
1625 case 5:
1626 driver_os_version = 6;
1627 driver_model = DRIVER_MODEL_NT5X;
1628 break;
1630 case 6:
1631 if (os_version.dwMinorVersion == 0)
1633 driver_os_version = 7;
1634 driver_model = DRIVER_MODEL_NT6X;
1636 else if (os_version.dwMinorVersion == 1)
1638 driver_os_version = 8;
1639 driver_model = DRIVER_MODEL_NT6X;
1641 else
1643 if (os_version.dwMinorVersion > 2)
1645 FIXME("Unhandled OS version %u.%u, reporting Win 8.\n",
1646 os_version.dwMajorVersion, os_version.dwMinorVersion);
1648 driver_os_version = 9;
1649 driver_model = DRIVER_MODEL_NT6X;
1651 break;
1653 case 10:
1654 driver_os_version = 10;
1655 driver_model = DRIVER_MODEL_NT6X;
1656 break;
1658 default:
1659 FIXME("Unhandled OS version %u.%u, reporting 2000/XP.\n",
1660 os_version.dwMajorVersion, os_version.dwMinorVersion);
1661 driver_os_version = 6;
1662 driver_model = DRIVER_MODEL_NT5X;
1663 break;
1667 driver_info->vendor = gpu_desc->vendor;
1668 driver_info->device = gpu_desc->card;
1669 driver_info->description = gpu_desc->description;
1670 driver_info->vram_bytes = vram_bytes ? vram_bytes : (UINT64)gpu_desc->vidmem * 1024 * 1024;
1671 driver = gpu_desc->driver;
1674 * Diablo 2 crashes when the amount of video memory is greater than 0x7fffffff.
1675 * In order to avoid this application bug we limit the amount of video memory
1676 * to LONG_MAX for older Windows versions.
1678 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
1680 TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
1681 driver_info->vram_bytes = LONG_MAX;
1684 /* Try to obtain driver version information for the current Windows version. This fails in
1685 * some cases:
1686 * - the gpu is not available on the currently selected OS version:
1687 * - Geforce GTX480 on Win98. When running applications in compatibility mode on Windows,
1688 * version information for the current Windows version is returned instead of faked info.
1689 * We do the same and assume the default Windows version to emulate is WinXP.
1691 * - Videocard is a Riva TNT but winver is set to win7 (there are no drivers for this beast)
1692 * For now return the XP driver info. Perhaps later on we should return VESA.
1694 * - the gpu is not in our database (can happen when the user overrides the vendor_id / device_id)
1695 * This could be an indication that our database is not up to date, so this should be fixed.
1697 if ((version_info = get_driver_version_info(driver, driver_model))
1698 || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))
1700 driver_info->name = version_info->driver_name;
1701 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, version_info->version);
1702 driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);
1704 else
1706 ERR("No driver version info found for device %04x:%04x, driver model %#x.\n",
1707 driver_info->vendor, driver_info->device, driver_model);
1708 driver_info->name = "Display";
1709 driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, 15);
1710 driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
1713 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
1714 driver_info->version_high, driver_info->version_low);
1717 /* Context activation is done by the caller. */
1718 static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1719 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1720 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1722 unsigned int i;
1724 for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
1726 if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
1727 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1728 quirk_table[i].apply(gl_info);
1731 /* Find out if PBOs work as they are supposed to. */
1732 test_pbo_functionality(gl_info);
1735 static DWORD wined3d_parse_gl_version(const char *gl_version)
1737 const char *ptr = gl_version;
1738 int major, minor;
1740 major = atoi(ptr);
1741 if (major <= 0)
1742 ERR("Invalid OpenGL major version %d.\n", major);
1744 while (isdigit(*ptr)) ++ptr;
1745 if (*ptr++ != '.')
1746 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1748 minor = atoi(ptr);
1750 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1752 return MAKEDWORD_VERSION(major, minor);
1755 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1756 const char *gl_vendor_string, const char *gl_renderer)
1758 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1759 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1760 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1762 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1763 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1764 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1765 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1766 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1767 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1768 * DirectDraw, not OpenGL. */
1769 if (gl_info->supported[APPLE_FENCE] && gl_info->supported[APPLE_YCBCR_422])
1770 return GL_VENDOR_APPLE;
1772 if (strstr(gl_vendor_string, "NVIDIA"))
1773 return GL_VENDOR_NVIDIA;
1775 if (strstr(gl_vendor_string, "ATI"))
1776 return GL_VENDOR_FGLRX;
1778 if (strstr(gl_vendor_string, "Mesa")
1779 || strstr(gl_vendor_string, "X.Org")
1780 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1781 || strstr(gl_vendor_string, "DRI R300 Project")
1782 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1783 || strstr(gl_vendor_string, "VMware, Inc.")
1784 || strstr(gl_vendor_string, "Intel")
1785 || strstr(gl_renderer, "Mesa")
1786 || strstr(gl_renderer, "Gallium")
1787 || strstr(gl_renderer, "Intel"))
1788 return GL_VENDOR_MESA;
1790 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1791 debugstr_a(gl_vendor_string));
1793 return GL_VENDOR_UNKNOWN;
1796 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1798 if (strstr(gl_vendor_string, "NVIDIA")
1799 || strstr(gl_vendor_string, "Nouveau")
1800 || strstr(gl_vendor_string, "nouveau"))
1801 return HW_VENDOR_NVIDIA;
1803 if (strstr(gl_vendor_string, "ATI")
1804 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1805 || strstr(gl_vendor_string, "X.Org R300 Project")
1806 || strstr(gl_renderer, "AMD")
1807 || strstr(gl_renderer, "R100")
1808 || strstr(gl_renderer, "R200")
1809 || strstr(gl_renderer, "R300")
1810 || strstr(gl_renderer, "R600")
1811 || strstr(gl_renderer, "R700"))
1812 return HW_VENDOR_AMD;
1814 if (strstr(gl_vendor_string, "Intel(R)")
1815 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1816 || strstr(gl_renderer, "Intel")
1817 || strstr(gl_renderer, "i915")
1818 || strstr(gl_vendor_string, "Intel Inc."))
1819 return HW_VENDOR_INTEL;
1821 if (strstr(gl_renderer, "SVGA3D"))
1822 return HW_VENDOR_VMWARE;
1824 if (strstr(gl_vendor_string, "Mesa")
1825 || strstr(gl_vendor_string, "Brian Paul")
1826 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1827 || strstr(gl_vendor_string, "VMware, Inc."))
1828 return HW_VENDOR_SOFTWARE;
1830 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1832 return HW_VENDOR_NVIDIA;
1835 static enum wined3d_d3d_level d3d_level_from_caps(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps, DWORD glsl_version)
1837 if (shader_caps->vs_version >= 5)
1838 return WINED3D_D3D_LEVEL_11;
1839 if (shader_caps->vs_version == 4)
1840 return WINED3D_D3D_LEVEL_10;
1841 if (shader_caps->vs_version == 3)
1843 /* wined3d with default settings at the moment doesn't expose SM4+ on
1844 * Mesa drivers. */
1845 if (glsl_version >= MAKEDWORD_VERSION(4, 30))
1846 return WINED3D_D3D_LEVEL_11;
1847 if (glsl_version >= MAKEDWORD_VERSION(1, 30))
1848 return WINED3D_D3D_LEVEL_10;
1849 return WINED3D_D3D_LEVEL_9_SM3;
1851 if (shader_caps->vs_version == 2)
1852 return WINED3D_D3D_LEVEL_9_SM2;
1853 if (shader_caps->vs_version == 1)
1854 return WINED3D_D3D_LEVEL_8;
1856 if (fragment_caps->TextureOpCaps & WINED3DTEXOPCAPS_DOTPRODUCT3)
1857 return WINED3D_D3D_LEVEL_7;
1858 if (fragment_caps->MaxSimultaneousTextures > 1)
1859 return WINED3D_D3D_LEVEL_6;
1861 return WINED3D_D3D_LEVEL_5;
1864 static const struct wined3d_renderer_table
1866 const char *renderer;
1867 enum wined3d_pci_device id;
1869 cards_nvidia_binary[] =
1871 /* Direct 3D 11 */
1872 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080}, /* GeForce 1000 - highend */
1873 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070}, /* GeForce 1000 - highend */
1874 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060}, /* GeForce 1000 - midend high */
1875 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050}, /* GeForce 1000 - midend */
1876 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI}, /* GeForce 900 - highend */
1877 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980}, /* GeForce 900 - highend */
1878 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M}, /* GeForce 900 - highend mobile*/
1879 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970}, /* GeForce 900 - highend */
1880 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX}, /* Geforce 900 - highend */
1881 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M}, /* GeForce 900 - midend high mobile */
1882 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960}, /* GeForce 900 - midend high */
1883 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M}, /* GeForce 900 - midend mobile */
1884 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950}, /* GeForce 900 - midend */
1885 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M}, /* GeForce 900 - midend mobile */
1886 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M}, /* GeForce 800 - mobile */
1887 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M}, /* GeForce 800 - mobile */
1888 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M}, /* GeForce 800 - mobile */
1889 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M}, /* GeForce 800 - mobile */
1890 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M}, /* GeForce 800 - mobile */
1891 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M}, /* GeForce 800 - mobile */
1892 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M}, /* GeForce 800 - mobile */
1893 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M}, /* GeForce 800 - mobile */
1894 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI}, /* Geforce 700 - highend */
1895 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB}, /* Geforce 700 - highend */
1896 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ}, /* Geforce 700 - highend */
1897 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN}, /* Geforce 700 - highend */
1898 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780}, /* Geforce 700 - highend */
1899 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
1900 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */
1901 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */
1902 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI}, /* Geforce 700 - midend high */
1903 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */
1904 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */
1905 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */
1906 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M}, /* Geforce 700 - midend mobile */
1907 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M}, /* Geforce 700 - midend mobile */
1908 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M}, /* Geforce 700 - midend mobile */
1909 {"GT 730", CARD_NVIDIA_GEFORCE_GT730}, /* Geforce 700 - lowend */
1910 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690}, /* Geforce 600 - highend */
1911 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1912 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX}, /* Geforce 600 - highend */
1913 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
1914 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1915 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
1916 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */
1917 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
1918 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
1919 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
1920 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1921 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1922 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1923 {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
1924 {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
1925 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1926 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1927 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1928 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1929 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1930 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1931 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1932 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M}, /* Geforce 500 - lowend mobile */
1933 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1934 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1935 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1936 /* Direct 3D 10 */
1937 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1938 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1939 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1940 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1941 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1942 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1943 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M}, /* Geforce 400 - lowend mobile */
1944 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1945 {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
1946 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1947 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1948 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1949 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1950 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1951 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1952 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1953 {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
1954 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1955 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1956 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1957 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1958 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1959 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250}, /* Geforce 200 - midend */
1960 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1961 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1962 {"GeForce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1963 {"GeForce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1964 {"GeForce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1965 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1966 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1967 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1968 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT}, /* Geforce 9 - midend */
1969 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1970 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1971 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1972 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1973 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1974 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1975 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1976 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1977 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1978 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1979 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1980 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1981 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1982 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1983 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1984 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1985 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1986 {"8500", CARD_NVIDIA_GEFORCE_8500GT}, /* Geforce 8 - mid-lowend */
1987 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1988 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1989 {"8200", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
1990 {"8100", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
1991 /* Direct 3D 9 SM3 */
1992 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1993 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1994 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1995 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1996 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1997 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1998 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1999 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
2000 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
2001 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
2002 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2003 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2004 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
2005 /* Direct 3D 9 SM2 */
2006 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2007 {"5950", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2008 {"5900", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2009 {"5800", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
2010 {"5750", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2011 {"5700", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2012 {"5650", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2013 {"5600", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
2014 {"5500", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2015 {"5300", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2016 {"5250", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2017 {"5200", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2018 {"5100", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
2019 /* Direct 3D 8 */
2020 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200},
2021 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
2022 /* Direct 3D 7 */
2023 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX}, /* MX420/MX440/MX460/MX4000 */
2024 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX},
2025 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX}, /* Geforce2 standard/MX100/MX200/MX400 */
2026 {"Quadro2", CARD_NVIDIA_GEFORCE2},
2027 {"GeForce2", CARD_NVIDIA_GEFORCE2}, /* Geforce2 GTS/Pro/Ti/Ultra */
2028 /* Direct 3D 6 */
2029 {"TNT2", CARD_NVIDIA_RIVA_TNT2}, /* Riva TNT2 standard/M64/Pro/Ultra */
2031 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
2033 * Beware: renderer string do not match exact card model,
2034 * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
2035 cards_amd_binary[] =
2037 {"RX 480", CARD_AMD_RADEON_RX_480},
2038 {"RX 460", CARD_AMD_RADEON_RX_460},
2039 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY},
2040 /* Southern Islands */
2041 {"HD 7900", CARD_AMD_RADEON_HD7900},
2042 {"HD 7800", CARD_AMD_RADEON_HD7800},
2043 {"HD 7700", CARD_AMD_RADEON_HD7700},
2044 /* Northern Islands */
2045 {"HD 6970", CARD_AMD_RADEON_HD6900},
2046 {"HD 6900", CARD_AMD_RADEON_HD6900},
2047 {"HD 6800", CARD_AMD_RADEON_HD6800},
2048 {"HD 6770M", CARD_AMD_RADEON_HD6600M},
2049 {"HD 6750M", CARD_AMD_RADEON_HD6600M},
2050 {"HD 6700", CARD_AMD_RADEON_HD6700},
2051 {"HD 6670", CARD_AMD_RADEON_HD6600},
2052 {"HD 6630M", CARD_AMD_RADEON_HD6600M},
2053 {"HD 6600M", CARD_AMD_RADEON_HD6600M},
2054 {"HD 6600", CARD_AMD_RADEON_HD6600},
2055 {"HD 6570", CARD_AMD_RADEON_HD6600},
2056 {"HD 6500M", CARD_AMD_RADEON_HD6600M},
2057 {"HD 6500", CARD_AMD_RADEON_HD6600},
2058 {"HD 6480G", CARD_AMD_RADEON_HD6480G},
2059 {"HD 6400", CARD_AMD_RADEON_HD6400},
2060 {"HD 6300", CARD_AMD_RADEON_HD6300},
2061 {"HD 6200", CARD_AMD_RADEON_HD6300},
2062 /* Evergreen */
2063 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
2064 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
2065 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
2066 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
2067 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
2068 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
2069 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
2070 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
2071 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
2072 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
2073 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
2074 /* R700 */
2075 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
2076 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2077 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2078 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
2079 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
2080 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
2081 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
2082 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2083 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2084 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
2085 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2086 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
2087 /* R600/R700 integrated */
2088 {"HD 4200M", CARD_AMD_RADEON_HD4200M},
2089 {"HD 3300", CARD_AMD_RADEON_HD3200},
2090 {"HD 3200", CARD_AMD_RADEON_HD3200},
2091 {"HD 3100", CARD_AMD_RADEON_HD3200},
2092 /* R600 */
2093 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2094 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2095 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
2096 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
2097 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2098 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2099 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
2100 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2101 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2102 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2103 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2104 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2105 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
2106 /* Radeon R5xx */
2107 {"X1950", CARD_AMD_RADEON_X1600},
2108 {"X1900", CARD_AMD_RADEON_X1600},
2109 {"X1800", CARD_AMD_RADEON_X1600},
2110 {"X1650", CARD_AMD_RADEON_X1600},
2111 {"X1600", CARD_AMD_RADEON_X1600},
2112 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
2113 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
2114 {"HD 2300", CARD_AMD_RADEON_X700},
2115 {"X2500", CARD_AMD_RADEON_X700},
2116 {"X2300", CARD_AMD_RADEON_X700},
2117 {"X1550", CARD_AMD_RADEON_X700},
2118 {"X1450", CARD_AMD_RADEON_X700},
2119 {"X1400", CARD_AMD_RADEON_X700},
2120 {"X1300", CARD_AMD_RADEON_X700},
2121 {"X850", CARD_AMD_RADEON_X700},
2122 {"X800", CARD_AMD_RADEON_X700},
2123 {"X700", CARD_AMD_RADEON_X700},
2124 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
2125 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M},
2127 cards_intel[] =
2129 /* Skylake */
2130 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1},
2131 {"Skylake", CARD_INTEL_HD520_1},
2132 /* Broadwell */
2133 {"Iris Pro P6300", CARD_INTEL_IPP6300},
2134 {"Iris Pro 6200", CARD_INTEL_IP6200},
2135 {"Iris 6100", CARD_INTEL_I6100},
2136 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100}, /* MacOS */
2137 /* Haswell */
2138 {"Iris Pro 5200", CARD_INTEL_IP5200_1},
2139 {"Iris 5100", CARD_INTEL_I5100_1},
2140 {"Haswell Mobile", CARD_INTEL_HWM},
2141 {"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */
2142 /* Ivybridge */
2143 {"Ivybridge Server", CARD_INTEL_IVBS},
2144 {"Ivybridge Mobile", CARD_INTEL_IVBM},
2145 {"Ivybridge Desktop", CARD_INTEL_IVBD},
2146 {"HD Graphics 4000", CARD_INTEL_IVBD}, /* MacOS */
2147 /* Sandybridge */
2148 {"Sandybridge Server", CARD_INTEL_SNBS},
2149 {"Sandybridge Mobile", CARD_INTEL_SNBM},
2150 {"Sandybridge Desktop", CARD_INTEL_SNBD},
2151 /* Ironlake */
2152 {"Ironlake Mobile", CARD_INTEL_ILKM},
2153 {"Ironlake Desktop", CARD_INTEL_ILKD},
2154 /* G4x */
2155 {"B43", CARD_INTEL_B43},
2156 {"G41", CARD_INTEL_G41},
2157 {"G45", CARD_INTEL_G45},
2158 {"Q45", CARD_INTEL_Q45},
2159 {"Integrated Graphics Device", CARD_INTEL_IGD},
2160 {"GM45", CARD_INTEL_GM45},
2161 /* i965 */
2162 {"965GME", CARD_INTEL_965GME},
2163 {"965GM", CARD_INTEL_965GM},
2164 {"X3100", CARD_INTEL_965GM}, /* MacOS */
2165 {"946GZ", CARD_INTEL_946GZ},
2166 {"965G", CARD_INTEL_965G},
2167 {"965Q", CARD_INTEL_965Q},
2168 /* i945 */
2169 {"Pineview M", CARD_INTEL_PNVM},
2170 {"Pineview G", CARD_INTEL_PNVG},
2171 {"IGD", CARD_INTEL_PNVG},
2172 {"Q33", CARD_INTEL_Q33},
2173 {"G33", CARD_INTEL_G33},
2174 {"Q35", CARD_INTEL_Q35},
2175 {"945GME", CARD_INTEL_945GME},
2176 {"945GM", CARD_INTEL_945GM},
2177 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
2178 {"945G", CARD_INTEL_945G},
2179 /* i915 */
2180 {"915GM", CARD_INTEL_915GM},
2181 {"E7221G", CARD_INTEL_E7221G},
2182 {"915G", CARD_INTEL_915G},
2183 /* i8xx */
2184 {"865G", CARD_INTEL_865G},
2185 {"845G", CARD_INTEL_845G},
2186 {"855GM", CARD_INTEL_855GM},
2187 {"830M", CARD_INTEL_830M},
2189 /* 20101109 - These are never returned by current Gallium radeon
2190 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
2192 * These are returned but not handled: RC410, RV380. */
2193 cards_amd_mesa[] =
2195 /* Polaris 10/11 */
2196 {"POLARIS10", CARD_AMD_RADEON_RX_480},
2197 {"POLARIS11", CARD_AMD_RADEON_RX_460},
2198 /* Volcanic Islands */
2199 {"FIJI", CARD_AMD_RADEON_R9_FURY},
2200 {"TONGA", CARD_AMD_RADEON_R9_285},
2201 /* Sea Islands */
2202 {"HAWAII", CARD_AMD_RADEON_R9_290},
2203 {"KAVERI", CARD_AMD_RADEON_R7 },
2204 {"KABINI", CARD_AMD_RADEON_R3 },
2205 {"BONAIRE", CARD_AMD_RADEON_HD8770},
2206 /* Southern Islands */
2207 {"OLAND", CARD_AMD_RADEON_HD8670},
2208 {"HAINAN", CARD_AMD_RADEON_HD8600M},
2209 {"TAHITI", CARD_AMD_RADEON_HD7900},
2210 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
2211 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
2212 /* Northern Islands */
2213 {"ARUBA", CARD_AMD_RADEON_HD7660D},
2214 {"CAYMAN", CARD_AMD_RADEON_HD6900},
2215 {"BARTS", CARD_AMD_RADEON_HD6800},
2216 {"TURKS", CARD_AMD_RADEON_HD6600},
2217 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
2218 {"SUMO", CARD_AMD_RADEON_HD6550D},
2219 {"CAICOS", CARD_AMD_RADEON_HD6400},
2220 {"PALM", CARD_AMD_RADEON_HD6300},
2221 /* Evergreen */
2222 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
2223 {"CYPRESS", CARD_AMD_RADEON_HD5800},
2224 {"JUNIPER", CARD_AMD_RADEON_HD5700},
2225 {"REDWOOD", CARD_AMD_RADEON_HD5600},
2226 {"CEDAR", CARD_AMD_RADEON_HD5400},
2227 /* R700 */
2228 {"R700", CARD_AMD_RADEON_HD4800},
2229 {"RV790", CARD_AMD_RADEON_HD4800},
2230 {"RV770", CARD_AMD_RADEON_HD4800},
2231 {"RV740", CARD_AMD_RADEON_HD4700},
2232 {"RV730", CARD_AMD_RADEON_HD4600},
2233 {"RV710", CARD_AMD_RADEON_HD4350},
2234 /* R600/R700 integrated */
2235 {"RS880", CARD_AMD_RADEON_HD4200M},
2236 {"RS780", CARD_AMD_RADEON_HD3200},
2237 /* R600 */
2238 {"R680", CARD_AMD_RADEON_HD2900},
2239 {"R600", CARD_AMD_RADEON_HD2900},
2240 {"RV670", CARD_AMD_RADEON_HD3850},
2241 {"RV635", CARD_AMD_RADEON_HD2600},
2242 {"RV630", CARD_AMD_RADEON_HD2600},
2243 {"RV620", CARD_AMD_RADEON_HD2350},
2244 {"RV610", CARD_AMD_RADEON_HD2350},
2245 /* R500 */
2246 {"R580", CARD_AMD_RADEON_X1600},
2247 {"R520", CARD_AMD_RADEON_X1600},
2248 {"RV570", CARD_AMD_RADEON_X1600},
2249 {"RV560", CARD_AMD_RADEON_X1600},
2250 {"RV535", CARD_AMD_RADEON_X1600},
2251 {"RV530", CARD_AMD_RADEON_X1600},
2252 {"RV516", CARD_AMD_RADEON_X700},
2253 {"RV515", CARD_AMD_RADEON_X700},
2254 /* R400 */
2255 {"R481", CARD_AMD_RADEON_X700},
2256 {"R480", CARD_AMD_RADEON_X700},
2257 {"R430", CARD_AMD_RADEON_X700},
2258 {"R423", CARD_AMD_RADEON_X700},
2259 {"R420", CARD_AMD_RADEON_X700},
2260 {"R410", CARD_AMD_RADEON_X700},
2261 {"RV410", CARD_AMD_RADEON_X700},
2262 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
2263 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
2264 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
2265 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
2266 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
2267 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
2268 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
2269 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
2270 /* R300 */
2271 {"R360", CARD_AMD_RADEON_9500},
2272 {"R350", CARD_AMD_RADEON_9500},
2273 {"R300", CARD_AMD_RADEON_9500},
2274 {"RV370", CARD_AMD_RADEON_9500},
2275 {"RV360", CARD_AMD_RADEON_9500},
2276 {"RV351", CARD_AMD_RADEON_9500},
2277 {"RV350", CARD_AMD_RADEON_9500},
2279 cards_nvidia_mesa[] =
2281 /* Maxwell */
2282 {"NV124", CARD_NVIDIA_GEFORCE_GTX970},
2283 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI},
2284 {"NV118", CARD_NVIDIA_GEFORCE_840M},
2285 {"NV117", CARD_NVIDIA_GEFORCE_GTX750},
2286 /* Kepler */
2287 {"NV108", CARD_NVIDIA_GEFORCE_GT740M},
2288 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI},
2289 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780},
2290 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
2291 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, /* 690 / 675MX / 760TI */
2292 /* Fermi */
2293 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
2294 {"NVD7", CARD_NVIDIA_GEFORCE_820M},
2295 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
2296 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
2297 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
2298 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
2299 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
2300 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
2301 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
2302 /* Tesla */
2303 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
2304 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
2305 {"NVAA", CARD_NVIDIA_GEFORCE_8200}, /* 8100 */
2306 {"NVA8", CARD_NVIDIA_GEFORCE_210},
2307 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
2308 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
2309 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
2310 {"NV98", CARD_NVIDIA_GEFORCE_9200},
2311 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
2312 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
2313 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
2314 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
2315 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
2316 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
2317 /* Curie */
2318 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
2319 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
2320 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
2321 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
2322 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
2323 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
2324 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
2325 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
2326 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
2327 {"NV46", CARD_NVIDIA_GEFORCE_7400},
2328 {"NV45", CARD_NVIDIA_GEFORCE_6800},
2329 {"NV44", CARD_NVIDIA_GEFORCE_6200},
2330 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
2331 {"NV42", CARD_NVIDIA_GEFORCE_6800},
2332 {"NV41", CARD_NVIDIA_GEFORCE_6800},
2333 {"NV40", CARD_NVIDIA_GEFORCE_6800},
2334 /* Rankine */
2335 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
2336 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
2337 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
2338 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
2339 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
2340 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
2341 /* Kelvin */
2342 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
2343 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
2344 {"nv20", CARD_NVIDIA_GEFORCE3},
2345 /* Celsius */
2346 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
2347 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
2348 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
2349 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
2350 {"nv16", CARD_NVIDIA_GEFORCE2},
2351 {"nv15", CARD_NVIDIA_GEFORCE2},
2352 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
2353 {"nv10", CARD_NVIDIA_GEFORCE},
2354 /* Fahrenheit */
2355 {"nv05", CARD_NVIDIA_RIVA_TNT2},
2356 {"nv04", CARD_NVIDIA_RIVA_TNT},
2357 {"nv03", CARD_NVIDIA_RIVA_128},
2359 cards_vmware[] =
2361 {"SVGA3D", CARD_VMWARE_SVGA3D},
2364 static const struct gl_vendor_selection
2366 enum wined3d_gl_vendor gl_vendor;
2367 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2368 const struct wined3d_renderer_table *cards; /* To be used as cards[], pointer to the first member in an array */
2369 size_t cards_size; /* Number of entries in the array above */
2371 amd_gl_vendor_table[] =
2373 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2374 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
2375 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", cards_amd_mesa, ARRAY_SIZE(cards_amd_mesa)},
2377 nvidia_gl_vendor_table[] =
2379 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2380 {GL_VENDOR_MESA, "Mesa Nouveau driver", cards_nvidia_mesa, ARRAY_SIZE(cards_nvidia_mesa)},
2381 {GL_VENDOR_NVIDIA, "Nvidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
2383 vmware_gl_vendor_table[] =
2385 {GL_VENDOR_MESA, "VMware driver", cards_vmware, ARRAY_SIZE(cards_vmware)},
2387 intel_gl_vendor_table[] =
2389 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", cards_intel, ARRAY_SIZE(cards_intel)},
2390 {GL_VENDOR_MESA, "Mesa Intel driver", cards_intel, ARRAY_SIZE(cards_intel)},
2393 static const enum wined3d_pci_device
2394 card_fallback_nvidia[] =
2396 CARD_NVIDIA_RIVA_128, /* D3D5 */
2397 CARD_NVIDIA_RIVA_TNT, /* D3D6 */
2398 CARD_NVIDIA_GEFORCE, /* D3D7 */
2399 CARD_NVIDIA_GEFORCE3, /* D3D8 */
2400 CARD_NVIDIA_GEFORCEFX_5800, /* D3D9_SM2 */
2401 CARD_NVIDIA_GEFORCE_6800, /* D3D9_SM3 */
2402 CARD_NVIDIA_GEFORCE_8800GTX, /* D3D10 */
2403 CARD_NVIDIA_GEFORCE_GTX470, /* D3D11 */
2405 card_fallback_amd[] =
2407 CARD_AMD_RAGE_128PRO, /* D3D5 */
2408 CARD_AMD_RAGE_128PRO, /* D3D6 */
2409 CARD_AMD_RADEON_7200, /* D3D7 */
2410 CARD_AMD_RADEON_8500, /* D3D8 */
2411 CARD_AMD_RADEON_9500, /* D3D9_SM2 */
2412 CARD_AMD_RADEON_X1600, /* D3D9_SM3 */
2413 CARD_AMD_RADEON_HD2900, /* D3D10 */
2414 CARD_AMD_RADEON_HD5600, /* D3D11 */
2416 card_fallback_intel[] =
2418 CARD_INTEL_845G, /* D3D5 */
2419 CARD_INTEL_845G, /* D3D6 */
2420 CARD_INTEL_845G, /* D3D7 */
2421 CARD_INTEL_915G, /* D3D8 */
2422 CARD_INTEL_915G, /* D3D9_SM2 */
2423 CARD_INTEL_945G, /* D3D9_SM3 */
2424 CARD_INTEL_G45, /* D3D10 */
2425 CARD_INTEL_IVBD, /* D3D11 */
2427 C_ASSERT(ARRAY_SIZE(card_fallback_nvidia) == WINED3D_D3D_LEVEL_COUNT);
2428 C_ASSERT(ARRAY_SIZE(card_fallback_amd) == WINED3D_D3D_LEVEL_COUNT);
2429 C_ASSERT(ARRAY_SIZE(card_fallback_intel) == WINED3D_D3D_LEVEL_COUNT);
2431 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
2432 unsigned int table_size, enum wined3d_gl_vendor gl_vendor, const char *gl_renderer)
2434 unsigned int i, j;
2436 for (i = 0; i < table_size; ++i)
2438 if (table[i].gl_vendor != gl_vendor)
2439 continue;
2441 TRACE("Applying card selector \"%s\".\n", table[i].description);
2443 for (j = 0; j < table[i].cards_size; ++j)
2445 if (strstr(gl_renderer, table[i].cards[j].renderer))
2446 return table[i].cards[j].id;
2448 return PCI_DEVICE_NONE;
2450 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2451 gl_vendor, debugstr_a(gl_renderer));
2453 return PCI_DEVICE_NONE;
2456 static const struct
2458 enum wined3d_pci_vendor card_vendor;
2459 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
2460 const struct gl_vendor_selection *gl_vendor_selection;
2461 unsigned int gl_vendor_count;
2462 const enum wined3d_pci_device *card_fallback; /* An array with D3D_LEVEL_COUNT elements */
2464 card_vendor_table[] =
2466 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
2467 sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table),
2468 card_fallback_amd},
2469 {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
2470 sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table),
2471 card_fallback_nvidia},
2472 {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table,
2473 sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table),
2474 card_fallback_amd},
2475 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
2476 sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table),
2477 card_fallback_intel},
2481 static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps,
2482 DWORD glsl_version, const char *gl_renderer, enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor)
2484 /* A Direct3D device object contains the PCI id (vendor + device) of the
2485 * videocard which is used for rendering. Various applications use this
2486 * information to get a rough estimation of the features of the card and
2487 * some might use it for enabling 3d effects only on certain types of
2488 * videocards. In some cases games might even use it to work around bugs
2489 * which happen on certain videocards/driver combinations. The problem is
2490 * that OpenGL only exposes a rendering string containing the name of the
2491 * videocard and not the PCI id.
2493 * Various games depend on the PCI id, so somehow we need to provide one.
2494 * A simple option is to parse the renderer string and translate this to
2495 * the right PCI id. This is a lot of work because there are more than 200
2496 * GPUs just for Nvidia. Various cards share the same renderer string, so
2497 * the amount of code might be 'small' but there are quite a number of
2498 * exceptions which would make this a pain to maintain. Another way would
2499 * be to query the PCI id from the operating system (assuming this is the
2500 * videocard which is used for rendering which is not always the case).
2501 * This would work but it is not very portable. Second it would not work
2502 * well in, let's say, a remote X situation in which the amount of 3d
2503 * features which can be used is limited.
2505 * As said most games only use the PCI id to get an indication of the
2506 * capabilities of the card. It doesn't really matter if the given id is
2507 * the correct one if we return the id of a card with similar 3d features.
2509 * The code below checks the OpenGL capabilities of a videocard and matches
2510 * that to a certain level of Direct3D functionality. Once a card passes
2511 * the Direct3D9 check, we know that the card (in case of Nvidia) is at
2512 * least a GeforceFX. To give a better estimate we do a basic check on the
2513 * renderer string but if that won't pass we return a default card. This
2514 * way is better than maintaining a full card database as even without a
2515 * full database we can return a card with similar features. Second the
2516 * size of the database can be made quite small because when you know what
2517 * type of 3d functionality a card has, you know to which GPU family the
2518 * GPU must belong. Because of this you only have to check a small part of
2519 * the renderer string to distinguish between different models from that
2520 * family.
2522 * The code also selects a default amount of video memory which we will
2523 * use for an estimation of the amount of free texture memory. In case of
2524 * real D3D the amount of texture memory includes video memory and system
2525 * memory (to be specific AGP memory or in case of PCIE TurboCache /
2526 * HyperMemory). We don't know how much system memory can be addressed by
2527 * the system but we can make a reasonable estimation about the amount of
2528 * video memory. If the value is slightly wrong it doesn't matter as we
2529 * didn't include AGP-like memory which makes the amount of addressable
2530 * memory higher and second OpenGL isn't that critical it moves to system
2531 * memory behind our backs if really needed. Note that the amount of video
2532 * memory can be overruled using a registry setting. */
2534 unsigned int i;
2535 enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version);
2536 enum wined3d_pci_device device;
2538 for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
2540 if (card_vendor_table[i].card_vendor != *card_vendor)
2541 continue;
2543 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
2544 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
2545 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_renderer);
2546 if (device != PCI_DEVICE_NONE)
2547 return device;
2549 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
2550 return card_vendor_table[i].card_fallback[d3d_level];
2553 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2554 *card_vendor, debugstr_a(gl_renderer));
2556 /* Default to generic Nvidia hardware based on the supported OpenGL extensions. */
2557 *card_vendor = HW_VENDOR_NVIDIA;
2558 return card_fallback_nvidia[d3d_level];
2561 static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
2562 const struct wined3d_shader_backend_ops *shader_backend_ops)
2564 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_VERTEX_SHADER])
2565 return &glsl_vertex_pipe;
2566 return &ffp_vertex_pipe;
2569 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
2570 const struct wined3d_shader_backend_ops *shader_backend_ops)
2572 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_FRAGMENT_SHADER])
2573 return &glsl_fragment_pipe;
2574 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2575 return &arbfp_fragment_pipeline;
2576 if (gl_info->supported[ATI_FRAGMENT_SHADER])
2577 return &atifs_fragment_pipeline;
2578 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
2579 return &nvts_fragment_pipeline;
2580 if (gl_info->supported[NV_REGISTER_COMBINERS])
2581 return &nvrc_fragment_pipeline;
2582 return &ffp_fragment_pipeline;
2585 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
2587 BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
2589 if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER])
2590 return &glsl_shader_backend;
2591 if (gl_info->supported[ARB_VERTEX_PROGRAM] && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2592 return &arb_program_shader_backend;
2593 if (glsl && (gl_info->supported[ARB_VERTEX_SHADER] || gl_info->supported[ARB_FRAGMENT_SHADER]))
2594 return &glsl_shader_backend;
2595 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
2596 return &arb_program_shader_backend;
2597 return &none_shader_backend;
2600 static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info,
2601 const struct wined3d_shader_backend_ops *shader_backend_ops)
2603 if ((shader_backend_ops == &glsl_shader_backend
2604 || shader_backend_ops == &arb_program_shader_backend)
2605 && gl_info->supported[ARB_FRAGMENT_PROGRAM])
2606 return &arbfp_blit;
2607 return &ffp_blit;
2610 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
2611 const struct wined3d_extension_map *map, UINT entry_count)
2613 while (*extensions)
2615 const char *start;
2616 size_t len;
2617 UINT i;
2619 while (isspace(*extensions))
2620 ++extensions;
2621 start = extensions;
2622 while (!isspace(*extensions) && *extensions)
2623 ++extensions;
2625 len = extensions - start;
2626 if (!len)
2627 continue;
2629 TRACE("- %s.\n", debugstr_an(start, len));
2631 for (i = 0; i < entry_count; ++i)
2633 if (len == strlen(map[i].extension_string)
2634 && !memcmp(start, map[i].extension_string, len))
2636 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2637 gl_info->supported[map[i].extension] = TRUE;
2638 break;
2644 static void enumerate_gl_extensions(struct wined3d_gl_info *gl_info,
2645 const struct wined3d_extension_map *map, unsigned int map_entries_count)
2647 const char *gl_extension_name;
2648 unsigned int i, j;
2649 GLint extensions_count;
2651 gl_info->gl_ops.gl.p_glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
2652 for (i = 0; i < extensions_count; ++i)
2654 gl_extension_name = (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS, i));
2655 TRACE("- %s.\n", debugstr_a(gl_extension_name));
2656 for (j = 0; j < map_entries_count; ++j)
2658 if (!strcmp(gl_extension_name, map[j].extension_string))
2660 TRACE("FOUND: %s support.\n", map[j].extension_string);
2661 gl_info->supported[map[j].extension] = TRUE;
2662 break;
2668 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2670 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2671 /* GL_APPLE_fence */
2672 USE_GL_FUNC(glDeleteFencesAPPLE)
2673 USE_GL_FUNC(glFinishFenceAPPLE)
2674 USE_GL_FUNC(glFinishObjectAPPLE)
2675 USE_GL_FUNC(glGenFencesAPPLE)
2676 USE_GL_FUNC(glIsFenceAPPLE)
2677 USE_GL_FUNC(glSetFenceAPPLE)
2678 USE_GL_FUNC(glTestFenceAPPLE)
2679 USE_GL_FUNC(glTestObjectAPPLE)
2680 /* GL_APPLE_flush_buffer_range */
2681 USE_GL_FUNC(glBufferParameteriAPPLE)
2682 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE)
2683 /* GL_ARB_blend_func_extended */
2684 USE_GL_FUNC(glBindFragDataLocationIndexed)
2685 USE_GL_FUNC(glGetFragDataIndex)
2686 /* GL_ARB_clip_control */
2687 USE_GL_FUNC(glClipControl)
2688 /* GL_ARB_color_buffer_float */
2689 USE_GL_FUNC(glClampColorARB)
2690 /* GL_ARB_compute_shader */
2691 USE_GL_FUNC(glDispatchCompute)
2692 USE_GL_FUNC(glDispatchComputeIndirect)
2693 /* GL_ARB_copy_buffer */
2694 USE_GL_FUNC(glCopyBufferSubData)
2695 /* GL_ARB_debug_output */
2696 USE_GL_FUNC(glDebugMessageCallbackARB)
2697 USE_GL_FUNC(glDebugMessageControlARB)
2698 USE_GL_FUNC(glDebugMessageInsertARB)
2699 USE_GL_FUNC(glGetDebugMessageLogARB)
2700 /* GL_ARB_draw_buffers */
2701 USE_GL_FUNC(glDrawBuffersARB)
2702 /* GL_ARB_draw_elements_base_vertex */
2703 USE_GL_FUNC(glDrawElementsBaseVertex)
2704 USE_GL_FUNC(glDrawElementsInstancedBaseVertex)
2705 USE_GL_FUNC(glDrawRangeElementsBaseVertex)
2706 USE_GL_FUNC(glMultiDrawElementsBaseVertex)
2707 /* GL_ARB_draw_instanced */
2708 USE_GL_FUNC(glDrawArraysInstancedARB)
2709 USE_GL_FUNC(glDrawElementsInstancedARB)
2710 /* GL_ARB_ES2_compatibility */
2711 USE_GL_FUNC(glReleaseShaderCompiler)
2712 USE_GL_FUNC(glShaderBinary)
2713 USE_GL_FUNC(glGetShaderPrecisionFormat)
2714 USE_GL_FUNC(glDepthRangef)
2715 USE_GL_FUNC(glClearDepthf)
2716 /* GL_ARB_framebuffer_object */
2717 USE_GL_FUNC(glBindFramebuffer)
2718 USE_GL_FUNC(glBindRenderbuffer)
2719 USE_GL_FUNC(glBlitFramebuffer)
2720 USE_GL_FUNC(glCheckFramebufferStatus)
2721 USE_GL_FUNC(glDeleteFramebuffers)
2722 USE_GL_FUNC(glDeleteRenderbuffers)
2723 USE_GL_FUNC(glFramebufferRenderbuffer)
2724 USE_GL_FUNC(glFramebufferTexture1D)
2725 USE_GL_FUNC(glFramebufferTexture2D)
2726 USE_GL_FUNC(glFramebufferTexture3D)
2727 USE_GL_FUNC(glFramebufferTextureLayer)
2728 USE_GL_FUNC(glGenFramebuffers)
2729 USE_GL_FUNC(glGenRenderbuffers)
2730 USE_GL_FUNC(glGenerateMipmap)
2731 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv)
2732 USE_GL_FUNC(glGetRenderbufferParameteriv)
2733 USE_GL_FUNC(glIsFramebuffer)
2734 USE_GL_FUNC(glIsRenderbuffer)
2735 USE_GL_FUNC(glRenderbufferStorage)
2736 USE_GL_FUNC(glRenderbufferStorageMultisample)
2737 /* GL_ARB_geometry_shader4 */
2738 USE_GL_FUNC(glFramebufferTextureARB)
2739 USE_GL_FUNC(glFramebufferTextureFaceARB)
2740 USE_GL_FUNC(glFramebufferTextureLayerARB)
2741 USE_GL_FUNC(glProgramParameteriARB)
2742 /* GL_ARB_instanced_arrays */
2743 USE_GL_FUNC(glVertexAttribDivisorARB)
2744 /* GL_ARB_internalformat_query */
2745 USE_GL_FUNC(glGetInternalformativ)
2746 /* GL_ARB_internalformat_query2 */
2747 USE_GL_FUNC(glGetInternalformati64v)
2748 /* GL_ARB_map_buffer_range */
2749 USE_GL_FUNC(glFlushMappedBufferRange)
2750 USE_GL_FUNC(glMapBufferRange)
2751 /* GL_ARB_multisample */
2752 USE_GL_FUNC(glSampleCoverageARB)
2753 /* GL_ARB_multitexture */
2754 USE_GL_FUNC(glActiveTextureARB)
2755 USE_GL_FUNC(glClientActiveTextureARB)
2756 USE_GL_FUNC(glMultiTexCoord1fARB)
2757 USE_GL_FUNC(glMultiTexCoord1fvARB)
2758 USE_GL_FUNC(glMultiTexCoord2fARB)
2759 USE_GL_FUNC(glMultiTexCoord2fvARB)
2760 USE_GL_FUNC(glMultiTexCoord2svARB)
2761 USE_GL_FUNC(glMultiTexCoord3fARB)
2762 USE_GL_FUNC(glMultiTexCoord3fvARB)
2763 USE_GL_FUNC(glMultiTexCoord4fARB)
2764 USE_GL_FUNC(glMultiTexCoord4fvARB)
2765 USE_GL_FUNC(glMultiTexCoord4svARB)
2766 /* GL_ARB_occlusion_query */
2767 USE_GL_FUNC(glBeginQueryARB)
2768 USE_GL_FUNC(glDeleteQueriesARB)
2769 USE_GL_FUNC(glEndQueryARB)
2770 USE_GL_FUNC(glGenQueriesARB)
2771 USE_GL_FUNC(glGetQueryivARB)
2772 USE_GL_FUNC(glGetQueryObjectivARB)
2773 USE_GL_FUNC(glGetQueryObjectuivARB)
2774 USE_GL_FUNC(glIsQueryARB)
2775 /* GL_ARB_point_parameters */
2776 USE_GL_FUNC(glPointParameterfARB)
2777 USE_GL_FUNC(glPointParameterfvARB)
2778 /* GL_ARB_provoking_vertex */
2779 USE_GL_FUNC(glProvokingVertex)
2780 /* GL_ARB_sampler_objects */
2781 USE_GL_FUNC(glGenSamplers)
2782 USE_GL_FUNC(glDeleteSamplers)
2783 USE_GL_FUNC(glIsSampler)
2784 USE_GL_FUNC(glBindSampler)
2785 USE_GL_FUNC(glSamplerParameteri)
2786 USE_GL_FUNC(glSamplerParameterf)
2787 USE_GL_FUNC(glSamplerParameteriv)
2788 USE_GL_FUNC(glSamplerParameterfv)
2789 USE_GL_FUNC(glSamplerParameterIiv)
2790 USE_GL_FUNC(glSamplerParameterIuiv)
2791 USE_GL_FUNC(glGetSamplerParameteriv)
2792 USE_GL_FUNC(glGetSamplerParameterfv)
2793 USE_GL_FUNC(glGetSamplerParameterIiv)
2794 USE_GL_FUNC(glGetSamplerParameterIuiv)
2795 /* GL_ARB_shader_atomic_counters */
2796 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv)
2797 /* GL_ARB_shader_image_load_store */
2798 USE_GL_FUNC(glBindImageTexture)
2799 USE_GL_FUNC(glMemoryBarrier)
2800 /* GL_ARB_shader_objects */
2801 USE_GL_FUNC(glAttachObjectARB)
2802 USE_GL_FUNC(glBindAttribLocationARB)
2803 USE_GL_FUNC(glCompileShaderARB)
2804 USE_GL_FUNC(glCreateProgramObjectARB)
2805 USE_GL_FUNC(glCreateShaderObjectARB)
2806 USE_GL_FUNC(glDeleteObjectARB)
2807 USE_GL_FUNC(glDetachObjectARB)
2808 USE_GL_FUNC(glGetActiveUniformARB)
2809 USE_GL_FUNC(glGetAttachedObjectsARB)
2810 USE_GL_FUNC(glGetAttribLocationARB)
2811 USE_GL_FUNC(glGetHandleARB)
2812 USE_GL_FUNC(glGetInfoLogARB)
2813 USE_GL_FUNC(glGetObjectParameterfvARB)
2814 USE_GL_FUNC(glGetObjectParameterivARB)
2815 USE_GL_FUNC(glGetShaderSourceARB)
2816 USE_GL_FUNC(glGetUniformLocationARB)
2817 USE_GL_FUNC(glGetUniformfvARB)
2818 USE_GL_FUNC(glGetUniformivARB)
2819 USE_GL_FUNC(glLinkProgramARB)
2820 USE_GL_FUNC(glShaderSourceARB)
2821 USE_GL_FUNC(glUniform1fARB)
2822 USE_GL_FUNC(glUniform1fvARB)
2823 USE_GL_FUNC(glUniform1iARB)
2824 USE_GL_FUNC(glUniform1ivARB)
2825 USE_GL_FUNC(glUniform2fARB)
2826 USE_GL_FUNC(glUniform2fvARB)
2827 USE_GL_FUNC(glUniform2iARB)
2828 USE_GL_FUNC(glUniform2ivARB)
2829 USE_GL_FUNC(glUniform3fARB)
2830 USE_GL_FUNC(glUniform3fvARB)
2831 USE_GL_FUNC(glUniform3iARB)
2832 USE_GL_FUNC(glUniform3ivARB)
2833 USE_GL_FUNC(glUniform4fARB)
2834 USE_GL_FUNC(glUniform4fvARB)
2835 USE_GL_FUNC(glUniform4iARB)
2836 USE_GL_FUNC(glUniform4ivARB)
2837 USE_GL_FUNC(glUniformMatrix2fvARB)
2838 USE_GL_FUNC(glUniformMatrix3fvARB)
2839 USE_GL_FUNC(glUniformMatrix4fvARB)
2840 USE_GL_FUNC(glUseProgramObjectARB)
2841 USE_GL_FUNC(glValidateProgramARB)
2842 /* GL_ARB_shader_storage_buffer_object */
2843 USE_GL_FUNC(glShaderStorageBlockBinding)
2844 /* GL_ARB_sync */
2845 USE_GL_FUNC(glClientWaitSync)
2846 USE_GL_FUNC(glDeleteSync)
2847 USE_GL_FUNC(glFenceSync)
2848 USE_GL_FUNC(glGetInteger64v)
2849 USE_GL_FUNC(glGetSynciv)
2850 USE_GL_FUNC(glIsSync)
2851 USE_GL_FUNC(glWaitSync)
2852 /* GL_ARB_texture_buffer_object */
2853 USE_GL_FUNC(glTexBufferARB)
2854 /* GL_ARB_texture_buffer_range */
2855 USE_GL_FUNC(glTexBufferRange)
2856 /* GL_ARB_texture_compression */
2857 USE_GL_FUNC(glCompressedTexImage2DARB)
2858 USE_GL_FUNC(glCompressedTexImage3DARB)
2859 USE_GL_FUNC(glCompressedTexSubImage2DARB)
2860 USE_GL_FUNC(glCompressedTexSubImage3DARB)
2861 USE_GL_FUNC(glGetCompressedTexImageARB)
2862 /* GL_ARB_texture_storage */
2863 USE_GL_FUNC(glTexStorage1D)
2864 USE_GL_FUNC(glTexStorage2D)
2865 USE_GL_FUNC(glTexStorage3D)
2866 /* GL_ARB_texture_view */
2867 USE_GL_FUNC(glTextureView)
2868 /* GL_ARB_timer_query */
2869 USE_GL_FUNC(glQueryCounter)
2870 USE_GL_FUNC(glGetQueryObjectui64v)
2871 /* GL_ARB_uniform_buffer_object */
2872 USE_GL_FUNC(glBindBufferBase)
2873 USE_GL_FUNC(glBindBufferRange)
2874 USE_GL_FUNC(glGetActiveUniformBlockName)
2875 USE_GL_FUNC(glGetActiveUniformBlockiv)
2876 USE_GL_FUNC(glGetActiveUniformName)
2877 USE_GL_FUNC(glGetActiveUniformsiv)
2878 USE_GL_FUNC(glGetIntegeri_v)
2879 USE_GL_FUNC(glGetUniformBlockIndex)
2880 USE_GL_FUNC(glGetUniformIndices)
2881 USE_GL_FUNC(glUniformBlockBinding)
2882 /* GL_ARB_vertex_blend */
2883 USE_GL_FUNC(glVertexBlendARB)
2884 USE_GL_FUNC(glWeightPointerARB)
2885 USE_GL_FUNC(glWeightbvARB)
2886 USE_GL_FUNC(glWeightdvARB)
2887 USE_GL_FUNC(glWeightfvARB)
2888 USE_GL_FUNC(glWeightivARB)
2889 USE_GL_FUNC(glWeightsvARB)
2890 USE_GL_FUNC(glWeightubvARB)
2891 USE_GL_FUNC(glWeightuivARB)
2892 USE_GL_FUNC(glWeightusvARB)
2893 /* GL_ARB_vertex_buffer_object */
2894 USE_GL_FUNC(glBindBufferARB)
2895 USE_GL_FUNC(glBufferDataARB)
2896 USE_GL_FUNC(glBufferSubDataARB)
2897 USE_GL_FUNC(glDeleteBuffersARB)
2898 USE_GL_FUNC(glGenBuffersARB)
2899 USE_GL_FUNC(glGetBufferParameterivARB)
2900 USE_GL_FUNC(glGetBufferPointervARB)
2901 USE_GL_FUNC(glGetBufferSubDataARB)
2902 USE_GL_FUNC(glIsBufferARB)
2903 USE_GL_FUNC(glMapBufferARB)
2904 USE_GL_FUNC(glUnmapBufferARB)
2905 /* GL_ARB_vertex_program */
2906 USE_GL_FUNC(glBindProgramARB)
2907 USE_GL_FUNC(glDeleteProgramsARB)
2908 USE_GL_FUNC(glDisableVertexAttribArrayARB)
2909 USE_GL_FUNC(glEnableVertexAttribArrayARB)
2910 USE_GL_FUNC(glGenProgramsARB)
2911 USE_GL_FUNC(glGetProgramivARB)
2912 USE_GL_FUNC(glProgramEnvParameter4fvARB)
2913 USE_GL_FUNC(glProgramLocalParameter4fvARB)
2914 USE_GL_FUNC(glProgramStringARB)
2915 USE_GL_FUNC(glVertexAttrib1dARB)
2916 USE_GL_FUNC(glVertexAttrib1dvARB)
2917 USE_GL_FUNC(glVertexAttrib1fARB)
2918 USE_GL_FUNC(glVertexAttrib1fvARB)
2919 USE_GL_FUNC(glVertexAttrib1sARB)
2920 USE_GL_FUNC(glVertexAttrib1svARB)
2921 USE_GL_FUNC(glVertexAttrib2dARB)
2922 USE_GL_FUNC(glVertexAttrib2dvARB)
2923 USE_GL_FUNC(glVertexAttrib2fARB)
2924 USE_GL_FUNC(glVertexAttrib2fvARB)
2925 USE_GL_FUNC(glVertexAttrib2sARB)
2926 USE_GL_FUNC(glVertexAttrib2svARB)
2927 USE_GL_FUNC(glVertexAttrib3dARB)
2928 USE_GL_FUNC(glVertexAttrib3dvARB)
2929 USE_GL_FUNC(glVertexAttrib3fARB)
2930 USE_GL_FUNC(glVertexAttrib3fvARB)
2931 USE_GL_FUNC(glVertexAttrib3sARB)
2932 USE_GL_FUNC(glVertexAttrib3svARB)
2933 USE_GL_FUNC(glVertexAttrib4NbvARB)
2934 USE_GL_FUNC(glVertexAttrib4NivARB)
2935 USE_GL_FUNC(glVertexAttrib4NsvARB)
2936 USE_GL_FUNC(glVertexAttrib4NubARB)
2937 USE_GL_FUNC(glVertexAttrib4NubvARB)
2938 USE_GL_FUNC(glVertexAttrib4NuivARB)
2939 USE_GL_FUNC(glVertexAttrib4NusvARB)
2940 USE_GL_FUNC(glVertexAttrib4bvARB)
2941 USE_GL_FUNC(glVertexAttrib4dARB)
2942 USE_GL_FUNC(glVertexAttrib4dvARB)
2943 USE_GL_FUNC(glVertexAttrib4fARB)
2944 USE_GL_FUNC(glVertexAttrib4fvARB)
2945 USE_GL_FUNC(glVertexAttrib4ivARB)
2946 USE_GL_FUNC(glVertexAttrib4sARB)
2947 USE_GL_FUNC(glVertexAttrib4svARB)
2948 USE_GL_FUNC(glVertexAttrib4ubvARB)
2949 USE_GL_FUNC(glVertexAttrib4uivARB)
2950 USE_GL_FUNC(glVertexAttrib4usvARB)
2951 USE_GL_FUNC(glVertexAttribPointerARB)
2952 /* GL_ARB_viewport_array */
2953 USE_GL_FUNC(glDepthRangeArrayv)
2954 USE_GL_FUNC(glDepthRangeIndexed)
2955 USE_GL_FUNC(glGetDoublei_v)
2956 USE_GL_FUNC(glGetFloati_v)
2957 USE_GL_FUNC(glScissorArrayv)
2958 USE_GL_FUNC(glScissorIndexed)
2959 USE_GL_FUNC(glScissorIndexedv)
2960 USE_GL_FUNC(glViewportArrayv)
2961 USE_GL_FUNC(glViewportIndexedf)
2962 USE_GL_FUNC(glViewportIndexedfv)
2963 /* GL_ATI_fragment_shader */
2964 USE_GL_FUNC(glAlphaFragmentOp1ATI)
2965 USE_GL_FUNC(glAlphaFragmentOp2ATI)
2966 USE_GL_FUNC(glAlphaFragmentOp3ATI)
2967 USE_GL_FUNC(glBeginFragmentShaderATI)
2968 USE_GL_FUNC(glBindFragmentShaderATI)
2969 USE_GL_FUNC(glColorFragmentOp1ATI)
2970 USE_GL_FUNC(glColorFragmentOp2ATI)
2971 USE_GL_FUNC(glColorFragmentOp3ATI)
2972 USE_GL_FUNC(glDeleteFragmentShaderATI)
2973 USE_GL_FUNC(glEndFragmentShaderATI)
2974 USE_GL_FUNC(glGenFragmentShadersATI)
2975 USE_GL_FUNC(glPassTexCoordATI)
2976 USE_GL_FUNC(glSampleMapATI)
2977 USE_GL_FUNC(glSetFragmentShaderConstantATI)
2978 /* GL_ATI_separate_stencil */
2979 USE_GL_FUNC(glStencilOpSeparateATI)
2980 USE_GL_FUNC(glStencilFuncSeparateATI)
2981 /* GL_EXT_blend_color */
2982 USE_GL_FUNC(glBlendColorEXT)
2983 /* GL_EXT_blend_equation_separate */
2984 USE_GL_FUNC(glBlendFuncSeparateEXT)
2985 /* GL_EXT_blend_func_separate */
2986 USE_GL_FUNC(glBlendEquationSeparateEXT)
2987 /* GL_EXT_blend_minmax */
2988 USE_GL_FUNC(glBlendEquationEXT)
2989 /* GL_EXT_depth_bounds_test */
2990 USE_GL_FUNC(glDepthBoundsEXT)
2991 /* GL_EXT_draw_buffers2 */
2992 USE_GL_FUNC(glColorMaskIndexedEXT)
2993 USE_GL_FUNC(glDisableIndexedEXT)
2994 USE_GL_FUNC(glEnableIndexedEXT)
2995 USE_GL_FUNC(glGetBooleanIndexedvEXT)
2996 USE_GL_FUNC(glGetIntegerIndexedvEXT)
2997 USE_GL_FUNC(glIsEnabledIndexedEXT)
2998 /* GL_EXT_fog_coord */
2999 USE_GL_FUNC(glFogCoordPointerEXT)
3000 USE_GL_FUNC(glFogCoorddEXT)
3001 USE_GL_FUNC(glFogCoorddvEXT)
3002 USE_GL_FUNC(glFogCoordfEXT)
3003 USE_GL_FUNC(glFogCoordfvEXT)
3004 /* GL_EXT_framebuffer_blit */
3005 USE_GL_FUNC(glBlitFramebufferEXT)
3006 /* GL_EXT_framebuffer_multisample */
3007 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT)
3008 /* GL_EXT_framebuffer_object */
3009 USE_GL_FUNC(glBindFramebufferEXT)
3010 USE_GL_FUNC(glBindRenderbufferEXT)
3011 USE_GL_FUNC(glCheckFramebufferStatusEXT)
3012 USE_GL_FUNC(glDeleteFramebuffersEXT)
3013 USE_GL_FUNC(glDeleteRenderbuffersEXT)
3014 USE_GL_FUNC(glFramebufferRenderbufferEXT)
3015 USE_GL_FUNC(glFramebufferTexture1DEXT)
3016 USE_GL_FUNC(glFramebufferTexture2DEXT)
3017 USE_GL_FUNC(glFramebufferTexture3DEXT)
3018 USE_GL_FUNC(glGenFramebuffersEXT)
3019 USE_GL_FUNC(glGenRenderbuffersEXT)
3020 USE_GL_FUNC(glGenerateMipmapEXT)
3021 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT)
3022 USE_GL_FUNC(glGetRenderbufferParameterivEXT)
3023 USE_GL_FUNC(glIsFramebufferEXT)
3024 USE_GL_FUNC(glIsRenderbufferEXT)
3025 USE_GL_FUNC(glRenderbufferStorageEXT)
3026 /* GL_EXT_gpu_program_parameters */
3027 USE_GL_FUNC(glProgramEnvParameters4fvEXT)
3028 USE_GL_FUNC(glProgramLocalParameters4fvEXT)
3029 /* GL_EXT_gpu_shader4 */
3030 USE_GL_FUNC(glBindFragDataLocationEXT)
3031 USE_GL_FUNC(glGetFragDataLocationEXT)
3032 USE_GL_FUNC(glGetUniformuivEXT)
3033 USE_GL_FUNC(glGetVertexAttribIivEXT)
3034 USE_GL_FUNC(glGetVertexAttribIuivEXT)
3035 USE_GL_FUNC(glUniform1uiEXT)
3036 USE_GL_FUNC(glUniform1uivEXT)
3037 USE_GL_FUNC(glUniform2uiEXT)
3038 USE_GL_FUNC(glUniform2uivEXT)
3039 USE_GL_FUNC(glUniform3uiEXT)
3040 USE_GL_FUNC(glUniform3uivEXT)
3041 USE_GL_FUNC(glUniform4uiEXT)
3042 USE_GL_FUNC(glUniform4uivEXT)
3043 USE_GL_FUNC(glVertexAttribI1iEXT)
3044 USE_GL_FUNC(glVertexAttribI1ivEXT)
3045 USE_GL_FUNC(glVertexAttribI1uiEXT)
3046 USE_GL_FUNC(glVertexAttribI1uivEXT)
3047 USE_GL_FUNC(glVertexAttribI2iEXT)
3048 USE_GL_FUNC(glVertexAttribI2ivEXT)
3049 USE_GL_FUNC(glVertexAttribI2uiEXT)
3050 USE_GL_FUNC(glVertexAttribI2uivEXT)
3051 USE_GL_FUNC(glVertexAttribI3iEXT)
3052 USE_GL_FUNC(glVertexAttribI3ivEXT)
3053 USE_GL_FUNC(glVertexAttribI3uiEXT)
3054 USE_GL_FUNC(glVertexAttribI3uivEXT)
3055 USE_GL_FUNC(glVertexAttribI4bvEXT)
3056 USE_GL_FUNC(glVertexAttribI4iEXT)
3057 USE_GL_FUNC(glVertexAttribI4ivEXT)
3058 USE_GL_FUNC(glVertexAttribI4svEXT)
3059 USE_GL_FUNC(glVertexAttribI4ubvEXT)
3060 USE_GL_FUNC(glVertexAttribI4uiEXT)
3061 USE_GL_FUNC(glVertexAttribI4uivEXT)
3062 USE_GL_FUNC(glVertexAttribI4usvEXT)
3063 USE_GL_FUNC(glVertexAttribIPointerEXT)
3064 /* GL_EXT_point_parameters */
3065 USE_GL_FUNC(glPointParameterfEXT)
3066 USE_GL_FUNC(glPointParameterfvEXT)
3067 /* GL_EXT_provoking_vertex */
3068 USE_GL_FUNC(glProvokingVertexEXT)
3069 /* GL_EXT_secondary_color */
3070 USE_GL_FUNC(glSecondaryColor3fEXT)
3071 USE_GL_FUNC(glSecondaryColor3fvEXT)
3072 USE_GL_FUNC(glSecondaryColor3ubEXT)
3073 USE_GL_FUNC(glSecondaryColor3ubvEXT)
3074 USE_GL_FUNC(glSecondaryColorPointerEXT)
3075 /* GL_EXT_stencil_two_side */
3076 USE_GL_FUNC(glActiveStencilFaceEXT)
3077 /* GL_EXT_texture3D */
3078 USE_GL_FUNC(glTexImage3D)
3079 USE_GL_FUNC(glTexImage3DEXT)
3080 USE_GL_FUNC(glTexSubImage3D)
3081 USE_GL_FUNC(glTexSubImage3DEXT)
3082 /* GL_NV_fence */
3083 USE_GL_FUNC(glDeleteFencesNV)
3084 USE_GL_FUNC(glFinishFenceNV)
3085 USE_GL_FUNC(glGenFencesNV)
3086 USE_GL_FUNC(glGetFenceivNV)
3087 USE_GL_FUNC(glIsFenceNV)
3088 USE_GL_FUNC(glSetFenceNV)
3089 USE_GL_FUNC(glTestFenceNV)
3090 /* GL_NV_half_float */
3091 USE_GL_FUNC(glColor3hNV)
3092 USE_GL_FUNC(glColor3hvNV)
3093 USE_GL_FUNC(glColor4hNV)
3094 USE_GL_FUNC(glColor4hvNV)
3095 USE_GL_FUNC(glFogCoordhNV)
3096 USE_GL_FUNC(glFogCoordhvNV)
3097 USE_GL_FUNC(glMultiTexCoord1hNV)
3098 USE_GL_FUNC(glMultiTexCoord1hvNV)
3099 USE_GL_FUNC(glMultiTexCoord2hNV)
3100 USE_GL_FUNC(glMultiTexCoord2hvNV)
3101 USE_GL_FUNC(glMultiTexCoord3hNV)
3102 USE_GL_FUNC(glMultiTexCoord3hvNV)
3103 USE_GL_FUNC(glMultiTexCoord4hNV)
3104 USE_GL_FUNC(glMultiTexCoord4hvNV)
3105 USE_GL_FUNC(glNormal3hNV)
3106 USE_GL_FUNC(glNormal3hvNV)
3107 USE_GL_FUNC(glSecondaryColor3hNV)
3108 USE_GL_FUNC(glSecondaryColor3hvNV)
3109 USE_GL_FUNC(glTexCoord1hNV)
3110 USE_GL_FUNC(glTexCoord1hvNV)
3111 USE_GL_FUNC(glTexCoord2hNV)
3112 USE_GL_FUNC(glTexCoord2hvNV)
3113 USE_GL_FUNC(glTexCoord3hNV)
3114 USE_GL_FUNC(glTexCoord3hvNV)
3115 USE_GL_FUNC(glTexCoord4hNV)
3116 USE_GL_FUNC(glTexCoord4hvNV)
3117 USE_GL_FUNC(glVertex2hNV)
3118 USE_GL_FUNC(glVertex2hvNV)
3119 USE_GL_FUNC(glVertex3hNV)
3120 USE_GL_FUNC(glVertex3hvNV)
3121 USE_GL_FUNC(glVertex4hNV)
3122 USE_GL_FUNC(glVertex4hvNV)
3123 USE_GL_FUNC(glVertexAttrib1hNV)
3124 USE_GL_FUNC(glVertexAttrib1hvNV)
3125 USE_GL_FUNC(glVertexAttrib2hNV)
3126 USE_GL_FUNC(glVertexAttrib2hvNV)
3127 USE_GL_FUNC(glVertexAttrib3hNV)
3128 USE_GL_FUNC(glVertexAttrib3hvNV)
3129 USE_GL_FUNC(glVertexAttrib4hNV)
3130 USE_GL_FUNC(glVertexAttrib4hvNV)
3131 USE_GL_FUNC(glVertexAttribs1hvNV)
3132 USE_GL_FUNC(glVertexAttribs2hvNV)
3133 USE_GL_FUNC(glVertexAttribs3hvNV)
3134 USE_GL_FUNC(glVertexAttribs4hvNV)
3135 USE_GL_FUNC(glVertexWeighthNV)
3136 USE_GL_FUNC(glVertexWeighthvNV)
3137 /* GL_NV_point_sprite */
3138 USE_GL_FUNC(glPointParameteriNV)
3139 USE_GL_FUNC(glPointParameterivNV)
3140 /* GL_NV_register_combiners */
3141 USE_GL_FUNC(glCombinerInputNV)
3142 USE_GL_FUNC(glCombinerOutputNV)
3143 USE_GL_FUNC(glCombinerParameterfNV)
3144 USE_GL_FUNC(glCombinerParameterfvNV)
3145 USE_GL_FUNC(glCombinerParameteriNV)
3146 USE_GL_FUNC(glCombinerParameterivNV)
3147 USE_GL_FUNC(glFinalCombinerInputNV)
3148 /* WGL extensions */
3149 USE_GL_FUNC(wglChoosePixelFormatARB)
3150 USE_GL_FUNC(wglGetExtensionsStringARB)
3151 USE_GL_FUNC(wglGetPixelFormatAttribfvARB)
3152 USE_GL_FUNC(wglGetPixelFormatAttribivARB)
3153 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE)
3154 USE_GL_FUNC(wglQueryCurrentRendererStringWINE)
3155 USE_GL_FUNC(wglQueryRendererIntegerWINE)
3156 USE_GL_FUNC(wglQueryRendererStringWINE)
3157 USE_GL_FUNC(wglSetPixelFormatWINE)
3158 USE_GL_FUNC(wglSwapIntervalEXT)
3160 /* Newer core functions */
3161 USE_GL_FUNC(glActiveTexture) /* OpenGL 1.3 */
3162 USE_GL_FUNC(glAttachShader) /* OpenGL 2.0 */
3163 USE_GL_FUNC(glBeginQuery) /* OpenGL 1.5 */
3164 USE_GL_FUNC(glBindAttribLocation) /* OpenGL 2.0 */
3165 USE_GL_FUNC(glBindBuffer) /* OpenGL 1.5 */
3166 USE_GL_FUNC(glBindVertexArray) /* OpenGL 3.0 */
3167 USE_GL_FUNC(glBlendColor) /* OpenGL 1.4 */
3168 USE_GL_FUNC(glBlendEquation) /* OpenGL 1.4 */
3169 USE_GL_FUNC(glBlendEquationSeparate) /* OpenGL 2.0 */
3170 USE_GL_FUNC(glBlendFuncSeparate) /* OpenGL 1.4 */
3171 USE_GL_FUNC(glBufferData) /* OpenGL 1.5 */
3172 USE_GL_FUNC(glBufferSubData) /* OpenGL 1.5 */
3173 USE_GL_FUNC(glColorMaski) /* OpenGL 3.0 */
3174 USE_GL_FUNC(glCompileShader) /* OpenGL 2.0 */
3175 USE_GL_FUNC(glCompressedTexImage2D) /* OpenGL 1.3 */
3176 USE_GL_FUNC(glCompressedTexImage3D) /* OpenGL 1.3 */
3177 USE_GL_FUNC(glCompressedTexSubImage2D) /* OpenGL 1.3 */
3178 USE_GL_FUNC(glCompressedTexSubImage3D) /* OpenGL 1.3 */
3179 USE_GL_FUNC(glCreateProgram) /* OpenGL 2.0 */
3180 USE_GL_FUNC(glCreateShader) /* OpenGL 2.0 */
3181 USE_GL_FUNC(glDebugMessageCallback) /* OpenGL 4.3 */
3182 USE_GL_FUNC(glDebugMessageControl) /* OpenGL 4.3 */
3183 USE_GL_FUNC(glDebugMessageInsert) /* OpenGL 4.3 */
3184 USE_GL_FUNC(glDeleteBuffers) /* OpenGL 1.5 */
3185 USE_GL_FUNC(glDeleteProgram) /* OpenGL 2.0 */
3186 USE_GL_FUNC(glDeleteQueries) /* OpenGL 1.5 */
3187 USE_GL_FUNC(glDeleteShader) /* OpenGL 2.0 */
3188 USE_GL_FUNC(glDeleteVertexArrays) /* OpenGL 3.0 */
3189 USE_GL_FUNC(glDetachShader) /* OpenGL 2.0 */
3190 USE_GL_FUNC(glDisablei) /* OpenGL 3.0 */
3191 USE_GL_FUNC(glDisableVertexAttribArray) /* OpenGL 2.0 */
3192 USE_GL_FUNC(glDrawArraysInstanced) /* OpenGL 3.1 */
3193 USE_GL_FUNC(glDrawBuffers) /* OpenGL 2.0 */
3194 USE_GL_FUNC(glDrawElementsInstanced) /* OpenGL 3.1 */
3195 USE_GL_FUNC(glEnablei) /* OpenGL 3.0 */
3196 USE_GL_FUNC(glEnableVertexAttribArray) /* OpenGL 2.0 */
3197 USE_GL_FUNC(glEndQuery) /* OpenGL 1.5 */
3198 USE_GL_FUNC(glGenBuffers) /* OpenGL 1.5 */
3199 USE_GL_FUNC(glGenQueries) /* OpenGL 1.5 */
3200 USE_GL_FUNC(glGenVertexArrays) /* OpenGL 3.0 */
3201 USE_GL_FUNC(glGetActiveUniform) /* OpenGL 2.0 */
3202 USE_GL_FUNC(glGetAttachedShaders) /* OpenGL 2.0 */
3203 USE_GL_FUNC(glGetAttribLocation) /* OpenGL 2.0 */
3204 USE_GL_FUNC(glGetBooleani_v) /* OpenGL 3.0 */
3205 USE_GL_FUNC(glGetBufferSubData) /* OpenGL 1.5 */
3206 USE_GL_FUNC(glGetCompressedTexImage) /* OpenGL 1.3 */
3207 USE_GL_FUNC(glGetDebugMessageLog) /* OpenGL 4.3 */
3208 USE_GL_FUNC(glGetIntegeri_v) /* OpenGL 3.0 */
3209 USE_GL_FUNC(glGetProgramInfoLog) /* OpenGL 2.0 */
3210 USE_GL_FUNC(glGetProgramiv) /* OpenGL 2.0 */
3211 USE_GL_FUNC(glGetQueryiv) /* OpenGL 1.5 */
3212 USE_GL_FUNC(glGetQueryObjectuiv) /* OpenGL 1.5 */
3213 USE_GL_FUNC(glGetShaderInfoLog) /* OpenGL 2.0 */
3214 USE_GL_FUNC(glGetShaderiv) /* OpenGL 2.0 */
3215 USE_GL_FUNC(glGetShaderSource) /* OpenGL 2.0 */
3216 USE_GL_FUNC(glGetStringi) /* OpenGL 3.0 */
3217 USE_GL_FUNC(glGetUniformfv) /* OpenGL 2.0 */
3218 USE_GL_FUNC(glGetUniformiv) /* OpenGL 2.0 */
3219 USE_GL_FUNC(glGetUniformLocation) /* OpenGL 2.0 */
3220 USE_GL_FUNC(glIsEnabledi) /* OpenGL 3.0 */
3221 USE_GL_FUNC(glLinkProgram) /* OpenGL 2.0 */
3222 USE_GL_FUNC(glMapBuffer) /* OpenGL 1.5 */
3223 USE_GL_FUNC(glPointParameteri) /* OpenGL 1.4 */
3224 USE_GL_FUNC(glPointParameteriv) /* OpenGL 1.4 */
3225 USE_GL_FUNC(glShaderSource) /* OpenGL 2.0 */
3226 USE_GL_FUNC(glStencilFuncSeparate) /* OpenGL 2.0 */
3227 USE_GL_FUNC(glStencilOpSeparate) /* OpenGL 2.0 */
3228 USE_GL_FUNC(glTexBuffer) /* OpenGL 3.1 */
3229 USE_GL_FUNC(glTexImage3D) /* OpenGL 1.2 */
3230 USE_GL_FUNC(glTexSubImage3D) /* OpenGL 1.2 */
3231 USE_GL_FUNC(glUniform1f) /* OpenGL 2.0 */
3232 USE_GL_FUNC(glUniform1fv) /* OpenGL 2.0 */
3233 USE_GL_FUNC(glUniform1i) /* OpenGL 2.0 */
3234 USE_GL_FUNC(glUniform1iv) /* OpenGL 2.0 */
3235 USE_GL_FUNC(glUniform2f) /* OpenGL 2.0 */
3236 USE_GL_FUNC(glUniform2fv) /* OpenGL 2.0 */
3237 USE_GL_FUNC(glUniform2i) /* OpenGL 2.0 */
3238 USE_GL_FUNC(glUniform2iv) /* OpenGL 2.0 */
3239 USE_GL_FUNC(glUniform3f) /* OpenGL 2.0 */
3240 USE_GL_FUNC(glUniform3fv) /* OpenGL 2.0 */
3241 USE_GL_FUNC(glUniform3i) /* OpenGL 2.0 */
3242 USE_GL_FUNC(glUniform3iv) /* OpenGL 2.0 */
3243 USE_GL_FUNC(glUniform4f) /* OpenGL 2.0 */
3244 USE_GL_FUNC(glUniform4fv) /* OpenGL 2.0 */
3245 USE_GL_FUNC(glUniform4i) /* OpenGL 2.0 */
3246 USE_GL_FUNC(glUniform4iv) /* OpenGL 2.0 */
3247 USE_GL_FUNC(glUniformMatrix2fv) /* OpenGL 2.0 */
3248 USE_GL_FUNC(glUniformMatrix3fv) /* OpenGL 2.0 */
3249 USE_GL_FUNC(glUniformMatrix4fv) /* OpenGL 2.0 */
3250 USE_GL_FUNC(glUnmapBuffer) /* OpenGL 1.5 */
3251 USE_GL_FUNC(glUseProgram) /* OpenGL 2.0 */
3252 USE_GL_FUNC(glValidateProgram) /* OpenGL 2.0 */
3253 USE_GL_FUNC(glVertexAttrib1f) /* OpenGL 2.0 */
3254 USE_GL_FUNC(glVertexAttrib1fv) /* OpenGL 2.0 */
3255 USE_GL_FUNC(glVertexAttrib2f) /* OpenGL 2.0 */
3256 USE_GL_FUNC(glVertexAttrib2fv) /* OpenGL 2.0 */
3257 USE_GL_FUNC(glVertexAttrib3f) /* OpenGL 2.0 */
3258 USE_GL_FUNC(glVertexAttrib3fv) /* OpenGL 2.0 */
3259 USE_GL_FUNC(glVertexAttrib4f) /* OpenGL 2.0 */
3260 USE_GL_FUNC(glVertexAttrib4fv) /* OpenGL 2.0 */
3261 USE_GL_FUNC(glVertexAttrib4Nsv) /* OpenGL 2.0 */
3262 USE_GL_FUNC(glVertexAttrib4Nub) /* OpenGL 2.0 */
3263 USE_GL_FUNC(glVertexAttrib4Nubv) /* OpenGL 2.0 */
3264 USE_GL_FUNC(glVertexAttrib4Nusv) /* OpenGL 2.0 */
3265 USE_GL_FUNC(glVertexAttrib4sv) /* OpenGL 2.0 */
3266 USE_GL_FUNC(glVertexAttrib4ubv) /* OpenGL 2.0 */
3267 USE_GL_FUNC(glVertexAttribDivisor) /* OpenGL 3.3 */
3268 USE_GL_FUNC(glVertexAttribIPointer) /* OpenGL 3.0 */
3269 USE_GL_FUNC(glVertexAttribPointer) /* OpenGL 2.0 */
3270 #undef USE_GL_FUNC
3272 #ifndef USE_WIN32_OPENGL
3273 /* hack: use the functions directly from the TEB table to bypass the thunks */
3274 /* note that we still need the above wglGetProcAddress calls to initialize the table */
3275 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
3276 #endif
3278 #define MAP_GL_FUNCTION(core_func, ext_func) \
3279 do \
3281 if (!gl_info->gl_ops.ext.p_##core_func) \
3282 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
3283 } while (0)
3284 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
3285 do \
3287 if (!gl_info->gl_ops.ext.p_##core_func) \
3288 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
3289 } while (0)
3291 MAP_GL_FUNCTION(glActiveTexture, glActiveTextureARB);
3292 MAP_GL_FUNCTION(glAttachShader, glAttachObjectARB);
3293 MAP_GL_FUNCTION(glBeginQuery, glBeginQueryARB);
3294 MAP_GL_FUNCTION(glBindAttribLocation, glBindAttribLocationARB);
3295 MAP_GL_FUNCTION(glBindBuffer, glBindBufferARB);
3296 MAP_GL_FUNCTION(glBlendColor, glBlendColorEXT);
3297 MAP_GL_FUNCTION(glBlendEquation, glBlendEquationEXT);
3298 MAP_GL_FUNCTION(glBlendEquationSeparate, glBlendEquationSeparateEXT);
3299 MAP_GL_FUNCTION(glBlendFuncSeparate, glBlendFuncSeparateEXT);
3300 MAP_GL_FUNCTION(glBufferData, glBufferDataARB);
3301 MAP_GL_FUNCTION(glBufferSubData, glBufferSubDataARB);
3302 MAP_GL_FUNCTION(glColorMaski, glColorMaskIndexedEXT);
3303 MAP_GL_FUNCTION(glCompileShader, glCompileShaderARB);
3304 MAP_GL_FUNCTION(glCompressedTexImage2D, glCompressedTexImage2DARB);
3305 MAP_GL_FUNCTION(glCompressedTexImage3D, glCompressedTexImage3DARB);
3306 MAP_GL_FUNCTION(glCompressedTexSubImage2D, glCompressedTexSubImage2DARB);
3307 MAP_GL_FUNCTION(glCompressedTexSubImage3D, glCompressedTexSubImage3DARB);
3308 MAP_GL_FUNCTION(glCreateProgram, glCreateProgramObjectARB);
3309 MAP_GL_FUNCTION(glCreateShader, glCreateShaderObjectARB);
3310 MAP_GL_FUNCTION(glDebugMessageCallback, glDebugMessageCallbackARB);
3311 MAP_GL_FUNCTION(glDebugMessageControl, glDebugMessageControlARB);
3312 MAP_GL_FUNCTION(glDebugMessageInsert, glDebugMessageInsertARB);
3313 MAP_GL_FUNCTION(glDeleteBuffers, glDeleteBuffersARB);
3314 MAP_GL_FUNCTION(glDeleteProgram, glDeleteObjectARB);
3315 MAP_GL_FUNCTION(glDeleteQueries, glDeleteQueriesARB);
3316 MAP_GL_FUNCTION(glDeleteShader, glDeleteObjectARB);
3317 MAP_GL_FUNCTION(glDetachShader, glDetachObjectARB);
3318 MAP_GL_FUNCTION(glDisablei, glDisableIndexedEXT);
3319 MAP_GL_FUNCTION(glDisableVertexAttribArray, glDisableVertexAttribArrayARB);
3320 MAP_GL_FUNCTION(glDrawArraysInstanced, glDrawArraysInstancedARB);
3321 MAP_GL_FUNCTION(glDrawBuffers, glDrawBuffersARB);
3322 MAP_GL_FUNCTION(glDrawElementsInstanced, glDrawElementsInstancedARB);
3323 MAP_GL_FUNCTION(glEnablei, glEnableIndexedEXT);
3324 MAP_GL_FUNCTION(glEnableVertexAttribArray, glEnableVertexAttribArrayARB);
3325 MAP_GL_FUNCTION(glEndQuery, glEndQueryARB);
3326 MAP_GL_FUNCTION(glGenBuffers, glGenBuffersARB);
3327 MAP_GL_FUNCTION(glGenQueries, glGenQueriesARB);
3328 MAP_GL_FUNCTION(glGetActiveUniform, glGetActiveUniformARB);
3329 MAP_GL_FUNCTION(glGetAttachedShaders, glGetAttachedObjectsARB);
3330 MAP_GL_FUNCTION(glGetAttribLocation, glGetAttribLocationARB);
3331 MAP_GL_FUNCTION(glGetBooleani_v, glGetBooleanIndexedvEXT);
3332 MAP_GL_FUNCTION(glGetBufferSubData, glGetBufferSubDataARB);
3333 MAP_GL_FUNCTION(glGetCompressedTexImage, glGetCompressedTexImageARB);
3334 MAP_GL_FUNCTION(glGetDebugMessageLog, glGetDebugMessageLogARB);
3335 MAP_GL_FUNCTION(glGetIntegeri_v, glGetIntegerIndexedvEXT);
3336 MAP_GL_FUNCTION(glGetProgramInfoLog, glGetInfoLogARB);
3337 MAP_GL_FUNCTION(glGetProgramiv, glGetObjectParameterivARB);
3338 MAP_GL_FUNCTION(glGetQueryiv, glGetQueryivARB);
3339 MAP_GL_FUNCTION(glGetQueryObjectuiv, glGetQueryObjectuivARB);
3340 MAP_GL_FUNCTION(glGetShaderInfoLog, glGetInfoLogARB);
3341 MAP_GL_FUNCTION(glGetShaderiv, glGetObjectParameterivARB);
3342 MAP_GL_FUNCTION(glGetShaderSource, glGetShaderSourceARB);
3343 MAP_GL_FUNCTION(glGetUniformfv, glGetUniformfvARB);
3344 MAP_GL_FUNCTION(glGetUniformiv, glGetUniformivARB);
3345 MAP_GL_FUNCTION(glGetUniformLocation, glGetUniformLocationARB);
3346 MAP_GL_FUNCTION(glIsEnabledi, glIsEnabledIndexedEXT);
3347 MAP_GL_FUNCTION(glLinkProgram, glLinkProgramARB);
3348 MAP_GL_FUNCTION(glMapBuffer, glMapBufferARB);
3349 MAP_GL_FUNCTION_CAST(glShaderSource, glShaderSourceARB);
3350 MAP_GL_FUNCTION(glTexBuffer, glTexBufferARB);
3351 MAP_GL_FUNCTION_CAST(glTexImage3D, glTexImage3DEXT);
3352 MAP_GL_FUNCTION(glTexSubImage3D, glTexSubImage3DEXT);
3353 MAP_GL_FUNCTION(glUniform1f, glUniform1fARB);
3354 MAP_GL_FUNCTION(glUniform1fv, glUniform1fvARB);
3355 MAP_GL_FUNCTION(glUniform1i, glUniform1iARB);
3356 MAP_GL_FUNCTION(glUniform1iv, glUniform1ivARB);
3357 MAP_GL_FUNCTION(glUniform2f, glUniform2fARB);
3358 MAP_GL_FUNCTION(glUniform2fv, glUniform2fvARB);
3359 MAP_GL_FUNCTION(glUniform2i, glUniform2iARB);
3360 MAP_GL_FUNCTION(glUniform2iv, glUniform2ivARB);
3361 MAP_GL_FUNCTION(glUniform3f, glUniform3fARB);
3362 MAP_GL_FUNCTION(glUniform3fv, glUniform3fvARB);
3363 MAP_GL_FUNCTION(glUniform3i, glUniform3iARB);
3364 MAP_GL_FUNCTION(glUniform3iv, glUniform3ivARB);
3365 MAP_GL_FUNCTION(glUniform4f, glUniform4fARB);
3366 MAP_GL_FUNCTION(glUniform4fv, glUniform4fvARB);
3367 MAP_GL_FUNCTION(glUniform4i, glUniform4iARB);
3368 MAP_GL_FUNCTION(glUniform4iv, glUniform4ivARB);
3369 MAP_GL_FUNCTION(glUniformMatrix2fv, glUniformMatrix2fvARB);
3370 MAP_GL_FUNCTION(glUniformMatrix3fv, glUniformMatrix3fvARB);
3371 MAP_GL_FUNCTION(glUniformMatrix4fv, glUniformMatrix4fvARB);
3372 MAP_GL_FUNCTION(glUnmapBuffer, glUnmapBufferARB);
3373 MAP_GL_FUNCTION(glUseProgram, glUseProgramObjectARB);
3374 MAP_GL_FUNCTION(glValidateProgram, glValidateProgramARB);
3375 MAP_GL_FUNCTION(glVertexAttrib1f, glVertexAttrib1fARB);
3376 MAP_GL_FUNCTION(glVertexAttrib1fv, glVertexAttrib1fvARB);
3377 MAP_GL_FUNCTION(glVertexAttrib2f, glVertexAttrib2fARB);
3378 MAP_GL_FUNCTION(glVertexAttrib2fv, glVertexAttrib2fvARB);
3379 MAP_GL_FUNCTION(glVertexAttrib3f, glVertexAttrib3fARB);
3380 MAP_GL_FUNCTION(glVertexAttrib3fv, glVertexAttrib3fvARB);
3381 MAP_GL_FUNCTION(glVertexAttrib4f, glVertexAttrib4fARB);
3382 MAP_GL_FUNCTION(glVertexAttrib4fv, glVertexAttrib4fvARB);
3383 MAP_GL_FUNCTION(glVertexAttrib4Nsv, glVertexAttrib4NsvARB);
3384 MAP_GL_FUNCTION(glVertexAttrib4Nub, glVertexAttrib4NubARB);
3385 MAP_GL_FUNCTION(glVertexAttrib4Nubv, glVertexAttrib4NubvARB);
3386 MAP_GL_FUNCTION(glVertexAttrib4Nusv, glVertexAttrib4NusvARB);
3387 MAP_GL_FUNCTION(glVertexAttrib4sv, glVertexAttrib4svARB);
3388 MAP_GL_FUNCTION(glVertexAttrib4ubv, glVertexAttrib4ubvARB);
3389 MAP_GL_FUNCTION(glVertexAttribDivisor, glVertexAttribDivisorARB);
3390 MAP_GL_FUNCTION(glVertexAttribIPointer, glVertexAttribIPointerEXT);
3391 MAP_GL_FUNCTION(glVertexAttribPointer, glVertexAttribPointerARB);
3392 #undef MAP_GL_FUNCTION
3393 #undef MAP_GL_FUNCTION_CAST
3396 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
3398 unsigned int i, sampler_count;
3399 GLfloat gl_floatv[2];
3400 GLint gl_max;
3402 gl_info->limits.blends = 1;
3403 gl_info->limits.buffers = 1;
3404 gl_info->limits.textures = 0;
3405 gl_info->limits.texture_coords = 0;
3406 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3408 gl_info->limits.uniform_blocks[i] = 0;
3409 gl_info->limits.samplers[i] = 0;
3411 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = 1;
3412 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3413 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3414 gl_info->limits.vertex_attribs = 16;
3415 gl_info->limits.texture_buffer_offset_alignment = 1;
3416 gl_info->limits.glsl_vs_float_constants = 0;
3417 gl_info->limits.glsl_ps_float_constants = 0;
3418 gl_info->limits.arb_vs_float_constants = 0;
3419 gl_info->limits.arb_vs_native_constants = 0;
3420 gl_info->limits.arb_vs_instructions = 0;
3421 gl_info->limits.arb_vs_temps = 0;
3422 gl_info->limits.arb_ps_float_constants = 0;
3423 gl_info->limits.arb_ps_local_constants = 0;
3424 gl_info->limits.arb_ps_instructions = 0;
3425 gl_info->limits.arb_ps_temps = 0;
3427 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES, &gl_max);
3428 gl_info->limits.user_clip_distances = min(MAX_CLIP_DISTANCES, gl_max);
3429 TRACE("Clip plane support - max planes %d.\n", gl_max);
3431 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3433 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
3434 gl_info->limits.lights = gl_max;
3435 TRACE("Light support - max lights %d.\n", gl_max);
3438 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
3439 gl_info->limits.texture_size = gl_max;
3440 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
3442 gl_info->gl_ops.gl.p_glGetFloatv(gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]
3443 ? GL_ALIASED_POINT_SIZE_RANGE : GL_POINT_SIZE_RANGE, gl_floatv);
3444 gl_info->limits.pointsize_min = gl_floatv[0];
3445 gl_info->limits.pointsize_max = gl_floatv[1];
3446 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
3448 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
3450 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
3451 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
3453 else
3455 WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
3457 if (gl_info->supported[NV_REGISTER_COMBINERS])
3459 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
3460 gl_info->limits.general_combiners = gl_max;
3461 TRACE("Max general combiners: %d.\n", gl_max);
3463 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3465 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
3466 gl_info->limits.buffers = gl_max;
3467 TRACE("Max draw buffers: %u.\n", gl_max);
3469 if (gl_info->supported[ARB_MULTITEXTURE])
3471 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3473 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
3474 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
3475 TRACE("Max textures: %d.\n", gl_info->limits.textures);
3477 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3479 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
3480 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
3482 else
3484 gl_info->limits.texture_coords = gl_info->limits.textures;
3486 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
3489 if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
3491 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max);
3492 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_max;
3494 else
3496 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_info->limits.textures;
3498 TRACE("Max fragment samplers: %d.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]);
3500 if (gl_info->supported[ARB_VERTEX_SHADER])
3502 unsigned int vertex_sampler_count;
3504 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3505 vertex_sampler_count = gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = gl_max;
3506 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
3507 gl_info->limits.combined_samplers = gl_max;
3508 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &gl_max);
3509 gl_info->limits.vertex_attribs = gl_max;
3511 /* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
3512 * is known at shader link time. In a vertex shader + pixel shader combination this isn't
3513 * an issue because then the sampler setup only depends on the two shaders. If a pixel
3514 * shader is used with fixed function vertex processing we're fine too because fixed function
3515 * vertex processing doesn't use any samplers. If fixed function fragment processing is
3516 * used we have to make sure that all vertex sampler setups are valid together with all
3517 * possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
3518 * <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
3519 * dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
3520 * dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
3521 * a fixed function pipeline anymore.
3523 * So this is just a check to check that our assumption holds true. If not, write a warning
3524 * and reduce the number of vertex samplers or probably disable vertex texture fetch. */
3525 if (vertex_sampler_count && gl_info->limits.combined_samplers < 12
3526 && MAX_TEXTURES + vertex_sampler_count > gl_info->limits.combined_samplers)
3528 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
3529 vertex_sampler_count, gl_info->limits.combined_samplers);
3530 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
3531 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
3532 vertex_sampler_count = gl_info->limits.combined_samplers - MAX_TEXTURES;
3533 else
3534 vertex_sampler_count = 0;
3535 gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = vertex_sampler_count;
3538 else
3540 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
3542 TRACE("Max vertex samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]);
3543 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
3544 TRACE("Max vertex attributes: %u.\n", gl_info->limits.vertex_attribs);
3546 else
3548 gl_info->limits.textures = 1;
3549 gl_info->limits.texture_coords = 1;
3552 if (gl_info->supported[ARB_VERTEX_BLEND])
3554 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
3555 gl_info->limits.blends = gl_max;
3556 TRACE("Max blends: %u.\n", gl_info->limits.blends);
3558 if (gl_info->supported[EXT_TEXTURE3D])
3560 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
3561 gl_info->limits.texture3d_size = gl_max;
3562 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
3564 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
3566 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
3567 gl_info->limits.anisotropy = gl_max;
3568 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
3570 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3572 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3573 gl_info->limits.arb_ps_float_constants = gl_max;
3574 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
3575 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3576 gl_info->limits.arb_ps_native_constants = gl_max;
3577 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3578 gl_info->limits.arb_ps_native_constants);
3579 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3580 gl_info->limits.arb_ps_temps = gl_max;
3581 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
3582 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3583 gl_info->limits.arb_ps_instructions = gl_max;
3584 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
3585 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
3586 gl_info->limits.arb_ps_local_constants = gl_max;
3587 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
3589 if (gl_info->supported[ARB_VERTEX_PROGRAM])
3591 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3592 gl_info->limits.arb_vs_float_constants = gl_max;
3593 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
3594 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3595 gl_info->limits.arb_vs_native_constants = gl_max;
3596 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3597 gl_info->limits.arb_vs_native_constants);
3598 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3599 gl_info->limits.arb_vs_temps = gl_max;
3600 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
3601 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3602 gl_info->limits.arb_vs_instructions = gl_max;
3603 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
3605 if (gl_info->supported[ARB_VERTEX_SHADER])
3607 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
3608 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
3609 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
3611 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3613 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &gl_max);
3614 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX] = min(gl_max, WINED3D_MAX_CBS);
3615 TRACE("Max vertex uniform blocks: %u (%d).\n",
3616 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX], gl_max);
3619 if ((!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] || gl_info->supported[ARB_GEOMETRY_SHADER4])
3620 && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3622 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gl_max);
3623 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY] = min(gl_max, WINED3D_MAX_CBS);
3624 TRACE("Max geometry uniform blocks: %u (%d).\n",
3625 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY], gl_max);
3626 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &gl_max);
3627 gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY] = gl_max;
3628 TRACE("Max geometry samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY]);
3630 if (gl_info->supported[ARB_FRAGMENT_SHADER])
3632 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
3633 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
3634 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
3635 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
3636 gl_info->limits.glsl_varyings = gl_max;
3637 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
3639 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3641 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &gl_max);
3642 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL] = min(gl_max, WINED3D_MAX_CBS);
3643 TRACE("Max fragment uniform blocks: %u (%d).\n",
3644 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL], gl_max);
3647 if (gl_info->supported[ARB_COMPUTE_SHADER])
3649 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &gl_max);
3650 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE] = min(gl_max, WINED3D_MAX_CBS);
3651 TRACE("Max compute uniform blocks: %u (%d).\n",
3652 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE], gl_max);
3653 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &gl_max);
3654 gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE] = gl_max;
3655 TRACE("Max compute samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]);
3657 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3659 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &gl_max);
3660 TRACE("Max combined uniform blocks: %d.\n", gl_max);
3661 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &gl_max);
3662 TRACE("Max uniform buffer bindings: %d.\n", gl_max);
3664 if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
3666 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_max);
3667 gl_info->limits.texture_buffer_offset_alignment = gl_max;
3668 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max);
3670 if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS])
3672 GLint max_fragment_buffers, max_combined_buffers, max_bindings;
3673 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &max_fragment_buffers);
3674 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers);
3675 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &max_combined_buffers);
3676 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers);
3677 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
3678 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings);
3679 if (max_fragment_buffers < MAX_UNORDERED_ACCESS_VIEWS
3680 || max_combined_buffers < MAX_UNORDERED_ACCESS_VIEWS
3681 || max_bindings < MAX_UNORDERED_ACCESS_VIEWS)
3683 WARN("Disabling ARB_shader_atomic_counters.\n");
3684 gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS] = FALSE;
3688 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
3689 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
3690 else
3691 gl_info->limits.shininess = 128.0f;
3693 if ((gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
3694 && wined3d_settings.allow_multisampling)
3696 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
3697 gl_info->limits.samples = gl_max;
3700 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] =
3701 min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_GL_FRAGMENT_SAMPLERS);
3702 sampler_count = 0;
3703 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3704 sampler_count += gl_info->limits.samplers[i];
3705 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->limits.combined_samplers < sampler_count)
3707 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3708 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3709 * the minimum value is increased to 80. */
3710 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3711 sampler_count, gl_info->limits.combined_samplers);
3712 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3713 gl_info->limits.samplers[i] = min(gl_info->limits.samplers[i], 16);
3716 /* A majority of OpenGL implementations allow us to statically partition
3717 * the set of texture bindings into six separate sets. */
3718 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3719 sampler_count = 0;
3720 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3721 sampler_count += gl_info->limits.samplers[i];
3722 if (gl_info->limits.combined_samplers >= sampler_count)
3723 gl_info->limits.graphics_samplers -= gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE];
3726 /* Context activation is done by the caller. */
3727 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
3728 struct wined3d_caps_gl_ctx *caps_gl_ctx, DWORD wined3d_creation_flags)
3730 static const struct
3732 enum wined3d_gl_extension extension;
3733 DWORD min_gl_version;
3735 core_extensions[] =
3737 {EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2)},
3738 {ARB_MULTISAMPLE, MAKEDWORD_VERSION(1, 3)},
3739 {ARB_MULTITEXTURE, MAKEDWORD_VERSION(1, 3)},
3740 {ARB_TEXTURE_BORDER_CLAMP, MAKEDWORD_VERSION(1, 3)},
3741 {ARB_TEXTURE_COMPRESSION, MAKEDWORD_VERSION(1, 3)},
3742 {ARB_TEXTURE_CUBE_MAP, MAKEDWORD_VERSION(1, 3)},
3743 {ARB_DEPTH_TEXTURE, MAKEDWORD_VERSION(1, 4)},
3744 {ARB_POINT_PARAMETERS, MAKEDWORD_VERSION(1, 4)},
3745 {ARB_SHADOW, MAKEDWORD_VERSION(1, 4)},
3746 {ARB_TEXTURE_MIRRORED_REPEAT, MAKEDWORD_VERSION(1, 4)},
3747 {EXT_BLEND_COLOR, MAKEDWORD_VERSION(1, 4)},
3748 {EXT_BLEND_FUNC_SEPARATE, MAKEDWORD_VERSION(1, 4)},
3749 {EXT_BLEND_MINMAX, MAKEDWORD_VERSION(1, 4)},
3750 {EXT_BLEND_SUBTRACT, MAKEDWORD_VERSION(1, 4)},
3751 {EXT_STENCIL_WRAP, MAKEDWORD_VERSION(1, 4)},
3752 {NV_POINT_SPRITE, MAKEDWORD_VERSION(1, 4)},
3753 {ARB_OCCLUSION_QUERY, MAKEDWORD_VERSION(1, 5)},
3754 {ARB_VERTEX_BUFFER_OBJECT, MAKEDWORD_VERSION(1, 5)},
3755 {ARB_DRAW_BUFFERS, MAKEDWORD_VERSION(2, 0)},
3756 {ARB_FRAGMENT_SHADER, MAKEDWORD_VERSION(2, 0)},
3757 {ARB_SHADING_LANGUAGE_100, MAKEDWORD_VERSION(2, 0)},
3758 {ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0)},
3759 {ARB_VERTEX_SHADER, MAKEDWORD_VERSION(2, 0)},
3760 {EXT_BLEND_EQUATION_SEPARATE, MAKEDWORD_VERSION(2, 0)},
3761 {ARB_PIXEL_BUFFER_OBJECT, MAKEDWORD_VERSION(2, 1)},
3762 {EXT_TEXTURE_SRGB, MAKEDWORD_VERSION(2, 1)},
3763 {ARB_COLOR_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3764 {ARB_DEPTH_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3765 {ARB_FRAMEBUFFER_OBJECT, MAKEDWORD_VERSION(3, 0)},
3766 {ARB_FRAMEBUFFER_SRGB, MAKEDWORD_VERSION(3, 0)},
3767 {ARB_HALF_FLOAT_PIXEL, MAKEDWORD_VERSION(3, 0)},
3768 {ARB_HALF_FLOAT_VERTEX, MAKEDWORD_VERSION(3, 0)},
3769 {ARB_MAP_BUFFER_RANGE, MAKEDWORD_VERSION(3, 0)},
3770 {ARB_TEXTURE_COMPRESSION_RGTC, MAKEDWORD_VERSION(3, 0)},
3771 {ARB_TEXTURE_FLOAT, MAKEDWORD_VERSION(3, 0)},
3772 {ARB_TEXTURE_RG, MAKEDWORD_VERSION(3, 0)},
3773 {EXT_DRAW_BUFFERS2, MAKEDWORD_VERSION(3, 0)},
3774 {EXT_PACKED_FLOAT, MAKEDWORD_VERSION(3, 0)},
3775 {EXT_TEXTURE_ARRAY, MAKEDWORD_VERSION(3, 0)},
3776 {EXT_TEXTURE_INTEGER, MAKEDWORD_VERSION(3, 0)},
3777 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3778 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3779 * enough that reusing the same flag for the new features hurts more
3780 * than it helps. */
3781 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3782 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3783 * are integrated into ARB_framebuffer_object. */
3785 {ARB_COPY_BUFFER, MAKEDWORD_VERSION(3, 1)},
3786 {ARB_DRAW_INSTANCED, MAKEDWORD_VERSION(3, 1)},
3787 {ARB_TEXTURE_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3788 {ARB_UNIFORM_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3789 {EXT_TEXTURE_SNORM, MAKEDWORD_VERSION(3, 1)},
3790 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3792 {ARB_DRAW_ELEMENTS_BASE_VERTEX, MAKEDWORD_VERSION(3, 2)},
3793 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3794 * core geometry shaders so it's not really correct to expose the
3795 * extension for core-only support. */
3796 {ARB_FRAGMENT_COORD_CONVENTIONS, MAKEDWORD_VERSION(3, 2)},
3797 {ARB_PROVOKING_VERTEX, MAKEDWORD_VERSION(3, 2)},
3798 {ARB_SEAMLESS_CUBE_MAP, MAKEDWORD_VERSION(3, 2)},
3799 {ARB_SYNC, MAKEDWORD_VERSION(3, 2)},
3800 {ARB_VERTEX_ARRAY_BGRA, MAKEDWORD_VERSION(3, 2)},
3802 {ARB_BLEND_FUNC_EXTENDED, MAKEDWORD_VERSION(3, 3)},
3803 {ARB_EXPLICIT_ATTRIB_LOCATION, MAKEDWORD_VERSION(3, 3)},
3804 {ARB_INSTANCED_ARRAYS, MAKEDWORD_VERSION(3, 3)},
3805 {ARB_SAMPLER_OBJECTS, MAKEDWORD_VERSION(3, 3)},
3806 {ARB_SHADER_BIT_ENCODING, MAKEDWORD_VERSION(3, 3)},
3807 {ARB_TEXTURE_RGB10_A2UI, MAKEDWORD_VERSION(3, 3)},
3808 {ARB_TEXTURE_SWIZZLE, MAKEDWORD_VERSION(3, 3)},
3809 {ARB_TIMER_QUERY, MAKEDWORD_VERSION(3, 3)},
3810 {ARB_VERTEX_TYPE_2_10_10_10_REV, MAKEDWORD_VERSION(3, 3)},
3812 {ARB_GPU_SHADER5, MAKEDWORD_VERSION(4, 0)},
3813 {ARB_TEXTURE_CUBE_MAP_ARRAY, MAKEDWORD_VERSION(4, 0)},
3815 {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)},
3816 {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)},
3818 {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)},
3819 {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)},
3820 {ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)},
3821 {ARB_SHADER_IMAGE_LOAD_STORE, MAKEDWORD_VERSION(4, 2)},
3822 {ARB_SHADING_LANGUAGE_420PACK, MAKEDWORD_VERSION(4, 2)},
3823 {ARB_SHADING_LANGUAGE_PACKING, MAKEDWORD_VERSION(4, 2)},
3824 {ARB_TEXTURE_COMPRESSION_BPTC, MAKEDWORD_VERSION(4, 2)},
3825 {ARB_TEXTURE_STORAGE, MAKEDWORD_VERSION(4, 2)},
3827 {ARB_COMPUTE_SHADER, MAKEDWORD_VERSION(4, 3)},
3828 {ARB_DEBUG_OUTPUT, MAKEDWORD_VERSION(4, 3)},
3829 {ARB_ES3_COMPATIBILITY, MAKEDWORD_VERSION(4, 3)},
3830 {ARB_INTERNALFORMAT_QUERY2, MAKEDWORD_VERSION(4, 3)},
3831 {ARB_SHADER_IMAGE_SIZE, MAKEDWORD_VERSION(4, 3)},
3832 {ARB_SHADER_STORAGE_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3833 {ARB_STENCIL_TEXTURING, MAKEDWORD_VERSION(4, 3)},
3834 {ARB_TEXTURE_BUFFER_RANGE, MAKEDWORD_VERSION(4, 3)},
3835 {ARB_TEXTURE_QUERY_LEVELS, MAKEDWORD_VERSION(4, 3)},
3836 {ARB_TEXTURE_VIEW, MAKEDWORD_VERSION(4, 3)},
3838 {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
3839 {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
3841 struct wined3d_driver_info *driver_info = &adapter->driver_info;
3842 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
3843 struct wined3d_gl_info *gl_info = &adapter->gl_info;
3844 const struct gpu_description *gpu_description;
3845 struct wined3d_vertex_caps vertex_caps;
3846 struct fragment_caps fragment_caps;
3847 struct shader_caps shader_caps;
3848 const char *WGL_Extensions = NULL;
3849 enum wined3d_gl_vendor gl_vendor;
3850 DWORD gl_version, gl_ext_emul_mask;
3851 UINT64 vram_bytes = 0;
3852 HDC hdc;
3853 unsigned int i, j;
3854 GLint context_profile = 0;
3856 TRACE("adapter %p.\n", adapter);
3858 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
3859 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
3860 if (!gl_renderer_str)
3862 ERR("Received a NULL GL_RENDERER.\n");
3863 return FALSE;
3866 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
3867 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
3868 if (!gl_vendor_str)
3870 ERR("Received a NULL GL_VENDOR.\n");
3871 return FALSE;
3874 /* Parse the GL_VERSION field into major and minor information */
3875 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
3876 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
3877 if (!gl_version_str)
3879 ERR("Received a NULL GL_VERSION.\n");
3880 return FALSE;
3882 gl_version = wined3d_parse_gl_version(gl_version_str);
3884 load_gl_funcs(gl_info);
3886 memset(gl_info->supported, 0, sizeof(gl_info->supported));
3887 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
3889 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3891 gl_info->gl_ops.gl.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &context_profile);
3892 checkGLcall("Querying context profile");
3894 if (context_profile & GL_CONTEXT_CORE_PROFILE_BIT)
3895 TRACE("Got a core profile context.\n");
3896 else
3897 gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] = TRUE;
3899 TRACE("GL extensions reported:\n");
3900 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3902 const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
3904 if (!gl_extensions)
3906 ERR("Received a NULL GL_EXTENSIONS.\n");
3907 return FALSE;
3909 parse_extension_string(gl_info, gl_extensions, gl_extension_map,
3910 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
3912 else
3914 enumerate_gl_extensions(gl_info, gl_extension_map,
3915 sizeof(gl_extension_map) / sizeof(*gl_extension_map));
3918 hdc = wglGetCurrentDC();
3919 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
3920 if (GL_EXTCALL(wglGetExtensionsStringARB))
3921 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
3922 if (!WGL_Extensions)
3923 WARN("WGL extensions not supported.\n");
3924 else
3925 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
3926 sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
3928 for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
3930 if (!gl_info->supported[core_extensions[i].extension]
3931 && gl_version >= core_extensions[i].min_gl_version)
3933 for (j = 0; j < ARRAY_SIZE(gl_extension_map); ++j)
3934 if (gl_extension_map[j].extension == core_extensions[i].extension)
3935 break;
3937 if (j < ARRAY_SIZE(gl_extension_map))
3939 TRACE("GL CORE: %s support.\n", gl_extension_map[j].extension_string);
3940 gl_info->supported[core_extensions[i].extension] = TRUE;
3942 else
3944 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions[i].extension);
3949 if (gl_info->supported[EXT_BLEND_MINMAX] || gl_info->supported[EXT_BLEND_SUBTRACT])
3950 gl_info->supported[WINED3D_GL_BLEND_EQUATION] = TRUE;
3952 if (gl_version >= MAKEDWORD_VERSION(2, 0))
3953 gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
3954 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3955 gl_info->supported[WINED3D_GL_VERSION_3_2] = TRUE;
3956 if (gl_version >= MAKEDWORD_VERSION(4, 3))
3957 gl_info->supported[WINED3D_GL_VERSION_4_3] = TRUE;
3959 /* All the points are actually point sprites in core contexts, the APIs from
3960 * ARB_point_sprite are not supported anymore. */
3961 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3962 gl_info->supported[ARB_POINT_SPRITE] = FALSE;
3964 if (gl_info->supported[APPLE_FENCE])
3966 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
3967 * The apple extension interacts with some other apple exts. Disable the NV
3968 * extension if the apple one is support to prevent confusion in other parts
3969 * of the code. */
3970 gl_info->supported[NV_FENCE] = FALSE;
3972 if (gl_info->supported[APPLE_FLOAT_PIXELS])
3974 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
3976 * The enums are the same:
3977 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
3978 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
3979 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
3980 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
3981 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
3983 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
3985 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
3986 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
3988 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3990 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
3991 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
3994 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
3996 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
3997 * functionality. Prefer the ARB extension */
3998 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
4000 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
4002 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
4003 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
4005 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
4007 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
4008 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
4010 if (!gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
4012 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
4013 gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] = TRUE;
4015 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
4017 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
4018 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
4020 if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && !gl_info->supported[ARB_TEXTURE_RG])
4022 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
4023 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = FALSE;
4025 if (gl_info->supported[NV_TEXTURE_SHADER2])
4027 if (gl_info->supported[NV_REGISTER_COMBINERS])
4029 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
4030 * are supported. The nv extensions provide the same functionality as the
4031 * ATI one, and a bit more(signed pixelformats). */
4032 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
4035 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
4037 /* If we have full NP2 texture support, disable
4038 * GL_ARB_texture_rectangle because we will never use it.
4039 * This saves a few redundant glDisable calls. */
4040 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
4042 if (gl_info->supported[ATI_FRAGMENT_SHADER])
4044 /* Disable NV_register_combiners and fragment shader if this is supported.
4045 * generally the NV extensions are preferred over the ATI ones, and this
4046 * extension is disabled if register_combiners and texture_shader2 are both
4047 * supported. So we reach this place only if we have incomplete NV dxlevel 8
4048 * fragment processing support. */
4049 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
4050 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
4051 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
4052 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
4054 if (gl_info->supported[NV_HALF_FLOAT])
4056 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
4057 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
4059 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
4061 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
4062 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
4063 * we never render to sRGB surfaces). */
4064 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
4065 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
4067 if (gl_info->supported[ARB_OCCLUSION_QUERY])
4069 GLint counter_bits;
4071 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &counter_bits));
4072 TRACE("Occlusion query counter has %d bits.\n", counter_bits);
4073 if (!counter_bits)
4074 gl_info->supported[ARB_OCCLUSION_QUERY] = FALSE;
4076 if (gl_info->supported[ARB_TIMER_QUERY])
4078 GLint counter_bits;
4080 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &counter_bits));
4081 TRACE("Timestamp query counter has %d bits.\n", counter_bits);
4082 if (!counter_bits)
4083 gl_info->supported[ARB_TIMER_QUERY] = FALSE;
4085 if (gl_info->supported[ARB_VIEWPORT_ARRAY])
4087 GLint subpixel_bits;
4089 gl_info->gl_ops.gl.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &subpixel_bits);
4090 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits);
4091 if (subpixel_bits < 8)
4092 gl_info->supported[ARB_VIEWPORT_ARRAY] = FALSE;
4094 if (gl_info->supported[ARB_CLIP_CONTROL] && !gl_info->supported[ARB_VIEWPORT_ARRAY])
4096 /* When using ARB_clip_control we need the float viewport parameters
4097 * introduced by ARB_viewport_array to take care of the shifted pixel
4098 * coordinates. */
4099 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
4100 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
4102 if (gl_info->supported[ARB_STENCIL_TEXTURING] && !gl_info->supported[ARB_TEXTURE_SWIZZLE])
4104 /* The stencil value needs to be placed in the green channel. */
4105 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
4106 gl_info->supported[ARB_STENCIL_TEXTURING] = FALSE;
4108 if (!gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] && gl_info->supported[EXT_TEXTURE_MIRROR_CLAMP])
4110 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
4111 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] = TRUE;
4113 if (!gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] && gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
4115 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
4116 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] = TRUE;
4118 if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422])
4120 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
4121 FIXME("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
4122 gl_info->supported[APPLE_YCBCR_422] = FALSE;
4125 wined3d_adapter_init_limits(gl_info);
4127 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
4128 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
4130 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
4132 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
4133 unsigned int major, minor;
4135 TRACE("GLSL version string: %s.\n", debugstr_a(str));
4137 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
4138 sscanf(str, "%u.%u", &major, &minor);
4139 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
4142 checkGLcall("extension detection");
4144 adapter->shader_backend = select_shader_backend(gl_info);
4145 adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
4146 adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
4147 adapter->blitter = select_blit_implementation(gl_info, adapter->shader_backend);
4149 adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
4150 adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
4151 adapter->d3d_info.limits.vs_version = shader_caps.vs_version;
4152 adapter->d3d_info.limits.hs_version = shader_caps.hs_version;
4153 adapter->d3d_info.limits.ds_version = shader_caps.ds_version;
4154 adapter->d3d_info.limits.gs_version = shader_caps.gs_version;
4155 adapter->d3d_info.limits.ps_version = shader_caps.ps_version;
4156 adapter->d3d_info.limits.cs_version = shader_caps.cs_version;
4157 adapter->d3d_info.limits.vs_uniform_count = shader_caps.vs_uniform_count;
4158 adapter->d3d_info.limits.ps_uniform_count = shader_caps.ps_uniform_count;
4159 adapter->d3d_info.limits.varying_count = shader_caps.varying_count;
4160 adapter->d3d_info.shader_double_precision = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION;
4162 adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
4163 adapter->d3d_info.xyzrhw = vertex_caps.xyzrhw;
4164 adapter->d3d_info.ffp_generic_attributes = vertex_caps.ffp_generic_attributes;
4165 adapter->d3d_info.limits.ffp_vertex_blend_matrices = vertex_caps.max_vertex_blend_matrices;
4166 adapter->d3d_info.limits.active_light_count = vertex_caps.max_active_lights;
4167 adapter->d3d_info.emulated_flatshading = vertex_caps.emulated_flatshading;
4169 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
4170 adapter->d3d_info.limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
4171 adapter->d3d_info.limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
4172 adapter->d3d_info.shader_color_key = fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_COLOR_KEY;
4173 adapter->d3d_info.wined3d_creation_flags = wined3d_creation_flags;
4174 TRACE("Max texture stages: %u.\n", adapter->d3d_info.limits.ffp_blend_stages);
4176 adapter->d3d_info.valid_rt_mask = 0;
4177 for (i = 0; i < gl_info->limits.buffers; ++i)
4178 adapter->d3d_info.valid_rt_mask |= (1u << i);
4180 if (!adapter->d3d_info.shader_color_key)
4182 /* We do not want to deal with re-creating immutable texture storage for color keying emulation. */
4183 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support color keying.\n");
4184 gl_info->supported[ARB_TEXTURE_STORAGE] = FALSE;
4187 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
4189 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
4190 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
4191 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
4192 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
4193 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
4194 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
4195 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
4196 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
4197 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
4198 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
4199 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
4200 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
4201 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
4202 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
4203 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
4204 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayer;
4205 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
4206 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4207 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
4208 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
4209 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
4211 else
4213 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
4215 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
4216 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
4217 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
4218 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
4219 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
4220 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
4221 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
4222 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
4223 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
4224 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
4225 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
4226 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
4227 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
4228 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
4229 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
4230 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
4231 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
4232 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
4234 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
4236 WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
4237 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
4240 if (gl_info->supported[ARB_GEOMETRY_SHADER4])
4242 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayerARB;
4244 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
4246 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
4248 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
4250 gl_info->fbo_ops.glRenderbufferStorageMultisample
4251 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
4255 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
4256 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
4257 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
4258 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
4259 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
4260 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
4261 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
4262 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] ? GL_MIRROR_CLAMP_TO_EDGE : GL_REPEAT;
4264 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4266 GLuint vao;
4268 GL_EXTCALL(glGenVertexArrays(1, &vao));
4269 GL_EXTCALL(glBindVertexArray(vao));
4270 checkGLcall("creating VAO");
4273 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
4274 TRACE("Guessed GL vendor %#x.\n", gl_vendor);
4276 if (!(gpu_description = query_gpu_description(gl_info, &vram_bytes)))
4278 static const struct gpu_description default_gpu_description =
4279 {HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_128, "Direct3D HAL", DRIVER_UNKNOWN, WINE_DEFAULT_VIDMEM};
4280 enum wined3d_pci_vendor vendor;
4281 enum wined3d_pci_device device;
4283 vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
4284 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor);
4286 device = wined3d_guess_card(&shader_caps, &fragment_caps, gl_info->glsl_version,
4287 gl_renderer_str, &gl_vendor, &vendor);
4288 TRACE("Guessed device PCI ID 0x%04x.\n", device);
4290 if (!(gpu_description = get_gpu_description(vendor, device)))
4292 ERR("Card %04x:%04x not found in driver DB.\n", vendor, device);
4293 gpu_description = &default_gpu_description;
4296 fixup_extensions(gl_info, caps_gl_ctx, gl_renderer_str, gl_vendor,
4297 gpu_description->vendor, gpu_description->card);
4298 init_driver_info(driver_info, gpu_description, vram_bytes);
4300 gl_ext_emul_mask = adapter->vertex_pipe->vp_get_emul_mask(gl_info)
4301 | adapter->fragment_pipe->get_emul_mask(gl_info);
4302 if (gl_ext_emul_mask & GL_EXT_EMUL_ARB_MULTITEXTURE)
4303 install_gl_compat_wrapper(gl_info, ARB_MULTITEXTURE);
4304 if (gl_ext_emul_mask & GL_EXT_EMUL_EXT_FOG_COORD)
4305 install_gl_compat_wrapper(gl_info, EXT_FOG_COORD);
4307 return TRUE;
4310 UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
4312 TRACE("wined3d %p, reporting %u adapters.\n",
4313 wined3d, wined3d->adapter_count);
4315 return wined3d->adapter_count;
4318 HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
4320 FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
4322 return WINED3D_OK;
4325 HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
4326 struct wined3d_output_desc *desc)
4328 enum wined3d_display_rotation rotation;
4329 const struct wined3d_adapter *adapter;
4330 struct wined3d_display_mode mode;
4331 HMONITOR monitor;
4332 HRESULT hr;
4334 TRACE("wined3d %p, adapter_idx %u, desc %p.\n", wined3d, adapter_idx, desc);
4336 if (adapter_idx >= wined3d->adapter_count)
4337 return WINED3DERR_INVALIDCALL;
4339 adapter = &wined3d->adapters[adapter_idx];
4340 if (!(monitor = MonitorFromPoint(adapter->monitor_position, MONITOR_DEFAULTTOPRIMARY)))
4341 return WINED3DERR_INVALIDCALL;
4343 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, &rotation)))
4344 return hr;
4346 memcpy(desc->device_name, adapter->DeviceName, sizeof(desc->device_name));
4347 SetRect(&desc->desktop_rect, 0, 0, mode.width, mode.height);
4348 OffsetRect(&desc->desktop_rect, adapter->monitor_position.x, adapter->monitor_position.y);
4349 /* FIXME: We should get this from EnumDisplayDevices() when the adapters
4350 * are created. */
4351 desc->attached_to_desktop = TRUE;
4352 desc->rotation = rotation;
4353 desc->monitor = monitor;
4355 return WINED3D_OK;
4358 /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
4359 of the same bpp but different resolutions */
4361 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4362 UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
4363 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
4365 const struct wined3d_adapter *adapter;
4366 const struct wined3d_format *format;
4367 unsigned int i = 0;
4368 unsigned int j = 0;
4369 UINT format_bits;
4370 DEVMODEW mode;
4372 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
4373 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
4375 if (adapter_idx >= wined3d->adapter_count)
4376 return 0;
4378 adapter = &wined3d->adapters[adapter_idx];
4379 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4380 format_bits = format->byte_count * CHAR_BIT;
4382 memset(&mode, 0, sizeof(mode));
4383 mode.dmSize = sizeof(mode);
4385 while (EnumDisplaySettingsExW(adapter->DeviceName, j++, &mode, 0))
4387 if (mode.dmFields & DM_DISPLAYFLAGS)
4389 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4390 && (mode.u2.dmDisplayFlags & DM_INTERLACED))
4391 continue;
4393 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4394 && !(mode.u2.dmDisplayFlags & DM_INTERLACED))
4395 continue;
4398 if (format_id == WINED3DFMT_UNKNOWN)
4400 /* This is for d3d8, do not enumerate P8 here. */
4401 if (mode.dmBitsPerPel == 32 || mode.dmBitsPerPel == 16) ++i;
4403 else if (mode.dmBitsPerPel == format_bits)
4405 ++i;
4409 TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
4411 return i;
4414 /* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
4415 HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
4416 enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
4417 UINT mode_idx, struct wined3d_display_mode *mode)
4419 const struct wined3d_adapter *adapter;
4420 const struct wined3d_format *format;
4421 UINT format_bits;
4422 DEVMODEW m;
4423 UINT i = 0;
4424 int j = 0;
4426 TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x, mode_idx %u, mode %p.\n",
4427 wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering, mode_idx, mode);
4429 if (!mode || adapter_idx >= wined3d->adapter_count)
4430 return WINED3DERR_INVALIDCALL;
4432 adapter = &wined3d->adapters[adapter_idx];
4433 format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
4434 format_bits = format->byte_count * CHAR_BIT;
4436 memset(&m, 0, sizeof(m));
4437 m.dmSize = sizeof(m);
4439 while (i <= mode_idx)
4441 if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
4443 WARN("Invalid mode_idx %u.\n", mode_idx);
4444 return WINED3DERR_INVALIDCALL;
4447 if (m.dmFields & DM_DISPLAYFLAGS)
4449 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_PROGRESSIVE
4450 && (m.u2.dmDisplayFlags & DM_INTERLACED))
4451 continue;
4453 if (scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED
4454 && !(m.u2.dmDisplayFlags & DM_INTERLACED))
4455 continue;
4458 if (format_id == WINED3DFMT_UNKNOWN)
4460 /* This is for d3d8, do not enumerate P8 here. */
4461 if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
4463 else if (m.dmBitsPerPel == format_bits)
4465 ++i;
4469 mode->width = m.dmPelsWidth;
4470 mode->height = m.dmPelsHeight;
4471 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4472 if (m.dmFields & DM_DISPLAYFREQUENCY)
4473 mode->refresh_rate = m.dmDisplayFrequency;
4475 if (format_id == WINED3DFMT_UNKNOWN)
4476 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4477 else
4478 mode->format_id = format_id;
4480 if (!(m.dmFields & DM_DISPLAYFLAGS))
4481 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4482 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4483 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4484 else
4485 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4487 TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4488 m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
4490 return WINED3D_OK;
4493 HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d,
4494 unsigned int adapter_idx, struct wined3d_display_mode *mode)
4496 unsigned int i, j, mode_count, matching_mode_count, closest;
4497 struct wined3d_display_mode **matching_modes;
4498 struct wined3d_display_mode *modes;
4499 HRESULT hr;
4501 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4503 if (!(mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
4504 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
4506 WARN("Adapter has 0 matching modes.\n");
4507 return E_FAIL;
4510 if (!(modes = wined3d_calloc(mode_count, sizeof(*modes))))
4511 return E_OUTOFMEMORY;
4512 if (!(matching_modes = wined3d_calloc(mode_count, sizeof(*matching_modes))))
4514 HeapFree(GetProcessHeap(), 0, modes);
4515 return E_OUTOFMEMORY;
4518 for (i = 0; i < mode_count; ++i)
4520 if (FAILED(hr = wined3d_enum_adapter_modes(wined3d, adapter_idx,
4521 mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &modes[i])))
4523 HeapFree(GetProcessHeap(), 0, matching_modes);
4524 HeapFree(GetProcessHeap(), 0, modes);
4525 return hr;
4527 matching_modes[i] = &modes[i];
4530 matching_mode_count = mode_count;
4532 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4534 for (i = 0, j = 0; i < matching_mode_count; ++i)
4536 if (matching_modes[i]->scanline_ordering == mode->scanline_ordering)
4537 matching_modes[j++] = matching_modes[i];
4539 if (j > 0)
4540 matching_mode_count = j;
4543 if (mode->refresh_rate)
4545 for (i = 0, j = 0; i < matching_mode_count; ++i)
4547 if (matching_modes[i]->refresh_rate == mode->refresh_rate)
4548 matching_modes[j++] = matching_modes[i];
4550 if (j > 0)
4551 matching_mode_count = j;
4554 if (!mode->width || !mode->height)
4556 struct wined3d_display_mode current_mode;
4557 if (FAILED(hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx,
4558 &current_mode, NULL)))
4560 HeapFree(GetProcessHeap(), 0, matching_modes);
4561 HeapFree(GetProcessHeap(), 0, modes);
4562 return hr;
4564 mode->width = current_mode.width;
4565 mode->height = current_mode.height;
4568 closest = ~0u;
4569 for (i = 0, j = 0; i < matching_mode_count; ++i)
4571 unsigned int d = abs(mode->width - matching_modes[i]->width)
4572 + abs(mode->height - matching_modes[i]->height);
4574 if (closest > d)
4576 closest = d;
4577 j = i;
4581 *mode = *matching_modes[j];
4583 HeapFree(GetProcessHeap(), 0, matching_modes);
4584 HeapFree(GetProcessHeap(), 0, modes);
4586 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4587 mode->refresh_rate, debug_d3dformat(mode->format_id),
4588 mode->scanline_ordering);
4590 return WINED3D_OK;
4593 HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
4594 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
4596 const struct wined3d_adapter *adapter;
4597 DEVMODEW m;
4599 TRACE("wined3d %p, adapter_idx %u, display_mode %p, rotation %p.\n",
4600 wined3d, adapter_idx, mode, rotation);
4602 if (!mode || adapter_idx >= wined3d->adapter_count)
4603 return WINED3DERR_INVALIDCALL;
4605 adapter = &wined3d->adapters[adapter_idx];
4607 memset(&m, 0, sizeof(m));
4608 m.dmSize = sizeof(m);
4610 EnumDisplaySettingsExW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &m, 0);
4611 mode->width = m.dmPelsWidth;
4612 mode->height = m.dmPelsHeight;
4613 mode->refresh_rate = DEFAULT_REFRESH_RATE;
4614 if (m.dmFields & DM_DISPLAYFREQUENCY)
4615 mode->refresh_rate = m.dmDisplayFrequency;
4616 mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
4618 /* Lie about the format. X11 can't change the color depth, and some apps
4619 * are pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
4620 * that GetDisplayMode still returns 24 bpp. This should probably be
4621 * handled in winex11 instead. */
4622 if (adapter->screen_format && adapter->screen_format != mode->format_id)
4624 WARN("Overriding format %s with stored format %s.\n",
4625 debug_d3dformat(mode->format_id),
4626 debug_d3dformat(adapter->screen_format));
4627 mode->format_id = adapter->screen_format;
4630 if (!(m.dmFields & DM_DISPLAYFLAGS))
4631 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
4632 else if (m.u2.dmDisplayFlags & DM_INTERLACED)
4633 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
4634 else
4635 mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
4637 if (rotation)
4639 switch (m.u1.s2.dmDisplayOrientation)
4641 case DMDO_DEFAULT:
4642 *rotation = WINED3D_DISPLAY_ROTATION_0;
4643 break;
4644 case DMDO_90:
4645 *rotation = WINED3D_DISPLAY_ROTATION_90;
4646 break;
4647 case DMDO_180:
4648 *rotation = WINED3D_DISPLAY_ROTATION_180;
4649 break;
4650 case DMDO_270:
4651 *rotation = WINED3D_DISPLAY_ROTATION_270;
4652 break;
4653 default:
4654 FIXME("Unhandled display rotation %#x.\n", m.u1.s2.dmDisplayOrientation);
4655 *rotation = WINED3D_DISPLAY_ROTATION_UNSPECIFIED;
4656 break;
4660 TRACE("Returning %ux%u@%u %s %#x.\n", mode->width, mode->height,
4661 mode->refresh_rate, debug_d3dformat(mode->format_id),
4662 mode->scanline_ordering);
4663 return WINED3D_OK;
4666 HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
4667 UINT adapter_idx, const struct wined3d_display_mode *mode)
4669 struct wined3d_adapter *adapter;
4670 DEVMODEW new_mode, current_mode;
4671 RECT clip_rc;
4672 LONG ret;
4673 enum wined3d_format_id new_format_id;
4675 TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
4677 if (adapter_idx >= wined3d->adapter_count)
4678 return WINED3DERR_INVALIDCALL;
4679 adapter = &wined3d->adapters[adapter_idx];
4681 memset(&new_mode, 0, sizeof(new_mode));
4682 new_mode.dmSize = sizeof(new_mode);
4683 memset(&current_mode, 0, sizeof(current_mode));
4684 current_mode.dmSize = sizeof(current_mode);
4685 if (mode)
4687 const struct wined3d_format *format;
4689 TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
4690 debug_d3dformat(mode->format_id), mode->scanline_ordering);
4692 format = wined3d_get_format(&adapter->gl_info, mode->format_id, WINED3DUSAGE_RENDERTARGET);
4694 new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
4695 new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
4696 new_mode.dmPelsWidth = mode->width;
4697 new_mode.dmPelsHeight = mode->height;
4699 new_mode.dmDisplayFrequency = mode->refresh_rate;
4700 if (mode->refresh_rate)
4701 new_mode.dmFields |= DM_DISPLAYFREQUENCY;
4703 if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN)
4705 new_mode.dmFields |= DM_DISPLAYFLAGS;
4706 if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED)
4707 new_mode.u2.dmDisplayFlags |= DM_INTERLACED;
4709 new_format_id = mode->format_id;
4711 else
4713 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_REGISTRY_SETTINGS, &new_mode))
4715 ERR("Failed to read mode from registry.\n");
4716 return WINED3DERR_NOTAVAILABLE;
4718 new_format_id = pixelformat_for_depth(new_mode.dmBitsPerPel);
4721 /* Only change the mode if necessary. */
4722 if (!EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &current_mode))
4724 ERR("Failed to get current display mode.\n");
4726 else if (current_mode.dmPelsWidth == new_mode.dmPelsWidth
4727 && current_mode.dmPelsHeight == new_mode.dmPelsHeight
4728 && current_mode.dmBitsPerPel == new_mode.dmBitsPerPel
4729 && (current_mode.dmDisplayFrequency == new_mode.dmDisplayFrequency
4730 || !(new_mode.dmFields & DM_DISPLAYFREQUENCY))
4731 && (current_mode.u2.dmDisplayFlags == new_mode.u2.dmDisplayFlags
4732 || !(new_mode.dmFields & DM_DISPLAYFLAGS)))
4734 TRACE("Skipping redundant mode setting call.\n");
4735 adapter->screen_format = new_format_id;
4736 return WINED3D_OK;
4739 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4740 if (ret != DISP_CHANGE_SUCCESSFUL)
4742 if (new_mode.dmFields & DM_DISPLAYFREQUENCY)
4744 WARN("ChangeDisplaySettingsExW failed, trying without the refresh rate.\n");
4745 new_mode.dmFields &= ~DM_DISPLAYFREQUENCY;
4746 new_mode.dmDisplayFrequency = 0;
4747 ret = ChangeDisplaySettingsExW(adapter->DeviceName, &new_mode, NULL, CDS_FULLSCREEN, NULL);
4749 if (ret != DISP_CHANGE_SUCCESSFUL)
4750 return WINED3DERR_NOTAVAILABLE;
4753 /* Store the new values. */
4754 adapter->screen_format = new_format_id;
4756 /* And finally clip mouse to our screen. */
4757 SetRect(&clip_rc, 0, 0, new_mode.dmPelsWidth, new_mode.dmPelsHeight);
4758 ClipCursor(&clip_rc);
4760 return WINED3D_OK;
4763 /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
4764 and fields being inserted in the middle, a new structure is used in place */
4765 HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
4766 UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
4768 const struct wined3d_adapter *adapter;
4769 size_t len;
4771 TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n",
4772 wined3d, adapter_idx, flags, identifier);
4774 if (adapter_idx >= wined3d->adapter_count)
4775 return WINED3DERR_INVALIDCALL;
4777 adapter = &wined3d->adapters[adapter_idx];
4779 if (identifier->driver_size)
4781 const char *name = adapter->driver_info.name;
4782 len = min(strlen(name), identifier->driver_size - 1);
4783 memcpy(identifier->driver, name, len);
4784 memset(&identifier->driver[len], 0, identifier->driver_size - len);
4787 if (identifier->description_size)
4789 const char *description = adapter->driver_info.description;
4790 len = min(strlen(description), identifier->description_size - 1);
4791 memcpy(identifier->description, description, len);
4792 memset(&identifier->description[len], 0, identifier->description_size - len);
4795 /* Note that d3d8 doesn't supply a device name. */
4796 if (identifier->device_name_size)
4798 if (!WideCharToMultiByte(CP_ACP, 0, adapter->DeviceName, -1, identifier->device_name,
4799 identifier->device_name_size, NULL, NULL))
4801 ERR("Failed to convert device name, last error %#x.\n", GetLastError());
4802 return WINED3DERR_INVALIDCALL;
4806 identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
4807 identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
4808 identifier->vendor_id = adapter->driver_info.vendor;
4809 identifier->device_id = adapter->driver_info.device;
4810 identifier->subsystem_id = 0;
4811 identifier->revision = 0;
4812 memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
4813 identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
4814 memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
4815 identifier->video_memory = min(~(SIZE_T)0, adapter->vram_bytes);
4817 return WINED3D_OK;
4820 HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
4821 struct wined3d_raster_status *raster_status)
4823 LONGLONG freq_per_frame, freq_per_line;
4824 LARGE_INTEGER counter, freq_per_sec;
4825 struct wined3d_display_mode mode;
4826 static UINT once;
4828 if (!once++)
4829 FIXME("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4830 wined3d, adapter_idx, raster_status);
4831 else
4832 WARN("wined3d %p, adapter_idx %u, raster_status %p semi-stub!\n",
4833 wined3d, adapter_idx, raster_status);
4835 /* Obtaining the raster status is a widely implemented but optional
4836 * feature. When this method returns OK StarCraft 2 expects the
4837 * raster_status->InVBlank value to actually change over time.
4838 * And Endless Alice Crysis doesn't care even if this method fails.
4839 * Thus this method returns OK and fakes raster_status by
4840 * QueryPerformanceCounter. */
4842 if (!QueryPerformanceCounter(&counter) || !QueryPerformanceFrequency(&freq_per_sec))
4843 return WINED3DERR_INVALIDCALL;
4844 if (FAILED(wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode, NULL)))
4845 return WINED3DERR_INVALIDCALL;
4846 if (mode.refresh_rate == DEFAULT_REFRESH_RATE)
4847 mode.refresh_rate = 60;
4849 freq_per_frame = freq_per_sec.QuadPart / mode.refresh_rate;
4850 /* Assume 20 scan lines in the vertical blank. */
4851 freq_per_line = freq_per_frame / (mode.height + 20);
4852 raster_status->scan_line = (counter.QuadPart % freq_per_frame) / freq_per_line;
4853 if (raster_status->scan_line < mode.height)
4854 raster_status->in_vblank = FALSE;
4855 else
4857 raster_status->scan_line = 0;
4858 raster_status->in_vblank = TRUE;
4861 TRACE("Returning fake value, in_vblank %u, scan_line %u.\n",
4862 raster_status->in_vblank, raster_status->scan_line);
4864 return WINED3D_OK;
4867 static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
4868 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
4870 /* Float formats need FBOs. If FBOs are used this function isn't called */
4871 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
4872 return FALSE;
4874 /* Probably a RGBA_float or color index mode. */
4875 if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
4876 return FALSE;
4878 if (cfg->redSize < format->red_size
4879 || cfg->greenSize < format->green_size
4880 || cfg->blueSize < format->blue_size
4881 || cfg->alphaSize < format->alpha_size)
4882 return FALSE;
4884 return TRUE;
4887 static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
4888 const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
4890 BOOL lockable = FALSE;
4892 /* Float formats need FBOs. If FBOs are used this function isn't called */
4893 if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
4894 return FALSE;
4896 if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
4897 lockable = TRUE;
4899 /* On some modern cards like the Geforce8/9, GLX doesn't offer some
4900 * depth/stencil formats which D3D9 reports. We can safely report
4901 * "compatible" formats (e.g. D24 can be used for D16) as long as we
4902 * aren't dealing with a lockable format. This also helps D3D <= 7 as they
4903 * expect D16 which isn't offered without this on Geforce8 cards. */
4904 if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size)))
4905 return FALSE;
4907 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also
4908 * need a format without stencil. We can allow a mismatch if the format
4909 * doesn't have any stencil bits. If it does have stencil bits the size
4910 * must match, or stencil wrapping would break. */
4911 if (format->stencil_size && cfg->stencilSize != format->stencil_size)
4912 return FALSE;
4914 return TRUE;
4917 HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
4918 UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
4919 enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
4921 const struct wined3d_format *rt_format;
4922 const struct wined3d_format *ds_format;
4923 const struct wined3d_adapter *adapter;
4925 TRACE("wined3d %p, adapter_idx %u, device_type %s,\n"
4926 "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
4927 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
4928 debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
4930 if (adapter_idx >= wined3d->adapter_count)
4931 return WINED3DERR_INVALIDCALL;
4933 adapter = &wined3d->adapters[adapter_idx];
4934 rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id, WINED3DUSAGE_RENDERTARGET);
4935 ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL);
4936 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
4938 if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
4939 && (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
4941 TRACE("Formats match.\n");
4942 return WINED3D_OK;
4945 else
4947 const struct wined3d_pixel_format *cfgs;
4948 unsigned int cfg_count;
4949 unsigned int i;
4951 cfgs = adapter->cfgs;
4952 cfg_count = adapter->cfg_count;
4953 for (i = 0; i < cfg_count; ++i)
4955 if (wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], rt_format)
4956 && wined3d_check_pixel_format_depth(&adapter->gl_info, &cfgs[i], ds_format))
4958 TRACE("Formats match.\n");
4959 return WINED3D_OK;
4964 TRACE("Unsupported format pair: %s and %s.\n",
4965 debug_d3dformat(render_target_format_id),
4966 debug_d3dformat(depth_stencil_format_id));
4968 return WINED3DERR_NOTAVAILABLE;
4971 HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
4972 enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
4973 enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
4975 const struct wined3d_gl_info *gl_info = &wined3d->adapters[adapter_idx].gl_info;
4976 const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id, 0);
4977 HRESULT hr = WINED3D_OK;
4979 TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
4980 "windowed %#x, multisample_type %#x, quality_levels %p.\n",
4981 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
4982 windowed, multisample_type, quality_levels);
4984 if (adapter_idx >= wined3d->adapter_count)
4985 return WINED3DERR_INVALIDCALL;
4986 if (surface_format_id == WINED3DFMT_UNKNOWN)
4987 return WINED3DERR_INVALIDCALL;
4988 if (multisample_type < WINED3D_MULTISAMPLE_NONE)
4989 return WINED3DERR_INVALIDCALL;
4990 if (multisample_type > WINED3D_MULTISAMPLE_16_SAMPLES)
4992 FIXME("multisample_type %u not handled yet.\n", multisample_type);
4993 return WINED3DERR_NOTAVAILABLE;
4996 if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
4997 hr = WINED3DERR_NOTAVAILABLE;
4999 if (SUCCEEDED(hr) || (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && format->multisample_types))
5001 if (quality_levels)
5003 if (multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
5004 *quality_levels = wined3d_popcount(format->multisample_types);
5005 else
5006 *quality_levels = 1;
5008 return WINED3D_OK;
5011 TRACE("Returning not supported.\n");
5012 return hr;
5015 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
5016 static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
5017 const struct wined3d_format *display_format, const struct wined3d_format *ds_format,
5018 enum wined3d_gl_resource_type gl_type)
5020 /* Only allow depth/stencil formats */
5021 if (!(ds_format->depth_size || ds_format->stencil_size)) return FALSE;
5023 /* Blacklist formats not supported on Windows */
5024 switch (ds_format->id)
5026 case WINED3DFMT_S1_UINT_D15_UNORM: /* Breaks the shadowvol2 dx7 sdk sample */
5027 case WINED3DFMT_S4X4_UINT_D24_UNORM:
5028 TRACE("[FAILED] - not supported on windows.\n");
5029 return FALSE;
5031 default:
5032 break;
5035 if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5037 /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
5038 if (ds_format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
5039 return TRUE;
5041 else
5043 unsigned int i;
5045 /* Walk through all WGL pixel formats to find a match */
5046 for (i = 0; i < adapter->cfg_count; ++i)
5048 const struct wined3d_pixel_format *cfg = &adapter->cfgs[i];
5049 if (wined3d_check_pixel_format_color(&adapter->gl_info, cfg, display_format)
5050 && wined3d_check_pixel_format_depth(&adapter->gl_info, cfg, ds_format))
5051 return TRUE;
5055 return FALSE;
5058 /* Check the render target capabilities of a format */
5059 static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
5060 const struct wined3d_format *adapter_format, const struct wined3d_format *check_format,
5061 enum wined3d_gl_resource_type gl_type)
5063 /* Filter out non-RT formats */
5064 if (!(check_format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
5065 return FALSE;
5066 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
5068 const struct wined3d_pixel_format *cfgs = adapter->cfgs;
5069 unsigned int i;
5071 /* In backbuffer mode the front and backbuffer share the same WGL
5072 * pixelformat. The format must match in RGB, alpha is allowed to be
5073 * different. (Only the backbuffer can have alpha.) */
5074 if (adapter_format->red_size != check_format->red_size
5075 || adapter_format->green_size != check_format->green_size
5076 || adapter_format->blue_size != check_format->blue_size)
5078 TRACE("[FAILED]\n");
5079 return FALSE;
5082 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
5083 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
5084 for (i = 0; i < adapter->cfg_count; ++i)
5086 if (cfgs[i].windowDrawable
5087 && wined3d_check_pixel_format_color(&adapter->gl_info, &cfgs[i], check_format))
5089 TRACE("Pixel format %d is compatible with format %s.\n",
5090 cfgs[i].iPixelFormat, debug_d3dformat(check_format->id));
5091 return TRUE;
5095 else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
5097 /* For now return TRUE for FBOs until we have some proper checks.
5098 * Note that this function will only be called when the format is around for texturing. */
5099 return TRUE;
5101 return FALSE;
5104 static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
5105 const struct wined3d_format *adapter_format,
5106 const struct wined3d_format *check_format, BOOL no3d)
5108 if (no3d)
5110 switch (check_format->id)
5112 case WINED3DFMT_B8G8R8_UNORM:
5113 TRACE("[FAILED] - Not enumerated on Windows.\n");
5114 return FALSE;
5115 case WINED3DFMT_B8G8R8A8_UNORM:
5116 case WINED3DFMT_B8G8R8X8_UNORM:
5117 case WINED3DFMT_B5G6R5_UNORM:
5118 case WINED3DFMT_B5G5R5X1_UNORM:
5119 case WINED3DFMT_B5G5R5A1_UNORM:
5120 case WINED3DFMT_B4G4R4A4_UNORM:
5121 case WINED3DFMT_B2G3R3_UNORM:
5122 case WINED3DFMT_A8_UNORM:
5123 case WINED3DFMT_B2G3R3A8_UNORM:
5124 case WINED3DFMT_B4G4R4X4_UNORM:
5125 case WINED3DFMT_R10G10B10A2_UNORM:
5126 case WINED3DFMT_R8G8B8A8_UNORM:
5127 case WINED3DFMT_R8G8B8X8_UNORM:
5128 case WINED3DFMT_R16G16_UNORM:
5129 case WINED3DFMT_B10G10R10A2_UNORM:
5130 case WINED3DFMT_R16G16B16A16_UNORM:
5131 case WINED3DFMT_P8_UINT:
5132 TRACE("[OK]\n");
5133 return TRUE;
5134 default:
5135 TRACE("[FAILED] - Not available on GDI surfaces.\n");
5136 return FALSE;
5140 /* All formats that are supported for textures are supported for surfaces
5141 * as well. */
5142 if (check_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE)
5143 return TRUE;
5144 /* All depth stencil formats are supported on surfaces */
5145 if (CheckDepthStencilCapability(adapter, adapter_format, check_format, WINED3D_GL_RES_TYPE_TEX_2D))
5146 return TRUE;
5147 if (CheckDepthStencilCapability(adapter, adapter_format, check_format, WINED3D_GL_RES_TYPE_RB))
5148 return TRUE;
5150 /* If opengl can't process the format natively, the blitter may be able to convert it */
5151 if (adapter->blitter->blit_supported(&adapter->gl_info, &adapter->d3d_info,
5152 WINED3D_BLIT_OP_COLOR_BLIT,
5153 NULL, WINED3D_POOL_DEFAULT, 0, check_format,
5154 NULL, WINED3D_POOL_DEFAULT, 0, adapter_format))
5156 TRACE("[OK]\n");
5157 return TRUE;
5160 /* Reject other formats */
5161 TRACE("[FAILED]\n");
5162 return FALSE;
5165 /* OpenGL supports mipmapping on all formats. Wrapping is unsupported, but we
5166 * have to report mipmapping so we cannot reject WRAPANDMIP. Tests show that
5167 * Windows reports WRAPANDMIP on unfilterable surfaces as well, apparently to
5168 * show that wrapping is supported. The lack of filtering will sort out the
5169 * mipmapping capability anyway.
5171 * For now lets report this on all formats, but in the future we may want to
5172 * restrict it to some should applications need that. */
5173 HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
5174 enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
5175 enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
5177 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5178 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5179 const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id,
5180 WINED3DUSAGE_RENDERTARGET);
5181 const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage);
5182 DWORD format_flags = 0;
5183 DWORD allowed_usage;
5184 enum wined3d_gl_resource_type gl_type;
5186 TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s, "
5187 "resource_type %s, check_format %s.\n",
5188 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
5189 debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
5190 debug_d3dformat(check_format_id));
5192 if (adapter_idx >= wined3d->adapter_count)
5193 return WINED3DERR_INVALIDCALL;
5195 switch (resource_type)
5197 case WINED3D_RTYPE_TEXTURE_2D:
5198 allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
5199 | WINED3DUSAGE_RENDERTARGET
5200 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
5201 if (usage & WINED3DUSAGE_RENDERTARGET)
5202 allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
5203 if (!(usage & WINED3DUSAGE_TEXTURE))
5205 if (!CheckSurfaceCapability(adapter, adapter_format, format, wined3d->flags & WINED3D_NO3D))
5207 TRACE("[FAILED] - Not supported for plain surfaces.\n");
5208 return WINED3DERR_NOTAVAILABLE;
5211 gl_type = WINED3D_GL_RES_TYPE_RB;
5212 break;
5214 allowed_usage |= WINED3DUSAGE_AUTOGENMIPMAP
5215 | WINED3DUSAGE_DYNAMIC
5216 | WINED3DUSAGE_LEGACY_CUBEMAP
5217 | WINED3DUSAGE_SOFTWAREPROCESSING
5218 | WINED3DUSAGE_TEXTURE
5219 | WINED3DUSAGE_QUERY_FILTER
5220 | WINED3DUSAGE_QUERY_LEGACYBUMPMAP
5221 | WINED3DUSAGE_QUERY_SRGBREAD
5222 | WINED3DUSAGE_QUERY_SRGBWRITE
5223 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5224 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5225 gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
5226 if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
5228 allowed_usage &= ~(WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_QUERY_LEGACYBUMPMAP);
5229 gl_type = WINED3D_GL_RES_TYPE_TEX_CUBE;
5231 else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5232 && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
5233 && !gl_info->supported[ARB_SHADOW])
5235 TRACE("[FAILED] - No shadow sampler support.\n");
5236 return WINED3DERR_NOTAVAILABLE;
5238 break;
5240 case WINED3D_RTYPE_TEXTURE_3D:
5241 allowed_usage = WINED3DUSAGE_DYNAMIC
5242 | WINED3DUSAGE_SOFTWAREPROCESSING
5243 | WINED3DUSAGE_TEXTURE
5244 | WINED3DUSAGE_QUERY_FILTER
5245 | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
5246 | WINED3DUSAGE_QUERY_SRGBREAD
5247 | WINED3DUSAGE_QUERY_SRGBWRITE
5248 | WINED3DUSAGE_QUERY_VERTEXTEXTURE
5249 | WINED3DUSAGE_QUERY_WRAPANDMIP;
5250 gl_type = WINED3D_GL_RES_TYPE_TEX_3D;
5251 break;
5253 default:
5254 FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
5255 return WINED3DERR_NOTAVAILABLE;
5258 if ((usage & allowed_usage) != usage)
5260 TRACE("Requested usage %#x, but resource type %s only allows %#x.\n",
5261 usage, debug_d3dresourcetype(resource_type), allowed_usage);
5262 return WINED3DERR_NOTAVAILABLE;
5265 if (usage & WINED3DUSAGE_TEXTURE)
5266 format_flags |= WINED3DFMT_FLAG_TEXTURE;
5267 if (usage & WINED3DUSAGE_QUERY_FILTER)
5268 format_flags |= WINED3DFMT_FLAG_FILTERING;
5269 if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
5270 format_flags |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
5271 if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
5272 format_flags |= WINED3DFMT_FLAG_SRGB_READ;
5273 if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
5274 format_flags |= WINED3DFMT_FLAG_SRGB_WRITE;
5275 if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
5276 format_flags |= WINED3DFMT_FLAG_VTF;
5277 if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
5278 format_flags |= WINED3DFMT_FLAG_BUMPMAP;
5280 if ((format->flags[gl_type] & format_flags) != format_flags)
5282 TRACE("Requested format flags %#x, but format %s only has %#x.\n",
5283 format_flags, debug_d3dformat(check_format_id), format->flags[gl_type]);
5284 return WINED3DERR_NOTAVAILABLE;
5287 if ((format_flags & WINED3DFMT_FLAG_TEXTURE) && (wined3d->flags & WINED3D_NO3D))
5289 TRACE("Requested texturing support, but wined3d was created with WINED3D_NO3D.\n");
5290 return WINED3DERR_NOTAVAILABLE;
5293 if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
5294 && !CheckDepthStencilCapability(adapter, adapter_format, format, gl_type))
5296 TRACE("Requested WINED3DUSAGE_DEPTHSTENCIL, but format %s is not supported for depth / stencil buffers.\n",
5297 debug_d3dformat(check_format_id));
5298 return WINED3DERR_NOTAVAILABLE;
5301 if ((usage & WINED3DUSAGE_RENDERTARGET)
5302 && !CheckRenderTargetCapability(adapter, adapter_format, format, gl_type))
5304 TRACE("Requested WINED3DUSAGE_RENDERTARGET, but format %s is not supported for render targets.\n",
5305 debug_d3dformat(check_format_id));
5306 return WINED3DERR_NOTAVAILABLE;
5309 if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !gl_info->supported[SGIS_GENERATE_MIPMAP])
5311 TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
5312 return WINED3DOK_NOAUTOGEN;
5315 return WINED3D_OK;
5318 UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
5319 enum wined3d_format_id format_id, UINT width)
5321 const struct wined3d_gl_info *gl_info;
5322 unsigned int row_pitch, slice_pitch;
5324 TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
5325 wined3d, adapter_idx, debug_d3dformat(format_id), width);
5327 if (adapter_idx >= wined3d->adapter_count)
5328 return ~0u;
5330 gl_info = &wined3d->adapters[adapter_idx].gl_info;
5331 wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id, 0),
5332 1, width, 1, &row_pitch, &slice_pitch);
5334 return row_pitch;
5337 HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
5338 enum wined3d_device_type device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
5340 FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
5341 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
5342 debug_d3dformat(dst_format));
5344 return WINED3D_OK;
5347 HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
5348 enum wined3d_device_type device_type, enum wined3d_format_id display_format,
5349 enum wined3d_format_id backbuffer_format, BOOL windowed)
5351 BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
5353 TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
5354 wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
5355 debug_d3dformat(backbuffer_format), windowed);
5357 if (adapter_idx >= wined3d->adapter_count)
5358 return WINED3DERR_INVALIDCALL;
5360 /* The task of this function is to check whether a certain display / backbuffer format
5361 * combination is available on the given adapter. In fullscreen mode microsoft specified
5362 * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer
5363 * and display format should match exactly.
5364 * In windowed mode format conversion can occur and this depends on the driver. */
5366 /* There are only 4 display formats. */
5367 if (!(display_format == WINED3DFMT_B5G6R5_UNORM
5368 || display_format == WINED3DFMT_B5G5R5X1_UNORM
5369 || display_format == WINED3DFMT_B8G8R8X8_UNORM
5370 || display_format == WINED3DFMT_B10G10R10A2_UNORM))
5372 TRACE("Format %s is not supported as display format.\n", debug_d3dformat(display_format));
5373 return WINED3DERR_NOTAVAILABLE;
5376 if (!windowed)
5378 /* If the requested display format is not available, don't continue. */
5379 if (!wined3d_get_adapter_mode_count(wined3d, adapter_idx,
5380 display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
5382 TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
5383 return WINED3DERR_NOTAVAILABLE;
5386 present_conversion = FALSE;
5388 else if (display_format == WINED3DFMT_B10G10R10A2_UNORM)
5390 /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */
5391 TRACE("Unsupported format combination %s / %s in windowed mode.\n",
5392 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5393 return WINED3DERR_NOTAVAILABLE;
5396 if (present_conversion)
5398 /* Use the display format as back buffer format if the latter is
5399 * WINED3DFMT_UNKNOWN. */
5400 if (backbuffer_format == WINED3DFMT_UNKNOWN)
5401 backbuffer_format = display_format;
5403 if (FAILED(wined3d_check_device_format_conversion(wined3d, adapter_idx,
5404 device_type, backbuffer_format, display_format)))
5406 TRACE("Format conversion from %s to %s not supported.\n",
5407 debug_d3dformat(backbuffer_format), debug_d3dformat(display_format));
5408 return WINED3DERR_NOTAVAILABLE;
5411 else
5413 /* When format conversion from the back buffer format to the display
5414 * format is not allowed, only a limited number of combinations are
5415 * valid. */
5417 if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM)
5419 TRACE("Unsupported format combination %s / %s.\n",
5420 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5421 return WINED3DERR_NOTAVAILABLE;
5424 if (display_format == WINED3DFMT_B5G5R5X1_UNORM
5425 && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM))
5427 TRACE("Unsupported format combination %s / %s.\n",
5428 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5429 return WINED3DERR_NOTAVAILABLE;
5432 if (display_format == WINED3DFMT_B8G8R8X8_UNORM
5433 && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM))
5435 TRACE("Unsupported format combination %s / %s.\n",
5436 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5437 return WINED3DERR_NOTAVAILABLE;
5440 if (display_format == WINED3DFMT_B10G10R10A2_UNORM
5441 && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM)
5443 TRACE("Unsupported format combination %s / %s.\n",
5444 debug_d3dformat(display_format), debug_d3dformat(backbuffer_format));
5445 return WINED3DERR_NOTAVAILABLE;
5449 /* Validate that the back buffer format is usable for render targets. */
5450 if (FAILED(wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
5451 WINED3DUSAGE_RENDERTARGET, WINED3D_RTYPE_TEXTURE_2D, backbuffer_format)))
5453 TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format));
5454 return WINED3DERR_NOTAVAILABLE;
5457 return WINED3D_OK;
5460 HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
5461 enum wined3d_device_type device_type, WINED3DCAPS *caps)
5463 const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
5464 const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
5465 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
5466 struct wined3d_vertex_caps vertex_caps;
5467 DWORD ckey_caps, blit_caps, fx_caps;
5468 struct fragment_caps fragment_caps;
5469 struct shader_caps shader_caps;
5471 TRACE("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
5472 wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
5474 if (adapter_idx >= wined3d->adapter_count)
5475 return WINED3DERR_INVALIDCALL;
5477 caps->DeviceType = (device_type == WINED3D_DEVICE_TYPE_HAL) ? WINED3D_DEVICE_TYPE_HAL : WINED3D_DEVICE_TYPE_REF;
5478 caps->AdapterOrdinal = adapter_idx;
5480 caps->Caps = 0;
5481 caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
5482 WINED3DCAPS2_FULLSCREENGAMMA |
5483 WINED3DCAPS2_DYNAMICTEXTURES;
5484 if (gl_info->supported[SGIS_GENERATE_MIPMAP])
5485 caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
5487 caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
5488 WINED3DCAPS3_COPY_TO_VIDMEM |
5489 WINED3DCAPS3_COPY_TO_SYSTEMMEM;
5491 caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
5492 WINED3DPRESENT_INTERVAL_ONE;
5494 caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
5495 WINED3DCURSORCAPS_LOWRES;
5497 caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
5498 WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
5499 WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
5500 WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
5501 WINED3DDEVCAPS_DRAWPRIMTLVERTEX |
5502 WINED3DDEVCAPS_HWTRANSFORMANDLIGHT |
5503 WINED3DDEVCAPS_EXECUTEVIDEOMEMORY |
5504 WINED3DDEVCAPS_PUREDEVICE |
5505 WINED3DDEVCAPS_HWRASTERIZATION |
5506 WINED3DDEVCAPS_TEXTUREVIDEOMEMORY |
5507 WINED3DDEVCAPS_TEXTURESYSTEMMEMORY |
5508 WINED3DDEVCAPS_CANRENDERAFTERFLIP |
5509 WINED3DDEVCAPS_DRAWPRIMITIVES2 |
5510 WINED3DDEVCAPS_DRAWPRIMITIVES2EX;
5512 caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
5513 WINED3DPMISCCAPS_CULLCCW |
5514 WINED3DPMISCCAPS_CULLCW |
5515 WINED3DPMISCCAPS_COLORWRITEENABLE |
5516 WINED3DPMISCCAPS_CLIPTLVERTS |
5517 WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
5518 WINED3DPMISCCAPS_MASKZ |
5519 WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
5520 /* TODO:
5521 WINED3DPMISCCAPS_NULLREFERENCE
5522 WINED3DPMISCCAPS_FOGANDSPECULARALPHA
5523 WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
5524 WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
5526 if (gl_info->supported[WINED3D_GL_BLEND_EQUATION])
5527 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_BLENDOP;
5528 if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
5529 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
5530 if (gl_info->supported[EXT_DRAW_BUFFERS2])
5531 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
5532 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB])
5533 caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT;
5535 caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
5536 WINED3DPRASTERCAPS_PAT |
5537 WINED3DPRASTERCAPS_WFOG |
5538 WINED3DPRASTERCAPS_ZFOG |
5539 WINED3DPRASTERCAPS_FOGVERTEX |
5540 WINED3DPRASTERCAPS_FOGTABLE |
5541 WINED3DPRASTERCAPS_STIPPLE |
5542 WINED3DPRASTERCAPS_SUBPIXEL |
5543 WINED3DPRASTERCAPS_ZTEST |
5544 WINED3DPRASTERCAPS_SCISSORTEST |
5545 WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
5546 WINED3DPRASTERCAPS_DEPTHBIAS;
5548 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5550 caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
5551 WINED3DPRASTERCAPS_ZBIAS |
5552 WINED3DPRASTERCAPS_MIPMAPLODBIAS;
5555 caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5556 WINED3DPCMPCAPS_EQUAL |
5557 WINED3DPCMPCAPS_GREATER |
5558 WINED3DPCMPCAPS_GREATEREQUAL |
5559 WINED3DPCMPCAPS_LESS |
5560 WINED3DPCMPCAPS_LESSEQUAL |
5561 WINED3DPCMPCAPS_NEVER |
5562 WINED3DPCMPCAPS_NOTEQUAL;
5564 /* WINED3DPBLENDCAPS_BOTHINVSRCALPHA and WINED3DPBLENDCAPS_BOTHSRCALPHA
5565 * are legacy settings for srcblend only. */
5566 caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
5567 WINED3DPBLENDCAPS_BOTHSRCALPHA |
5568 WINED3DPBLENDCAPS_DESTALPHA |
5569 WINED3DPBLENDCAPS_DESTCOLOR |
5570 WINED3DPBLENDCAPS_INVDESTALPHA |
5571 WINED3DPBLENDCAPS_INVDESTCOLOR |
5572 WINED3DPBLENDCAPS_INVSRCALPHA |
5573 WINED3DPBLENDCAPS_INVSRCCOLOR |
5574 WINED3DPBLENDCAPS_ONE |
5575 WINED3DPBLENDCAPS_SRCALPHA |
5576 WINED3DPBLENDCAPS_SRCALPHASAT |
5577 WINED3DPBLENDCAPS_SRCCOLOR |
5578 WINED3DPBLENDCAPS_ZERO;
5580 caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
5581 WINED3DPBLENDCAPS_DESTCOLOR |
5582 WINED3DPBLENDCAPS_INVDESTALPHA |
5583 WINED3DPBLENDCAPS_INVDESTCOLOR |
5584 WINED3DPBLENDCAPS_INVSRCALPHA |
5585 WINED3DPBLENDCAPS_INVSRCCOLOR |
5586 WINED3DPBLENDCAPS_ONE |
5587 WINED3DPBLENDCAPS_SRCALPHA |
5588 WINED3DPBLENDCAPS_SRCCOLOR |
5589 WINED3DPBLENDCAPS_ZERO;
5591 if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED])
5592 caps->DestBlendCaps |= WINED3DPBLENDCAPS_SRCALPHASAT;
5594 if (gl_info->supported[EXT_BLEND_COLOR])
5596 caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5597 caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
5601 caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
5602 WINED3DPCMPCAPS_EQUAL |
5603 WINED3DPCMPCAPS_GREATER |
5604 WINED3DPCMPCAPS_GREATEREQUAL |
5605 WINED3DPCMPCAPS_LESS |
5606 WINED3DPCMPCAPS_LESSEQUAL |
5607 WINED3DPCMPCAPS_NEVER |
5608 WINED3DPCMPCAPS_NOTEQUAL;
5610 caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
5611 WINED3DPSHADECAPS_COLORGOURAUDRGB |
5612 WINED3DPSHADECAPS_ALPHAFLATBLEND |
5613 WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
5614 WINED3DPSHADECAPS_COLORFLATRGB |
5615 WINED3DPSHADECAPS_FOGFLAT |
5616 WINED3DPSHADECAPS_FOGGOURAUD |
5617 WINED3DPSHADECAPS_SPECULARFLATRGB;
5619 caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
5620 WINED3DPTEXTURECAPS_ALPHAPALETTE |
5621 WINED3DPTEXTURECAPS_TRANSPARENCY |
5622 WINED3DPTEXTURECAPS_BORDER |
5623 WINED3DPTEXTURECAPS_MIPMAP |
5624 WINED3DPTEXTURECAPS_PROJECTED |
5625 WINED3DPTEXTURECAPS_PERSPECTIVE;
5627 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5629 caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2;
5630 if (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] || gl_info->supported[ARB_TEXTURE_RECTANGLE])
5631 caps->TextureCaps |= WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
5634 if (gl_info->supported[EXT_TEXTURE3D])
5636 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
5637 WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
5638 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5640 caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
5644 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5646 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
5647 WINED3DPTEXTURECAPS_MIPCUBEMAP;
5648 if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
5650 caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
5654 caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5655 WINED3DPTFILTERCAPS_MAGFPOINT |
5656 WINED3DPTFILTERCAPS_MINFLINEAR |
5657 WINED3DPTFILTERCAPS_MINFPOINT |
5658 WINED3DPTFILTERCAPS_MIPFLINEAR |
5659 WINED3DPTFILTERCAPS_MIPFPOINT |
5660 WINED3DPTFILTERCAPS_LINEAR |
5661 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5662 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5663 WINED3DPTFILTERCAPS_MIPLINEAR |
5664 WINED3DPTFILTERCAPS_MIPNEAREST |
5665 WINED3DPTFILTERCAPS_NEAREST;
5667 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5669 caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5670 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5673 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
5675 caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5676 WINED3DPTFILTERCAPS_MAGFPOINT |
5677 WINED3DPTFILTERCAPS_MINFLINEAR |
5678 WINED3DPTFILTERCAPS_MINFPOINT |
5679 WINED3DPTFILTERCAPS_MIPFLINEAR |
5680 WINED3DPTFILTERCAPS_MIPFPOINT |
5681 WINED3DPTFILTERCAPS_LINEAR |
5682 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5683 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5684 WINED3DPTFILTERCAPS_MIPLINEAR |
5685 WINED3DPTFILTERCAPS_MIPNEAREST |
5686 WINED3DPTFILTERCAPS_NEAREST;
5688 if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
5690 caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
5691 WINED3DPTFILTERCAPS_MINFANISOTROPIC;
5694 else
5696 caps->CubeTextureFilterCaps = 0;
5699 if (gl_info->supported[EXT_TEXTURE3D])
5701 caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
5702 WINED3DPTFILTERCAPS_MAGFPOINT |
5703 WINED3DPTFILTERCAPS_MINFLINEAR |
5704 WINED3DPTFILTERCAPS_MINFPOINT |
5705 WINED3DPTFILTERCAPS_MIPFLINEAR |
5706 WINED3DPTFILTERCAPS_MIPFPOINT |
5707 WINED3DPTFILTERCAPS_LINEAR |
5708 WINED3DPTFILTERCAPS_LINEARMIPLINEAR |
5709 WINED3DPTFILTERCAPS_LINEARMIPNEAREST |
5710 WINED3DPTFILTERCAPS_MIPLINEAR |
5711 WINED3DPTFILTERCAPS_MIPNEAREST |
5712 WINED3DPTFILTERCAPS_NEAREST;
5714 else
5716 caps->VolumeTextureFilterCaps = 0;
5719 caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5720 WINED3DPTADDRESSCAPS_CLAMP |
5721 WINED3DPTADDRESSCAPS_WRAP;
5723 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5725 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5727 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5729 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5731 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5733 caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5736 if (gl_info->supported[EXT_TEXTURE3D])
5738 caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
5739 WINED3DPTADDRESSCAPS_CLAMP |
5740 WINED3DPTADDRESSCAPS_WRAP;
5741 if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
5743 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
5745 if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
5747 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
5749 if (gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE])
5751 caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
5754 else
5756 caps->VolumeTextureAddressCaps = 0;
5759 caps->LineCaps = WINED3DLINECAPS_TEXTURE |
5760 WINED3DLINECAPS_ZTEST |
5761 WINED3DLINECAPS_BLEND |
5762 WINED3DLINECAPS_ALPHACMP |
5763 WINED3DLINECAPS_FOG;
5764 /* WINED3DLINECAPS_ANTIALIAS is not supported on Windows, and dx and gl seem to have a different
5765 * idea how generating the smoothing alpha values works; the result is different
5768 caps->MaxTextureWidth = gl_info->limits.texture_size;
5769 caps->MaxTextureHeight = gl_info->limits.texture_size;
5771 if (gl_info->supported[EXT_TEXTURE3D])
5772 caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
5773 else
5774 caps->MaxVolumeExtent = 0;
5776 caps->MaxTextureRepeat = 32768;
5777 caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
5778 caps->MaxVertexW = 1.0f;
5780 caps->GuardBandLeft = 0.0f;
5781 caps->GuardBandTop = 0.0f;
5782 caps->GuardBandRight = 0.0f;
5783 caps->GuardBandBottom = 0.0f;
5785 caps->ExtentsAdjust = 0.0f;
5787 caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
5788 WINED3DSTENCILCAPS_INCRSAT |
5789 WINED3DSTENCILCAPS_INVERT |
5790 WINED3DSTENCILCAPS_KEEP |
5791 WINED3DSTENCILCAPS_REPLACE |
5792 WINED3DSTENCILCAPS_ZERO;
5793 if (gl_info->supported[EXT_STENCIL_WRAP])
5795 caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
5796 WINED3DSTENCILCAPS_INCR;
5798 if (gl_info->supported[WINED3D_GL_VERSION_2_0] || gl_info->supported[EXT_STENCIL_TWO_SIDE]
5799 || gl_info->supported[ATI_SEPARATE_STENCIL])
5801 caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
5804 caps->MaxAnisotropy = gl_info->limits.anisotropy;
5805 caps->MaxPointSize = gl_info->limits.pointsize_max;
5807 caps->MaxPrimitiveCount = 0x555555; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5808 caps->MaxVertexIndex = 0xffffff; /* Taken from an AMD Radeon HD 5700 (Evergreen) GPU. */
5809 caps->MaxStreams = MAX_STREAMS;
5810 caps->MaxStreamStride = 1024;
5812 /* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
5813 caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
5814 WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
5815 caps->MaxNpatchTessellationLevel = 0;
5816 caps->MasterAdapterOrdinal = 0;
5817 caps->AdapterOrdinalInGroup = 0;
5818 caps->NumberOfAdaptersInGroup = 1;
5820 caps->NumSimultaneousRTs = gl_info->limits.buffers;
5822 caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
5823 WINED3DPTFILTERCAPS_MAGFPOINT |
5824 WINED3DPTFILTERCAPS_MINFLINEAR |
5825 WINED3DPTFILTERCAPS_MAGFLINEAR;
5826 caps->VertexTextureFilterCaps = 0;
5828 adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
5829 adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
5830 adapter->vertex_pipe->vp_get_caps(&adapter->gl_info, &vertex_caps);
5832 /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
5833 caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
5835 caps->VertexShaderVersion = shader_caps.vs_version;
5836 caps->MaxVertexShaderConst = shader_caps.vs_uniform_count;
5838 caps->PixelShaderVersion = shader_caps.ps_version;
5839 caps->PixelShader1xMaxValue = shader_caps.ps_1x_max_value;
5841 caps->TextureOpCaps = fragment_caps.TextureOpCaps;
5842 caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
5843 caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
5845 caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
5846 caps->MaxActiveLights = vertex_caps.max_active_lights;
5847 caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
5848 caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
5849 caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
5850 caps->FVFCaps = vertex_caps.fvf_caps;
5851 caps->RasterCaps |= vertex_caps.raster_caps;
5853 /* The following caps are shader specific, but they are things we cannot detect, or which
5854 * are the same among all shader models. So to avoid code duplication set the shader version
5855 * specific, but otherwise constant caps here
5857 if (caps->VertexShaderVersion >= 3)
5859 /* Where possible set the caps based on OpenGL extensions and if they
5860 * aren't set (in case of software rendering) use the VS 3.0 from
5861 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5862 * VS3.0 value. */
5863 caps->VS20Caps.caps = WINED3DVS20CAPS_PREDICATION;
5864 /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5865 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5866 caps->VS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_vs_temps);
5867 /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
5868 caps->VS20Caps.static_flow_control_depth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
5870 caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
5871 caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
5872 caps->VertexTextureFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT;
5874 else if (caps->VertexShaderVersion == 2)
5876 caps->VS20Caps.caps = 0;
5877 caps->VS20Caps.dynamic_flow_control_depth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
5878 caps->VS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_vs_temps);
5879 caps->VS20Caps.static_flow_control_depth = 1;
5881 caps->MaxVShaderInstructionsExecuted = 65535;
5882 caps->MaxVertexShader30InstructionSlots = 0;
5884 else
5885 { /* VS 1.x */
5886 caps->VS20Caps.caps = 0;
5887 caps->VS20Caps.dynamic_flow_control_depth = 0;
5888 caps->VS20Caps.temp_count = 0;
5889 caps->VS20Caps.static_flow_control_depth = 0;
5891 caps->MaxVShaderInstructionsExecuted = 0;
5892 caps->MaxVertexShader30InstructionSlots = 0;
5895 if (caps->PixelShaderVersion >= 3)
5897 /* Where possible set the caps based on OpenGL extensions and if they
5898 * aren't set (in case of software rendering) use the PS 3.0 from
5899 * MSDN or else if there's OpenGL spec use a hardcoded value minimum
5900 * PS 3.0 value. */
5902 /* Caps is more or less undocumented on MSDN but it appears to be
5903 * used for PS20Caps based on results from R9600/FX5900/Geforce6800
5904 * cards from Windows */
5905 caps->PS20Caps.caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
5906 WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
5907 WINED3DPS20CAPS_PREDICATION |
5908 WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
5909 WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
5910 /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
5911 caps->PS20Caps.dynamic_flow_control_depth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
5912 caps->PS20Caps.temp_count = max(32, adapter->gl_info.limits.arb_ps_temps);
5913 /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
5914 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
5915 /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
5916 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
5918 caps->MaxPShaderInstructionsExecuted = 65535;
5919 caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
5920 adapter->gl_info.limits.arb_ps_instructions);
5922 else if(caps->PixelShaderVersion == 2)
5924 /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
5925 caps->PS20Caps.caps = 0;
5926 caps->PS20Caps.dynamic_flow_control_depth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
5927 caps->PS20Caps.temp_count = max(12, adapter->gl_info.limits.arb_ps_temps);
5928 caps->PS20Caps.static_flow_control_depth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
5929 /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
5930 caps->PS20Caps.instruction_slot_count = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
5932 caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
5933 caps->MaxPixelShader30InstructionSlots = 0;
5935 else /* PS 1.x */
5937 caps->PS20Caps.caps = 0;
5938 caps->PS20Caps.dynamic_flow_control_depth = 0;
5939 caps->PS20Caps.temp_count = 0;
5940 caps->PS20Caps.static_flow_control_depth = 0;
5941 caps->PS20Caps.instruction_slot_count = 0;
5943 caps->MaxPShaderInstructionsExecuted = 0;
5944 caps->MaxPixelShader30InstructionSlots = 0;
5947 if (caps->VertexShaderVersion >= 2)
5949 /* OpenGL supports all the formats below, perhaps not always
5950 * without conversion, but it supports them.
5951 * Further GLSL doesn't seem to have an official unsigned type so
5952 * don't advertise it yet as I'm not sure how we handle it.
5953 * We might need to add some clamping in the shader engine to
5954 * support it.
5955 * TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
5956 caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
5957 WINED3DDTCAPS_UBYTE4N |
5958 WINED3DDTCAPS_SHORT2N |
5959 WINED3DDTCAPS_SHORT4N;
5960 if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
5962 caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
5963 WINED3DDTCAPS_FLOAT16_4;
5966 else
5968 caps->DeclTypes = 0;
5971 /* Set DirectDraw helper Caps */
5972 ckey_caps = WINEDDCKEYCAPS_DESTBLT |
5973 WINEDDCKEYCAPS_SRCBLT;
5974 fx_caps = WINEDDFXCAPS_BLTALPHA |
5975 WINEDDFXCAPS_BLTMIRRORLEFTRIGHT |
5976 WINEDDFXCAPS_BLTMIRRORUPDOWN |
5977 WINEDDFXCAPS_BLTROTATION90 |
5978 WINEDDFXCAPS_BLTSHRINKX |
5979 WINEDDFXCAPS_BLTSHRINKXN |
5980 WINEDDFXCAPS_BLTSHRINKY |
5981 WINEDDFXCAPS_BLTSHRINKYN |
5982 WINEDDFXCAPS_BLTSTRETCHX |
5983 WINEDDFXCAPS_BLTSTRETCHXN |
5984 WINEDDFXCAPS_BLTSTRETCHY |
5985 WINEDDFXCAPS_BLTSTRETCHYN;
5986 blit_caps = WINEDDCAPS_BLT |
5987 WINEDDCAPS_BLTCOLORFILL |
5988 WINEDDCAPS_BLTDEPTHFILL |
5989 WINEDDCAPS_BLTSTRETCH |
5990 WINEDDCAPS_CANBLTSYSMEM |
5991 WINEDDCAPS_CANCLIP |
5992 WINEDDCAPS_CANCLIPSTRETCHED |
5993 WINEDDCAPS_COLORKEY |
5994 WINEDDCAPS_COLORKEYHWASSIST;
5996 /* Fill the ddraw caps structure */
5997 caps->ddraw_caps.caps = WINEDDCAPS_GDI |
5998 WINEDDCAPS_PALETTE |
5999 blit_caps;
6000 caps->ddraw_caps.caps2 = WINEDDCAPS2_CERTIFIED |
6001 WINEDDCAPS2_NOPAGELOCKREQUIRED |
6002 WINEDDCAPS2_PRIMARYGAMMA |
6003 WINEDDCAPS2_WIDESURFACES |
6004 WINEDDCAPS2_CANRENDERWINDOWED;
6005 caps->ddraw_caps.color_key_caps = ckey_caps;
6006 caps->ddraw_caps.fx_caps = fx_caps;
6007 caps->ddraw_caps.svb_caps = blit_caps;
6008 caps->ddraw_caps.svb_color_key_caps = ckey_caps;
6009 caps->ddraw_caps.svb_fx_caps = fx_caps;
6010 caps->ddraw_caps.vsb_caps = blit_caps;
6011 caps->ddraw_caps.vsb_color_key_caps = ckey_caps;
6012 caps->ddraw_caps.vsb_fx_caps = fx_caps;
6013 caps->ddraw_caps.ssb_caps = blit_caps;
6014 caps->ddraw_caps.ssb_color_key_caps = ckey_caps;
6015 caps->ddraw_caps.ssb_fx_caps = fx_caps;
6017 caps->ddraw_caps.dds_caps = WINEDDSCAPS_ALPHA |
6018 WINEDDSCAPS_BACKBUFFER |
6019 WINEDDSCAPS_FLIP |
6020 WINEDDSCAPS_FRONTBUFFER |
6021 WINEDDSCAPS_OFFSCREENPLAIN |
6022 WINEDDSCAPS_PALETTE |
6023 WINEDDSCAPS_PRIMARYSURFACE |
6024 WINEDDSCAPS_SYSTEMMEMORY |
6025 WINEDDSCAPS_VIDEOMEMORY |
6026 WINEDDSCAPS_VISIBLE;
6028 if (!(wined3d->flags & WINED3D_NO3D))
6030 caps->ddraw_caps.dds_caps |= WINEDDSCAPS_3DDEVICE |
6031 WINEDDSCAPS_MIPMAP |
6032 WINEDDSCAPS_TEXTURE |
6033 WINEDDSCAPS_ZBUFFER;
6034 caps->ddraw_caps.caps |= WINEDDCAPS_3D;
6037 caps->shader_double_precision = d3d_info->shader_double_precision;
6039 return WINED3D_OK;
6042 HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type,
6043 HWND focus_window, DWORD flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent,
6044 struct wined3d_device **device)
6046 struct wined3d_device *object;
6047 HRESULT hr;
6049 TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, surface_alignment %u, device_parent %p, device %p.\n",
6050 wined3d, adapter_idx, device_type, focus_window, flags, surface_alignment, device_parent, device);
6052 /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
6053 * number and create a device without a 3D adapter for 2D only operation. */
6054 if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
6055 return WINED3DERR_INVALIDCALL;
6057 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
6058 if (!object)
6059 return E_OUTOFMEMORY;
6061 hr = device_init(object, wined3d, adapter_idx, device_type,
6062 focus_window, flags, surface_alignment, device_parent);
6063 if (FAILED(hr))
6065 WARN("Failed to initialize device, hr %#x.\n", hr);
6066 HeapFree(GetProcessHeap(), 0, object);
6067 return hr;
6070 TRACE("Created device %p.\n", object);
6071 *device = object;
6073 device_parent->ops->wined3d_device_created(device_parent, *device);
6075 return WINED3D_OK;
6078 static void WINE_GLAPI invalid_func(const void *data)
6080 ERR("Invalid vertex attribute function called.\n");
6081 DebugBreak();
6084 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
6086 ERR("Invalid texcoord function called.\n");
6087 DebugBreak();
6090 static void WINE_GLAPI invalid_generic_attrib_func(GLuint idx, const void *data)
6092 ERR("Invalid attribute function called.\n");
6093 DebugBreak();
6096 /* Helper functions for providing vertex data to OpenGL. The arrays are
6097 * initialised based on the extension detection and are used in
6098 * draw_primitive_immediate_mode(). */
6099 static void WINE_GLAPI position_d3dcolor(const void *data)
6101 DWORD pos = *((const DWORD *)data);
6103 FIXME("Add a test for fixed function position from d3dcolor type.\n");
6104 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
6105 D3DCOLOR_B_G(pos),
6106 D3DCOLOR_B_B(pos),
6107 D3DCOLOR_B_A(pos));
6110 static void WINE_GLAPI position_float4(const void *data)
6112 const GLfloat *pos = data;
6114 if (pos[3] != 0.0f && pos[3] != 1.0f)
6116 float w = 1.0f / pos[3];
6118 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
6120 else
6122 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
6126 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
6128 DWORD diffuseColor = *((const DWORD *)data);
6130 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
6131 D3DCOLOR_B_G(diffuseColor),
6132 D3DCOLOR_B_B(diffuseColor),
6133 D3DCOLOR_B_A(diffuseColor));
6136 static void WINE_GLAPI specular_d3dcolor(const void *data)
6138 DWORD specularColor = *((const DWORD *)data);
6139 GLubyte d[] =
6141 D3DCOLOR_B_R(specularColor),
6142 D3DCOLOR_B_G(specularColor),
6143 D3DCOLOR_B_B(specularColor)
6146 context_get_current()->gl_info->gl_ops.ext.p_glSecondaryColor3ubvEXT(d);
6149 static void WINE_GLAPI warn_no_specular_func(const void *data)
6151 WARN("GL_EXT_secondary_color not supported.\n");
6154 static void WINE_GLAPI generic_d3dcolor(GLuint idx, const void *data)
6156 DWORD color = *((const DWORD *)data);
6158 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nub(idx,
6159 D3DCOLOR_B_R(color), D3DCOLOR_B_G(color),
6160 D3DCOLOR_B_B(color), D3DCOLOR_B_A(color));
6163 static void WINE_GLAPI generic_short2n(GLuint idx, const void *data)
6165 const GLshort s[] = {((const GLshort *)data)[0], ((const GLshort *)data)[1], 0, 1};
6167 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nsv(idx, s);
6170 static void WINE_GLAPI generic_ushort2n(GLuint idx, const void *data)
6172 const GLushort s[] = {((const GLushort *)data)[0], ((const GLushort *)data)[1], 0, 1};
6174 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nusv(idx, s);
6177 static void WINE_GLAPI generic_float16_2(GLuint idx, const void *data)
6179 float x = float_16_to_32(((const unsigned short *)data) + 0);
6180 float y = float_16_to_32(((const unsigned short *)data) + 1);
6182 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib2f(idx, x, y);
6185 static void WINE_GLAPI generic_float16_4(GLuint idx, const void *data)
6187 float x = float_16_to_32(((const unsigned short *)data) + 0);
6188 float y = float_16_to_32(((const unsigned short *)data) + 1);
6189 float z = float_16_to_32(((const unsigned short *)data) + 2);
6190 float w = float_16_to_32(((const unsigned short *)data) + 3);
6192 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4f(idx, x, y, z, w);
6195 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter *adapter)
6197 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6198 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
6199 struct wined3d_ffp_attrib_ops *ops = &d3d_info->ffp_attrib_ops;
6200 unsigned int i;
6202 for (i = 0; i < WINED3D_FFP_EMIT_COUNT; ++i)
6204 ops->position[i] = invalid_func;
6205 ops->diffuse[i] = invalid_func;
6206 ops->specular[i] = invalid_func;
6207 ops->normal[i] = invalid_func;
6208 ops->texcoord[i] = invalid_texcoord_func;
6209 ops->generic[i] = invalid_generic_attrib_func;
6212 ops->position[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex3fv;
6213 if (!d3d_info->xyzrhw)
6214 ops->position[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
6215 else
6216 ops->position[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex4fv;
6217 ops->position[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
6218 ops->position[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex2sv;
6220 ops->diffuse[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor3fv;
6221 ops->diffuse[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4fv;
6222 ops->diffuse[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
6223 ops->diffuse[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4ubv;
6224 ops->diffuse[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4sv;
6225 ops->diffuse[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4usv;
6227 /* No 4 component entry points here. */
6228 if (gl_info->supported[EXT_SECONDARY_COLOR])
6229 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)GL_EXTCALL(glSecondaryColor3fvEXT);
6230 else
6231 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
6232 if (gl_info->supported[EXT_SECONDARY_COLOR])
6233 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
6234 else
6235 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
6237 /* Only 3 component entry points here. Test how others behave. Float4
6238 * normals are used by one of our tests, trying to pass it to the pixel
6239 * shader, which fails on Windows. */
6240 ops->normal[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6241 /* Just ignore the 4th value. */
6242 ops->normal[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
6244 ops->texcoord[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord1fvARB;
6245 ops->texcoord[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2fvARB;
6246 ops->texcoord[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord3fvARB;
6247 ops->texcoord[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4fvARB;
6248 ops->texcoord[WINED3D_FFP_EMIT_SHORT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2svARB;
6249 ops->texcoord[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4svARB;
6250 if (gl_info->supported[NV_HALF_FLOAT])
6252 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
6253 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_2] =
6254 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2hvNV;
6255 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_4] =
6256 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4hvNV;
6259 ops->generic[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib1fv;
6260 ops->generic[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2fv;
6261 ops->generic[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib3fv;
6262 ops->generic[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4fv;
6263 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
6264 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] = generic_d3dcolor;
6265 else
6266 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] =
6267 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6268 ops->generic[WINED3D_FFP_EMIT_UBYTE4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4ubv;
6269 ops->generic[WINED3D_FFP_EMIT_SHORT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2sv;
6270 ops->generic[WINED3D_FFP_EMIT_SHORT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4sv;
6271 ops->generic[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
6272 ops->generic[WINED3D_FFP_EMIT_SHORT2N] = generic_short2n;
6273 ops->generic[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nsv;
6274 ops->generic[WINED3D_FFP_EMIT_USHORT2N] = generic_ushort2n;
6275 ops->generic[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nusv;
6276 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
6278 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] =
6279 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2hvNV;
6280 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] =
6281 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4hvNV;
6283 else
6285 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] = generic_float16_2;
6286 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] = generic_float16_4;
6290 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc)
6292 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
6293 int i;
6295 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
6297 UINT attrib_count = 0;
6298 GLint cfg_count;
6299 int attribs[11];
6300 int values[11];
6301 int attribute;
6303 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
6304 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
6306 adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
6307 attribs[attrib_count++] = WGL_RED_BITS_ARB;
6308 attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
6309 attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
6310 attribs[attrib_count++] = WGL_ALPHA_BITS_ARB;
6311 attribs[attrib_count++] = WGL_COLOR_BITS_ARB;
6312 attribs[attrib_count++] = WGL_DEPTH_BITS_ARB;
6313 attribs[attrib_count++] = WGL_STENCIL_BITS_ARB;
6314 attribs[attrib_count++] = WGL_DRAW_TO_WINDOW_ARB;
6315 attribs[attrib_count++] = WGL_PIXEL_TYPE_ARB;
6316 attribs[attrib_count++] = WGL_DOUBLE_BUFFER_ARB;
6317 attribs[attrib_count++] = WGL_AUX_BUFFERS_ARB;
6319 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6321 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6322 int format_id = i + 1;
6324 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, attrib_count, attribs, values)))
6325 continue;
6327 cfg->iPixelFormat = format_id;
6328 cfg->redSize = values[0];
6329 cfg->greenSize = values[1];
6330 cfg->blueSize = values[2];
6331 cfg->alphaSize = values[3];
6332 cfg->colorSize = values[4];
6333 cfg->depthSize = values[5];
6334 cfg->stencilSize = values[6];
6335 cfg->windowDrawable = values[7];
6336 cfg->iPixelType = values[8];
6337 cfg->doubleBuffer = values[9];
6338 cfg->auxBuffers = values[10];
6340 cfg->numSamples = 0;
6341 /* Check multisample support. */
6342 if (gl_info->supported[ARB_MULTISAMPLE])
6344 int attribs[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
6345 int values[2];
6347 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, 2, attribs, values)))
6349 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
6350 * multisampling is supported. values[1] = number of
6351 * multisample buffers. */
6352 if (values[0])
6353 cfg->numSamples = values[1];
6357 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6358 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
6359 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6360 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6361 cfg->depthSize, cfg->stencilSize, cfg->numSamples, cfg->windowDrawable);
6363 ++adapter->cfg_count;
6366 else
6368 int cfg_count;
6370 cfg_count = DescribePixelFormat(dc, 0, 0, 0);
6371 adapter->cfgs = wined3d_calloc(cfg_count, sizeof(*adapter->cfgs));
6373 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
6375 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
6376 PIXELFORMATDESCRIPTOR pfd;
6377 int format_id = i + 1;
6379 if (!DescribePixelFormat(dc, format_id, sizeof(pfd), &pfd))
6380 continue;
6382 /* We only want HW acceleration using an OpenGL ICD driver.
6383 * PFD_GENERIC_FORMAT = slow opengl 1.1 gdi software rendering.
6384 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
6385 * driver (e.g. 3dfx minigl). */
6386 if (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
6388 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id);
6389 continue;
6392 cfg->iPixelFormat = format_id;
6393 cfg->redSize = pfd.cRedBits;
6394 cfg->greenSize = pfd.cGreenBits;
6395 cfg->blueSize = pfd.cBlueBits;
6396 cfg->alphaSize = pfd.cAlphaBits;
6397 cfg->colorSize = pfd.cColorBits;
6398 cfg->depthSize = pfd.cDepthBits;
6399 cfg->stencilSize = pfd.cStencilBits;
6400 cfg->windowDrawable = (pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
6401 cfg->iPixelType = (pfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
6402 cfg->doubleBuffer = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
6403 cfg->auxBuffers = pfd.cAuxBuffers;
6404 cfg->numSamples = 0;
6406 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
6407 "depth=%d, stencil=%d, windowDrawable=%d\n",
6408 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
6409 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
6410 cfg->depthSize, cfg->stencilSize, cfg->windowDrawable);
6412 ++adapter->cfg_count;
6417 static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags)
6419 static const DWORD supported_gl_versions[] =
6421 MAKEDWORD_VERSION(3, 2),
6422 MAKEDWORD_VERSION(1, 0),
6424 struct wined3d_gl_info *gl_info = &adapter->gl_info;
6425 struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
6426 unsigned int i;
6427 DISPLAY_DEVICEW display_device;
6429 TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
6431 adapter->ordinal = ordinal;
6433 /* Dynamically load all GL core functions */
6434 #ifdef USE_WIN32_OPENGL
6436 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
6437 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
6438 ALL_WGL_FUNCS
6439 #undef USE_GL_FUNC
6440 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
6441 gl_info->gl_ops.wgl.p_wglGetPixelFormat = (void *)GetProcAddress(mod_gl, "wglGetPixelFormat");
6443 #else
6444 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
6446 HDC hdc = GetDC( 0 );
6447 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
6448 ReleaseDC( 0, hdc );
6449 if (!wgl_driver || wgl_driver == (void *)-1) return FALSE;
6450 gl_info->gl_ops.wgl = wgl_driver->wgl;
6451 gl_info->gl_ops.gl = wgl_driver->gl;
6453 #endif
6455 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
6456 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
6458 if (!AllocateLocallyUniqueId(&adapter->luid))
6460 ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
6461 return FALSE;
6463 TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
6464 adapter->luid.HighPart, adapter->luid.LowPart, adapter);
6466 if (!wined3d_caps_gl_ctx_create(adapter, &caps_gl_ctx))
6468 ERR("Failed to get a GL context for adapter %p.\n", adapter);
6469 return FALSE;
6472 for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
6474 if (supported_gl_versions[i] <= wined3d_settings.max_gl_version)
6475 break;
6477 if (i == ARRAY_SIZE(supported_gl_versions))
6479 ERR_(winediag)("Requested invalid GL version %u.%u.\n",
6480 wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff);
6481 i = ARRAY_SIZE(supported_gl_versions) - 1;
6484 for (; i < ARRAY_SIZE(supported_gl_versions); ++i)
6486 gl_info->selected_gl_version = supported_gl_versions[i];
6488 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx, gl_info))
6489 break;
6491 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
6492 supported_gl_versions[i] >> 16, supported_gl_versions[i] & 0xffff);
6495 if (!wined3d_adapter_init_gl_caps(adapter, &caps_gl_ctx, wined3d_creation_flags))
6497 ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
6498 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6499 return FALSE;
6502 wined3d_adapter_init_fb_cfgs(adapter, caps_gl_ctx.dc);
6503 /* We haven't found any suitable formats. This should only happen in
6504 * case of GDI software rendering, which is pretty useless anyway. */
6505 if (!adapter->cfg_count)
6507 WARN("No suitable pixel formats found.\n");
6508 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6509 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
6510 return FALSE;
6513 if (!wined3d_adapter_init_format_info(adapter, &caps_gl_ctx))
6515 ERR("Failed to initialize GL format info.\n");
6516 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6517 HeapFree(GetProcessHeap(), 0, adapter->cfgs);
6518 return FALSE;
6521 gl_info->fixed_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH_COMPONENT);
6522 if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT])
6523 gl_info->float_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH32F_STENCIL8);
6525 adapter->vram_bytes = adapter->driver_info.vram_bytes;
6526 adapter->vram_bytes_used = 0;
6527 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
6529 display_device.cb = sizeof(display_device);
6530 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6531 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6532 strcpyW(adapter->DeviceName, display_device.DeviceName);
6534 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
6536 wined3d_adapter_init_ffp_attrib_ops(adapter);
6538 return TRUE;
6541 static BOOL wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordinal)
6543 DISPLAY_DEVICEW display_device;
6545 memset(adapter, 0, sizeof(*adapter));
6546 adapter->ordinal = ordinal;
6548 adapter->driver_info.name = "Display";
6549 adapter->driver_info.description = "WineD3D DirectDraw Emulation";
6550 if (wined3d_settings.emulated_textureram)
6551 adapter->vram_bytes = wined3d_settings.emulated_textureram;
6552 else
6553 adapter->vram_bytes = 128 * 1024 * 1024;
6555 if (!wined3d_adapter_init_format_info(adapter, NULL))
6556 return FALSE;
6558 adapter->vertex_pipe = &none_vertex_pipe;
6559 adapter->fragment_pipe = &none_fragment_pipe;
6560 adapter->shader_backend = &none_shader_backend;
6561 adapter->blitter = &cpu_blit;
6563 display_device.cb = sizeof(display_device);
6564 EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
6565 TRACE("DeviceName: %s\n", debugstr_w(display_device.DeviceName));
6566 strcpyW(adapter->DeviceName, display_device.DeviceName);
6568 return TRUE;
6571 static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
6573 const struct wined3d_parent_ops wined3d_null_parent_ops =
6575 wined3d_null_wined3d_object_destroyed,
6578 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags)
6580 BOOL ret;
6582 wined3d->ref = 1;
6583 wined3d->flags = flags;
6585 TRACE("Initializing adapters.\n");
6587 if (flags & WINED3D_NO3D)
6588 ret = wined3d_adapter_init_nogl(&wined3d->adapters[0], 0);
6589 else
6590 ret = wined3d_adapter_init(&wined3d->adapters[0], 0, flags);
6591 if (!ret)
6593 WARN("Failed to initialize adapter.\n");
6594 return E_FAIL;
6596 wined3d->adapter_count = 1;
6598 return WINED3D_OK;