From 1e56e68701363f38ae008d2b243dc2476a2f4943 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Dec 2012 17:08:17 +0100 Subject: gl_common: properly reject old OpenGL versions The extension checking logic was broken, which reported OpenGL 3 if the OpenGL .so exported OpenGL 3-only symbols, even if the reported OpenGL version is below 3.0. Fix it and simplify the code a bit. Also never fail hard if required functions are not found. The caller should check the capability flags instead. Give up on the idea that we should print a warning if essential functions are not found (makes loading of ancient legacy-only extensions easier). This was experienced with the following version strings: OpenGL vendor string: Intel Open Source Technology Center OpenGL renderer string: Mesa DRI Intel(R) 915GM x86/MMX/SSE2 OpenGL version string: 1.4 Mesa 9.0.1 (Possibly reports a very old version because it has no GLSL support, and thus isn't even GL 2.0 compliant.) --- video/out/gl_common.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'video') diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 06c208f36e..00e21ff312 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -655,11 +655,20 @@ static void getFunctions(GL *gl, void *(*getProcAddress)(const GLubyte *), if (gl3 && section->ver_removed && gl->version >= section->ver_removed) continue; - bool must_exist = section->ver_core && gl->version >= section->ver_core - && !section->partial_ok; + // NOTE: Function entrypoints can exist, even if they do not work. + // We must always check extension strings and versions. - if (!must_exist && section->extension && - !strstr(gl->extensions, section->extension)) + bool exists = false; + if (section->ver_core) + exists = gl->version >= section->ver_core; + + if (section->extension && strstr(gl->extensions, section->extension)) + exists = true; + + if (section->partial_ok) + exists = true; // possibly + + if (!exists) continue; void *loaded[MAX_FN_COUNT] = {0}; @@ -677,13 +686,13 @@ static void getFunctions(GL *gl, void *(*getProcAddress)(const GLubyte *), ptr = fn->fallback; if (!ptr) { all_loaded = false; - if (must_exist) { - // Either we or the driver are not conforming to OpenGL. - mp_msg(MSGT_VO, MSGL_ERR, "[gl] Required function '%s' not " - "found.\n", fn->funcnames[0]); - talloc_free_children(gl); - *gl = (GL) {0}; - return; + if (!section->partial_ok) { + mp_msg(MSGT_VO, MSGL_V, "[gl] Required function '%s' not " + "found for %s/%d.%d.\n", fn->funcnames[0], + section->extension ? section->extension : "native", + MPGL_VER_GET_MAJOR(section->ver_core), + MPGL_VER_GET_MINOR(section->ver_core)); + break; } } assert(i < MAX_FN_COUNT); -- cgit v1.2.3