/* XXX Need to decide how to do dynamic name lookup on Windows */
static const char *DefaultDriverNames[] = {
- "egl_gallium_swrast"
+ "egl_gallium"
};
typedef HMODULE lib_handle;
static const char *DefaultDriverNames[] = {
+ "egl_gallium",
"egl_dri2",
"egl_glx"
};
#endif
-#define NUM_PROBE_CACHE_SLOTS 8
-static struct {
- EGLint keys[NUM_PROBE_CACHE_SLOTS];
- const void *values[NUM_PROBE_CACHE_SLOTS];
-} _eglProbeCache;
-
-
/**
* Open the named driver and find its bootstrap function: _eglMain().
*/
}
-/**
- * A loader function for use with _eglPreloadForEach. The loader data is the
- * pattern (prefix) of the files to look for.
- */
-static EGLBoolean
-_eglLoaderPattern(const char *dir, size_t len, void *loader_data)
-{
-#if defined(_EGL_OS_UNIX)
- const char *prefix, *suffix;
- size_t prefix_len, suffix_len;
- DIR *dirp;
- struct dirent *dirent;
- char path[1024];
-
- if (len + 2 > sizeof(path))
- return EGL_TRUE;
- if (len) {
- memcpy(path, dir, len);
- path[len++] = '/';
- }
- path[len] = '\0';
-
- dirp = opendir(path);
- if (!dirp)
- return EGL_TRUE;
-
- prefix = (const char *) loader_data;
- prefix_len = strlen(prefix);
- suffix = library_suffix();
- suffix_len = (suffix) ? strlen(suffix) : 0;
-
- while ((dirent = readdir(dirp))) {
- _EGLDriver *drv;
- size_t dirent_len = strlen(dirent->d_name);
- const char *p;
-
- /* match the prefix */
- if (strncmp(dirent->d_name, prefix, prefix_len) != 0)
- continue;
- /* match the suffix */
- if (suffix) {
- p = dirent->d_name + dirent_len - suffix_len;
- if (p < dirent->d_name || strcmp(p, suffix) != 0)
- continue;
- }
-
- /* make a full path and load the driver */
- if (len + dirent_len + 1 <= sizeof(path)) {
- strcpy(path + len, dirent->d_name);
- drv = _eglLoadDriver(path, NULL);
- if (drv)
- _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv;
- }
- }
-
- closedir(dirp);
-
- return EGL_TRUE;
-#else /* _EGL_OS_UNIX */
- /* stop immediately */
- return EGL_FALSE;
-#endif
-}
-
-
/**
* Run the preload function on each driver directory and return the number of
* drivers loaded.
}
-/**
- * Preload Gallium drivers.
- *
- * FIXME This makes libEGL a memory hog if an user driver is not specified and
- * there are many Gallium drivers
- */
-static EGLBoolean
-_eglPreloadGalliumDrivers(void)
-{
- return (_eglPreloadForEach(_eglGetSearchPath(),
- _eglLoaderPattern, (void *) "egl_gallium_") > 0);
-}
-
-
/**
* Preload drivers.
*
return EGL_TRUE;
}
- loaded = (_eglPreloadUserDriver() ||
- _eglPreloadGalliumDrivers());
+ loaded = _eglPreloadUserDriver();
_eglUnlockMutex(_eglGlobal.Mutex);
_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDriver *drv = NULL;
+ EGLBoolean ok;
int i;
_eglLockMutex(_eglGlobal.Mutex);
if (_eglGlobal.NumDrivers == 0)
continue;
drv = _eglGlobal.Drivers[0];
- if (drv->API.Initialize(drv, dpy, major, minor))
- break;
+
+ _eglUnlockMutex(_eglGlobal.Mutex);
+ ok = drv->API.Initialize(drv, dpy, major, minor);
+ _eglLockMutex(_eglGlobal.Mutex);
+ if (ok)
+ break;
+
_eglUnloadDrivers();
- }
+ }
_eglUnlockMutex(_eglGlobal.Mutex);
const char *search_path = _eglGetSearchPath();
_eglPreloadForEach(search_path, callback, callback_data);
}
-
-
-/**
- * Set the probe cache at the given key.
- *
- * A key, instead of a _EGLDriver, is used to allow the probe cache to be share
- * by multiple drivers.
- */
-void
-_eglSetProbeCache(EGLint key, const void *val)
-{
- EGLint idx;
-
- for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) {
- if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key)
- break;
- }
- assert(key > 0);
- assert(idx < NUM_PROBE_CACHE_SLOTS);
-
- _eglProbeCache.keys[idx] = key;
- _eglProbeCache.values[idx] = val;
-}
-
-
-/**
- * Return the probe cache at the given key.
- */
-const void *
-_eglGetProbeCache(EGLint key)
-{
- EGLint idx;
-
- for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) {
- if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key)
- break;
- }
-
- return (idx < NUM_PROBE_CACHE_SLOTS && _eglProbeCache.keys[idx] == key) ?
- _eglProbeCache.values[idx] : NULL;
-}