odbc32: Use the ARRAY_SIZE() macro.
[wine.git] / dlls / wined3d / adapter_gl.c
blob99df19cc3172e9c8cc114c00a869a23510026a96
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, 2018 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"
31 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
32 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
33 WINE_DECLARE_DEBUG_CHANNEL(winediag);
35 enum wined3d_gl_vendor
37 GL_VENDOR_UNKNOWN,
38 GL_VENDOR_APPLE,
39 GL_VENDOR_FGLRX,
40 GL_VENDOR_MESA,
41 GL_VENDOR_NVIDIA,
44 struct wined3d_extension_map
46 const char *extension_string;
47 enum wined3d_gl_extension extension;
50 static const struct wined3d_extension_map gl_extension_map[] =
52 /* APPLE */
53 {"GL_APPLE_fence", APPLE_FENCE },
54 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS },
55 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE },
56 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422 },
58 /* ARB */
59 {"GL_ARB_base_instance", ARB_BASE_INSTANCE },
60 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED },
61 {"GL_ARB_buffer_storage", ARB_BUFFER_STORAGE },
62 {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT },
63 {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE },
64 {"GL_ARB_clip_control", ARB_CLIP_CONTROL },
65 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
66 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER },
67 {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH },
68 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
69 {"GL_ARB_copy_image", ARB_COPY_IMAGE },
70 {"GL_ARB_cull_distance", ARB_CULL_DISTANCE },
71 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
72 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
73 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
74 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
75 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
76 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
77 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
78 {"GL_ARB_draw_indirect", ARB_DRAW_INDIRECT },
79 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED },
80 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY },
81 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY },
82 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION },
83 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS},
84 {"GL_ARB_fragment_layer_viewport", ARB_FRAGMENT_LAYER_VIEWPORT },
85 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM },
86 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER },
87 {"GL_ARB_framebuffer_no_attachments", ARB_FRAMEBUFFER_NO_ATTACHMENTS},
88 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT },
89 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB },
90 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4 },
91 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5 },
92 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL },
93 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX },
94 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS },
95 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY },
96 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2 },
97 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT },
98 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE },
99 {"GL_ARB_multisample", ARB_MULTISAMPLE },
100 {"GL_ARB_multitexture", ARB_MULTITEXTURE },
101 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY },
102 {"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY },
103 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
104 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
105 {"GL_ARB_point_sprite", ARB_POINT_SPRITE },
106 {"GL_ARB_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP },
107 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
108 {"GL_ARB_query_buffer_object", ARB_QUERY_BUFFER_OBJECT },
109 {"GL_ARB_sample_shading", ARB_SAMPLE_SHADING },
110 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS },
111 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP },
112 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS },
113 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING },
114 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE },
115 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE },
116 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT},
117 {"GL_ARB_shader_texture_image_samples", ARB_SHADER_TEXTURE_IMAGE_SAMPLES},
118 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD },
119 {"GL_ARB_shader_viewport_layer_array", ARB_SHADER_VIEWPORT_LAYER_ARRAY},
120 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 },
121 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK },
122 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING },
123 {"GL_ARB_shadow", ARB_SHADOW },
124 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING },
125 {"GL_ARB_sync", ARB_SYNC },
126 {"GL_ARB_tessellation_shader", ARB_TESSELLATION_SHADER },
127 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP },
128 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT },
129 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE },
130 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION },
131 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC },
132 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC },
133 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP },
134 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY },
135 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
136 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
137 {"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
138 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
139 {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER },
140 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
141 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE},
142 {"GL_ARB_texture_multisample", ARB_TEXTURE_MULTISAMPLE },
143 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO },
144 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS },
145 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE },
146 {"GL_ARB_texture_rg", ARB_TEXTURE_RG },
147 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI },
148 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE },
149 {"GL_ARB_texture_storage_multisample", ARB_TEXTURE_STORAGE_MULTISAMPLE},
150 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE },
151 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW },
152 {"GL_ARB_timer_query", ARB_TIMER_QUERY },
153 {"GL_ARB_transform_feedback2", ARB_TRANSFORM_FEEDBACK2 },
154 {"GL_ARB_transform_feedback3", ARB_TRANSFORM_FEEDBACK3 },
155 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT },
156 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA },
157 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT },
158 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM },
159 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER },
160 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV},
161 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY },
163 /* ATI */
164 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER },
165 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL },
166 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC },
167 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3 },
168 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE },
170 /* EXT */
171 {"GL_EXT_blend_color", EXT_BLEND_COLOR },
172 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE },
173 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE },
174 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX },
175 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT },
176 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST },
177 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2 },
178 {"GL_EXT_fog_coord", EXT_FOG_COORD },
179 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT },
180 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE },
181 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT },
182 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS },
183 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4 },
184 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
185 {"GL_EXT_packed_float", EXT_PACKED_FLOAT },
186 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
187 {"GL_EXT_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP },
188 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
189 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
190 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
191 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP },
192 {"GL_EXT_texture3D", EXT_TEXTURE3D },
193 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY },
194 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC },
195 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
196 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
197 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
198 {"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
199 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER },
200 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
201 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP },
202 {"GL_EXT_texture_shared_exponent", EXT_TEXTURE_SHARED_EXPONENT },
203 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM },
204 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB },
205 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE },
206 {"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
208 /* NV */
209 {"GL_NV_fence", NV_FENCE },
210 {"GL_NV_fog_distance", NV_FOG_DISTANCE },
211 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
212 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2 },
213 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION },
214 {"GL_NV_half_float", NV_HALF_FLOAT },
215 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT },
216 {"GL_NV_point_sprite", NV_POINT_SPRITE },
217 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS },
218 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2 },
219 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION },
220 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4 },
221 {"GL_NV_texture_shader", NV_TEXTURE_SHADER },
222 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2 },
223 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM },
224 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1 },
225 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
226 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
227 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
230 static const struct wined3d_extension_map wgl_extension_map[] =
232 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT },
233 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL },
234 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH},
235 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER },
238 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx *ctx)
240 const struct wined3d_gl_info *gl_info = ctx->gl_info;
242 TRACE("Destroying caps GL context.\n");
244 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
245 * this function might be called before the relevant function pointers
246 * in gl_info are initialized. */
247 if (ctx->test_program_id || ctx->test_vbo)
249 GL_EXTCALL(glDeleteProgram(ctx->test_program_id));
250 GL_EXTCALL(glDeleteBuffers(1, &ctx->test_vbo));
253 if (!wglMakeCurrent(NULL, NULL))
254 ERR("Failed to disable caps GL context.\n");
256 if (!wglDeleteContext(ctx->gl_ctx))
258 DWORD err = GetLastError();
259 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
262 wined3d_release_dc(ctx->wnd, ctx->dc);
263 DestroyWindow(ctx->wnd);
265 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
266 ERR("Failed to restore previous GL context.\n");
269 static BOOL wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx *caps_gl_ctx,
270 struct wined3d_gl_info *gl_info)
272 HGLRC new_ctx;
274 if (!(gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
275 return TRUE;
277 if (!(new_ctx = context_create_wgl_attribs(gl_info, caps_gl_ctx->dc, NULL)))
279 gl_info->p_wglCreateContextAttribsARB = NULL;
280 return FALSE;
283 if (!wglMakeCurrent(caps_gl_ctx->dc, new_ctx))
285 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
286 if (!wglDeleteContext(new_ctx))
287 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
288 gl_info->p_wglCreateContextAttribsARB = NULL;
289 return TRUE;
292 if (!wglDeleteContext(caps_gl_ctx->gl_ctx))
293 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
294 caps_gl_ctx->gl_ctx = new_ctx;
296 return TRUE;
299 static BOOL wined3d_caps_gl_ctx_create(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
301 PIXELFORMATDESCRIPTOR pfd;
302 int iPixelFormat;
304 TRACE("getting context...\n");
306 ctx->restore_dc = wglGetCurrentDC();
307 ctx->restore_gl_ctx = wglGetCurrentContext();
309 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
310 ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
311 WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
312 if (!ctx->wnd)
314 ERR("Failed to create a window.\n");
315 goto fail;
318 ctx->dc = GetDC(ctx->wnd);
319 if (!ctx->dc)
321 ERR("Failed to get a DC.\n");
322 goto fail;
325 /* PixelFormat selection */
326 ZeroMemory(&pfd, sizeof(pfd));
327 pfd.nSize = sizeof(pfd);
328 pfd.nVersion = 1;
329 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */
330 pfd.iPixelType = PFD_TYPE_RGBA;
331 pfd.cColorBits = 32;
332 pfd.iLayerType = PFD_MAIN_PLANE;
334 if (!(iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd)))
336 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
337 ERR("Failed to find a suitable pixel format.\n");
338 goto fail;
340 DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd);
341 SetPixelFormat(ctx->dc, iPixelFormat, &pfd);
343 /* Create a GL context. */
344 if (!(ctx->gl_ctx = wglCreateContext(ctx->dc)))
346 WARN("Failed to create default context for capabilities initialization.\n");
347 goto fail;
350 /* Make it the current GL context. */
351 if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
353 ERR("Failed to make caps GL context current.\n");
354 goto fail;
357 ctx->gl_info = &adapter->gl_info;
358 return TRUE;
360 fail:
361 if (ctx->gl_ctx) wglDeleteContext(ctx->gl_ctx);
362 ctx->gl_ctx = NULL;
363 if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);
364 ctx->dc = NULL;
365 if (ctx->wnd) DestroyWindow(ctx->wnd);
366 ctx->wnd = NULL;
367 if (ctx->restore_gl_ctx && !wglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx))
368 ERR("Failed to restore previous GL context.\n");
370 return FALSE;
373 /* Context activation is done by the caller. */
374 static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
376 GLuint prog;
377 BOOL ret = FALSE;
378 static const char testcode[] =
379 "!!ARBvp1.0\n"
380 "PARAM C[66] = { program.env[0..65] };\n"
381 "ADDRESS A0;"
382 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
383 "ARL A0.x, zero.x;\n"
384 "MOV result.position, C[A0.x + 65];\n"
385 "END\n";
387 while (gl_info->gl_ops.gl.p_glGetError());
388 GL_EXTCALL(glGenProgramsARB(1, &prog));
389 if(!prog) {
390 ERR("Failed to create an ARB offset limit test program\n");
392 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
393 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
394 strlen(testcode), testcode));
395 if (gl_info->gl_ops.gl.p_glGetError())
397 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
398 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
399 ret = TRUE;
400 } else TRACE("OpenGL implementation allows offsets > 63\n");
402 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
403 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
404 checkGLcall("ARB vp offset limit test cleanup");
406 return ret;
409 static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
410 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
411 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
413 return card_vendor == HW_VENDOR_AMD
414 && (device == CARD_AMD_RADEON_9500
415 || device == CARD_AMD_RADEON_X700
416 || device == CARD_AMD_RADEON_X1600);
419 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
420 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
421 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
423 return card_vendor == HW_VENDOR_NVIDIA
424 && (device == CARD_NVIDIA_GEFORCEFX_5200
425 || device == CARD_NVIDIA_GEFORCEFX_5600
426 || device == CARD_NVIDIA_GEFORCEFX_5800);
429 static BOOL match_apple(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
430 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
431 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
433 /* MacOS has various specialities in the extensions it advertises. Some
434 * have to be loaded from the OpenGL 1.2+ core, while other extensions are
435 * advertised, but software emulated. So try to detect the Apple OpenGL
436 * implementation to apply some extension fixups afterwards.
438 * Detecting this isn't really easy. The vendor string doesn't mention
439 * Apple. Compile-time checks aren't sufficient either because a Linux
440 * binary may display on a macOS X server via remote X11. So try to detect
441 * the OpenGL implementation by looking at certain Apple extensions. Some
442 * extensions like client storage might be supported on other
443 * implementations too, but GL_APPLE_flush_render is specific to the
444 * macOS X window management, and GL_APPLE_ycbcr_422 is QuickTime
445 * specific. So the chance that other implementations support them is
446 * rather small since Win32 QuickTime uses DirectDraw, not OpenGL.
448 * This test has been moved into wined3d_guess_gl_vendor(). */
449 return gl_vendor == GL_VENDOR_APPLE;
452 /* Context activation is done by the caller. */
453 static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
455 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
456 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
457 * all the texture. This function detects this bug by its symptom and disables PBOs
458 * if the test fails.
460 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
461 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
462 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
463 * read back is compared to the original. If they are equal PBOs are assumed to work,
464 * otherwise the PBO extension is disabled. */
465 GLuint texture, pbo;
466 static const unsigned int pattern[] =
468 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
469 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
470 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
471 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
473 unsigned int check[ARRAY_SIZE(pattern)];
475 /* No PBO -> No point in testing them. */
476 if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
478 while (gl_info->gl_ops.gl.p_glGetError());
479 gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
480 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
482 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
483 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);
484 checkGLcall("Specifying the PBO test texture");
486 GL_EXTCALL(glGenBuffers(1, &pbo));
487 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo));
488 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pattern), pattern, GL_STREAM_DRAW));
489 checkGLcall("Specifying the PBO test pbo");
491 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);
492 checkGLcall("Loading the PBO test texture");
494 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
496 gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
498 memset(check, 0, sizeof(check));
499 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
500 checkGLcall("Reading back the PBO test texture");
502 gl_info->gl_ops.gl.p_glDeleteTextures(1, &texture);
503 GL_EXTCALL(glDeleteBuffers(1, &pbo));
504 checkGLcall("PBO test cleanup");
506 if (memcmp(check, pattern, sizeof(check)))
508 WARN_(d3d_perf)("PBO test failed, read back data doesn't match original.\n"
509 "Disabling PBOs. This may result in slower performance.\n");
510 gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
512 else
514 TRACE("PBO test successful.\n");
518 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
519 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
520 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
522 return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
525 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
526 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
527 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
529 if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
530 if (card_vendor != HW_VENDOR_AMD) return FALSE;
531 if (device == CARD_AMD_RADEON_X1600) return FALSE;
532 return TRUE;
535 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
536 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
537 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
539 /* Direct3D 9 cards support 40 single float varyings in hardware, most
540 * drivers report 32. ATI misreports 44 varyings. So assume that if we
541 * have more than 44 varyings we have a Direct3D 10+ card. This detection
542 * is for the gl_ClipPos varying quirk. If a Direct3D 9 card really
543 * supports more than 44 varyings and we subtract one in Direct3D 9
544 * shaders it's not going to hurt us because the Direct3D 9 limit is
545 * hardcoded.
547 * Direct3D 10 cards usually have 64 varyings. */
548 return gl_info->limits.glsl_varyings > 44;
551 static BOOL match_not_dx10_capable(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
552 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
553 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
555 return !match_dx10_capable(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device);
558 /* A GL context is provided by the caller */
559 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
560 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
561 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
563 GLenum error;
564 DWORD data[16];
566 if (!gl_info->supported[EXT_SECONDARY_COLOR] || !gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
567 return FALSE;
569 while (gl_info->gl_ops.gl.p_glGetError());
570 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
571 error = gl_info->gl_ops.gl.p_glGetError();
573 if (error == GL_NO_ERROR)
575 TRACE("GL Implementation accepts 4 component specular color pointers\n");
576 return TRUE;
578 else
580 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
581 debug_glerror(error));
582 return FALSE;
586 /* A GL context is provided by the caller */
587 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
588 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
589 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
591 GLuint prog;
592 BOOL ret = FALSE;
593 GLint pos;
594 static const char testcode[] =
595 "!!ARBvp1.0\n"
596 "OPTION NV_vertex_program2;\n"
597 "MOV result.clip[0], 0.0;\n"
598 "MOV result.position, 0.0;\n"
599 "END\n";
601 if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
603 while (gl_info->gl_ops.gl.p_glGetError());
605 GL_EXTCALL(glGenProgramsARB(1, &prog));
606 if(!prog)
608 ERR("Failed to create the NVvp clip test program\n");
609 return FALSE;
611 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
612 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
613 strlen(testcode), testcode));
614 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
615 if(pos != -1)
617 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
618 TRACE("error: %s\n", debugstr_a((const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
619 ret = TRUE;
620 while (gl_info->gl_ops.gl.p_glGetError());
622 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
624 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
625 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
626 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
628 return ret;
631 /* Context activation is done by the caller. */
632 static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
633 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
634 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
636 char data[4 * 4 * 4];
637 GLuint tex, fbo;
638 GLenum status;
640 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
642 memset(data, 0xcc, sizeof(data));
644 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
645 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
646 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
647 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
648 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);
649 checkGLcall("glTexImage2D");
651 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
652 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
653 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
654 checkGLcall("glFramebufferTexture2D");
656 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
657 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
658 checkGLcall("glCheckFramebufferStatus");
660 memset(data, 0x11, sizeof(data));
661 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);
662 checkGLcall("glTexSubImage2D");
664 gl_info->gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
665 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
666 checkGLcall("glClear");
668 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
669 checkGLcall("glGetTexImage");
671 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
672 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
673 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
674 checkGLcall("glBindTexture");
676 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
677 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
678 checkGLcall("glDeleteTextures");
680 return *(DWORD *)data == 0x11111111;
683 /* Context activation is done by the caller. */
684 static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
685 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
686 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
688 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
689 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
690 GLuint tex;
691 GLint size;
693 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
694 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
695 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
696 checkGLcall("glTexImage2D");
698 gl_info->gl_ops.gl.p_glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &size);
699 checkGLcall("glGetTexLevelParameteriv");
700 TRACE("Real color depth is %d\n", size);
702 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
703 checkGLcall("glBindTexture");
704 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
705 checkGLcall("glDeleteTextures");
707 return size < 16;
710 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
711 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
712 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
714 return gl_vendor == GL_VENDOR_FGLRX;
717 static BOOL match_r200(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
718 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
719 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
721 if (card_vendor != HW_VENDOR_AMD) return FALSE;
722 if (device == CARD_AMD_RADEON_8500) return TRUE;
723 return FALSE;
726 static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
727 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
728 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
730 DWORD data[4];
731 GLuint tex, fbo;
732 GLenum status;
733 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
734 GLuint prog;
735 GLint err_pos;
736 static const char program_code[] =
737 "!!ARBfp1.0\n"
738 "OPTION ARB_fog_linear;\n"
739 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
740 "END\n";
742 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
743 return FALSE;
744 if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
745 return FALSE;
746 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
747 return FALSE;
749 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
750 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
751 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
752 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
753 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);
754 checkGLcall("glTexImage2D");
756 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
757 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
758 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
759 checkGLcall("glFramebufferTexture2D");
761 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
762 if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
763 checkGLcall("glCheckFramebufferStatus");
765 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
766 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
767 checkGLcall("glClear");
768 gl_info->gl_ops.gl.p_glViewport(0, 0, 4, 1);
769 checkGLcall("glViewport");
771 gl_info->gl_ops.gl.p_glEnable(GL_FOG);
772 gl_info->gl_ops.gl.p_glFogf(GL_FOG_START, 0.5f);
773 gl_info->gl_ops.gl.p_glFogf(GL_FOG_END, 0.5f);
774 gl_info->gl_ops.gl.p_glFogi(GL_FOG_MODE, GL_LINEAR);
775 gl_info->gl_ops.gl.p_glHint(GL_FOG_HINT, GL_NICEST);
776 gl_info->gl_ops.gl.p_glFogfv(GL_FOG_COLOR, color);
777 checkGLcall("fog setup");
779 GL_EXTCALL(glGenProgramsARB(1, &prog));
780 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog));
781 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
782 strlen(program_code), program_code));
783 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
784 checkGLcall("Test fragment program setup");
786 gl_info->gl_ops.gl.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &err_pos);
787 if (err_pos != -1)
789 const char *error_str;
790 error_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB);
791 FIXME("Fog test program error at position %d: %s\n\n", err_pos, debugstr_a(error_str));
794 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
795 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
796 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
797 gl_info->gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
798 gl_info->gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
799 gl_info->gl_ops.gl.p_glEnd();
800 checkGLcall("ARBfp fog test draw");
802 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
803 checkGLcall("glGetTexImage");
804 data[0] &= 0x00ffffff;
805 data[1] &= 0x00ffffff;
806 data[2] &= 0x00ffffff;
807 data[3] &= 0x00ffffff;
809 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
810 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, 0);
812 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
813 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
814 gl_info->gl_ops.gl.p_glDisable(GL_FOG);
815 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
816 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
817 GL_EXTCALL(glDeleteProgramsARB(1, &prog));
818 checkGLcall("ARBfp fog test teardown");
820 TRACE("Fog test data: %08x %08x %08x %08x\n", data[0], data[1], data[2], data[3]);
821 return data[0] != 0x00ff0000 || data[3] != 0x0000ff00;
824 static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl_info,
825 struct wined3d_caps_gl_ctx *ctx, const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
826 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
828 if (!gl_info->supported[ARB_VIEWPORT_ARRAY])
829 return FALSE;
830 if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
831 return FALSE;
832 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx);
835 static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
837 /* MacOS needs uniforms for relative addressing offsets. This can
838 * accumulate to quite a few uniforms. Beyond that the general uniform
839 * isn't optimal, so reserve a number of uniforms. 12 vec4's should allow
840 * 48 different offsets or other helper immediate values. */
841 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
842 gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
845 static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
847 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and
848 * earlier cards, although these cards only support
849 * GL_ARB_texture_rectangle (D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
851 * If real NP2 textures are used, the driver falls back to software. We
852 * could just disable the extension and use GL_ARB_texture_rectangle
853 * instead, but texture_rectangle is inconvenient due to the
854 * non-normalised texture coordinates. Thus set an internal extension
855 * flag, GL_WINE_normalized_texrect, which signals the code that it can
856 * use non-power-of-two textures as per GL_ARB_texture_non_power_of_two,
857 * but has to stick to the texture_rectangle limits.
859 * Fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it
860 * advertises OpenGL 2.0, which has this extension promoted to core. The
861 * extension loading code sets this extension supported due to that, so
862 * this code works on fglrx as well. */
863 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
865 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
866 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
867 gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] = TRUE;
871 static void quirk_no_np2(struct wined3d_gl_info *gl_info)
873 /* The NVIDIA GeForce FX series reports OpenGL 2.0 capabilities with the
874 * latest drivers versions, but doesn't explicitly advertise the
875 * ARB_tex_npot extension in the OpenGL extension string. This usually
876 * means that ARB_tex_npot is supported in hardware as long as the
877 * application is staying within the limits enforced by the
878 * ARB_texture_rectangle extension. This however is not true for the
879 * FX series, which instantly falls back to a slower software path as
880 * soon as ARB_tex_npot is used. We therefore completely remove
881 * ARB_tex_npot from the list of supported extensions.
883 * Note that WINE_normalized_texrect can't be used in this case because
884 * internally it uses ARB_tex_npot, triggering the software fallback.
885 * There is not much we can do here apart from disabling the
886 * software-emulated extension and re-enable ARB_tex_rect (which was
887 * previously disabled in wined3d_adapter_init_gl_caps).
889 * This fixup removes performance problems on both the FX 5900 and
890 * FX 5700 (e.g. for framebuffer post-processing effects in the game
891 * "Max Payne 2"). The behaviour can be verified through a simple test
892 * app attached in bugreport #14724. */
893 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
894 gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
895 gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
898 static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
900 /* The Intel GPUs on macOS set the .w register of texcoords to 0.0 by
901 * default, which causes problems with fixed-function fragment processing.
902 * Ideally this flag should be detected with a test shader and OpenGL
903 * feedback mode, but some OpenGL implementations (macOS ATI at least,
904 * probably all macOS ones) do not like vertex shaders in feedback mode
905 * and return an error, even though it should be valid according to the
906 * spec.
908 * We don't want to enable this on all cards, as it adds an extra
909 * instruction per texcoord used. This makes the shader slower and eats
910 * instruction slots which should be available to the Direct3D
911 * application.
913 * ATI Radeon HD 2xxx cards on macOS have the issue. Instead of checking
914 * for the buggy cards, blacklist all Radeon cards on macOS and whitelist
915 * the good ones. That way we're prepared for the future. If this
916 * workaround is activated on cards that do not need it, it won't break
917 * things, just affect performance negatively. */
918 TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
919 gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
922 static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
924 gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
927 static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
929 gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
932 static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
934 gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
937 static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
939 gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
942 static void quirk_broken_rgba16(struct wined3d_gl_info *gl_info)
944 gl_info->quirks |= WINED3D_QUIRK_BROKEN_RGBA16;
947 static void quirk_infolog_spam(struct wined3d_gl_info *gl_info)
949 gl_info->quirks |= WINED3D_QUIRK_INFO_LOG_SPAM;
952 static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
954 /* NVIDIA GeForce 6xxx and 7xxx support accelerated VTF only on a few
955 * selected texture formats. They are apparently the only Direct3D 9 class
956 * GPUs supporting VTF. Also, Direct3D 9-era GPUs are somewhat limited
957 * with float texture filtering and blending. */
958 gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
961 static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
963 /* The Mesa r200 driver (and there is no other driver for this GPU Wine
964 * would run on) loads some fog parameters (start, end, exponent, but not
965 * the colour) into the program.
967 * Apparently the fog hardware is only able to handle linear fog with a
968 * range of 0.0;1.0, and it is the responsibility of the vertex pipeline
969 * to handle non-linear fog and linear fog with start and end other than
970 * 0.0 and 1.0. */
971 TRACE("Reserving 1 ARB constant for compiler private use.\n");
972 gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
975 static void quirk_broken_arb_fog(struct wined3d_gl_info *gl_info)
977 gl_info->quirks |= WINED3D_QUIRK_BROKEN_ARB_FOG;
980 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info *gl_info)
982 if (gl_info->supported[ARB_CLIP_CONTROL])
984 TRACE("Disabling ARB_clip_control.\n");
985 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
989 static const struct wined3d_gpu_description *query_gpu_description(const struct wined3d_gl_info *gl_info,
990 UINT64 *vram_bytes)
992 const struct wined3d_gpu_description *gpu_description;
993 enum wined3d_pci_vendor vendor = PCI_VENDOR_NONE;
994 enum wined3d_pci_device device = PCI_DEVICE_NONE;
995 static unsigned int once;
997 if (gl_info->supported[WGL_WINE_QUERY_RENDERER])
999 GLuint value;
1001 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE, &value)))
1002 vendor = value;
1003 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE, &value)))
1004 device = value;
1005 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE, &value)))
1006 *vram_bytes = (UINT64)value * 1024 * 1024;
1007 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1008 vendor, device, wine_dbgstr_longlong(*vram_bytes));
1011 if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
1013 vendor = wined3d_settings.pci_vendor_id;
1014 TRACE("Overriding vendor PCI ID with 0x%04x.\n", vendor);
1017 if (wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
1019 device = wined3d_settings.pci_device_id;
1020 TRACE("Overriding device PCI ID with 0x%04x.\n", device);
1023 if (!(gpu_description = wined3d_get_gpu_description(vendor, device))
1024 && (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE
1025 || wined3d_settings.pci_device_id != PCI_DEVICE_NONE) && !once++)
1026 ERR_(winediag)("Invalid GPU override %04x:%04x specified, ignoring.\n", vendor, device);
1028 return gpu_description;
1031 /* Context activation is done by the caller. */
1032 static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1033 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1034 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
1036 unsigned int i;
1038 static const struct driver_quirk
1040 BOOL (*match)(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
1041 const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
1042 enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
1043 void (*apply)(struct wined3d_gl_info *gl_info);
1044 const char *description;
1046 quirk_table[] =
1049 match_amd_r300_to_500,
1050 quirk_amd_dx9,
1051 "AMD normalised texrect quirk"
1054 match_apple,
1055 quirk_apple_glsl_constants,
1056 "Apple GLSL uniform override"
1059 match_geforce5,
1060 quirk_no_np2,
1061 "Geforce 5 NP2 disable"
1064 match_apple_intel,
1065 quirk_texcoord_w,
1066 "Init texcoord .w for Apple Intel GPU driver"
1069 match_apple_nonr500ati,
1070 quirk_texcoord_w,
1071 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1074 match_dx10_capable,
1075 quirk_clip_varying,
1076 "Reserved varying for gl_ClipPos"
1079 /* GL_EXT_secondary_color does not allow 4 component secondary
1080 * colours, but most OpenGL implementations accept it. Apple's
1081 * is the only OpenGL implementation known to reject it.
1083 * If we can pass 4-component specular colours, do it, because
1084 * (a) we don't have to screw around with the data, and (b) the
1085 * Direct3D fixed-function vertex pipeline passes specular alpha
1086 * to the pixel shader if any is used. Otherwise the specular
1087 * alpha is used to pass the fog coordinate, which we pass to
1088 * OpenGL via GL_EXT_fog_coord. */
1089 match_allows_spec_alpha,
1090 quirk_allows_specular_alpha,
1091 "Allow specular alpha quirk"
1094 match_broken_nv_clip,
1095 quirk_disable_nvvp_clip,
1096 "Apple NV_vertex_program clip bug quirk"
1099 match_fbo_tex_update,
1100 quirk_fbo_tex_update,
1101 "FBO rebind for attachment updates"
1104 match_broken_rgba16,
1105 quirk_broken_rgba16,
1106 "True RGBA16 is not available"
1109 match_fglrx,
1110 quirk_infolog_spam,
1111 "Not printing GLSL infolog"
1114 match_not_dx10_capable,
1115 quirk_limited_tex_filtering,
1116 "Texture filtering, blending and VTF support is limited"
1119 match_r200,
1120 quirk_r200_constants,
1121 "r200 vertex shader constants"
1124 match_broken_arb_fog,
1125 quirk_broken_arb_fog,
1126 "ARBfp fogstart == fogend workaround"
1129 match_broken_viewport_subpixel_bits,
1130 quirk_broken_viewport_subpixel_bits,
1131 "NVIDIA viewport subpixel bits bug"
1135 for (i = 0; i < ARRAY_SIZE(quirk_table); ++i)
1137 if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
1138 TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
1139 quirk_table[i].apply(gl_info);
1142 /* Find out if PBOs work as they are supposed to. */
1143 test_pbo_functionality(gl_info);
1146 static DWORD wined3d_parse_gl_version(const char *gl_version)
1148 const char *ptr = gl_version;
1149 int major, minor;
1151 major = atoi(ptr);
1152 if (major <= 0)
1153 ERR("Invalid OpenGL major version %d.\n", major);
1155 while (isdigit(*ptr)) ++ptr;
1156 if (*ptr++ != '.')
1157 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version));
1159 minor = atoi(ptr);
1161 TRACE("Found OpenGL version %d.%d.\n", major, minor);
1163 return MAKEDWORD_VERSION(major, minor);
1166 static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_info *gl_info,
1167 const char *gl_vendor_string, const char *gl_renderer, const char *gl_version)
1169 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1170 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1171 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1173 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1174 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1175 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1176 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1177 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1178 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1179 * DirectDraw, not OpenGL. */
1180 if (gl_info->supported[APPLE_FENCE] && gl_info->supported[APPLE_YCBCR_422])
1181 return GL_VENDOR_APPLE;
1183 if (strstr(gl_vendor_string, "NVIDIA"))
1184 return GL_VENDOR_NVIDIA;
1186 if (strstr(gl_vendor_string, "ATI"))
1187 return GL_VENDOR_FGLRX;
1189 if (strstr(gl_vendor_string, "Mesa")
1190 || strstr(gl_vendor_string, "X.Org")
1191 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1192 || strstr(gl_vendor_string, "DRI R300 Project")
1193 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1194 || strstr(gl_vendor_string, "VMware, Inc.")
1195 || strstr(gl_vendor_string, "Intel")
1196 || strstr(gl_renderer, "Mesa")
1197 || strstr(gl_renderer, "Gallium")
1198 || strstr(gl_renderer, "Intel")
1199 || strstr(gl_version, "Mesa"))
1200 return GL_VENDOR_MESA;
1202 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1203 debugstr_a(gl_vendor_string));
1205 return GL_VENDOR_UNKNOWN;
1208 static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
1210 if (strstr(gl_vendor_string, "NVIDIA")
1211 || strstr(gl_vendor_string, "Nouveau")
1212 || strstr(gl_vendor_string, "nouveau"))
1213 return HW_VENDOR_NVIDIA;
1215 if (strstr(gl_vendor_string, "ATI")
1216 || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
1217 || strstr(gl_vendor_string, "X.Org R300 Project")
1218 || strstr(gl_renderer, "AMD")
1219 || strstr(gl_renderer, "FirePro")
1220 || strstr(gl_renderer, "Radeon")
1221 || strstr(gl_renderer, "R100")
1222 || strstr(gl_renderer, "R200")
1223 || strstr(gl_renderer, "R300")
1224 || strstr(gl_renderer, "R600")
1225 || strstr(gl_renderer, "R700"))
1226 return HW_VENDOR_AMD;
1228 if (strstr(gl_vendor_string, "Intel(R)")
1229 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1230 || strstr(gl_renderer, "Intel")
1231 || strstr(gl_renderer, "i915")
1232 || strstr(gl_vendor_string, "Intel Inc."))
1233 return HW_VENDOR_INTEL;
1235 if (strstr(gl_renderer, "SVGA3D"))
1236 return HW_VENDOR_VMWARE;
1238 if (strstr(gl_vendor_string, "Mesa")
1239 || strstr(gl_vendor_string, "Brian Paul")
1240 || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
1241 || strstr(gl_vendor_string, "VMware, Inc."))
1242 return HW_VENDOR_SOFTWARE;
1244 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
1246 return HW_VENDOR_NVIDIA;
1249 static enum wined3d_feature_level feature_level_from_caps(const struct wined3d_gl_info *gl_info,
1250 const struct shader_caps *shader_caps, const struct fragment_caps *fragment_caps)
1252 unsigned int shader_model;
1254 shader_model = min(shader_caps->vs_version, shader_caps->ps_version);
1255 shader_model = min(shader_model, max(shader_caps->gs_version, 3));
1256 shader_model = min(shader_model, max(shader_caps->hs_version, 4));
1257 shader_model = min(shader_model, max(shader_caps->ds_version, 4));
1259 if (gl_info->supported[WINED3D_GL_VERSION_3_2]
1260 && gl_info->supported[ARB_POLYGON_OFFSET_CLAMP]
1261 && gl_info->supported[ARB_SAMPLER_OBJECTS])
1263 if (shader_model >= 5
1264 && gl_info->supported[ARB_DRAW_INDIRECT]
1265 && gl_info->supported[ARB_TEXTURE_COMPRESSION_BPTC])
1266 return WINED3D_FEATURE_LEVEL_11_1;
1268 if (shader_model >= 4)
1270 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY])
1271 return WINED3D_FEATURE_LEVEL_10_1;
1272 return WINED3D_FEATURE_LEVEL_10;
1276 if (shader_model >= 3)
1277 return WINED3D_FEATURE_LEVEL_9_SM3;
1278 if (shader_model >= 2)
1279 return WINED3D_FEATURE_LEVEL_9_SM2;
1280 if (shader_model >= 1)
1281 return WINED3D_FEATURE_LEVEL_8;
1283 if (fragment_caps->TextureOpCaps & WINED3DTEXOPCAPS_DOTPRODUCT3)
1284 return WINED3D_FEATURE_LEVEL_7;
1285 if (fragment_caps->MaxSimultaneousTextures > 1)
1286 return WINED3D_FEATURE_LEVEL_6;
1288 return WINED3D_FEATURE_LEVEL_5;
1291 static const struct wined3d_renderer_table
1293 const char *renderer;
1294 enum wined3d_pci_device id;
1296 cards_nvidia_binary[] =
1298 /* Direct 3D 11 */
1299 {"TITAN V", CARD_NVIDIA_TITANV}, /* GeForce 1000 - highend */
1300 {"TITAN X (Pascal)", CARD_NVIDIA_TITANX_PASCAL}, /* GeForce 1000 - highend */
1301 {"GTX 1080 Ti", CARD_NVIDIA_GEFORCE_GTX1080TI}, /* GeForce 1000 - highend */
1302 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080}, /* GeForce 1000 - highend */
1303 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070}, /* GeForce 1000 - highend */
1304 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060}, /* GeForce 1000 - midend high */
1305 {"GTX 1050 Ti", CARD_NVIDIA_GEFORCE_GTX1050TI}, /* GeForce 1000 - midend */
1306 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050}, /* GeForce 1000 - midend */
1307 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI}, /* GeForce 900 - highend */
1308 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980}, /* GeForce 900 - highend */
1309 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M}, /* GeForce 900 - highend mobile*/
1310 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970}, /* GeForce 900 - highend */
1311 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX}, /* Geforce 900 - highend */
1312 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M}, /* GeForce 900 - midend high mobile */
1313 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960}, /* GeForce 900 - midend high */
1314 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M}, /* GeForce 900 - midend mobile */
1315 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950}, /* GeForce 900 - midend */
1316 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M}, /* GeForce 900 - midend mobile */
1317 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M}, /* GeForce 800 - mobile */
1318 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M}, /* GeForce 800 - mobile */
1319 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M}, /* GeForce 800 - mobile */
1320 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M}, /* GeForce 800 - mobile */
1321 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M}, /* GeForce 800 - mobile */
1322 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M}, /* GeForce 800 - mobile */
1323 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M}, /* GeForce 800 - mobile */
1324 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M}, /* GeForce 800 - mobile */
1325 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI}, /* Geforce 700 - highend */
1326 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB}, /* Geforce 700 - highend */
1327 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ}, /* Geforce 700 - highend */
1328 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN}, /* Geforce 700 - highend */
1329 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780}, /* Geforce 700 - highend */
1330 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M}, /* Geforce 700 - midend high mobile */
1331 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770}, /* Geforce 700 - highend */
1332 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M}, /* Geforce 700 - midend high mobile */
1333 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI}, /* Geforce 700 - midend high */
1334 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */
1335 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */
1336 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */
1337 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M}, /* Geforce 700 - midend mobile */
1338 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M}, /* Geforce 700 - midend mobile */
1339 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M}, /* Geforce 700 - midend mobile */
1340 {"GT 730", CARD_NVIDIA_GEFORCE_GT730}, /* Geforce 700 - lowend */
1341 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690}, /* Geforce 600 - highend */
1342 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
1343 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX}, /* Geforce 600 - highend */
1344 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
1345 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
1346 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI}, /* Geforce 600 - midend high */
1347 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M}, /* Geforce 600 - midend high mobile */
1348 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660}, /* Geforce 600 - midend high */
1349 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI}, /* Geforce 600 - lowend */
1350 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650}, /* Geforce 600 - lowend */
1351 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M}, /* Geforce 600 - midend mobile */
1352 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M}, /* Geforce 600 - midend mobile */
1353 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M}, /* Geforce 600 - midend mobile */
1354 {"GT 630", CARD_NVIDIA_GEFORCE_GT630}, /* Geforce 600 - lowend */
1355 {"GT 610", CARD_NVIDIA_GEFORCE_GT610}, /* Geforce 600 - lowend */
1356 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
1357 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
1358 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
1359 {"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M}, /* Geforce 500 - midend mobile */
1360 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
1361 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
1362 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
1363 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M}, /* Geforce 500 - midend mobile */
1364 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M}, /* Geforce 500 - lowend mobile */
1365 {"GT 520", CARD_NVIDIA_GEFORCE_GT520}, /* Geforce 500 - lowend */
1366 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
1367 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
1368 /* Direct 3D 10 */
1369 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
1370 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M}, /* Geforce 400 - highend mobile */
1371 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
1372 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
1373 {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
1374 {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
1375 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M}, /* Geforce 400 - lowend mobile */
1376 {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
1377 {"410M", CARD_NVIDIA_GEFORCE_410M}, /* Geforce 400 - lowend mobile */
1378 {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
1379 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1380 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
1381 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1382 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
1383 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
1384 {"320M", CARD_NVIDIA_GEFORCE_320M}, /* Geforce 300 - midend mobile */
1385 {"315M", CARD_NVIDIA_GEFORCE_315M}, /* Geforce 300 - midend mobile */
1386 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1387 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1388 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
1389 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
1390 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
1391 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250}, /* Geforce 200 - midend */
1392 {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
1393 {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
1394 {"GeForce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1395 {"GeForce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1396 {"GeForce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1397 {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
1398 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1399 {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
1400 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT}, /* Geforce 9 - midend */
1401 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1402 {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
1403 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1404 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1405 {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
1406 {"9400M", CARD_NVIDIA_GEFORCE_9400M}, /* Geforce 9 - lowend */
1407 {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
1408 {"9300", CARD_NVIDIA_GEFORCE_9300}, /* Geforce 9 - lowend low */
1409 {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1410 {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1411 {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
1412 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
1413 {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
1414 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1415 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
1416 {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1417 {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
1418 {"8500", CARD_NVIDIA_GEFORCE_8500GT}, /* Geforce 8 - mid-lowend */
1419 {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
1420 {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
1421 {"8200", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
1422 {"8100", CARD_NVIDIA_GEFORCE_8200}, /* Geforce 8 - lowend */
1423 /* Direct 3D 9 SM3 */
1424 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1425 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1426 {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1427 {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1428 {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
1429 {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1430 {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
1431 {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
1432 {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
1433 {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
1434 {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1435 {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1436 {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
1437 /* Direct 3D 9 SM2 */
1438 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
1439 {"5950", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
1440 {"5900", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
1441 {"5800", CARD_NVIDIA_GEFORCEFX_5800}, /* GeforceFX - highend */
1442 {"5750", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
1443 {"5700", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
1444 {"5650", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
1445 {"5600", CARD_NVIDIA_GEFORCEFX_5600}, /* GeforceFX - midend */
1446 {"5500", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
1447 {"5300", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
1448 {"5250", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
1449 {"5200", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
1450 {"5100", CARD_NVIDIA_GEFORCEFX_5200}, /* GeforceFX - lowend */
1451 /* Direct 3D 8 */
1452 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200},
1453 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
1454 /* Direct 3D 7 */
1455 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX}, /* MX420/MX440/MX460/MX4000 */
1456 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX},
1457 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX}, /* Geforce2 standard/MX100/MX200/MX400 */
1458 {"Quadro2", CARD_NVIDIA_GEFORCE2},
1459 {"GeForce2", CARD_NVIDIA_GEFORCE2}, /* Geforce2 GTS/Pro/Ti/Ultra */
1460 /* Direct 3D 6 */
1461 {"TNT2", CARD_NVIDIA_RIVA_TNT2}, /* Riva TNT2 standard/M64/Pro/Ultra */
1463 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
1465 * Beware: renderer string do not match exact card model,
1466 * e.g. HD 4800 is returned for multiple cards, even for RV790 based ones. */
1467 cards_amd_binary[] =
1469 {"RX 480", CARD_AMD_RADEON_RX_480},
1470 {"RX 460", CARD_AMD_RADEON_RX_460},
1471 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY},
1472 /* Southern Islands */
1473 {"HD 7900", CARD_AMD_RADEON_HD7900},
1474 {"HD 7800", CARD_AMD_RADEON_HD7800},
1475 {"HD 7700", CARD_AMD_RADEON_HD7700},
1476 /* Northern Islands */
1477 {"HD 6970", CARD_AMD_RADEON_HD6900},
1478 {"HD 6900", CARD_AMD_RADEON_HD6900},
1479 {"HD 6800", CARD_AMD_RADEON_HD6800},
1480 {"HD 6770M", CARD_AMD_RADEON_HD6600M},
1481 {"HD 6750M", CARD_AMD_RADEON_HD6600M},
1482 {"HD 6700", CARD_AMD_RADEON_HD6700},
1483 {"HD 6670", CARD_AMD_RADEON_HD6600},
1484 {"HD 6630M", CARD_AMD_RADEON_HD6600M},
1485 {"HD 6600M", CARD_AMD_RADEON_HD6600M},
1486 {"HD 6600", CARD_AMD_RADEON_HD6600},
1487 {"HD 6570", CARD_AMD_RADEON_HD6600},
1488 {"HD 6500M", CARD_AMD_RADEON_HD6600M},
1489 {"HD 6500", CARD_AMD_RADEON_HD6600},
1490 {"HD 6480G", CARD_AMD_RADEON_HD6480G},
1491 {"HD 6400", CARD_AMD_RADEON_HD6400},
1492 {"HD 6300", CARD_AMD_RADEON_HD6300},
1493 {"HD 6200", CARD_AMD_RADEON_HD6300},
1494 /* Evergreen */
1495 {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
1496 {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
1497 {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1498 {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
1499 {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
1500 {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1501 {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
1502 {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1503 {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1504 {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
1505 {"HD 5000", CARD_AMD_RADEON_HD5600}, /* Defaulting to HD 5600 */
1506 /* R700 */
1507 {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
1508 {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1509 {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1510 {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
1511 {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
1512 {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
1513 {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
1514 {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1515 {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1516 {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
1517 {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1518 {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
1519 /* R600/R700 integrated */
1520 {"HD 4200M", CARD_AMD_RADEON_HD4200M},
1521 {"HD 3300", CARD_AMD_RADEON_HD3200},
1522 {"HD 3200", CARD_AMD_RADEON_HD3200},
1523 {"HD 3100", CARD_AMD_RADEON_HD3200},
1524 /* R600 */
1525 {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1526 {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1527 {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
1528 {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
1529 {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1530 {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1531 {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
1532 {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1533 {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1534 {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1535 {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1536 {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1537 {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
1538 /* Radeon R5xx */
1539 {"X1950", CARD_AMD_RADEON_X1600},
1540 {"X1900", CARD_AMD_RADEON_X1600},
1541 {"X1800", CARD_AMD_RADEON_X1600},
1542 {"X1650", CARD_AMD_RADEON_X1600},
1543 {"X1600", CARD_AMD_RADEON_X1600},
1544 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1545 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1546 {"HD 2300", CARD_AMD_RADEON_X700},
1547 {"X2500", CARD_AMD_RADEON_X700},
1548 {"X2300", CARD_AMD_RADEON_X700},
1549 {"X1550", CARD_AMD_RADEON_X700},
1550 {"X1450", CARD_AMD_RADEON_X700},
1551 {"X1400", CARD_AMD_RADEON_X700},
1552 {"X1300", CARD_AMD_RADEON_X700},
1553 {"X850", CARD_AMD_RADEON_X700},
1554 {"X800", CARD_AMD_RADEON_X700},
1555 {"X700", CARD_AMD_RADEON_X700},
1556 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
1557 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M},
1559 cards_intel[] =
1561 /* Skylake */
1562 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1},
1563 {"Skylake", CARD_INTEL_HD520_1},
1564 /* Broadwell */
1565 {"Iris Pro P6300", CARD_INTEL_IPP6300},
1566 {"Iris Pro 6200", CARD_INTEL_IP6200},
1567 {"Iris 6100", CARD_INTEL_I6100},
1568 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100}, /* MacOS */
1569 /* Haswell */
1570 {"Iris Pro 5200", CARD_INTEL_IP5200_1},
1571 {"Iris 5100", CARD_INTEL_I5100_1},
1572 {"HD Graphics 5000", CARD_INTEL_HD5000}, /* MacOS */
1573 {"Haswell Mobile", CARD_INTEL_HWM},
1574 {"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */
1575 /* Ivybridge */
1576 {"Ivybridge Server", CARD_INTEL_IVBS},
1577 {"Ivybridge Mobile", CARD_INTEL_IVBM},
1578 {"Ivybridge Desktop", CARD_INTEL_IVBD},
1579 {"HD Graphics 4000", CARD_INTEL_IVBD}, /* MacOS */
1580 /* Sandybridge */
1581 {"Sandybridge Server", CARD_INTEL_SNBS},
1582 {"Sandybridge Mobile", CARD_INTEL_SNBM},
1583 {"Sandybridge Desktop", CARD_INTEL_SNBD},
1584 /* Ironlake */
1585 {"Ironlake Mobile", CARD_INTEL_ILKM},
1586 {"Ironlake Desktop", CARD_INTEL_ILKD},
1587 /* G4x */
1588 {"B43", CARD_INTEL_B43},
1589 {"G41", CARD_INTEL_G41},
1590 {"G45", CARD_INTEL_G45},
1591 {"Q45", CARD_INTEL_Q45},
1592 {"Integrated Graphics Device", CARD_INTEL_IGD},
1593 {"GM45", CARD_INTEL_GM45},
1594 /* i965 */
1595 {"965GME", CARD_INTEL_965GME},
1596 {"965GM", CARD_INTEL_965GM},
1597 {"X3100", CARD_INTEL_965GM}, /* MacOS */
1598 {"946GZ", CARD_INTEL_946GZ},
1599 {"965G", CARD_INTEL_965G},
1600 {"965Q", CARD_INTEL_965Q},
1601 /* i945 */
1602 {"Pineview M", CARD_INTEL_PNVM},
1603 {"Pineview G", CARD_INTEL_PNVG},
1604 {"IGD", CARD_INTEL_PNVG},
1605 {"Q33", CARD_INTEL_Q33},
1606 {"G33", CARD_INTEL_G33},
1607 {"Q35", CARD_INTEL_Q35},
1608 {"945GME", CARD_INTEL_945GME},
1609 {"945GM", CARD_INTEL_945GM},
1610 {"GMA 950", CARD_INTEL_945GM}, /* MacOS */
1611 {"945G", CARD_INTEL_945G},
1612 /* i915 */
1613 {"915GM", CARD_INTEL_915GM},
1614 {"E7221G", CARD_INTEL_E7221G},
1615 {"915G", CARD_INTEL_915G},
1616 /* i8xx */
1617 {"865G", CARD_INTEL_865G},
1618 {"845G", CARD_INTEL_845G},
1619 {"855GM", CARD_INTEL_855GM},
1620 {"830M", CARD_INTEL_830M},
1622 /* 20101109 - These are never returned by current Gallium radeon
1623 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. */
1624 cards_amd_mesa[] =
1626 /* Polaris 10/11 */
1627 {"POLARIS10", CARD_AMD_RADEON_RX_480},
1628 {"POLARIS11", CARD_AMD_RADEON_RX_460},
1629 /* Volcanic Islands */
1630 {"FIJI", CARD_AMD_RADEON_R9_FURY},
1631 {"TONGA", CARD_AMD_RADEON_R9_285},
1632 /* Sea Islands */
1633 {"HAWAII", CARD_AMD_RADEON_R9_290},
1634 {"KAVERI", CARD_AMD_RADEON_R7 },
1635 {"KABINI", CARD_AMD_RADEON_R3 },
1636 {"BONAIRE", CARD_AMD_RADEON_HD8770},
1637 /* Southern Islands */
1638 {"OLAND", CARD_AMD_RADEON_HD8670},
1639 {"HAINAN", CARD_AMD_RADEON_HD8600M},
1640 {"TAHITI", CARD_AMD_RADEON_HD7900},
1641 {"PITCAIRN", CARD_AMD_RADEON_HD7800},
1642 {"CAPE VERDE", CARD_AMD_RADEON_HD7700},
1643 /* Northern Islands */
1644 {"ARUBA", CARD_AMD_RADEON_HD7660D},
1645 {"CAYMAN", CARD_AMD_RADEON_HD6900},
1646 {"BARTS", CARD_AMD_RADEON_HD6800},
1647 {"TURKS", CARD_AMD_RADEON_HD6600},
1648 {"SUMO2", CARD_AMD_RADEON_HD6410D}, /* SUMO2 first, because we do a strstr(). */
1649 {"SUMO", CARD_AMD_RADEON_HD6550D},
1650 {"CAICOS", CARD_AMD_RADEON_HD6400},
1651 {"PALM", CARD_AMD_RADEON_HD6300},
1652 /* Evergreen */
1653 {"HEMLOCK", CARD_AMD_RADEON_HD5900},
1654 {"CYPRESS", CARD_AMD_RADEON_HD5800},
1655 {"JUNIPER", CARD_AMD_RADEON_HD5700},
1656 {"REDWOOD", CARD_AMD_RADEON_HD5600},
1657 {"CEDAR", CARD_AMD_RADEON_HD5400},
1658 /* R700 */
1659 {"R700", CARD_AMD_RADEON_HD4800},
1660 {"RV790", CARD_AMD_RADEON_HD4800},
1661 {"RV770", CARD_AMD_RADEON_HD4800},
1662 {"RV740", CARD_AMD_RADEON_HD4700},
1663 {"RV730", CARD_AMD_RADEON_HD4600},
1664 {"RV710", CARD_AMD_RADEON_HD4350},
1665 /* R600/R700 integrated */
1666 {"RS880", CARD_AMD_RADEON_HD4200M},
1667 {"RS780", CARD_AMD_RADEON_HD3200},
1668 /* R600 */
1669 {"R680", CARD_AMD_RADEON_HD2900},
1670 {"R600", CARD_AMD_RADEON_HD2900},
1671 {"RV670", CARD_AMD_RADEON_HD3850},
1672 {"RV635", CARD_AMD_RADEON_HD2600},
1673 {"RV630", CARD_AMD_RADEON_HD2600},
1674 {"RV620", CARD_AMD_RADEON_HD2350},
1675 {"RV610", CARD_AMD_RADEON_HD2350},
1676 /* R500 */
1677 {"R580", CARD_AMD_RADEON_X1600},
1678 {"R520", CARD_AMD_RADEON_X1600},
1679 {"RV570", CARD_AMD_RADEON_X1600},
1680 {"RV560", CARD_AMD_RADEON_X1600},
1681 {"RV535", CARD_AMD_RADEON_X1600},
1682 {"RV530", CARD_AMD_RADEON_X1600},
1683 {"RV516", CARD_AMD_RADEON_X700},
1684 {"RV515", CARD_AMD_RADEON_X700},
1685 /* R400 */
1686 {"R481", CARD_AMD_RADEON_X700},
1687 {"R480", CARD_AMD_RADEON_X700},
1688 {"R430", CARD_AMD_RADEON_X700},
1689 {"R423", CARD_AMD_RADEON_X700},
1690 {"R420", CARD_AMD_RADEON_X700},
1691 {"R410", CARD_AMD_RADEON_X700},
1692 {"RV410", CARD_AMD_RADEON_X700},
1693 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
1694 {"RS740", CARD_AMD_RADEON_XPRESS_200M},
1695 {"RS690", CARD_AMD_RADEON_XPRESS_200M},
1696 {"RS600", CARD_AMD_RADEON_XPRESS_200M},
1697 {"RS485", CARD_AMD_RADEON_XPRESS_200M},
1698 {"RS482", CARD_AMD_RADEON_XPRESS_200M},
1699 {"RS480", CARD_AMD_RADEON_XPRESS_200M},
1700 {"RS400", CARD_AMD_RADEON_XPRESS_200M},
1701 {"RC410", CARD_AMD_RADEON_XPRESS_200M},
1702 /* R300 */
1703 {"R360", CARD_AMD_RADEON_9500},
1704 {"R350", CARD_AMD_RADEON_9500},
1705 {"R300", CARD_AMD_RADEON_9500},
1706 {"RV380", CARD_AMD_RADEON_9500},
1707 {"RV370", CARD_AMD_RADEON_9500},
1708 {"RV360", CARD_AMD_RADEON_9500},
1709 {"RV351", CARD_AMD_RADEON_9500},
1710 {"RV350", CARD_AMD_RADEON_9500},
1712 cards_nvidia_mesa[] =
1714 /* Maxwell */
1715 {"NV124", CARD_NVIDIA_GEFORCE_GTX970},
1716 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI},
1717 {"NV118", CARD_NVIDIA_GEFORCE_840M},
1718 {"NV117", CARD_NVIDIA_GEFORCE_GTX750},
1719 /* Kepler */
1720 {"NV108", CARD_NVIDIA_GEFORCE_GT740M},
1721 {"NV106", CARD_NVIDIA_GEFORCE_GT720},
1722 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI},
1723 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780},
1724 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M},
1725 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680}, /* 690 / 675MX / 760TI */
1726 /* Fermi */
1727 {"NVD9", CARD_NVIDIA_GEFORCE_GT520},
1728 {"NVD7", CARD_NVIDIA_GEFORCE_820M},
1729 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550},
1730 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560},
1731 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
1732 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
1733 {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
1734 {"NVC1", CARD_NVIDIA_GEFORCE_GT420},
1735 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
1736 /* Tesla */
1737 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
1738 {"NVAC", CARD_NVIDIA_GEFORCE_8200},
1739 {"NVAA", CARD_NVIDIA_GEFORCE_8200}, /* 8100 */
1740 {"NVA8", CARD_NVIDIA_GEFORCE_210},
1741 {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
1742 {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
1743 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
1744 {"NV98", CARD_NVIDIA_GEFORCE_9200},
1745 {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
1746 {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
1747 {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
1748 {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
1749 {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
1750 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
1751 /* Curie */
1752 {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
1753 {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
1754 {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
1755 {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
1756 {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
1757 {"NV4B", CARD_NVIDIA_GEFORCE_7600},
1758 {"NV4A", CARD_NVIDIA_GEFORCE_6200},
1759 {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
1760 {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
1761 {"NV46", CARD_NVIDIA_GEFORCE_7400},
1762 {"NV45", CARD_NVIDIA_GEFORCE_6800},
1763 {"NV44", CARD_NVIDIA_GEFORCE_6200},
1764 {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
1765 {"NV42", CARD_NVIDIA_GEFORCE_6800},
1766 {"NV41", CARD_NVIDIA_GEFORCE_6800},
1767 {"NV40", CARD_NVIDIA_GEFORCE_6800},
1768 /* Rankine */
1769 {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
1770 {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
1771 {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
1772 {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
1773 {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
1774 {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
1775 /* Kelvin */
1776 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200},
1777 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200},
1778 {"nv20", CARD_NVIDIA_GEFORCE3},
1779 /* Celsius */
1780 {"nv1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
1781 {"nv1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
1782 {"nv18", CARD_NVIDIA_GEFORCE4_MX},
1783 {"nv17", CARD_NVIDIA_GEFORCE4_MX},
1784 {"nv16", CARD_NVIDIA_GEFORCE2},
1785 {"nv15", CARD_NVIDIA_GEFORCE2},
1786 {"nv11", CARD_NVIDIA_GEFORCE2_MX},
1787 {"nv10", CARD_NVIDIA_GEFORCE},
1788 /* Fahrenheit */
1789 {"nv05", CARD_NVIDIA_RIVA_TNT2},
1790 {"nv04", CARD_NVIDIA_RIVA_TNT},
1791 {"nv03", CARD_NVIDIA_RIVA_128},
1793 cards_vmware[] =
1795 {"SVGA3D", CARD_VMWARE_SVGA3D},
1798 static const struct gl_vendor_selection
1800 enum wined3d_gl_vendor gl_vendor;
1801 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
1802 const struct wined3d_renderer_table *cards; /* To be used as cards[], pointer to the first member in an array */
1803 size_t cards_size; /* Number of entries in the array above */
1805 amd_gl_vendor_table[] =
1807 {GL_VENDOR_APPLE, "Apple OSX AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
1808 {GL_VENDOR_FGLRX, "AMD/ATI binary driver", cards_amd_binary, ARRAY_SIZE(cards_amd_binary)},
1809 {GL_VENDOR_MESA, "Mesa AMD/ATI driver", cards_amd_mesa, ARRAY_SIZE(cards_amd_mesa)},
1811 nvidia_gl_vendor_table[] =
1813 {GL_VENDOR_APPLE, "Apple OSX NVidia binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
1814 {GL_VENDOR_MESA, "Mesa Nouveau driver", cards_nvidia_mesa, ARRAY_SIZE(cards_nvidia_mesa)},
1815 {GL_VENDOR_NVIDIA, "NVIDIA binary driver", cards_nvidia_binary, ARRAY_SIZE(cards_nvidia_binary)},
1817 vmware_gl_vendor_table[] =
1819 {GL_VENDOR_MESA, "VMware driver", cards_vmware, ARRAY_SIZE(cards_vmware)},
1821 intel_gl_vendor_table[] =
1823 {GL_VENDOR_APPLE, "Apple OSX Intel binary driver", cards_intel, ARRAY_SIZE(cards_intel)},
1824 {GL_VENDOR_MESA, "Mesa Intel driver", cards_intel, ARRAY_SIZE(cards_intel)},
1827 static enum wined3d_pci_device select_card_handler(const struct gl_vendor_selection *table,
1828 unsigned int table_size, enum wined3d_gl_vendor gl_vendor, const char *gl_renderer)
1830 unsigned int i, j;
1832 for (i = 0; i < table_size; ++i)
1834 if (table[i].gl_vendor != gl_vendor)
1835 continue;
1837 TRACE("Applying card selector \"%s\".\n", table[i].description);
1839 for (j = 0; j < table[i].cards_size; ++j)
1841 if (strstr(gl_renderer, table[i].cards[j].renderer))
1842 return table[i].cards[j].id;
1844 return PCI_DEVICE_NONE;
1846 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
1847 gl_vendor, debugstr_a(gl_renderer));
1849 return PCI_DEVICE_NONE;
1852 static const struct
1854 enum wined3d_pci_vendor card_vendor;
1855 const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
1856 const struct gl_vendor_selection *gl_vendor_selection;
1857 unsigned int gl_vendor_count;
1859 card_vendor_table[] =
1861 {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table, ARRAY_SIZE(amd_gl_vendor_table)},
1862 {HW_VENDOR_NVIDIA, "NVIDIA", nvidia_gl_vendor_table, ARRAY_SIZE(nvidia_gl_vendor_table)},
1863 {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table, ARRAY_SIZE(vmware_gl_vendor_table)},
1864 {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table, ARRAY_SIZE(intel_gl_vendor_table)},
1867 static enum wined3d_pci_device wined3d_guess_card(enum wined3d_feature_level feature_level,
1868 DWORD glsl_version, const char *gl_renderer, enum wined3d_gl_vendor *gl_vendor,
1869 enum wined3d_pci_vendor *card_vendor)
1871 /* A Direct3D device object contains the PCI id (vendor + device) of the
1872 * videocard which is used for rendering. Various applications use this
1873 * information to get a rough estimation of the features of the card and
1874 * some might use it for enabling 3d effects only on certain types of
1875 * videocards. In some cases games might even use it to work around bugs
1876 * which happen on certain videocards/driver combinations. The problem is
1877 * that OpenGL only exposes a rendering string containing the name of the
1878 * videocard and not the PCI id.
1880 * Various games depend on the PCI id, so somehow we need to provide one.
1881 * A simple option is to parse the renderer string and translate this to
1882 * the right PCI id. This is a lot of work because there are more than 200
1883 * GPUs just for NVIDIA. Various cards share the same renderer string, so
1884 * the amount of code might be 'small' but there are quite a number of
1885 * exceptions which would make this a pain to maintain. Another way would
1886 * be to query the PCI id from the operating system (assuming this is the
1887 * videocard which is used for rendering which is not always the case).
1888 * This would work but it is not very portable. Second it would not work
1889 * well in, let's say, a remote X situation in which the amount of 3d
1890 * features which can be used is limited.
1892 * As said most games only use the PCI id to get an indication of the
1893 * capabilities of the card. It doesn't really matter if the given id is
1894 * the correct one if we return the id of a card with similar 3d features.
1896 * The code below checks the OpenGL capabilities of a videocard and matches
1897 * that to a certain level of Direct3D functionality. Once a card passes
1898 * the Direct3D9 check, we know that the card (in case of NVIDIA) is at
1899 * least a GeforceFX. To give a better estimate we do a basic check on the
1900 * renderer string but if that won't pass we return a default card. This
1901 * way is better than maintaining a full card database as even without a
1902 * full database we can return a card with similar features. Second the
1903 * size of the database can be made quite small because when you know what
1904 * type of 3d functionality a card has, you know to which GPU family the
1905 * GPU must belong. Because of this you only have to check a small part of
1906 * the renderer string to distinguish between different models from that
1907 * family.
1909 * The code also selects a default amount of video memory which we will
1910 * use for an estimation of the amount of free texture memory. In case of
1911 * real D3D the amount of texture memory includes video memory and system
1912 * memory (to be specific AGP memory or in case of PCIE TurboCache /
1913 * HyperMemory). We don't know how much system memory can be addressed by
1914 * the system but we can make a reasonable estimation about the amount of
1915 * video memory. If the value is slightly wrong it doesn't matter as we
1916 * didn't include AGP-like memory which makes the amount of addressable
1917 * memory higher and second OpenGL isn't that critical it moves to system
1918 * memory behind our backs if really needed. Note that the amount of video
1919 * memory can be overruled using a registry setting. */
1921 enum wined3d_pci_device device;
1922 unsigned int i;
1924 for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i)
1926 if (card_vendor_table[i].card_vendor != *card_vendor)
1927 continue;
1929 TRACE("Applying card selector \"%s\".\n", card_vendor_table[i].description);
1930 device = select_card_handler(card_vendor_table[i].gl_vendor_selection,
1931 card_vendor_table[i].gl_vendor_count, *gl_vendor, gl_renderer);
1932 if (device != PCI_DEVICE_NONE)
1933 return device;
1935 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer));
1937 return wined3d_gpu_from_feature_level(card_vendor, feature_level);
1940 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
1941 *card_vendor, debugstr_a(gl_renderer));
1943 return wined3d_gpu_from_feature_level(card_vendor, feature_level);
1946 static const struct wined3d_vertex_pipe_ops *select_vertex_implementation(const struct wined3d_gl_info *gl_info,
1947 const struct wined3d_shader_backend_ops *shader_backend_ops)
1949 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_VERTEX_SHADER])
1950 return &glsl_vertex_pipe;
1951 return &ffp_vertex_pipe;
1954 static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
1955 const struct wined3d_shader_backend_ops *shader_backend_ops)
1957 if (shader_backend_ops == &glsl_shader_backend && gl_info->supported[ARB_FRAGMENT_SHADER])
1958 return &glsl_fragment_pipe;
1959 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
1960 return &arbfp_fragment_pipeline;
1961 if (gl_info->supported[ATI_FRAGMENT_SHADER])
1962 return &atifs_fragment_pipeline;
1963 if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
1964 return &nvts_fragment_pipeline;
1965 if (gl_info->supported[NV_REGISTER_COMBINERS])
1966 return &nvrc_fragment_pipeline;
1967 return &ffp_fragment_pipeline;
1970 static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
1972 BOOL glsl = wined3d_settings.use_glsl && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
1973 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] && !wined3d_settings.use_glsl)
1975 ERR_(winediag)("Ignoring the UseGLSL registry key. "
1976 "GLSL is the only shader backend available on core profile contexts. "
1977 "You need to explicitly set GL version to use legacy contexts.\n");
1978 glsl = TRUE;
1981 if (glsl && gl_info->supported[ARB_VERTEX_SHADER] && gl_info->supported[ARB_FRAGMENT_SHADER])
1982 return &glsl_shader_backend;
1983 if (gl_info->supported[ARB_VERTEX_PROGRAM] && gl_info->supported[ARB_FRAGMENT_PROGRAM])
1984 return &arb_program_shader_backend;
1985 if (glsl && (gl_info->supported[ARB_VERTEX_SHADER] || gl_info->supported[ARB_FRAGMENT_SHADER]))
1986 return &glsl_shader_backend;
1987 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
1988 return &arb_program_shader_backend;
1989 return &none_shader_backend;
1992 static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
1993 const struct wined3d_extension_map *map, UINT entry_count)
1995 while (*extensions)
1997 const char *start;
1998 size_t len;
1999 UINT i;
2001 while (isspace(*extensions))
2002 ++extensions;
2003 start = extensions;
2004 while (!isspace(*extensions) && *extensions)
2005 ++extensions;
2007 len = extensions - start;
2008 if (!len)
2009 continue;
2011 TRACE("- %s.\n", debugstr_an(start, len));
2013 for (i = 0; i < entry_count; ++i)
2015 if (len == strlen(map[i].extension_string)
2016 && !memcmp(start, map[i].extension_string, len))
2018 TRACE(" FOUND: %s support.\n", map[i].extension_string);
2019 gl_info->supported[map[i].extension] = TRUE;
2020 break;
2026 static void enumerate_gl_extensions(struct wined3d_gl_info *gl_info,
2027 const struct wined3d_extension_map *map, unsigned int map_entries_count)
2029 const char *gl_extension_name;
2030 unsigned int i, j;
2031 GLint extensions_count;
2033 gl_info->gl_ops.gl.p_glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
2034 for (i = 0; i < extensions_count; ++i)
2036 gl_extension_name = (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS, i));
2037 TRACE("- %s.\n", debugstr_a(gl_extension_name));
2038 for (j = 0; j < map_entries_count; ++j)
2040 if (!strcmp(gl_extension_name, map[j].extension_string))
2042 TRACE("FOUND: %s support.\n", map[j].extension_string);
2043 gl_info->supported[map[j].extension] = TRUE;
2044 break;
2050 static void load_gl_funcs(struct wined3d_gl_info *gl_info)
2052 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2053 /* GL_APPLE_fence */
2054 USE_GL_FUNC(glDeleteFencesAPPLE)
2055 USE_GL_FUNC(glFinishFenceAPPLE)
2056 USE_GL_FUNC(glFinishObjectAPPLE)
2057 USE_GL_FUNC(glGenFencesAPPLE)
2058 USE_GL_FUNC(glIsFenceAPPLE)
2059 USE_GL_FUNC(glSetFenceAPPLE)
2060 USE_GL_FUNC(glTestFenceAPPLE)
2061 USE_GL_FUNC(glTestObjectAPPLE)
2062 /* GL_APPLE_flush_buffer_range */
2063 USE_GL_FUNC(glBufferParameteriAPPLE)
2064 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE)
2065 /* GL_ARB_base_instance */
2066 USE_GL_FUNC(glDrawArraysInstancedBaseInstance)
2067 USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance)
2068 /* GL_ARB_blend_func_extended */
2069 USE_GL_FUNC(glBindFragDataLocationIndexed)
2070 USE_GL_FUNC(glGetFragDataIndex)
2071 /* GL_ARB_buffer_storage */
2072 USE_GL_FUNC(glBufferStorage)
2073 /* GL_ARB_clear_buffer_object */
2074 USE_GL_FUNC(glClearBufferData)
2075 USE_GL_FUNC(glClearBufferSubData)
2076 /* GL_ARB_clear_texture */
2077 USE_GL_FUNC(glClearTexImage)
2078 USE_GL_FUNC(glClearTexSubImage)
2079 /* GL_ARB_clip_control */
2080 USE_GL_FUNC(glClipControl)
2081 /* GL_ARB_color_buffer_float */
2082 USE_GL_FUNC(glClampColorARB)
2083 /* GL_ARB_compute_shader */
2084 USE_GL_FUNC(glDispatchCompute)
2085 USE_GL_FUNC(glDispatchComputeIndirect)
2086 /* GL_ARB_copy_buffer */
2087 USE_GL_FUNC(glCopyBufferSubData)
2088 /* GL_ARB_copy_image */
2089 USE_GL_FUNC(glCopyImageSubData)
2090 /* GL_ARB_debug_output */
2091 USE_GL_FUNC(glDebugMessageCallbackARB)
2092 USE_GL_FUNC(glDebugMessageControlARB)
2093 USE_GL_FUNC(glDebugMessageInsertARB)
2094 USE_GL_FUNC(glGetDebugMessageLogARB)
2095 /* GL_ARB_draw_buffers */
2096 USE_GL_FUNC(glDrawBuffersARB)
2097 /* GL_ARB_draw_elements_base_vertex */
2098 USE_GL_FUNC(glDrawElementsBaseVertex)
2099 USE_GL_FUNC(glDrawElementsInstancedBaseVertex)
2100 USE_GL_FUNC(glDrawRangeElementsBaseVertex)
2101 USE_GL_FUNC(glMultiDrawElementsBaseVertex)
2102 /* GL_ARB_draw_indirect */
2103 USE_GL_FUNC(glDrawArraysIndirect)
2104 USE_GL_FUNC(glDrawElementsIndirect)
2105 /* GL_ARB_draw_instanced */
2106 USE_GL_FUNC(glDrawArraysInstancedARB)
2107 USE_GL_FUNC(glDrawElementsInstancedARB)
2108 /* GL_ARB_ES2_compatibility */
2109 USE_GL_FUNC(glReleaseShaderCompiler)
2110 USE_GL_FUNC(glShaderBinary)
2111 USE_GL_FUNC(glGetShaderPrecisionFormat)
2112 USE_GL_FUNC(glDepthRangef)
2113 USE_GL_FUNC(glClearDepthf)
2114 /* GL_ARB_framebuffer_no_attachments */
2115 USE_GL_FUNC(glFramebufferParameteri)
2116 /* GL_ARB_framebuffer_object */
2117 USE_GL_FUNC(glBindFramebuffer)
2118 USE_GL_FUNC(glBindRenderbuffer)
2119 USE_GL_FUNC(glBlitFramebuffer)
2120 USE_GL_FUNC(glCheckFramebufferStatus)
2121 USE_GL_FUNC(glDeleteFramebuffers)
2122 USE_GL_FUNC(glDeleteRenderbuffers)
2123 USE_GL_FUNC(glFramebufferRenderbuffer)
2124 USE_GL_FUNC(glFramebufferTexture)
2125 USE_GL_FUNC(glFramebufferTexture1D)
2126 USE_GL_FUNC(glFramebufferTexture2D)
2127 USE_GL_FUNC(glFramebufferTexture3D)
2128 USE_GL_FUNC(glFramebufferTextureLayer)
2129 USE_GL_FUNC(glGenFramebuffers)
2130 USE_GL_FUNC(glGenRenderbuffers)
2131 USE_GL_FUNC(glGenerateMipmap)
2132 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv)
2133 USE_GL_FUNC(glGetRenderbufferParameteriv)
2134 USE_GL_FUNC(glIsFramebuffer)
2135 USE_GL_FUNC(glIsRenderbuffer)
2136 USE_GL_FUNC(glRenderbufferStorage)
2137 USE_GL_FUNC(glRenderbufferStorageMultisample)
2138 /* GL_ARB_geometry_shader4 */
2139 USE_GL_FUNC(glFramebufferTextureARB)
2140 USE_GL_FUNC(glFramebufferTextureFaceARB)
2141 USE_GL_FUNC(glFramebufferTextureLayerARB)
2142 USE_GL_FUNC(glProgramParameteriARB)
2143 /* GL_ARB_instanced_arrays */
2144 USE_GL_FUNC(glVertexAttribDivisorARB)
2145 /* GL_ARB_internalformat_query */
2146 USE_GL_FUNC(glGetInternalformativ)
2147 /* GL_ARB_internalformat_query2 */
2148 USE_GL_FUNC(glGetInternalformati64v)
2149 /* GL_ARB_map_buffer_range */
2150 USE_GL_FUNC(glFlushMappedBufferRange)
2151 USE_GL_FUNC(glMapBufferRange)
2152 /* GL_ARB_multisample */
2153 USE_GL_FUNC(glSampleCoverageARB)
2154 /* GL_ARB_multitexture */
2155 USE_GL_FUNC(glActiveTextureARB)
2156 USE_GL_FUNC(glClientActiveTextureARB)
2157 USE_GL_FUNC(glMultiTexCoord1fARB)
2158 USE_GL_FUNC(glMultiTexCoord1fvARB)
2159 USE_GL_FUNC(glMultiTexCoord2fARB)
2160 USE_GL_FUNC(glMultiTexCoord2fvARB)
2161 USE_GL_FUNC(glMultiTexCoord2svARB)
2162 USE_GL_FUNC(glMultiTexCoord3fARB)
2163 USE_GL_FUNC(glMultiTexCoord3fvARB)
2164 USE_GL_FUNC(glMultiTexCoord4fARB)
2165 USE_GL_FUNC(glMultiTexCoord4fvARB)
2166 USE_GL_FUNC(glMultiTexCoord4svARB)
2167 /* GL_ARB_occlusion_query */
2168 USE_GL_FUNC(glBeginQueryARB)
2169 USE_GL_FUNC(glDeleteQueriesARB)
2170 USE_GL_FUNC(glEndQueryARB)
2171 USE_GL_FUNC(glGenQueriesARB)
2172 USE_GL_FUNC(glGetQueryivARB)
2173 USE_GL_FUNC(glGetQueryObjectivARB)
2174 USE_GL_FUNC(glGetQueryObjectuivARB)
2175 USE_GL_FUNC(glIsQueryARB)
2176 /* GL_ARB_point_parameters */
2177 USE_GL_FUNC(glPointParameterfARB)
2178 USE_GL_FUNC(glPointParameterfvARB)
2179 /* GL_ARB_polgyon_offset_clamp */
2180 USE_GL_FUNC(glPolygonOffsetClamp)
2181 /* GL_ARB_provoking_vertex */
2182 USE_GL_FUNC(glProvokingVertex)
2183 /* GL_ARB_sample_shading */
2184 USE_GL_FUNC(glMinSampleShadingARB)
2185 /* GL_ARB_sampler_objects */
2186 USE_GL_FUNC(glGenSamplers)
2187 USE_GL_FUNC(glDeleteSamplers)
2188 USE_GL_FUNC(glIsSampler)
2189 USE_GL_FUNC(glBindSampler)
2190 USE_GL_FUNC(glSamplerParameteri)
2191 USE_GL_FUNC(glSamplerParameterf)
2192 USE_GL_FUNC(glSamplerParameteriv)
2193 USE_GL_FUNC(glSamplerParameterfv)
2194 USE_GL_FUNC(glSamplerParameterIiv)
2195 USE_GL_FUNC(glSamplerParameterIuiv)
2196 USE_GL_FUNC(glGetSamplerParameteriv)
2197 USE_GL_FUNC(glGetSamplerParameterfv)
2198 USE_GL_FUNC(glGetSamplerParameterIiv)
2199 USE_GL_FUNC(glGetSamplerParameterIuiv)
2200 /* GL_ARB_shader_atomic_counters */
2201 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv)
2202 /* GL_ARB_shader_image_load_store */
2203 USE_GL_FUNC(glBindImageTexture)
2204 USE_GL_FUNC(glMemoryBarrier)
2205 /* GL_ARB_shader_objects */
2206 USE_GL_FUNC(glAttachObjectARB)
2207 USE_GL_FUNC(glBindAttribLocationARB)
2208 USE_GL_FUNC(glCompileShaderARB)
2209 USE_GL_FUNC(glCreateProgramObjectARB)
2210 USE_GL_FUNC(glCreateShaderObjectARB)
2211 USE_GL_FUNC(glDeleteObjectARB)
2212 USE_GL_FUNC(glDetachObjectARB)
2213 USE_GL_FUNC(glGetActiveUniformARB)
2214 USE_GL_FUNC(glGetAttachedObjectsARB)
2215 USE_GL_FUNC(glGetAttribLocationARB)
2216 USE_GL_FUNC(glGetHandleARB)
2217 USE_GL_FUNC(glGetInfoLogARB)
2218 USE_GL_FUNC(glGetObjectParameterfvARB)
2219 USE_GL_FUNC(glGetObjectParameterivARB)
2220 USE_GL_FUNC(glGetShaderSourceARB)
2221 USE_GL_FUNC(glGetUniformLocationARB)
2222 USE_GL_FUNC(glGetUniformfvARB)
2223 USE_GL_FUNC(glGetUniformivARB)
2224 USE_GL_FUNC(glLinkProgramARB)
2225 USE_GL_FUNC(glShaderSourceARB)
2226 USE_GL_FUNC(glUniform1fARB)
2227 USE_GL_FUNC(glUniform1fvARB)
2228 USE_GL_FUNC(glUniform1iARB)
2229 USE_GL_FUNC(glUniform1ivARB)
2230 USE_GL_FUNC(glUniform2fARB)
2231 USE_GL_FUNC(glUniform2fvARB)
2232 USE_GL_FUNC(glUniform2iARB)
2233 USE_GL_FUNC(glUniform2ivARB)
2234 USE_GL_FUNC(glUniform3fARB)
2235 USE_GL_FUNC(glUniform3fvARB)
2236 USE_GL_FUNC(glUniform3iARB)
2237 USE_GL_FUNC(glUniform3ivARB)
2238 USE_GL_FUNC(glUniform4fARB)
2239 USE_GL_FUNC(glUniform4fvARB)
2240 USE_GL_FUNC(glUniform4iARB)
2241 USE_GL_FUNC(glUniform4ivARB)
2242 USE_GL_FUNC(glUniformMatrix2fvARB)
2243 USE_GL_FUNC(glUniformMatrix3fvARB)
2244 USE_GL_FUNC(glUniformMatrix4fvARB)
2245 USE_GL_FUNC(glUseProgramObjectARB)
2246 USE_GL_FUNC(glValidateProgramARB)
2247 /* GL_ARB_shader_storage_buffer_object */
2248 USE_GL_FUNC(glShaderStorageBlockBinding)
2249 /* GL_ARB_sync */
2250 USE_GL_FUNC(glClientWaitSync)
2251 USE_GL_FUNC(glDeleteSync)
2252 USE_GL_FUNC(glFenceSync)
2253 USE_GL_FUNC(glGetInteger64v)
2254 USE_GL_FUNC(glGetSynciv)
2255 USE_GL_FUNC(glIsSync)
2256 USE_GL_FUNC(glWaitSync)
2257 /* GL_ARB_tessellation_shader */
2258 USE_GL_FUNC(glPatchParameteri)
2259 USE_GL_FUNC(glPatchParameterfv)
2260 /* GL_ARB_texture_buffer_object */
2261 USE_GL_FUNC(glTexBufferARB)
2262 /* GL_ARB_texture_buffer_range */
2263 USE_GL_FUNC(glTexBufferRange)
2264 /* GL_ARB_texture_compression */
2265 USE_GL_FUNC(glCompressedTexImage2DARB)
2266 USE_GL_FUNC(glCompressedTexImage3DARB)
2267 USE_GL_FUNC(glCompressedTexSubImage2DARB)
2268 USE_GL_FUNC(glCompressedTexSubImage3DARB)
2269 USE_GL_FUNC(glGetCompressedTexImageARB)
2270 /* GL_ARB_texture_multisample */
2271 USE_GL_FUNC(glGetMultisamplefv);
2272 USE_GL_FUNC(glSampleMaski);
2273 USE_GL_FUNC(glTexImage2DMultisample);
2274 USE_GL_FUNC(glTexImage3DMultisample);
2275 /* GL_ARB_texture_storage */
2276 USE_GL_FUNC(glTexStorage1D)
2277 USE_GL_FUNC(glTexStorage2D)
2278 USE_GL_FUNC(glTexStorage3D)
2279 /* GL_ARB_texture_storage_multisample */
2280 USE_GL_FUNC(glTexStorage2DMultisample);
2281 USE_GL_FUNC(glTexStorage3DMultisample);
2282 /* GL_ARB_texture_view */
2283 USE_GL_FUNC(glTextureView)
2284 /* GL_ARB_timer_query */
2285 USE_GL_FUNC(glQueryCounter)
2286 USE_GL_FUNC(glGetQueryObjectui64v)
2287 /* GL_ARB_transform_feedback2 */
2288 USE_GL_FUNC(glBindTransformFeedback);
2289 USE_GL_FUNC(glDeleteTransformFeedbacks);
2290 USE_GL_FUNC(glDrawTransformFeedback);
2291 USE_GL_FUNC(glGenTransformFeedbacks);
2292 USE_GL_FUNC(glIsTransformFeedback);
2293 USE_GL_FUNC(glPauseTransformFeedback);
2294 USE_GL_FUNC(glResumeTransformFeedback);
2295 /* GL_ARB_transform_feedback3 */
2296 USE_GL_FUNC(glBeginQueryIndexed);
2297 USE_GL_FUNC(glDrawTransformFeedbackStream);
2298 USE_GL_FUNC(glEndQueryIndexed);
2299 USE_GL_FUNC(glGetQueryIndexediv);
2300 /* GL_ARB_uniform_buffer_object */
2301 USE_GL_FUNC(glBindBufferBase)
2302 USE_GL_FUNC(glBindBufferRange)
2303 USE_GL_FUNC(glGetActiveUniformBlockName)
2304 USE_GL_FUNC(glGetActiveUniformBlockiv)
2305 USE_GL_FUNC(glGetActiveUniformName)
2306 USE_GL_FUNC(glGetActiveUniformsiv)
2307 USE_GL_FUNC(glGetIntegeri_v)
2308 USE_GL_FUNC(glGetUniformBlockIndex)
2309 USE_GL_FUNC(glGetUniformIndices)
2310 USE_GL_FUNC(glUniformBlockBinding)
2311 /* GL_ARB_vertex_buffer_object */
2312 USE_GL_FUNC(glBindBufferARB)
2313 USE_GL_FUNC(glBufferDataARB)
2314 USE_GL_FUNC(glBufferSubDataARB)
2315 USE_GL_FUNC(glDeleteBuffersARB)
2316 USE_GL_FUNC(glGenBuffersARB)
2317 USE_GL_FUNC(glGetBufferParameterivARB)
2318 USE_GL_FUNC(glGetBufferPointervARB)
2319 USE_GL_FUNC(glGetBufferSubDataARB)
2320 USE_GL_FUNC(glIsBufferARB)
2321 USE_GL_FUNC(glMapBufferARB)
2322 USE_GL_FUNC(glUnmapBufferARB)
2323 /* GL_ARB_vertex_program */
2324 USE_GL_FUNC(glBindProgramARB)
2325 USE_GL_FUNC(glDeleteProgramsARB)
2326 USE_GL_FUNC(glDisableVertexAttribArrayARB)
2327 USE_GL_FUNC(glEnableVertexAttribArrayARB)
2328 USE_GL_FUNC(glGenProgramsARB)
2329 USE_GL_FUNC(glGetProgramivARB)
2330 USE_GL_FUNC(glProgramEnvParameter4fvARB)
2331 USE_GL_FUNC(glProgramLocalParameter4fvARB)
2332 USE_GL_FUNC(glProgramStringARB)
2333 USE_GL_FUNC(glVertexAttrib1dARB)
2334 USE_GL_FUNC(glVertexAttrib1dvARB)
2335 USE_GL_FUNC(glVertexAttrib1fARB)
2336 USE_GL_FUNC(glVertexAttrib1fvARB)
2337 USE_GL_FUNC(glVertexAttrib1sARB)
2338 USE_GL_FUNC(glVertexAttrib1svARB)
2339 USE_GL_FUNC(glVertexAttrib2dARB)
2340 USE_GL_FUNC(glVertexAttrib2dvARB)
2341 USE_GL_FUNC(glVertexAttrib2fARB)
2342 USE_GL_FUNC(glVertexAttrib2fvARB)
2343 USE_GL_FUNC(glVertexAttrib2sARB)
2344 USE_GL_FUNC(glVertexAttrib2svARB)
2345 USE_GL_FUNC(glVertexAttrib3dARB)
2346 USE_GL_FUNC(glVertexAttrib3dvARB)
2347 USE_GL_FUNC(glVertexAttrib3fARB)
2348 USE_GL_FUNC(glVertexAttrib3fvARB)
2349 USE_GL_FUNC(glVertexAttrib3sARB)
2350 USE_GL_FUNC(glVertexAttrib3svARB)
2351 USE_GL_FUNC(glVertexAttrib4NbvARB)
2352 USE_GL_FUNC(glVertexAttrib4NivARB)
2353 USE_GL_FUNC(glVertexAttrib4NsvARB)
2354 USE_GL_FUNC(glVertexAttrib4NubARB)
2355 USE_GL_FUNC(glVertexAttrib4NubvARB)
2356 USE_GL_FUNC(glVertexAttrib4NuivARB)
2357 USE_GL_FUNC(glVertexAttrib4NusvARB)
2358 USE_GL_FUNC(glVertexAttrib4bvARB)
2359 USE_GL_FUNC(glVertexAttrib4dARB)
2360 USE_GL_FUNC(glVertexAttrib4dvARB)
2361 USE_GL_FUNC(glVertexAttrib4fARB)
2362 USE_GL_FUNC(glVertexAttrib4fvARB)
2363 USE_GL_FUNC(glVertexAttrib4ivARB)
2364 USE_GL_FUNC(glVertexAttrib4sARB)
2365 USE_GL_FUNC(glVertexAttrib4svARB)
2366 USE_GL_FUNC(glVertexAttrib4ubvARB)
2367 USE_GL_FUNC(glVertexAttrib4uivARB)
2368 USE_GL_FUNC(glVertexAttrib4usvARB)
2369 USE_GL_FUNC(glVertexAttribPointerARB)
2370 /* GL_ARB_viewport_array */
2371 USE_GL_FUNC(glDepthRangeArrayv)
2372 USE_GL_FUNC(glDepthRangeIndexed)
2373 USE_GL_FUNC(glGetDoublei_v)
2374 USE_GL_FUNC(glGetFloati_v)
2375 USE_GL_FUNC(glScissorArrayv)
2376 USE_GL_FUNC(glScissorIndexed)
2377 USE_GL_FUNC(glScissorIndexedv)
2378 USE_GL_FUNC(glViewportArrayv)
2379 USE_GL_FUNC(glViewportIndexedf)
2380 USE_GL_FUNC(glViewportIndexedfv)
2381 /* GL_ATI_fragment_shader */
2382 USE_GL_FUNC(glAlphaFragmentOp1ATI)
2383 USE_GL_FUNC(glAlphaFragmentOp2ATI)
2384 USE_GL_FUNC(glAlphaFragmentOp3ATI)
2385 USE_GL_FUNC(glBeginFragmentShaderATI)
2386 USE_GL_FUNC(glBindFragmentShaderATI)
2387 USE_GL_FUNC(glColorFragmentOp1ATI)
2388 USE_GL_FUNC(glColorFragmentOp2ATI)
2389 USE_GL_FUNC(glColorFragmentOp3ATI)
2390 USE_GL_FUNC(glDeleteFragmentShaderATI)
2391 USE_GL_FUNC(glEndFragmentShaderATI)
2392 USE_GL_FUNC(glGenFragmentShadersATI)
2393 USE_GL_FUNC(glPassTexCoordATI)
2394 USE_GL_FUNC(glSampleMapATI)
2395 USE_GL_FUNC(glSetFragmentShaderConstantATI)
2396 /* GL_ATI_separate_stencil */
2397 USE_GL_FUNC(glStencilOpSeparateATI)
2398 USE_GL_FUNC(glStencilFuncSeparateATI)
2399 /* GL_EXT_blend_color */
2400 USE_GL_FUNC(glBlendColorEXT)
2401 /* GL_EXT_blend_equation_separate */
2402 USE_GL_FUNC(glBlendFuncSeparateEXT)
2403 /* GL_EXT_blend_func_separate */
2404 USE_GL_FUNC(glBlendEquationSeparateEXT)
2405 /* GL_EXT_blend_minmax */
2406 USE_GL_FUNC(glBlendEquationEXT)
2407 /* GL_EXT_depth_bounds_test */
2408 USE_GL_FUNC(glDepthBoundsEXT)
2409 /* GL_EXT_draw_buffers2 */
2410 USE_GL_FUNC(glColorMaskIndexedEXT)
2411 USE_GL_FUNC(glDisableIndexedEXT)
2412 USE_GL_FUNC(glEnableIndexedEXT)
2413 USE_GL_FUNC(glGetBooleanIndexedvEXT)
2414 USE_GL_FUNC(glGetIntegerIndexedvEXT)
2415 USE_GL_FUNC(glIsEnabledIndexedEXT)
2416 /* GL_EXT_fog_coord */
2417 USE_GL_FUNC(glFogCoordPointerEXT)
2418 USE_GL_FUNC(glFogCoorddEXT)
2419 USE_GL_FUNC(glFogCoorddvEXT)
2420 USE_GL_FUNC(glFogCoordfEXT)
2421 USE_GL_FUNC(glFogCoordfvEXT)
2422 /* GL_EXT_framebuffer_blit */
2423 USE_GL_FUNC(glBlitFramebufferEXT)
2424 /* GL_EXT_framebuffer_multisample */
2425 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT)
2426 /* GL_EXT_framebuffer_object */
2427 USE_GL_FUNC(glBindFramebufferEXT)
2428 USE_GL_FUNC(glBindRenderbufferEXT)
2429 USE_GL_FUNC(glCheckFramebufferStatusEXT)
2430 USE_GL_FUNC(glDeleteFramebuffersEXT)
2431 USE_GL_FUNC(glDeleteRenderbuffersEXT)
2432 USE_GL_FUNC(glFramebufferRenderbufferEXT)
2433 USE_GL_FUNC(glFramebufferTexture1DEXT)
2434 USE_GL_FUNC(glFramebufferTexture2DEXT)
2435 USE_GL_FUNC(glFramebufferTexture3DEXT)
2436 USE_GL_FUNC(glGenFramebuffersEXT)
2437 USE_GL_FUNC(glGenRenderbuffersEXT)
2438 USE_GL_FUNC(glGenerateMipmapEXT)
2439 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT)
2440 USE_GL_FUNC(glGetRenderbufferParameterivEXT)
2441 USE_GL_FUNC(glIsFramebufferEXT)
2442 USE_GL_FUNC(glIsRenderbufferEXT)
2443 USE_GL_FUNC(glRenderbufferStorageEXT)
2444 /* GL_EXT_gpu_program_parameters */
2445 USE_GL_FUNC(glProgramEnvParameters4fvEXT)
2446 USE_GL_FUNC(glProgramLocalParameters4fvEXT)
2447 /* GL_EXT_gpu_shader4 */
2448 USE_GL_FUNC(glBindFragDataLocationEXT)
2449 USE_GL_FUNC(glGetFragDataLocationEXT)
2450 USE_GL_FUNC(glGetUniformuivEXT)
2451 USE_GL_FUNC(glGetVertexAttribIivEXT)
2452 USE_GL_FUNC(glGetVertexAttribIuivEXT)
2453 USE_GL_FUNC(glUniform1uiEXT)
2454 USE_GL_FUNC(glUniform1uivEXT)
2455 USE_GL_FUNC(glUniform2uiEXT)
2456 USE_GL_FUNC(glUniform2uivEXT)
2457 USE_GL_FUNC(glUniform3uiEXT)
2458 USE_GL_FUNC(glUniform3uivEXT)
2459 USE_GL_FUNC(glUniform4uiEXT)
2460 USE_GL_FUNC(glUniform4uivEXT)
2461 USE_GL_FUNC(glVertexAttribI1iEXT)
2462 USE_GL_FUNC(glVertexAttribI1ivEXT)
2463 USE_GL_FUNC(glVertexAttribI1uiEXT)
2464 USE_GL_FUNC(glVertexAttribI1uivEXT)
2465 USE_GL_FUNC(glVertexAttribI2iEXT)
2466 USE_GL_FUNC(glVertexAttribI2ivEXT)
2467 USE_GL_FUNC(glVertexAttribI2uiEXT)
2468 USE_GL_FUNC(glVertexAttribI2uivEXT)
2469 USE_GL_FUNC(glVertexAttribI3iEXT)
2470 USE_GL_FUNC(glVertexAttribI3ivEXT)
2471 USE_GL_FUNC(glVertexAttribI3uiEXT)
2472 USE_GL_FUNC(glVertexAttribI3uivEXT)
2473 USE_GL_FUNC(glVertexAttribI4bvEXT)
2474 USE_GL_FUNC(glVertexAttribI4iEXT)
2475 USE_GL_FUNC(glVertexAttribI4ivEXT)
2476 USE_GL_FUNC(glVertexAttribI4svEXT)
2477 USE_GL_FUNC(glVertexAttribI4ubvEXT)
2478 USE_GL_FUNC(glVertexAttribI4uiEXT)
2479 USE_GL_FUNC(glVertexAttribI4uivEXT)
2480 USE_GL_FUNC(glVertexAttribI4usvEXT)
2481 USE_GL_FUNC(glVertexAttribIPointerEXT)
2482 /* GL_EXT_point_parameters */
2483 USE_GL_FUNC(glPointParameterfEXT)
2484 USE_GL_FUNC(glPointParameterfvEXT)
2485 /* GL_EXT_polgyon_offset_clamp */
2486 USE_GL_FUNC(glPolygonOffsetClampEXT)
2487 /* GL_EXT_provoking_vertex */
2488 USE_GL_FUNC(glProvokingVertexEXT)
2489 /* GL_EXT_secondary_color */
2490 USE_GL_FUNC(glSecondaryColor3fEXT)
2491 USE_GL_FUNC(glSecondaryColor3fvEXT)
2492 USE_GL_FUNC(glSecondaryColor3ubEXT)
2493 USE_GL_FUNC(glSecondaryColor3ubvEXT)
2494 USE_GL_FUNC(glSecondaryColorPointerEXT)
2495 /* GL_EXT_stencil_two_side */
2496 USE_GL_FUNC(glActiveStencilFaceEXT)
2497 /* GL_EXT_texture3D */
2498 USE_GL_FUNC(glTexImage3D)
2499 USE_GL_FUNC(glTexImage3DEXT)
2500 USE_GL_FUNC(glTexSubImage3D)
2501 USE_GL_FUNC(glTexSubImage3DEXT)
2502 /* GL_NV_fence */
2503 USE_GL_FUNC(glDeleteFencesNV)
2504 USE_GL_FUNC(glFinishFenceNV)
2505 USE_GL_FUNC(glGenFencesNV)
2506 USE_GL_FUNC(glGetFenceivNV)
2507 USE_GL_FUNC(glIsFenceNV)
2508 USE_GL_FUNC(glSetFenceNV)
2509 USE_GL_FUNC(glTestFenceNV)
2510 /* GL_NV_half_float */
2511 USE_GL_FUNC(glColor3hNV)
2512 USE_GL_FUNC(glColor3hvNV)
2513 USE_GL_FUNC(glColor4hNV)
2514 USE_GL_FUNC(glColor4hvNV)
2515 USE_GL_FUNC(glFogCoordhNV)
2516 USE_GL_FUNC(glFogCoordhvNV)
2517 USE_GL_FUNC(glMultiTexCoord1hNV)
2518 USE_GL_FUNC(glMultiTexCoord1hvNV)
2519 USE_GL_FUNC(glMultiTexCoord2hNV)
2520 USE_GL_FUNC(glMultiTexCoord2hvNV)
2521 USE_GL_FUNC(glMultiTexCoord3hNV)
2522 USE_GL_FUNC(glMultiTexCoord3hvNV)
2523 USE_GL_FUNC(glMultiTexCoord4hNV)
2524 USE_GL_FUNC(glMultiTexCoord4hvNV)
2525 USE_GL_FUNC(glNormal3hNV)
2526 USE_GL_FUNC(glNormal3hvNV)
2527 USE_GL_FUNC(glSecondaryColor3hNV)
2528 USE_GL_FUNC(glSecondaryColor3hvNV)
2529 USE_GL_FUNC(glTexCoord1hNV)
2530 USE_GL_FUNC(glTexCoord1hvNV)
2531 USE_GL_FUNC(glTexCoord2hNV)
2532 USE_GL_FUNC(glTexCoord2hvNV)
2533 USE_GL_FUNC(glTexCoord3hNV)
2534 USE_GL_FUNC(glTexCoord3hvNV)
2535 USE_GL_FUNC(glTexCoord4hNV)
2536 USE_GL_FUNC(glTexCoord4hvNV)
2537 USE_GL_FUNC(glVertex2hNV)
2538 USE_GL_FUNC(glVertex2hvNV)
2539 USE_GL_FUNC(glVertex3hNV)
2540 USE_GL_FUNC(glVertex3hvNV)
2541 USE_GL_FUNC(glVertex4hNV)
2542 USE_GL_FUNC(glVertex4hvNV)
2543 USE_GL_FUNC(glVertexAttrib1hNV)
2544 USE_GL_FUNC(glVertexAttrib1hvNV)
2545 USE_GL_FUNC(glVertexAttrib2hNV)
2546 USE_GL_FUNC(glVertexAttrib2hvNV)
2547 USE_GL_FUNC(glVertexAttrib3hNV)
2548 USE_GL_FUNC(glVertexAttrib3hvNV)
2549 USE_GL_FUNC(glVertexAttrib4hNV)
2550 USE_GL_FUNC(glVertexAttrib4hvNV)
2551 USE_GL_FUNC(glVertexAttribs1hvNV)
2552 USE_GL_FUNC(glVertexAttribs2hvNV)
2553 USE_GL_FUNC(glVertexAttribs3hvNV)
2554 USE_GL_FUNC(glVertexAttribs4hvNV)
2555 USE_GL_FUNC(glVertexWeighthNV)
2556 USE_GL_FUNC(glVertexWeighthvNV)
2557 /* GL_NV_point_sprite */
2558 USE_GL_FUNC(glPointParameteriNV)
2559 USE_GL_FUNC(glPointParameterivNV)
2560 /* GL_NV_register_combiners */
2561 USE_GL_FUNC(glCombinerInputNV)
2562 USE_GL_FUNC(glCombinerOutputNV)
2563 USE_GL_FUNC(glCombinerParameterfNV)
2564 USE_GL_FUNC(glCombinerParameterfvNV)
2565 USE_GL_FUNC(glCombinerParameteriNV)
2566 USE_GL_FUNC(glCombinerParameterivNV)
2567 USE_GL_FUNC(glFinalCombinerInputNV)
2568 /* WGL extensions */
2569 USE_GL_FUNC(wglChoosePixelFormatARB)
2570 USE_GL_FUNC(wglGetExtensionsStringARB)
2571 USE_GL_FUNC(wglGetPixelFormatAttribfvARB)
2572 USE_GL_FUNC(wglGetPixelFormatAttribivARB)
2573 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE)
2574 USE_GL_FUNC(wglQueryCurrentRendererStringWINE)
2575 USE_GL_FUNC(wglQueryRendererIntegerWINE)
2576 USE_GL_FUNC(wglQueryRendererStringWINE)
2577 USE_GL_FUNC(wglSetPixelFormatWINE)
2578 USE_GL_FUNC(wglSwapIntervalEXT)
2580 /* Newer core functions */
2581 USE_GL_FUNC(glActiveTexture) /* OpenGL 1.3 */
2582 USE_GL_FUNC(glAttachShader) /* OpenGL 2.0 */
2583 USE_GL_FUNC(glBeginQuery) /* OpenGL 1.5 */
2584 USE_GL_FUNC(glBeginTransformFeedback) /* OpenGL 3.0 */
2585 USE_GL_FUNC(glBindAttribLocation) /* OpenGL 2.0 */
2586 USE_GL_FUNC(glBindBuffer) /* OpenGL 1.5 */
2587 USE_GL_FUNC(glBindFragDataLocation) /* OpenGL 3.0 */
2588 USE_GL_FUNC(glBindVertexArray) /* OpenGL 3.0 */
2589 USE_GL_FUNC(glBlendColor) /* OpenGL 1.4 */
2590 USE_GL_FUNC(glBlendEquation) /* OpenGL 1.4 */
2591 USE_GL_FUNC(glBlendEquationSeparate) /* OpenGL 2.0 */
2592 USE_GL_FUNC(glBlendFuncSeparate) /* OpenGL 1.4 */
2593 USE_GL_FUNC(glBufferData) /* OpenGL 1.5 */
2594 USE_GL_FUNC(glBufferSubData) /* OpenGL 1.5 */
2595 USE_GL_FUNC(glColorMaski) /* OpenGL 3.0 */
2596 USE_GL_FUNC(glCompileShader) /* OpenGL 2.0 */
2597 USE_GL_FUNC(glCompressedTexImage2D) /* OpenGL 1.3 */
2598 USE_GL_FUNC(glCompressedTexImage3D) /* OpenGL 1.3 */
2599 USE_GL_FUNC(glCompressedTexSubImage2D) /* OpenGL 1.3 */
2600 USE_GL_FUNC(glCompressedTexSubImage3D) /* OpenGL 1.3 */
2601 USE_GL_FUNC(glCreateProgram) /* OpenGL 2.0 */
2602 USE_GL_FUNC(glCreateShader) /* OpenGL 2.0 */
2603 USE_GL_FUNC(glDebugMessageCallback) /* OpenGL 4.3 */
2604 USE_GL_FUNC(glDebugMessageControl) /* OpenGL 4.3 */
2605 USE_GL_FUNC(glDebugMessageInsert) /* OpenGL 4.3 */
2606 USE_GL_FUNC(glDeleteBuffers) /* OpenGL 1.5 */
2607 USE_GL_FUNC(glDeleteProgram) /* OpenGL 2.0 */
2608 USE_GL_FUNC(glDeleteQueries) /* OpenGL 1.5 */
2609 USE_GL_FUNC(glDeleteShader) /* OpenGL 2.0 */
2610 USE_GL_FUNC(glDeleteVertexArrays) /* OpenGL 3.0 */
2611 USE_GL_FUNC(glDetachShader) /* OpenGL 2.0 */
2612 USE_GL_FUNC(glDisablei) /* OpenGL 3.0 */
2613 USE_GL_FUNC(glDisableVertexAttribArray) /* OpenGL 2.0 */
2614 USE_GL_FUNC(glDrawArraysInstanced) /* OpenGL 3.1 */
2615 USE_GL_FUNC(glDrawBuffers) /* OpenGL 2.0 */
2616 USE_GL_FUNC(glDrawElementsInstanced) /* OpenGL 3.1 */
2617 USE_GL_FUNC(glEnablei) /* OpenGL 3.0 */
2618 USE_GL_FUNC(glEnableVertexAttribArray) /* OpenGL 2.0 */
2619 USE_GL_FUNC(glEndQuery) /* OpenGL 1.5 */
2620 USE_GL_FUNC(glEndTransformFeedback) /* OpenGL 3.0 */
2621 USE_GL_FUNC(glFramebufferTexture) /* OpenGL 3.2 */
2622 USE_GL_FUNC(glGenBuffers) /* OpenGL 1.5 */
2623 USE_GL_FUNC(glGenQueries) /* OpenGL 1.5 */
2624 USE_GL_FUNC(glGenVertexArrays) /* OpenGL 3.0 */
2625 USE_GL_FUNC(glGetActiveUniform) /* OpenGL 2.0 */
2626 USE_GL_FUNC(glGetAttachedShaders) /* OpenGL 2.0 */
2627 USE_GL_FUNC(glGetAttribLocation) /* OpenGL 2.0 */
2628 USE_GL_FUNC(glGetBooleani_v) /* OpenGL 3.0 */
2629 USE_GL_FUNC(glGetBufferSubData) /* OpenGL 1.5 */
2630 USE_GL_FUNC(glGetCompressedTexImage) /* OpenGL 1.3 */
2631 USE_GL_FUNC(glGetDebugMessageLog) /* OpenGL 4.3 */
2632 USE_GL_FUNC(glGetIntegeri_v) /* OpenGL 3.0 */
2633 USE_GL_FUNC(glGetProgramInfoLog) /* OpenGL 2.0 */
2634 USE_GL_FUNC(glGetProgramiv) /* OpenGL 2.0 */
2635 USE_GL_FUNC(glGetQueryiv) /* OpenGL 1.5 */
2636 USE_GL_FUNC(glGetQueryObjectuiv) /* OpenGL 1.5 */
2637 USE_GL_FUNC(glGetShaderInfoLog) /* OpenGL 2.0 */
2638 USE_GL_FUNC(glGetShaderiv) /* OpenGL 2.0 */
2639 USE_GL_FUNC(glGetShaderSource) /* OpenGL 2.0 */
2640 USE_GL_FUNC(glGetStringi) /* OpenGL 3.0 */
2641 USE_GL_FUNC(glGetTextureLevelParameteriv) /* OpenGL 4.5 */
2642 USE_GL_FUNC(glGetTextureParameteriv) /* OpenGL 4.5 */
2643 USE_GL_FUNC(glGetUniformfv) /* OpenGL 2.0 */
2644 USE_GL_FUNC(glGetUniformiv) /* OpenGL 2.0 */
2645 USE_GL_FUNC(glGetUniformLocation) /* OpenGL 2.0 */
2646 USE_GL_FUNC(glIsEnabledi) /* OpenGL 3.0 */
2647 USE_GL_FUNC(glLinkProgram) /* OpenGL 2.0 */
2648 USE_GL_FUNC(glMapBuffer) /* OpenGL 1.5 */
2649 USE_GL_FUNC(glMinSampleShading) /* OpenGL 4.0 */
2650 USE_GL_FUNC(glPointParameteri) /* OpenGL 1.4 */
2651 USE_GL_FUNC(glPointParameteriv) /* OpenGL 1.4 */
2652 USE_GL_FUNC(glShaderSource) /* OpenGL 2.0 */
2653 USE_GL_FUNC(glStencilFuncSeparate) /* OpenGL 2.0 */
2654 USE_GL_FUNC(glStencilOpSeparate) /* OpenGL 2.0 */
2655 USE_GL_FUNC(glTexBuffer) /* OpenGL 3.1 */
2656 USE_GL_FUNC(glTexImage3D) /* OpenGL 1.2 */
2657 USE_GL_FUNC(glTexSubImage3D) /* OpenGL 1.2 */
2658 USE_GL_FUNC(glTransformFeedbackVaryings) /* OpenGL 3.0 */
2659 USE_GL_FUNC(glUniform1f) /* OpenGL 2.0 */
2660 USE_GL_FUNC(glUniform1fv) /* OpenGL 2.0 */
2661 USE_GL_FUNC(glUniform1i) /* OpenGL 2.0 */
2662 USE_GL_FUNC(glUniform1iv) /* OpenGL 2.0 */
2663 USE_GL_FUNC(glUniform2f) /* OpenGL 2.0 */
2664 USE_GL_FUNC(glUniform2fv) /* OpenGL 2.0 */
2665 USE_GL_FUNC(glUniform2i) /* OpenGL 2.0 */
2666 USE_GL_FUNC(glUniform2iv) /* OpenGL 2.0 */
2667 USE_GL_FUNC(glUniform3f) /* OpenGL 2.0 */
2668 USE_GL_FUNC(glUniform3fv) /* OpenGL 2.0 */
2669 USE_GL_FUNC(glUniform3i) /* OpenGL 2.0 */
2670 USE_GL_FUNC(glUniform3iv) /* OpenGL 2.0 */
2671 USE_GL_FUNC(glUniform4f) /* OpenGL 2.0 */
2672 USE_GL_FUNC(glUniform4fv) /* OpenGL 2.0 */
2673 USE_GL_FUNC(glUniform4i) /* OpenGL 2.0 */
2674 USE_GL_FUNC(glUniform4iv) /* OpenGL 2.0 */
2675 USE_GL_FUNC(glUniformMatrix2fv) /* OpenGL 2.0 */
2676 USE_GL_FUNC(glUniformMatrix3fv) /* OpenGL 2.0 */
2677 USE_GL_FUNC(glUniformMatrix4fv) /* OpenGL 2.0 */
2678 USE_GL_FUNC(glUnmapBuffer) /* OpenGL 1.5 */
2679 USE_GL_FUNC(glUseProgram) /* OpenGL 2.0 */
2680 USE_GL_FUNC(glValidateProgram) /* OpenGL 2.0 */
2681 USE_GL_FUNC(glVertexAttrib1f) /* OpenGL 2.0 */
2682 USE_GL_FUNC(glVertexAttrib1fv) /* OpenGL 2.0 */
2683 USE_GL_FUNC(glVertexAttrib2f) /* OpenGL 2.0 */
2684 USE_GL_FUNC(glVertexAttrib2fv) /* OpenGL 2.0 */
2685 USE_GL_FUNC(glVertexAttrib3f) /* OpenGL 2.0 */
2686 USE_GL_FUNC(glVertexAttrib3fv) /* OpenGL 2.0 */
2687 USE_GL_FUNC(glVertexAttrib4f) /* OpenGL 2.0 */
2688 USE_GL_FUNC(glVertexAttrib4fv) /* OpenGL 2.0 */
2689 USE_GL_FUNC(glVertexAttrib4Nsv) /* OpenGL 2.0 */
2690 USE_GL_FUNC(glVertexAttrib4Nub) /* OpenGL 2.0 */
2691 USE_GL_FUNC(glVertexAttrib4Nubv) /* OpenGL 2.0 */
2692 USE_GL_FUNC(glVertexAttrib4Nusv) /* OpenGL 2.0 */
2693 USE_GL_FUNC(glVertexAttrib4sv) /* OpenGL 2.0 */
2694 USE_GL_FUNC(glVertexAttrib4ubv) /* OpenGL 2.0 */
2695 USE_GL_FUNC(glVertexAttribDivisor) /* OpenGL 3.3 */
2696 USE_GL_FUNC(glVertexAttribIPointer) /* OpenGL 3.0 */
2697 USE_GL_FUNC(glVertexAttribPointer) /* OpenGL 2.0 */
2698 #undef USE_GL_FUNC
2700 #ifndef USE_WIN32_OPENGL
2701 /* hack: use the functions directly from the TEB table to bypass the thunks */
2702 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2703 gl_info->gl_ops.ext = ((struct opengl_funcs *)NtCurrentTeb()->glTable)->ext;
2704 #endif
2706 #define MAP_GL_FUNCTION(core_func, ext_func) \
2707 do \
2709 if (!gl_info->gl_ops.ext.p_##core_func) \
2710 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
2711 } while (0)
2712 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
2713 do \
2715 if (!gl_info->gl_ops.ext.p_##core_func) \
2716 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
2717 } while (0)
2719 MAP_GL_FUNCTION(glActiveTexture, glActiveTextureARB);
2720 MAP_GL_FUNCTION(glAttachShader, glAttachObjectARB);
2721 MAP_GL_FUNCTION(glBeginQuery, glBeginQueryARB);
2722 MAP_GL_FUNCTION(glBindAttribLocation, glBindAttribLocationARB);
2723 MAP_GL_FUNCTION(glBindBuffer, glBindBufferARB);
2724 MAP_GL_FUNCTION(glBindFragDataLocation, glBindFragDataLocationEXT);
2725 MAP_GL_FUNCTION(glBlendColor, glBlendColorEXT);
2726 MAP_GL_FUNCTION(glBlendEquation, glBlendEquationEXT);
2727 MAP_GL_FUNCTION(glBlendEquationSeparate, glBlendEquationSeparateEXT);
2728 MAP_GL_FUNCTION(glBlendFuncSeparate, glBlendFuncSeparateEXT);
2729 MAP_GL_FUNCTION(glBufferData, glBufferDataARB);
2730 MAP_GL_FUNCTION(glBufferSubData, glBufferSubDataARB);
2731 MAP_GL_FUNCTION(glColorMaski, glColorMaskIndexedEXT);
2732 MAP_GL_FUNCTION(glCompileShader, glCompileShaderARB);
2733 MAP_GL_FUNCTION(glCompressedTexImage2D, glCompressedTexImage2DARB);
2734 MAP_GL_FUNCTION(glCompressedTexImage3D, glCompressedTexImage3DARB);
2735 MAP_GL_FUNCTION(glCompressedTexSubImage2D, glCompressedTexSubImage2DARB);
2736 MAP_GL_FUNCTION(glCompressedTexSubImage3D, glCompressedTexSubImage3DARB);
2737 MAP_GL_FUNCTION(glCreateProgram, glCreateProgramObjectARB);
2738 MAP_GL_FUNCTION(glCreateShader, glCreateShaderObjectARB);
2739 MAP_GL_FUNCTION(glDebugMessageCallback, glDebugMessageCallbackARB);
2740 MAP_GL_FUNCTION(glDebugMessageControl, glDebugMessageControlARB);
2741 MAP_GL_FUNCTION(glDebugMessageInsert, glDebugMessageInsertARB);
2742 MAP_GL_FUNCTION(glDeleteBuffers, glDeleteBuffersARB);
2743 MAP_GL_FUNCTION(glDeleteProgram, glDeleteObjectARB);
2744 MAP_GL_FUNCTION(glDeleteQueries, glDeleteQueriesARB);
2745 MAP_GL_FUNCTION(glDeleteShader, glDeleteObjectARB);
2746 MAP_GL_FUNCTION(glDetachShader, glDetachObjectARB);
2747 MAP_GL_FUNCTION(glDisablei, glDisableIndexedEXT);
2748 MAP_GL_FUNCTION(glDisableVertexAttribArray, glDisableVertexAttribArrayARB);
2749 MAP_GL_FUNCTION(glDrawArraysInstanced, glDrawArraysInstancedARB);
2750 MAP_GL_FUNCTION(glDrawBuffers, glDrawBuffersARB);
2751 MAP_GL_FUNCTION(glDrawElementsInstanced, glDrawElementsInstancedARB);
2752 MAP_GL_FUNCTION(glEnablei, glEnableIndexedEXT);
2753 MAP_GL_FUNCTION(glEnableVertexAttribArray, glEnableVertexAttribArrayARB);
2754 MAP_GL_FUNCTION(glEndQuery, glEndQueryARB);
2755 MAP_GL_FUNCTION(glFramebufferTexture, glFramebufferTextureARB);
2756 MAP_GL_FUNCTION(glGenBuffers, glGenBuffersARB);
2757 MAP_GL_FUNCTION(glGenQueries, glGenQueriesARB);
2758 MAP_GL_FUNCTION(glGetActiveUniform, glGetActiveUniformARB);
2759 MAP_GL_FUNCTION(glGetAttachedShaders, glGetAttachedObjectsARB);
2760 MAP_GL_FUNCTION(glGetAttribLocation, glGetAttribLocationARB);
2761 MAP_GL_FUNCTION(glGetBooleani_v, glGetBooleanIndexedvEXT);
2762 MAP_GL_FUNCTION(glGetBufferSubData, glGetBufferSubDataARB);
2763 MAP_GL_FUNCTION(glGetCompressedTexImage, glGetCompressedTexImageARB);
2764 MAP_GL_FUNCTION(glGetDebugMessageLog, glGetDebugMessageLogARB);
2765 MAP_GL_FUNCTION(glGetIntegeri_v, glGetIntegerIndexedvEXT);
2766 MAP_GL_FUNCTION(glGetProgramInfoLog, glGetInfoLogARB);
2767 MAP_GL_FUNCTION(glGetProgramiv, glGetObjectParameterivARB);
2768 MAP_GL_FUNCTION(glGetQueryiv, glGetQueryivARB);
2769 MAP_GL_FUNCTION(glGetQueryObjectuiv, glGetQueryObjectuivARB);
2770 MAP_GL_FUNCTION(glGetShaderInfoLog, glGetInfoLogARB);
2771 MAP_GL_FUNCTION(glGetShaderiv, glGetObjectParameterivARB);
2772 MAP_GL_FUNCTION(glGetShaderSource, glGetShaderSourceARB);
2773 MAP_GL_FUNCTION(glGetUniformfv, glGetUniformfvARB);
2774 MAP_GL_FUNCTION(glGetUniformiv, glGetUniformivARB);
2775 MAP_GL_FUNCTION(glGetUniformLocation, glGetUniformLocationARB);
2776 MAP_GL_FUNCTION(glIsEnabledi, glIsEnabledIndexedEXT);
2777 MAP_GL_FUNCTION(glLinkProgram, glLinkProgramARB);
2778 MAP_GL_FUNCTION(glMapBuffer, glMapBufferARB);
2779 MAP_GL_FUNCTION(glMinSampleShading, glMinSampleShadingARB);
2780 MAP_GL_FUNCTION(glPolygonOffsetClamp, glPolygonOffsetClampEXT);
2781 MAP_GL_FUNCTION_CAST(glShaderSource, glShaderSourceARB);
2782 MAP_GL_FUNCTION(glTexBuffer, glTexBufferARB);
2783 MAP_GL_FUNCTION_CAST(glTexImage3D, glTexImage3DEXT);
2784 MAP_GL_FUNCTION(glTexSubImage3D, glTexSubImage3DEXT);
2785 MAP_GL_FUNCTION(glUniform1f, glUniform1fARB);
2786 MAP_GL_FUNCTION(glUniform1fv, glUniform1fvARB);
2787 MAP_GL_FUNCTION(glUniform1i, glUniform1iARB);
2788 MAP_GL_FUNCTION(glUniform1iv, glUniform1ivARB);
2789 MAP_GL_FUNCTION(glUniform2f, glUniform2fARB);
2790 MAP_GL_FUNCTION(glUniform2fv, glUniform2fvARB);
2791 MAP_GL_FUNCTION(glUniform2i, glUniform2iARB);
2792 MAP_GL_FUNCTION(glUniform2iv, glUniform2ivARB);
2793 MAP_GL_FUNCTION(glUniform3f, glUniform3fARB);
2794 MAP_GL_FUNCTION(glUniform3fv, glUniform3fvARB);
2795 MAP_GL_FUNCTION(glUniform3i, glUniform3iARB);
2796 MAP_GL_FUNCTION(glUniform3iv, glUniform3ivARB);
2797 MAP_GL_FUNCTION(glUniform4f, glUniform4fARB);
2798 MAP_GL_FUNCTION(glUniform4fv, glUniform4fvARB);
2799 MAP_GL_FUNCTION(glUniform4i, glUniform4iARB);
2800 MAP_GL_FUNCTION(glUniform4iv, glUniform4ivARB);
2801 MAP_GL_FUNCTION(glUniformMatrix2fv, glUniformMatrix2fvARB);
2802 MAP_GL_FUNCTION(glUniformMatrix3fv, glUniformMatrix3fvARB);
2803 MAP_GL_FUNCTION(glUniformMatrix4fv, glUniformMatrix4fvARB);
2804 MAP_GL_FUNCTION(glUnmapBuffer, glUnmapBufferARB);
2805 MAP_GL_FUNCTION(glUseProgram, glUseProgramObjectARB);
2806 MAP_GL_FUNCTION(glValidateProgram, glValidateProgramARB);
2807 MAP_GL_FUNCTION(glVertexAttrib1f, glVertexAttrib1fARB);
2808 MAP_GL_FUNCTION(glVertexAttrib1fv, glVertexAttrib1fvARB);
2809 MAP_GL_FUNCTION(glVertexAttrib2f, glVertexAttrib2fARB);
2810 MAP_GL_FUNCTION(glVertexAttrib2fv, glVertexAttrib2fvARB);
2811 MAP_GL_FUNCTION(glVertexAttrib3f, glVertexAttrib3fARB);
2812 MAP_GL_FUNCTION(glVertexAttrib3fv, glVertexAttrib3fvARB);
2813 MAP_GL_FUNCTION(glVertexAttrib4f, glVertexAttrib4fARB);
2814 MAP_GL_FUNCTION(glVertexAttrib4fv, glVertexAttrib4fvARB);
2815 MAP_GL_FUNCTION(glVertexAttrib4Nsv, glVertexAttrib4NsvARB);
2816 MAP_GL_FUNCTION(glVertexAttrib4Nub, glVertexAttrib4NubARB);
2817 MAP_GL_FUNCTION(glVertexAttrib4Nubv, glVertexAttrib4NubvARB);
2818 MAP_GL_FUNCTION(glVertexAttrib4Nusv, glVertexAttrib4NusvARB);
2819 MAP_GL_FUNCTION(glVertexAttrib4sv, glVertexAttrib4svARB);
2820 MAP_GL_FUNCTION(glVertexAttrib4ubv, glVertexAttrib4ubvARB);
2821 MAP_GL_FUNCTION(glVertexAttribDivisor, glVertexAttribDivisorARB);
2822 MAP_GL_FUNCTION(glVertexAttribIPointer, glVertexAttribIPointerEXT);
2823 MAP_GL_FUNCTION(glVertexAttribPointer, glVertexAttribPointerARB);
2824 #undef MAP_GL_FUNCTION
2825 #undef MAP_GL_FUNCTION_CAST
2828 static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info, struct wined3d_d3d_info *d3d_info)
2830 unsigned int i, sampler_count;
2831 GLfloat gl_floatv[2];
2832 GLint gl_max;
2834 gl_info->limits.buffers = 1;
2835 gl_info->limits.textures = 0;
2836 gl_info->limits.texture_coords = 0;
2837 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
2839 gl_info->limits.uniform_blocks[i] = 0;
2840 gl_info->limits.samplers[i] = 0;
2842 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = 1;
2843 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
2844 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
2845 gl_info->limits.vertex_attribs = 16;
2846 gl_info->limits.texture_buffer_offset_alignment = 1;
2847 gl_info->limits.glsl_vs_float_constants = 0;
2848 gl_info->limits.glsl_ps_float_constants = 0;
2849 gl_info->limits.arb_vs_float_constants = 0;
2850 gl_info->limits.arb_vs_native_constants = 0;
2851 gl_info->limits.arb_vs_instructions = 0;
2852 gl_info->limits.arb_vs_temps = 0;
2853 gl_info->limits.arb_ps_float_constants = 0;
2854 gl_info->limits.arb_ps_local_constants = 0;
2855 gl_info->limits.arb_ps_instructions = 0;
2856 gl_info->limits.arb_ps_temps = 0;
2858 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES, &gl_max);
2859 gl_info->limits.user_clip_distances = min(MAX_CLIP_DISTANCES, gl_max);
2860 TRACE("Clip plane support - max planes %d.\n", gl_max);
2862 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2864 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
2865 gl_info->limits.lights = gl_max;
2866 TRACE("Light support - max lights %d.\n", gl_max);
2869 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max);
2870 d3d_info->limits.texture_size = gl_max;
2871 TRACE("Maximum texture size support - max texture size %d.\n", gl_max);
2873 gl_info->gl_ops.gl.p_glGetFloatv(gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]
2874 ? GL_ALIASED_POINT_SIZE_RANGE : GL_POINT_SIZE_RANGE, gl_floatv);
2875 d3d_info->limits.pointsize_max = gl_floatv[1];
2876 TRACE("Maximum point size support - max point size %f.\n", gl_floatv[1]);
2878 if (gl_info->supported[ARB_MAP_BUFFER_ALIGNMENT])
2880 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &gl_max);
2881 TRACE("Minimum buffer map alignment: %d.\n", gl_max);
2883 else
2885 WARN_(d3d_perf)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2887 if (gl_info->supported[NV_REGISTER_COMBINERS])
2889 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
2890 gl_info->limits.general_combiners = gl_max;
2891 TRACE("Max general combiners: %d.\n", gl_max);
2893 if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
2895 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
2896 gl_info->limits.buffers = min(MAX_RENDER_TARGET_VIEWS, gl_max);
2897 TRACE("Max draw buffers: %u.\n", gl_max);
2899 if (gl_info->supported[ARB_MULTITEXTURE])
2901 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2903 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
2904 gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
2905 TRACE("Max textures: %d.\n", gl_info->limits.textures);
2907 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
2909 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &gl_max);
2910 gl_info->limits.texture_coords = min(MAX_TEXTURES, gl_max);
2912 else
2914 gl_info->limits.texture_coords = gl_info->limits.textures;
2916 TRACE("Max texture coords: %d.\n", gl_info->limits.texture_coords);
2919 if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
2921 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max);
2922 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_max;
2924 else
2926 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_info->limits.textures;
2928 TRACE("Max fragment samplers: %d.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]);
2930 if (gl_info->supported[ARB_VERTEX_SHADER])
2932 unsigned int vertex_sampler_count;
2934 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
2935 vertex_sampler_count = gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = gl_max;
2936 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
2937 gl_info->limits.combined_samplers = gl_max;
2938 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &gl_max);
2939 gl_info->limits.vertex_attribs = gl_max;
2941 /* Loading GLSL sampler uniforms is much simpler if we can assume
2942 * that the sampler setup is known at shader link time. In a
2943 * vertex shader + pixel shader combination this isn't an issue
2944 * because then the sampler setup only depends on the two shaders.
2945 * If a pixel shader is used with fixed-function vertex processing
2946 * we're fine too because fixed-function vertex processing doesn't
2947 * use any samplers. If fixed-function fragment processing is used
2948 * we have to make sure that all vertex sampler setups are valid
2949 * together with all possible fixed-function fragment processing
2950 * setups. This is true if vsamplers + MAX_TEXTURES <= max_samplers.
2951 * This is true on all Direct3D 9 cards that support vertex
2952 * texture fetch (GeForce 6 and GeForce 7 cards). Direct3D 9
2953 * Radeon cards do not support vertex texture fetch. Direct3D 10
2954 * cards have 128 samplers, and Direct3D 9 is limited to 8
2955 * fixed-function texture stages and 4 vertex samplers.
2956 * Direct3D 10 does not have a fixed-function pipeline anymore.
2958 * So this is just a check to check that our assumption holds
2959 * true. If not, write a warning and reduce the number of vertex
2960 * samplers or probably disable vertex texture fetch. */
2961 if (vertex_sampler_count && gl_info->limits.combined_samplers < 12
2962 && MAX_TEXTURES + vertex_sampler_count > gl_info->limits.combined_samplers)
2964 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
2965 vertex_sampler_count, gl_info->limits.combined_samplers);
2966 FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
2967 if (gl_info->limits.combined_samplers > MAX_TEXTURES)
2968 vertex_sampler_count = gl_info->limits.combined_samplers - MAX_TEXTURES;
2969 else
2970 vertex_sampler_count = 0;
2971 gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = vertex_sampler_count;
2974 else
2976 gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL];
2978 TRACE("Max vertex samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]);
2979 TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
2980 TRACE("Max vertex attributes: %u.\n", gl_info->limits.vertex_attribs);
2982 else
2984 gl_info->limits.textures = 1;
2985 gl_info->limits.texture_coords = 1;
2988 if (gl_info->supported[EXT_TEXTURE3D])
2990 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max);
2991 gl_info->limits.texture3d_size = gl_max;
2992 TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
2994 if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
2996 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &gl_max);
2997 gl_info->limits.anisotropy = gl_max;
2998 TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
3000 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3002 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3003 gl_info->limits.arb_ps_float_constants = gl_max;
3004 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
3005 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3006 gl_info->limits.arb_ps_native_constants = gl_max;
3007 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3008 gl_info->limits.arb_ps_native_constants);
3009 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3010 gl_info->limits.arb_ps_temps = gl_max;
3011 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
3012 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3013 gl_info->limits.arb_ps_instructions = gl_max;
3014 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
3015 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
3016 gl_info->limits.arb_ps_local_constants = gl_max;
3017 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
3019 if (gl_info->supported[ARB_VERTEX_PROGRAM])
3021 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
3022 gl_info->limits.arb_vs_float_constants = gl_max;
3023 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
3024 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max));
3025 gl_info->limits.arb_vs_native_constants = gl_max;
3026 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3027 gl_info->limits.arb_vs_native_constants);
3028 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max));
3029 gl_info->limits.arb_vs_temps = gl_max;
3030 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
3031 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max));
3032 gl_info->limits.arb_vs_instructions = gl_max;
3033 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
3035 if (gl_info->supported[ARB_VERTEX_SHADER])
3037 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max);
3038 gl_info->limits.glsl_vs_float_constants = gl_max / 4;
3039 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
3041 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3043 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &gl_max);
3044 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX] = min(gl_max, WINED3D_MAX_CBS);
3045 TRACE("Max vertex uniform blocks: %u (%d).\n",
3046 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX], gl_max);
3049 if (gl_info->supported[ARB_TESSELLATION_SHADER])
3051 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS, &gl_max);
3052 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL] = min(gl_max, WINED3D_MAX_CBS);
3053 TRACE("Max hull uniform blocks: %u (%d).\n",
3054 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_HULL], gl_max);
3055 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, &gl_max);
3056 gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL] = gl_max;
3057 TRACE("Max hull samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_HULL]);
3059 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, &gl_max);
3060 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN] = min(gl_max, WINED3D_MAX_CBS);
3061 TRACE("Max domain uniform blocks: %u (%d).\n",
3062 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_DOMAIN], gl_max);
3063 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, &gl_max);
3064 gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN] = gl_max;
3065 TRACE("Max domain samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_DOMAIN]);
3067 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3069 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, &gl_max);
3070 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY] = min(gl_max, WINED3D_MAX_CBS);
3071 TRACE("Max geometry uniform blocks: %u (%d).\n",
3072 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY], gl_max);
3073 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &gl_max);
3074 gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY] = gl_max;
3075 TRACE("Max geometry samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY]);
3077 if (gl_info->supported[ARB_FRAGMENT_SHADER])
3079 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
3080 gl_info->limits.glsl_ps_float_constants = gl_max / 4;
3081 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
3082 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3084 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
3085 gl_info->limits.glsl_varyings = gl_max;
3087 else
3089 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, &gl_max);
3090 gl_info->limits.glsl_varyings = gl_max - 4;
3092 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_info->limits.glsl_varyings,
3093 gl_info->limits.glsl_varyings / 4);
3095 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3097 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &gl_max);
3098 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL] = min(gl_max, WINED3D_MAX_CBS);
3099 TRACE("Max fragment uniform blocks: %u (%d).\n",
3100 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_PIXEL], gl_max);
3103 if (gl_info->supported[ARB_COMPUTE_SHADER])
3105 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &gl_max);
3106 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE] = min(gl_max, WINED3D_MAX_CBS);
3107 TRACE("Max compute uniform blocks: %u (%d).\n",
3108 gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE], gl_max);
3109 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &gl_max);
3110 gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE] = gl_max;
3111 TRACE("Max compute samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]);
3113 if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
3115 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &gl_max);
3116 TRACE("Max combined uniform blocks: %d.\n", gl_max);
3117 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &gl_max);
3118 TRACE("Max uniform buffer bindings: %d.\n", gl_max);
3120 if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
3122 gl_info->gl_ops.gl.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &gl_max);
3123 gl_info->limits.texture_buffer_offset_alignment = gl_max;
3124 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max);
3126 if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS])
3128 GLint max_fragment_buffers, max_combined_buffers, max_bindings;
3129 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, &max_fragment_buffers);
3130 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers);
3131 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, &max_combined_buffers);
3132 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers);
3133 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &max_bindings);
3134 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings);
3135 if (max_fragment_buffers < MAX_UNORDERED_ACCESS_VIEWS
3136 || max_combined_buffers < MAX_UNORDERED_ACCESS_VIEWS
3137 || max_bindings < MAX_UNORDERED_ACCESS_VIEWS)
3139 WARN("Disabling ARB_shader_atomic_counters.\n");
3140 gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS] = FALSE;
3143 if (gl_info->supported[ARB_TRANSFORM_FEEDBACK3])
3145 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_STREAMS, &gl_max);
3146 TRACE("Max vertex streams: %d.\n", gl_max);
3149 if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
3150 gl_info->gl_ops.gl.p_glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
3151 else
3152 gl_info->limits.shininess = 128.0f;
3154 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
3156 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_SAMPLES, &gl_max);
3157 gl_info->limits.samples = gl_max;
3160 if (gl_info->supported[ARB_FRAMEBUFFER_NO_ATTACHMENTS])
3162 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_WIDTH, &gl_max);
3163 gl_info->limits.framebuffer_width = gl_max;
3164 gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_HEIGHT, &gl_max);
3165 gl_info->limits.framebuffer_height = gl_max;
3167 else
3169 gl_info->limits.framebuffer_width = d3d_info->limits.texture_size;
3170 gl_info->limits.framebuffer_height = d3d_info->limits.texture_size;
3173 gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] =
3174 min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_GL_FRAGMENT_SAMPLERS);
3175 sampler_count = 0;
3176 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3177 sampler_count += gl_info->limits.samplers[i];
3178 if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->limits.combined_samplers < sampler_count)
3180 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3181 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3182 * the minimum value is increased to 80. */
3183 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3184 sampler_count, gl_info->limits.combined_samplers);
3185 for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
3186 gl_info->limits.samplers[i] = min(gl_info->limits.samplers[i], 16);
3189 /* A majority of OpenGL implementations allow us to statically partition
3190 * the set of texture bindings into six separate sets. */
3191 gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers;
3192 sampler_count = 0;
3193 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
3194 sampler_count += gl_info->limits.samplers[i];
3195 if (gl_info->limits.combined_samplers >= sampler_count)
3196 gl_info->limits.graphics_samplers -= gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE];
3199 /* Context activation is done by the caller. */
3200 static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
3201 struct wined3d_caps_gl_ctx *caps_gl_ctx, DWORD wined3d_creation_flags)
3203 static const struct
3205 enum wined3d_gl_extension extension;
3206 DWORD min_gl_version;
3208 core_extensions[] =
3210 {EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2)},
3211 {ARB_MULTISAMPLE, MAKEDWORD_VERSION(1, 3)},
3212 {ARB_MULTITEXTURE, MAKEDWORD_VERSION(1, 3)},
3213 {ARB_TEXTURE_BORDER_CLAMP, MAKEDWORD_VERSION(1, 3)},
3214 {ARB_TEXTURE_COMPRESSION, MAKEDWORD_VERSION(1, 3)},
3215 {ARB_TEXTURE_CUBE_MAP, MAKEDWORD_VERSION(1, 3)},
3216 {ARB_DEPTH_TEXTURE, MAKEDWORD_VERSION(1, 4)},
3217 {ARB_POINT_PARAMETERS, MAKEDWORD_VERSION(1, 4)},
3218 {ARB_SHADOW, MAKEDWORD_VERSION(1, 4)},
3219 {ARB_TEXTURE_MIRRORED_REPEAT, MAKEDWORD_VERSION(1, 4)},
3220 {EXT_BLEND_COLOR, MAKEDWORD_VERSION(1, 4)},
3221 {EXT_BLEND_FUNC_SEPARATE, MAKEDWORD_VERSION(1, 4)},
3222 {EXT_BLEND_MINMAX, MAKEDWORD_VERSION(1, 4)},
3223 {EXT_BLEND_SUBTRACT, MAKEDWORD_VERSION(1, 4)},
3224 {EXT_STENCIL_WRAP, MAKEDWORD_VERSION(1, 4)},
3225 {NV_POINT_SPRITE, MAKEDWORD_VERSION(1, 4)},
3226 {ARB_OCCLUSION_QUERY, MAKEDWORD_VERSION(1, 5)},
3227 {ARB_VERTEX_BUFFER_OBJECT, MAKEDWORD_VERSION(1, 5)},
3228 {ARB_DRAW_BUFFERS, MAKEDWORD_VERSION(2, 0)},
3229 {ARB_FRAGMENT_SHADER, MAKEDWORD_VERSION(2, 0)},
3230 {ARB_SHADING_LANGUAGE_100, MAKEDWORD_VERSION(2, 0)},
3231 {ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0)},
3232 {ARB_VERTEX_SHADER, MAKEDWORD_VERSION(2, 0)},
3233 {EXT_BLEND_EQUATION_SEPARATE, MAKEDWORD_VERSION(2, 0)},
3234 {ARB_PIXEL_BUFFER_OBJECT, MAKEDWORD_VERSION(2, 1)},
3235 {EXT_TEXTURE_SRGB, MAKEDWORD_VERSION(2, 1)},
3236 {ARB_COLOR_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3237 {ARB_DEPTH_BUFFER_FLOAT, MAKEDWORD_VERSION(3, 0)},
3238 {ARB_FRAMEBUFFER_OBJECT, MAKEDWORD_VERSION(3, 0)},
3239 {ARB_FRAMEBUFFER_SRGB, MAKEDWORD_VERSION(3, 0)},
3240 {ARB_HALF_FLOAT_PIXEL, MAKEDWORD_VERSION(3, 0)},
3241 {ARB_HALF_FLOAT_VERTEX, MAKEDWORD_VERSION(3, 0)},
3242 {ARB_MAP_BUFFER_RANGE, MAKEDWORD_VERSION(3, 0)},
3243 {ARB_TEXTURE_COMPRESSION_RGTC, MAKEDWORD_VERSION(3, 0)},
3244 {ARB_TEXTURE_FLOAT, MAKEDWORD_VERSION(3, 0)},
3245 {ARB_TEXTURE_RG, MAKEDWORD_VERSION(3, 0)},
3246 {EXT_DRAW_BUFFERS2, MAKEDWORD_VERSION(3, 0)},
3247 {EXT_PACKED_FLOAT, MAKEDWORD_VERSION(3, 0)},
3248 {EXT_TEXTURE_ARRAY, MAKEDWORD_VERSION(3, 0)},
3249 {EXT_TEXTURE_INTEGER, MAKEDWORD_VERSION(3, 0)},
3250 {EXT_TEXTURE_SHARED_EXPONENT, MAKEDWORD_VERSION(3, 0)},
3251 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3252 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3253 * enough that reusing the same flag for the new features hurts more
3254 * than it helps. */
3255 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3256 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3257 * are integrated into ARB_framebuffer_object. */
3259 {ARB_COPY_BUFFER, MAKEDWORD_VERSION(3, 1)},
3260 {ARB_DRAW_INSTANCED, MAKEDWORD_VERSION(3, 1)},
3261 {ARB_TEXTURE_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3262 {ARB_UNIFORM_BUFFER_OBJECT, MAKEDWORD_VERSION(3, 1)},
3263 {EXT_TEXTURE_SNORM, MAKEDWORD_VERSION(3, 1)},
3264 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3266 {ARB_DEPTH_CLAMP, MAKEDWORD_VERSION(3, 2)},
3267 {ARB_DRAW_ELEMENTS_BASE_VERTEX, MAKEDWORD_VERSION(3, 2)},
3268 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3269 * core geometry shaders so it's not really correct to expose the
3270 * extension for core-only support. */
3271 {ARB_FRAGMENT_COORD_CONVENTIONS, MAKEDWORD_VERSION(3, 2)},
3272 {ARB_PROVOKING_VERTEX, MAKEDWORD_VERSION(3, 2)},
3273 {ARB_SEAMLESS_CUBE_MAP, MAKEDWORD_VERSION(3, 2)},
3274 {ARB_SYNC, MAKEDWORD_VERSION(3, 2)},
3275 {ARB_TEXTURE_MULTISAMPLE, MAKEDWORD_VERSION(3, 2)},
3276 {ARB_VERTEX_ARRAY_BGRA, MAKEDWORD_VERSION(3, 2)},
3278 {ARB_BLEND_FUNC_EXTENDED, MAKEDWORD_VERSION(3, 3)},
3279 {ARB_EXPLICIT_ATTRIB_LOCATION, MAKEDWORD_VERSION(3, 3)},
3280 {ARB_INSTANCED_ARRAYS, MAKEDWORD_VERSION(3, 3)},
3281 {ARB_SAMPLER_OBJECTS, MAKEDWORD_VERSION(3, 3)},
3282 {ARB_SHADER_BIT_ENCODING, MAKEDWORD_VERSION(3, 3)},
3283 {ARB_TEXTURE_RGB10_A2UI, MAKEDWORD_VERSION(3, 3)},
3284 {ARB_TEXTURE_SWIZZLE, MAKEDWORD_VERSION(3, 3)},
3285 {ARB_TIMER_QUERY, MAKEDWORD_VERSION(3, 3)},
3286 {ARB_VERTEX_TYPE_2_10_10_10_REV, MAKEDWORD_VERSION(3, 3)},
3288 {ARB_DRAW_INDIRECT, MAKEDWORD_VERSION(4, 0)},
3289 {ARB_GPU_SHADER5, MAKEDWORD_VERSION(4, 0)},
3290 {ARB_SAMPLE_SHADING, MAKEDWORD_VERSION(4, 0)},
3291 {ARB_TESSELLATION_SHADER, MAKEDWORD_VERSION(4, 0)},
3292 {ARB_TEXTURE_CUBE_MAP_ARRAY, MAKEDWORD_VERSION(4, 0)},
3293 {ARB_TEXTURE_GATHER, MAKEDWORD_VERSION(4, 0)},
3294 {ARB_TRANSFORM_FEEDBACK2, MAKEDWORD_VERSION(4, 0)},
3295 {ARB_TRANSFORM_FEEDBACK3, MAKEDWORD_VERSION(4, 0)},
3297 {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)},
3298 {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)},
3300 {ARB_BASE_INSTANCE, MAKEDWORD_VERSION(4, 2)},
3301 {ARB_CONSERVATIVE_DEPTH, MAKEDWORD_VERSION(4, 2)},
3302 {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)},
3303 {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)},
3304 {ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)},
3305 {ARB_SHADER_IMAGE_LOAD_STORE, MAKEDWORD_VERSION(4, 2)},
3306 {ARB_SHADING_LANGUAGE_420PACK, MAKEDWORD_VERSION(4, 2)},
3307 {ARB_SHADING_LANGUAGE_PACKING, MAKEDWORD_VERSION(4, 2)},
3308 {ARB_TEXTURE_COMPRESSION_BPTC, MAKEDWORD_VERSION(4, 2)},
3309 {ARB_TEXTURE_STORAGE, MAKEDWORD_VERSION(4, 2)},
3311 {ARB_CLEAR_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3312 {ARB_COMPUTE_SHADER, MAKEDWORD_VERSION(4, 3)},
3313 {ARB_COPY_IMAGE, MAKEDWORD_VERSION(4, 3)},
3314 {ARB_DEBUG_OUTPUT, MAKEDWORD_VERSION(4, 3)},
3315 {ARB_ES3_COMPATIBILITY, MAKEDWORD_VERSION(4, 3)},
3316 {ARB_FRAGMENT_LAYER_VIEWPORT, MAKEDWORD_VERSION(4, 3)},
3317 {ARB_FRAMEBUFFER_NO_ATTACHMENTS, MAKEDWORD_VERSION(4, 3)},
3318 {ARB_INTERNALFORMAT_QUERY2, MAKEDWORD_VERSION(4, 3)},
3319 {ARB_SHADER_IMAGE_SIZE, MAKEDWORD_VERSION(4, 3)},
3320 {ARB_SHADER_STORAGE_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 3)},
3321 {ARB_STENCIL_TEXTURING, MAKEDWORD_VERSION(4, 3)},
3322 {ARB_TEXTURE_BUFFER_RANGE, MAKEDWORD_VERSION(4, 3)},
3323 {ARB_TEXTURE_QUERY_LEVELS, MAKEDWORD_VERSION(4, 3)},
3324 {ARB_TEXTURE_STORAGE_MULTISAMPLE, MAKEDWORD_VERSION(4, 2)},
3325 {ARB_TEXTURE_VIEW, MAKEDWORD_VERSION(4, 3)},
3327 {ARB_BUFFER_STORAGE, MAKEDWORD_VERSION(4, 4)},
3328 {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
3329 {ARB_QUERY_BUFFER_OBJECT, MAKEDWORD_VERSION(4, 4)},
3331 {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
3332 {ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)},
3333 {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
3334 {ARB_SHADER_TEXTURE_IMAGE_SAMPLES, MAKEDWORD_VERSION(4, 5)},
3336 {ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)},
3337 {ARB_POLYGON_OFFSET_CLAMP, MAKEDWORD_VERSION(4, 6)},
3338 {ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)},
3340 struct wined3d_driver_info *driver_info = &adapter->driver_info;
3341 const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
3342 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
3343 const struct wined3d_gpu_description *gpu_description;
3344 struct wined3d_gl_info *gl_info = &adapter->gl_info;
3345 struct wined3d_vertex_caps vertex_caps;
3346 struct fragment_caps fragment_caps;
3347 struct shader_caps shader_caps;
3348 const char *WGL_Extensions = NULL;
3349 enum wined3d_gl_vendor gl_vendor;
3350 DWORD gl_version, gl_ext_emul_mask;
3351 GLint context_profile = 0;
3352 UINT64 vram_bytes = 0;
3353 unsigned int i, j;
3354 HDC hdc;
3356 TRACE("adapter %p.\n", adapter);
3358 gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
3359 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
3360 if (!gl_renderer_str)
3362 ERR("Received a NULL GL_RENDERER.\n");
3363 return FALSE;
3366 gl_vendor_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
3367 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
3368 if (!gl_vendor_str)
3370 ERR("Received a NULL GL_VENDOR.\n");
3371 return FALSE;
3374 /* Parse the GL_VERSION field into major and minor information */
3375 gl_version_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VERSION);
3376 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
3377 if (!gl_version_str)
3379 ERR("Received a NULL GL_VERSION.\n");
3380 return FALSE;
3382 gl_version = wined3d_parse_gl_version(gl_version_str);
3384 load_gl_funcs(gl_info);
3386 memset(gl_info->supported, 0, sizeof(gl_info->supported));
3387 gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
3389 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3391 gl_info->gl_ops.gl.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &context_profile);
3392 checkGLcall("Querying context profile");
3394 if (context_profile & GL_CONTEXT_CORE_PROFILE_BIT)
3395 TRACE("Got a core profile context.\n");
3396 else
3397 gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] = TRUE;
3399 TRACE("GL extensions reported:\n");
3400 if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3402 const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
3404 if (!gl_extensions)
3406 ERR("Received a NULL GL_EXTENSIONS.\n");
3407 return FALSE;
3409 parse_extension_string(gl_info, gl_extensions, gl_extension_map, ARRAY_SIZE(gl_extension_map));
3411 else
3413 enumerate_gl_extensions(gl_info, gl_extension_map, ARRAY_SIZE(gl_extension_map));
3416 hdc = wglGetCurrentDC();
3417 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
3418 if (GL_EXTCALL(wglGetExtensionsStringARB))
3419 WGL_Extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc));
3420 if (!WGL_Extensions)
3421 WARN("WGL extensions not supported.\n");
3422 else
3423 parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, ARRAY_SIZE(wgl_extension_map));
3425 for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
3427 if (!gl_info->supported[core_extensions[i].extension]
3428 && gl_version >= core_extensions[i].min_gl_version)
3430 for (j = 0; j < ARRAY_SIZE(gl_extension_map); ++j)
3431 if (gl_extension_map[j].extension == core_extensions[i].extension)
3432 break;
3434 if (j < ARRAY_SIZE(gl_extension_map))
3436 TRACE("GL CORE: %s support.\n", gl_extension_map[j].extension_string);
3437 gl_info->supported[core_extensions[i].extension] = TRUE;
3439 else
3441 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions[i].extension);
3446 if (gl_info->supported[EXT_BLEND_MINMAX] || gl_info->supported[EXT_BLEND_SUBTRACT])
3447 gl_info->supported[WINED3D_GL_BLEND_EQUATION] = TRUE;
3449 if (gl_version >= MAKEDWORD_VERSION(2, 0))
3451 gl_info->supported[WINED3D_GL_VERSION_2_0] = TRUE;
3452 /* We want to use the core APIs for two-sided stencil in GL 2.0. */
3453 gl_info->supported[EXT_STENCIL_TWO_SIDE] = FALSE;
3455 if (gl_version >= MAKEDWORD_VERSION(3, 2))
3456 gl_info->supported[WINED3D_GL_VERSION_3_2] = TRUE;
3458 /* All the points are actually point sprites in core contexts, the APIs from
3459 * ARB_point_sprite are not supported anymore. */
3460 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3461 gl_info->supported[ARB_POINT_SPRITE] = FALSE;
3463 if (gl_info->supported[APPLE_FENCE])
3465 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
3466 * The apple extension interacts with some other apple exts. Disable the NV
3467 * extension if the apple one is support to prevent confusion in other parts
3468 * of the code. */
3469 gl_info->supported[NV_FENCE] = FALSE;
3471 if (gl_info->supported[APPLE_FLOAT_PIXELS])
3473 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
3475 * The enums are the same:
3476 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
3477 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
3478 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
3479 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
3480 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
3482 if (!gl_info->supported[ARB_TEXTURE_FLOAT])
3484 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
3485 gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
3487 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3489 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
3490 gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
3493 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
3495 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
3496 * functionality. Prefer the ARB extension */
3497 gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
3499 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
3501 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
3502 gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
3504 if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
3506 TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
3507 gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
3509 if (!gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC])
3511 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
3512 gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC] = TRUE;
3514 if (!gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
3516 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
3517 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = TRUE;
3519 if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] && !gl_info->supported[ARB_TEXTURE_RG])
3521 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
3522 gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] = FALSE;
3524 if (gl_info->supported[NV_TEXTURE_SHADER2])
3526 if (gl_info->supported[NV_REGISTER_COMBINERS])
3528 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
3529 * are supported. The nv extensions provide the same functionality as the
3530 * ATI one, and a bit more(signed pixelformats). */
3531 gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
3534 if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
3536 /* If we have full NP2 texture support, disable
3537 * GL_ARB_texture_rectangle because we will never use it.
3538 * This saves a few redundant glDisable calls. */
3539 gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
3541 if (gl_info->supported[ATI_FRAGMENT_SHADER])
3543 /* Disable NV_register_combiners and fragment shader if this is supported.
3544 * generally the NV extensions are preferred over the ATI ones, and this
3545 * extension is disabled if register_combiners and texture_shader2 are both
3546 * supported. So we reach this place only if we have incomplete NV dxlevel 8
3547 * fragment processing support. */
3548 gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
3549 gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
3550 gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
3551 gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
3553 if (gl_info->supported[NV_HALF_FLOAT])
3555 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
3556 gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
3558 if (gl_info->supported[ARB_FRAMEBUFFER_SRGB] && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
3560 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
3561 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
3562 * we never render to sRGB surfaces). */
3563 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
3564 gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
3566 if (gl_info->supported[ARB_OCCLUSION_QUERY])
3568 GLint counter_bits;
3570 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &counter_bits));
3571 TRACE("Occlusion query counter has %d bits.\n", counter_bits);
3572 if (!counter_bits)
3573 gl_info->supported[ARB_OCCLUSION_QUERY] = FALSE;
3575 if (gl_info->supported[ARB_TIMER_QUERY])
3577 GLint counter_bits;
3579 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &counter_bits));
3580 TRACE("Timestamp query counter has %d bits.\n", counter_bits);
3581 if (!counter_bits)
3582 gl_info->supported[ARB_TIMER_QUERY] = FALSE;
3584 if (gl_version >= MAKEDWORD_VERSION(3, 0))
3586 GLint counter_bits;
3588 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = TRUE;
3590 GL_EXTCALL(glGetQueryiv(GL_PRIMITIVES_GENERATED, GL_QUERY_COUNTER_BITS, &counter_bits));
3591 TRACE("Primitives query counter has %d bits.\n", counter_bits);
3592 if (!counter_bits)
3593 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
3595 GL_EXTCALL(glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_QUERY_COUNTER_BITS, &counter_bits));
3596 TRACE("Transform feedback primitives query counter has %d bits.\n", counter_bits);
3597 if (!counter_bits)
3598 gl_info->supported[WINED3D_GL_PRIMITIVE_QUERY] = FALSE;
3600 if (gl_info->supported[ARB_VIEWPORT_ARRAY])
3602 GLint subpixel_bits;
3604 gl_info->gl_ops.gl.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &subpixel_bits);
3605 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits);
3606 if (subpixel_bits < 8 && gl_info->supported[ARB_CLIP_CONTROL])
3608 TRACE("Disabling ARB_clip_control because viewport subpixel bits < 8.\n");
3609 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
3612 if (gl_info->supported[ARB_CLIP_CONTROL] && !gl_info->supported[ARB_VIEWPORT_ARRAY])
3614 /* When using ARB_clip_control we need the float viewport parameters
3615 * introduced by ARB_viewport_array to take care of the shifted pixel
3616 * coordinates. */
3617 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
3618 gl_info->supported[ARB_CLIP_CONTROL] = FALSE;
3620 if (gl_info->supported[ARB_STENCIL_TEXTURING] && !gl_info->supported[ARB_TEXTURE_SWIZZLE])
3622 /* The stencil value needs to be placed in the green channel. */
3623 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
3624 gl_info->supported[ARB_STENCIL_TEXTURING] = FALSE;
3626 if (!gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] && gl_info->supported[EXT_TEXTURE_MIRROR_CLAMP])
3628 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
3629 gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] = TRUE;
3631 if (!gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] && gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
3633 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
3634 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] = TRUE;
3636 if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422])
3638 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
3639 ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
3640 gl_info->supported[APPLE_YCBCR_422] = FALSE;
3642 if (gl_info->supported[ARB_DRAW_INDIRECT] && !gl_info->supported[ARB_BASE_INSTANCE])
3644 /* If ARB_base_instance is not supported the baseInstance field
3645 * in indirect draw parameters must be 0 or behavior is undefined.
3647 WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n");
3648 gl_info->supported[ARB_DRAW_INDIRECT] = FALSE;
3650 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE] && !wined3d_settings.multisample_textures)
3651 gl_info->supported[ARB_TEXTURE_MULTISAMPLE] = FALSE;
3652 if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE] && !gl_info->supported[ARB_TEXTURE_STORAGE_MULTISAMPLE])
3654 WARN("Disabling ARB_texture_multisample because immutable storage is not supported.\n");
3655 gl_info->supported[ARB_TEXTURE_MULTISAMPLE] = FALSE;
3658 wined3d_adapter_init_limits(gl_info, d3d_info);
3660 if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
3661 gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
3663 if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
3665 const char *str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
3666 unsigned int major, minor;
3668 TRACE("GLSL version string: %s.\n", debugstr_a(str));
3670 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
3671 sscanf(str, "%u.%u", &major, &minor);
3672 gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
3673 if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30))
3674 gl_info->supported[WINED3D_GLSL_130] = TRUE;
3677 checkGLcall("extension detection");
3679 adapter->shader_backend = select_shader_backend(gl_info);
3680 adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
3681 adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
3683 d3d_info->limits.max_rt_count = gl_info->limits.buffers;
3684 d3d_info->limits.max_clip_distances = gl_info->limits.user_clip_distances;
3686 adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
3687 d3d_info->vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
3688 d3d_info->limits.vs_version = shader_caps.vs_version;
3689 d3d_info->limits.hs_version = shader_caps.hs_version;
3690 d3d_info->limits.ds_version = shader_caps.ds_version;
3691 d3d_info->limits.gs_version = shader_caps.gs_version;
3692 d3d_info->limits.ps_version = shader_caps.ps_version;
3693 d3d_info->limits.cs_version = shader_caps.cs_version;
3694 d3d_info->limits.vs_uniform_count = shader_caps.vs_uniform_count;
3695 d3d_info->limits.ps_uniform_count = shader_caps.ps_uniform_count;
3696 d3d_info->limits.varying_count = shader_caps.varying_count;
3697 d3d_info->shader_double_precision = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION);
3699 d3d_info->viewport_array_index_any_shader = !!gl_info->supported[ARB_SHADER_VIEWPORT_LAYER_ARRAY];
3701 adapter->vertex_pipe->vp_get_caps(gl_info, &vertex_caps);
3702 d3d_info->xyzrhw = vertex_caps.xyzrhw;
3703 d3d_info->ffp_generic_attributes = vertex_caps.ffp_generic_attributes;
3704 d3d_info->limits.ffp_vertex_blend_matrices = vertex_caps.max_vertex_blend_matrices;
3705 d3d_info->limits.active_light_count = vertex_caps.max_active_lights;
3706 d3d_info->emulated_flatshading = vertex_caps.emulated_flatshading;
3708 adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
3709 d3d_info->limits.ffp_blend_stages = fragment_caps.MaxTextureBlendStages;
3710 d3d_info->limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
3711 d3d_info->shader_color_key = !!(fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_COLOR_KEY);
3712 d3d_info->wined3d_creation_flags = wined3d_creation_flags;
3713 d3d_info->feature_level = feature_level_from_caps(gl_info, &shader_caps, &fragment_caps);
3715 d3d_info->texture_npot = !!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO];
3716 d3d_info->texture_npot_conditional = gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]
3717 || gl_info->supported[ARB_TEXTURE_RECTANGLE];
3719 TRACE("Max texture stages: %u.\n", d3d_info->limits.ffp_blend_stages);
3721 d3d_info->valid_rt_mask = 0;
3722 for (i = 0; i < gl_info->limits.buffers; ++i)
3723 d3d_info->valid_rt_mask |= (1u << i);
3725 if (!d3d_info->shader_color_key)
3727 /* We do not want to deal with re-creating immutable texture storage
3728 * for colour-keying emulation. */
3729 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support colour-keying.\n");
3730 gl_info->supported[ARB_TEXTURE_STORAGE] = FALSE;
3733 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3735 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbuffer;
3736 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbuffer;
3737 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffers;
3738 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffers;
3739 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorage;
3740 gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisample;
3741 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameteriv;
3742 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebuffer;
3743 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebuffer;
3744 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffers;
3745 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffers;
3746 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatus;
3747 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1D;
3748 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2D;
3749 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3D;
3750 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayer;
3751 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbuffer;
3752 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
3753 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameteriv;
3754 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebuffer;
3755 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmap;
3756 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTexture;
3758 else
3760 if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
3762 gl_info->fbo_ops.glIsRenderbuffer = gl_info->gl_ops.ext.p_glIsRenderbufferEXT;
3763 gl_info->fbo_ops.glBindRenderbuffer = gl_info->gl_ops.ext.p_glBindRenderbufferEXT;
3764 gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->gl_ops.ext.p_glDeleteRenderbuffersEXT;
3765 gl_info->fbo_ops.glGenRenderbuffers = gl_info->gl_ops.ext.p_glGenRenderbuffersEXT;
3766 gl_info->fbo_ops.glRenderbufferStorage = gl_info->gl_ops.ext.p_glRenderbufferStorageEXT;
3767 gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->gl_ops.ext.p_glGetRenderbufferParameterivEXT;
3768 gl_info->fbo_ops.glIsFramebuffer = gl_info->gl_ops.ext.p_glIsFramebufferEXT;
3769 gl_info->fbo_ops.glBindFramebuffer = gl_info->gl_ops.ext.p_glBindFramebufferEXT;
3770 gl_info->fbo_ops.glDeleteFramebuffers = gl_info->gl_ops.ext.p_glDeleteFramebuffersEXT;
3771 gl_info->fbo_ops.glGenFramebuffers = gl_info->gl_ops.ext.p_glGenFramebuffersEXT;
3772 gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->gl_ops.ext.p_glCheckFramebufferStatusEXT;
3773 gl_info->fbo_ops.glFramebufferTexture1D = gl_info->gl_ops.ext.p_glFramebufferTexture1DEXT;
3774 gl_info->fbo_ops.glFramebufferTexture2D = gl_info->gl_ops.ext.p_glFramebufferTexture2DEXT;
3775 gl_info->fbo_ops.glFramebufferTexture3D = gl_info->gl_ops.ext.p_glFramebufferTexture3DEXT;
3776 gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->gl_ops.ext.p_glFramebufferRenderbufferEXT;
3777 gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv
3778 = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT;
3779 gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT;
3781 else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
3783 WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
3784 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
3787 if (gl_info->supported[ARB_GEOMETRY_SHADER4])
3789 gl_info->fbo_ops.glFramebufferTexture = gl_info->gl_ops.ext.p_glFramebufferTextureARB;
3790 gl_info->fbo_ops.glFramebufferTextureLayer = gl_info->gl_ops.ext.p_glFramebufferTextureLayerARB;
3792 if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
3794 gl_info->fbo_ops.glBlitFramebuffer = gl_info->gl_ops.ext.p_glBlitFramebufferEXT;
3796 if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
3798 gl_info->fbo_ops.glRenderbufferStorageMultisample
3799 = gl_info->gl_ops.ext.p_glRenderbufferStorageMultisampleEXT;
3803 gl_info->wrap_lookup[WINED3D_TADDRESS_WRAP - WINED3D_TADDRESS_WRAP] = GL_REPEAT;
3804 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR - WINED3D_TADDRESS_WRAP] =
3805 gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
3806 gl_info->wrap_lookup[WINED3D_TADDRESS_CLAMP - WINED3D_TADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
3807 gl_info->wrap_lookup[WINED3D_TADDRESS_BORDER - WINED3D_TADDRESS_WRAP] =
3808 gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
3809 gl_info->wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP] =
3810 gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] ? GL_MIRROR_CLAMP_TO_EDGE : GL_REPEAT;
3812 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3814 GLuint vao;
3816 GL_EXTCALL(glGenVertexArrays(1, &vao));
3817 GL_EXTCALL(glBindVertexArray(vao));
3818 checkGLcall("creating VAO");
3821 gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str, gl_version_str);
3822 TRACE("Guessed GL vendor %#x.\n", gl_vendor);
3824 if (!(gpu_description = query_gpu_description(gl_info, &vram_bytes)))
3826 enum wined3d_pci_vendor vendor;
3827 enum wined3d_pci_device device;
3829 vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
3830 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor);
3832 device = wined3d_guess_card(d3d_info->feature_level, gl_info->glsl_version,
3833 gl_renderer_str, &gl_vendor, &vendor);
3834 TRACE("Guessed device PCI ID 0x%04x.\n", device);
3836 if (!(gpu_description = wined3d_get_gpu_description(vendor, device)))
3838 ERR("Card %04x:%04x not found in driver DB.\n", vendor, device);
3839 return FALSE;
3842 fixup_extensions(gl_info, caps_gl_ctx, gl_renderer_str, gl_vendor,
3843 gpu_description->vendor, gpu_description->device);
3844 wined3d_driver_info_init(driver_info, gpu_description, vram_bytes);
3845 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
3846 driver_info->version_high, driver_info->version_low);
3848 adapter->vram_bytes = driver_info->vram_bytes;
3849 adapter->vram_bytes_used = 0;
3850 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
3852 gl_ext_emul_mask = adapter->vertex_pipe->vp_get_emul_mask(gl_info)
3853 | adapter->fragment_pipe->get_emul_mask(gl_info);
3854 if (gl_ext_emul_mask & GL_EXT_EMUL_ARB_MULTITEXTURE)
3855 install_gl_compat_wrapper(gl_info, ARB_MULTITEXTURE);
3856 if (gl_ext_emul_mask & GL_EXT_EMUL_EXT_FOG_COORD)
3857 install_gl_compat_wrapper(gl_info, EXT_FOG_COORD);
3859 return TRUE;
3862 static void WINE_GLAPI invalid_func(const void *data)
3864 ERR("Invalid vertex attribute function called.\n");
3865 DebugBreak();
3868 static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
3870 ERR("Invalid texcoord function called.\n");
3871 DebugBreak();
3874 static void WINE_GLAPI invalid_generic_attrib_func(GLuint idx, const void *data)
3876 ERR("Invalid attribute function called.\n");
3877 DebugBreak();
3880 /* Helper functions for providing vertex data to OpenGL. The arrays are
3881 * initialised based on the extension detection and are used in
3882 * draw_primitive_immediate_mode(). */
3883 static void WINE_GLAPI position_d3dcolor(const void *data)
3885 DWORD pos = *((const DWORD *)data);
3887 FIXME("Add a test for fixed function position from d3dcolor type.\n");
3888 context_get_current()->gl_info->gl_ops.gl.p_glVertex4s(D3DCOLOR_B_R(pos),
3889 D3DCOLOR_B_G(pos),
3890 D3DCOLOR_B_B(pos),
3891 D3DCOLOR_B_A(pos));
3894 static void WINE_GLAPI position_float4(const void *data)
3896 const GLfloat *pos = data;
3898 if (pos[3] != 0.0f && pos[3] != 1.0f)
3900 float w = 1.0f / pos[3];
3902 context_get_current()->gl_info->gl_ops.gl.p_glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w);
3904 else
3906 context_get_current()->gl_info->gl_ops.gl.p_glVertex3fv(pos);
3910 static void WINE_GLAPI diffuse_d3dcolor(const void *data)
3912 DWORD diffuseColor = *((const DWORD *)data);
3914 context_get_current()->gl_info->gl_ops.gl.p_glColor4ub(D3DCOLOR_B_R(diffuseColor),
3915 D3DCOLOR_B_G(diffuseColor),
3916 D3DCOLOR_B_B(diffuseColor),
3917 D3DCOLOR_B_A(diffuseColor));
3920 static void WINE_GLAPI specular_d3dcolor(const void *data)
3922 DWORD specularColor = *((const DWORD *)data);
3923 GLubyte d[] =
3925 D3DCOLOR_B_R(specularColor),
3926 D3DCOLOR_B_G(specularColor),
3927 D3DCOLOR_B_B(specularColor)
3930 context_get_current()->gl_info->gl_ops.ext.p_glSecondaryColor3ubvEXT(d);
3933 static void WINE_GLAPI warn_no_specular_func(const void *data)
3935 WARN("GL_EXT_secondary_color not supported.\n");
3938 static void WINE_GLAPI generic_d3dcolor(GLuint idx, const void *data)
3940 DWORD color = *((const DWORD *)data);
3942 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nub(idx,
3943 D3DCOLOR_B_R(color), D3DCOLOR_B_G(color),
3944 D3DCOLOR_B_B(color), D3DCOLOR_B_A(color));
3947 static void WINE_GLAPI generic_short2n(GLuint idx, const void *data)
3949 const GLshort s[] = {((const GLshort *)data)[0], ((const GLshort *)data)[1], 0, 1};
3951 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nsv(idx, s);
3954 static void WINE_GLAPI generic_ushort2n(GLuint idx, const void *data)
3956 const GLushort s[] = {((const GLushort *)data)[0], ((const GLushort *)data)[1], 0, 1};
3958 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4Nusv(idx, s);
3961 static void WINE_GLAPI generic_float16_2(GLuint idx, const void *data)
3963 float x = float_16_to_32(((const unsigned short *)data) + 0);
3964 float y = float_16_to_32(((const unsigned short *)data) + 1);
3966 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib2f(idx, x, y);
3969 static void WINE_GLAPI generic_float16_4(GLuint idx, const void *data)
3971 float x = float_16_to_32(((const unsigned short *)data) + 0);
3972 float y = float_16_to_32(((const unsigned short *)data) + 1);
3973 float z = float_16_to_32(((const unsigned short *)data) + 2);
3974 float w = float_16_to_32(((const unsigned short *)data) + 3);
3976 context_get_current()->gl_info->gl_ops.ext.p_glVertexAttrib4f(idx, x, y, z, w);
3979 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter *adapter)
3981 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
3982 struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
3983 struct wined3d_ffp_attrib_ops *ops = &d3d_info->ffp_attrib_ops;
3984 unsigned int i;
3986 for (i = 0; i < WINED3D_FFP_EMIT_COUNT; ++i)
3988 ops->position[i] = invalid_func;
3989 ops->diffuse[i] = invalid_func;
3990 ops->specular[i] = invalid_func;
3991 ops->normal[i] = invalid_func;
3992 ops->texcoord[i] = invalid_texcoord_func;
3993 ops->generic[i] = invalid_generic_attrib_func;
3996 ops->position[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex3fv;
3997 if (!d3d_info->xyzrhw)
3998 ops->position[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
3999 else
4000 ops->position[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex4fv;
4001 ops->position[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
4002 ops->position[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glVertex2sv;
4004 ops->diffuse[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor3fv;
4005 ops->diffuse[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4fv;
4006 ops->diffuse[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
4007 ops->diffuse[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4ubv;
4008 ops->diffuse[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4sv;
4009 ops->diffuse[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glColor4usv;
4011 /* No 4 component entry points here. */
4012 if (gl_info->supported[EXT_SECONDARY_COLOR])
4013 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)GL_EXTCALL(glSecondaryColor3fvEXT);
4014 else
4015 ops->specular[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
4016 if (gl_info->supported[EXT_SECONDARY_COLOR])
4017 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
4018 else
4019 ops->specular[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
4021 /* Only 3 component entry points here. Test how others behave. Float4
4022 * normals are used by one of our tests, trying to pass it to the pixel
4023 * shader, which fails on Windows. */
4024 ops->normal[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
4025 /* Just ignore the 4th value. */
4026 ops->normal[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_attrib_func)gl_info->gl_ops.gl.p_glNormal3fv;
4028 ops->texcoord[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord1fvARB;
4029 ops->texcoord[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2fvARB;
4030 ops->texcoord[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord3fvARB;
4031 ops->texcoord[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4fvARB;
4032 ops->texcoord[WINED3D_FFP_EMIT_SHORT2] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2svARB;
4033 ops->texcoord[WINED3D_FFP_EMIT_SHORT4] = (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4svARB;
4034 if (gl_info->supported[NV_HALF_FLOAT])
4036 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
4037 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_2] =
4038 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord2hvNV;
4039 ops->texcoord[WINED3D_FFP_EMIT_FLOAT16_4] =
4040 (wined3d_ffp_texcoord_func)gl_info->gl_ops.ext.p_glMultiTexCoord4hvNV;
4043 ops->generic[WINED3D_FFP_EMIT_FLOAT1] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib1fv;
4044 ops->generic[WINED3D_FFP_EMIT_FLOAT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2fv;
4045 ops->generic[WINED3D_FFP_EMIT_FLOAT3] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib3fv;
4046 ops->generic[WINED3D_FFP_EMIT_FLOAT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4fv;
4047 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
4048 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] = generic_d3dcolor;
4049 else
4050 ops->generic[WINED3D_FFP_EMIT_D3DCOLOR] =
4051 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
4052 ops->generic[WINED3D_FFP_EMIT_UBYTE4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4ubv;
4053 ops->generic[WINED3D_FFP_EMIT_SHORT2] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2sv;
4054 ops->generic[WINED3D_FFP_EMIT_SHORT4] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4sv;
4055 ops->generic[WINED3D_FFP_EMIT_UBYTE4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nubv;
4056 ops->generic[WINED3D_FFP_EMIT_SHORT2N] = generic_short2n;
4057 ops->generic[WINED3D_FFP_EMIT_SHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nsv;
4058 ops->generic[WINED3D_FFP_EMIT_USHORT2N] = generic_ushort2n;
4059 ops->generic[WINED3D_FFP_EMIT_USHORT4N] = (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4Nusv;
4060 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
4062 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] =
4063 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib2hvNV;
4064 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] =
4065 (wined3d_generic_attrib_func)gl_info->gl_ops.ext.p_glVertexAttrib4hvNV;
4067 else
4069 ops->generic[WINED3D_FFP_EMIT_FLOAT16_2] = generic_float16_2;
4070 ops->generic[WINED3D_FFP_EMIT_FLOAT16_4] = generic_float16_4;
4074 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc)
4076 const struct wined3d_gl_info *gl_info = &adapter->gl_info;
4077 int i;
4079 if (gl_info->supported[WGL_ARB_PIXEL_FORMAT])
4081 UINT attrib_count = 0;
4082 GLint cfg_count;
4083 int attribs[11];
4084 int values[11];
4085 int attribute;
4087 attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
4088 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, 0, 0, 1, &attribute, &cfg_count));
4090 adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
4091 attribs[attrib_count++] = WGL_RED_BITS_ARB;
4092 attribs[attrib_count++] = WGL_GREEN_BITS_ARB;
4093 attribs[attrib_count++] = WGL_BLUE_BITS_ARB;
4094 attribs[attrib_count++] = WGL_ALPHA_BITS_ARB;
4095 attribs[attrib_count++] = WGL_COLOR_BITS_ARB;
4096 attribs[attrib_count++] = WGL_DEPTH_BITS_ARB;
4097 attribs[attrib_count++] = WGL_STENCIL_BITS_ARB;
4098 attribs[attrib_count++] = WGL_DRAW_TO_WINDOW_ARB;
4099 attribs[attrib_count++] = WGL_PIXEL_TYPE_ARB;
4100 attribs[attrib_count++] = WGL_DOUBLE_BUFFER_ARB;
4101 attribs[attrib_count++] = WGL_AUX_BUFFERS_ARB;
4103 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
4105 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
4106 int format_id = i + 1;
4108 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, attrib_count, attribs, values)))
4109 continue;
4111 cfg->iPixelFormat = format_id;
4112 cfg->redSize = values[0];
4113 cfg->greenSize = values[1];
4114 cfg->blueSize = values[2];
4115 cfg->alphaSize = values[3];
4116 cfg->colorSize = values[4];
4117 cfg->depthSize = values[5];
4118 cfg->stencilSize = values[6];
4119 cfg->windowDrawable = values[7];
4120 cfg->iPixelType = values[8];
4121 cfg->doubleBuffer = values[9];
4122 cfg->auxBuffers = values[10];
4124 cfg->numSamples = 0;
4125 /* Check multisample support. */
4126 if (gl_info->supported[ARB_MULTISAMPLE])
4128 int attribs[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
4129 int values[2];
4131 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc, format_id, 0, 2, attribs, values)))
4133 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
4134 * multisampling is supported. values[1] = number of
4135 * multisample buffers. */
4136 if (values[0])
4137 cfg->numSamples = values[1];
4141 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4142 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
4143 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
4144 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
4145 cfg->depthSize, cfg->stencilSize, cfg->numSamples, cfg->windowDrawable);
4147 ++adapter->cfg_count;
4150 else
4152 int cfg_count;
4154 cfg_count = DescribePixelFormat(dc, 0, 0, 0);
4155 adapter->cfgs = heap_calloc(cfg_count, sizeof(*adapter->cfgs));
4157 for (i = 0, adapter->cfg_count = 0; i < cfg_count; ++i)
4159 struct wined3d_pixel_format *cfg = &adapter->cfgs[adapter->cfg_count];
4160 PIXELFORMATDESCRIPTOR pfd;
4161 int format_id = i + 1;
4163 if (!DescribePixelFormat(dc, format_id, sizeof(pfd), &pfd))
4164 continue;
4166 /* We only want HW acceleration using an OpenGL ICD driver.
4167 * PFD_GENERIC_FORMAT = slow OpenGL 1.1 GDI software rendering.
4168 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
4169 * driver (e.g. 3dfx minigl). */
4170 if (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
4172 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id);
4173 continue;
4176 cfg->iPixelFormat = format_id;
4177 cfg->redSize = pfd.cRedBits;
4178 cfg->greenSize = pfd.cGreenBits;
4179 cfg->blueSize = pfd.cBlueBits;
4180 cfg->alphaSize = pfd.cAlphaBits;
4181 cfg->colorSize = pfd.cColorBits;
4182 cfg->depthSize = pfd.cDepthBits;
4183 cfg->stencilSize = pfd.cStencilBits;
4184 cfg->windowDrawable = (pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
4185 cfg->iPixelType = (pfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
4186 cfg->doubleBuffer = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
4187 cfg->auxBuffers = pfd.cAuxBuffers;
4188 cfg->numSamples = 0;
4190 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4191 "depth=%d, stencil=%d, windowDrawable=%d\n",
4192 cfg->iPixelFormat, cfg->iPixelType, cfg->doubleBuffer,
4193 cfg->redSize, cfg->greenSize, cfg->blueSize, cfg->alphaSize,
4194 cfg->depthSize, cfg->stencilSize, cfg->windowDrawable);
4196 ++adapter->cfg_count;
4201 static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
4203 wined3d_adapter_gl_create_context,
4206 BOOL wined3d_adapter_gl_init(struct wined3d_adapter *adapter, DWORD wined3d_creation_flags)
4208 static const DWORD supported_gl_versions[] =
4210 MAKEDWORD_VERSION(4, 4),
4211 MAKEDWORD_VERSION(3, 2),
4212 MAKEDWORD_VERSION(1, 0),
4214 struct wined3d_gl_info *gl_info = &adapter->gl_info;
4215 struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
4216 unsigned int i;
4218 TRACE("adapter %p, wined3d_creation_flags %#x.\n", adapter, wined3d_creation_flags);
4220 /* Dynamically load all GL core functions */
4221 #ifdef USE_WIN32_OPENGL
4223 HMODULE mod_gl = GetModuleHandleA("opengl32.dll");
4224 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
4225 ALL_WGL_FUNCS
4226 #undef USE_GL_FUNC
4227 gl_info->gl_ops.wgl.p_wglSwapBuffers = (void *)GetProcAddress(mod_gl, "wglSwapBuffers");
4228 gl_info->gl_ops.wgl.p_wglGetPixelFormat = (void *)GetProcAddress(mod_gl, "wglGetPixelFormat");
4230 #else
4231 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
4233 HDC hdc = GetDC( 0 );
4234 const struct opengl_funcs *wgl_driver = __wine_get_wgl_driver( hdc, WINE_WGL_DRIVER_VERSION );
4235 ReleaseDC( 0, hdc );
4236 if (!wgl_driver || wgl_driver == (void *)-1) return FALSE;
4237 gl_info->gl_ops.wgl = wgl_driver->wgl;
4238 gl_info->gl_ops.gl = wgl_driver->gl;
4240 #endif
4242 glEnableWINE = gl_info->gl_ops.gl.p_glEnable;
4243 glDisableWINE = gl_info->gl_ops.gl.p_glDisable;
4245 if (!wined3d_caps_gl_ctx_create(adapter, &caps_gl_ctx))
4247 ERR("Failed to get a GL context for adapter %p.\n", adapter);
4248 return FALSE;
4251 for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
4253 if (supported_gl_versions[i] <= wined3d_settings.max_gl_version)
4254 break;
4256 if (i == ARRAY_SIZE(supported_gl_versions))
4258 ERR_(winediag)("Requested invalid GL version %u.%u.\n",
4259 wined3d_settings.max_gl_version >> 16, wined3d_settings.max_gl_version & 0xffff);
4260 i = ARRAY_SIZE(supported_gl_versions) - 1;
4263 for (; i < ARRAY_SIZE(supported_gl_versions); ++i)
4265 gl_info->selected_gl_version = supported_gl_versions[i];
4267 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx, gl_info))
4268 break;
4270 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
4271 supported_gl_versions[i] >> 16, supported_gl_versions[i] & 0xffff);
4274 if (!wined3d_adapter_init_gl_caps(adapter, &caps_gl_ctx, wined3d_creation_flags))
4276 ERR("Failed to initialize GL caps for adapter %p.\n", adapter);
4277 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
4278 return FALSE;
4281 if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
4282 ERR_(winediag)("You are using the backbuffer for offscreen rendering. "
4283 "This is unsupported, and will be removed in a future version.\n");
4285 wined3d_adapter_init_fb_cfgs(adapter, caps_gl_ctx.dc);
4286 /* We haven't found any suitable formats. This should only happen in
4287 * case of GDI software rendering, which is pretty useless anyway. */
4288 if (!adapter->cfg_count)
4290 WARN("No suitable pixel formats found.\n");
4291 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
4292 heap_free(adapter->cfgs);
4293 return FALSE;
4296 if (!wined3d_adapter_gl_init_format_info(adapter, &caps_gl_ctx))
4298 ERR("Failed to initialize GL format info.\n");
4299 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
4300 heap_free(adapter->cfgs);
4301 return FALSE;
4304 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx);
4306 wined3d_adapter_init_ffp_attrib_ops(adapter);
4307 adapter->adapter_ops = &wined3d_adapter_gl_ops;
4309 return TRUE;