summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2011-01-30 04:52:31 +0800
committerChia-I Wu <olv@lunarg.com>2011-01-30 04:55:08 +0800
commitf36cba6cf3d51a3937d3bb429609d258399751a0 (patch)
treeb80cc3759790e454846507a3076dd813af58d2b0
parentb825e4955243b8ecb57e58afafd8b2286fdd4369 (diff)
egl: Make the transition to built-in drivers more smooth.
When the user sets EGL_DRIVER to egl_dri2 (or egl_glx), make sure the built-in driver is used. The user might leave the outdated egl_dri2.so (or egl_glx.so) on the filesystem and we do not want to load it.
-rw-r--r--src/egl/main/egldriver.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index e133c220f5..b75e8b6a2c 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -437,6 +437,7 @@ _eglAddUserDriver(void)
{
const char *search_path = _eglGetSearchPath();
char *env;
+ size_t name_len = 0;
env = getenv("EGL_DRIVER");
#if defined(_EGL_OS_UNIX)
@@ -448,21 +449,39 @@ _eglAddUserDriver(void)
env = NULL;
}
}
+ else if (env) {
+ char *suffix = strchr(env, '.');
+ name_len = (suffix) ? suffix - env : strlen(env);
+ }
+#else
+ if (env)
+ name_len = strlen(env);
#endif /* _EGL_OS_UNIX */
- if (env) {
+
+ /*
+ * Try built-in drivers first if we know the driver name. This makes sure
+ * we do not load the outdated external driver that is still on the
+ * filesystem.
+ */
+ if (name_len) {
_EGLModule *mod;
EGLint i;
- /* env can be a path */
- _eglPreloadForEach(search_path, _eglLoaderFile, (void *) env);
- /* or the name of a built-in driver */
for (i = 0; _eglBuiltInDrivers[i].name; i++) {
- if (!strcmp(_eglBuiltInDrivers[i].name, env)) {
+ if (strlen(_eglBuiltInDrivers[i].name) == name_len &&
+ !strncmp(_eglBuiltInDrivers[i].name, env, name_len)) {
mod = _eglAddModule(env);
if (mod)
mod->BuiltIn = _eglBuiltInDrivers[i].main;
+
+ return EGL_TRUE;
}
}
+ }
+
+ /* otherwise, treat env as a path */
+ if (env) {
+ _eglPreloadForEach(search_path, _eglLoaderFile, (void *) env);
return EGL_TRUE;
}