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.)
This commit is contained in:
wm4 2012-12-27 17:08:17 +01:00
parent 56382c91e4
commit 1e56e68701
1 changed files with 20 additions and 11 deletions

View File

@ -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);