summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-11-15 13:54:49 -0800
committerEric Anholt <[email protected]>2018-11-16 17:49:17 -0800
commitd971a4230d54069c996bca78b6ed6a6a23377821 (patch)
tree2d9c29c0c0df5405a0bad5b2c7860bcc614069a2 /src/egl
parentcc198157382a988590b0288d287281139c5f73e6 (diff)
loader: Factor out the common driver opening logic from each loader.
I copied the code from egl_dri2.c, but the functionality was equivalent between all the loaders other than their particular environment variables. v2: Drop the logging function equivalent to loader_default_logger() (requested by Eric, Emil). Move the SCons workaround across. Drop the now-unused driGetDriverExtensions() declaration that was lost in a rebase. Reviewed-by: Eric Engestrom <[email protected]> (v1) Reviewed-by: Emil Velikov <[email protected]> (v1)
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/Makefile.am3
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c75
-rw-r--r--src/egl/meson.build3
3 files changed, 8 insertions, 73 deletions
diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
index 24a8e96a8e1..7269912d96f 100644
--- a/src/egl/Makefile.am
+++ b/src/egl/Makefile.am
@@ -119,8 +119,7 @@ AM_CFLAGS += \
-I$(top_srcdir)/src/egl/drivers/dri2 \
-I$(top_srcdir)/src/gbm/backends/dri \
-I$(top_builddir)/src/egl/wayland/wayland-drm \
- -I$(top_srcdir)/src/egl/wayland/wayland-drm \
- -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\"
+ -I$(top_srcdir)/src/egl/wayland/wayland-drm
nodist_libEGL_common_la_SOURCES = \
$(dri2_backend_GENERATED_FILES)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index af2b3a6fa8f..0be9235835d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -483,75 +483,14 @@ static const __DRIextension **
dri2_open_driver(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- const __DRIextension **extensions = NULL;
- char path[PATH_MAX], *search_paths, *next, *end;
- char *get_extensions_name;
- const __DRIextension **(*get_extensions)(void);
-
- search_paths = NULL;
- if (geteuid() == getuid()) {
- /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
- search_paths = getenv("LIBGL_DRIVERS_PATH");
- }
- if (search_paths == NULL)
- search_paths = DEFAULT_DRIVER_DIR;
-
- dri2_dpy->driver = NULL;
- end = search_paths + strlen(search_paths);
- for (char *p = search_paths; p < end; p = next + 1) {
- int len;
- next = strchr(p, ':');
- if (next == NULL)
- next = end;
-
- len = next - p;
-#if GLX_USE_TLS
- snprintf(path, sizeof path,
- "%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name);
- dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
-#endif
- if (dri2_dpy->driver == NULL) {
- snprintf(path, sizeof path,
- "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name);
- dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
- if (dri2_dpy->driver == NULL)
- _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
- }
- /* not need continue to loop all paths once the driver is found */
- if (dri2_dpy->driver != NULL)
- break;
- }
-
- if (dri2_dpy->driver == NULL) {
- _eglLog(_EGL_WARNING,
- "DRI2: failed to open %s (search paths %s)",
- dri2_dpy->driver_name, search_paths);
- return NULL;
- }
-
- _eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path);
-
- get_extensions_name = loader_get_extensions_name(dri2_dpy->driver_name);
- if (get_extensions_name) {
- get_extensions = dlsym(dri2_dpy->driver, get_extensions_name);
- if (get_extensions) {
- extensions = get_extensions();
- } else {
- _eglLog(_EGL_DEBUG, "driver does not expose %s(): %s\n",
- get_extensions_name, dlerror());
- }
- free(get_extensions_name);
- }
-
- if (!extensions)
- extensions = dlsym(dri2_dpy->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- _eglLog(_EGL_WARNING,
- "DRI2: driver exports no extensions (%s)", dlerror());
- dlclose(dri2_dpy->driver);
- }
+ static const char *search_path_vars[] = {
+ "LIBGL_DRIVERS_PATH",
+ NULL,
+ };
- return extensions;
+ return loader_open_driver(dri2_dpy->driver_name,
+ &dri2_dpy->driver,
+ search_path_vars);
}
EGLBoolean
diff --git a/src/egl/meson.build b/src/egl/meson.build
index 8c0ffea8b40..372842967d3 100644
--- a/src/egl/meson.build
+++ b/src/egl/meson.build
@@ -93,9 +93,6 @@ if with_dri2
'drivers/dri2/egl_dri2.h',
'drivers/dri2/egl_dri2_fallbacks.h',
)
- c_args_for_egl += [
- '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_search_path),
- ]
if with_platform_x11
files_egl += files('drivers/dri2/platform_x11.c')