if (!drv) {
_eglPreloadDrivers();
drv = _eglMatchDriver(disp);
- if (!drv)
- RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
+ /* Initialize the particular display now */
+ if (drv && !drv->API.Initialize(drv, disp, &major_int, &minor_int))
+ RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
}
-
- /* Initialize the particular display now */
- if (!drv->API.Initialize(drv, disp, &major_int, &minor_int))
- RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
+ if (!drv)
+ /* Load and initialize the first default driver that works */
+ drv = _eglLoadDefaultDriver(disp, &major_int, &minor_int);
+ if (!drv)
+ RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
disp->APImajor = major_int;
disp->APIminor = minor_int;
/* XXX Need to decide how to do dynamic name lookup on Windows */
-static const char DefaultDriverName[] = "TBD";
+static const char DefaultDriverNames[] = {
+ "TBD",
+};
typedef HMODULE lib_handle;
#elif defined(_EGL_PLATFORM_POSIX)
-static const char DefaultDriverName[] = "egl_glx";
+static const char *DefaultDriverNames[] = {
+ "egl_dri2",
+ "egl_glx"
+};
typedef void * lib_handle;
}
-/**
- * Preload the default driver.
- */
-static EGLBoolean
-_eglPreloadDefaultDriver(void)
-{
- return (_eglPreloadForEach(_eglGetSearchPath(),
- _eglLoaderFile, (void *) DefaultDriverName) > 0);
-}
-
-
/**
* Preload drivers.
*
}
loaded = (_eglPreloadUserDriver() ||
- _eglPreloadDisplayDrivers() ||
- _eglPreloadDefaultDriver());
+ _eglPreloadDisplayDrivers());
_eglUnlockMutex(_eglGlobal.Mutex);
return loaded;
}
-
/**
* Unload preloaded drivers.
*/
_eglGlobal.NumDrivers = 0;
}
+_EGLDriver *
+_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ _EGLDriver *drv = NULL;
+ int i;
+
+ _eglLockMutex(_eglGlobal.Mutex);
+
+ for (i = 0; i < ARRAY_SIZE(DefaultDriverNames); i++) {
+ _eglPreloadForEach(_eglGetSearchPath(),
+ _eglLoaderFile, (void *) DefaultDriverNames[i]);
+ if (_eglGlobal.NumDrivers == 0)
+ continue;
+ drv = _eglGlobal.Drivers[0];
+ if (drv->API.Initialize(drv, dpy, major, minor))
+ break;
+ _eglUnloadDrivers();
+ }
+
+ _eglUnlockMutex(_eglGlobal.Mutex);
+
+ return drv;
+}
+
/**
* Plug all the available fallback routines into the given driver's