summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c56
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h3
-rw-r--r--src/egl/drivers/dri2/platform_x11.c4
3 files changed, 44 insertions, 19 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3d5827e15a1..a38bff5711d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -334,8 +334,8 @@ dri2_bind_extensions(struct dri2_egl_display *dri2_dpy,
return ret;
}
-EGLBoolean
-dri2_load_driver(_EGLDisplay *disp)
+static const __DRIextension **
+dri2_open_driver(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy = disp->DriverData;
const __DRIextension **extensions;
@@ -374,9 +374,9 @@ dri2_load_driver(_EGLDisplay *disp)
if (dri2_dpy->driver == NULL) {
_eglLog(_EGL_WARNING,
- "DRI2: failed to open any driver (search paths %s)",
- search_paths);
- return EGL_FALSE;
+ "DRI2: failed to open %s (search paths %s)",
+ dri2_dpy->driver_name, search_paths);
+ return NULL;
}
_eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path);
@@ -385,20 +385,44 @@ dri2_load_driver(_EGLDisplay *disp)
_eglLog(_EGL_WARNING,
"DRI2: driver exports no extensions (%s)", dlerror());
dlclose(dri2_dpy->driver);
+ }
+
+ return extensions;
+}
+
+EGLBoolean
+dri2_load_driver(_EGLDisplay *disp)
+{
+ struct dri2_egl_display *dri2_dpy = disp->DriverData;
+ const __DRIextension **extensions;
+
+ extensions = dri2_open_driver(disp);
+ if (!extensions)
+ return EGL_FALSE;
+
+ if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions)) {
+ dlclose(dri2_dpy->driver);
return EGL_FALSE;
}
- if (strcmp(dri2_dpy->driver_name, "swrast") == 0) {
- if (!dri2_bind_extensions(dri2_dpy, swrast_driver_extensions, extensions)) {
- dlclose(dri2_dpy->driver);
- return EGL_FALSE;
- }
- } else {
- if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions)) {
- dlclose(dri2_dpy->driver);
- return EGL_FALSE;
- }
- }
+ return EGL_TRUE;
+}
+
+EGLBoolean
+dri2_load_driver_swrast(_EGLDisplay *disp)
+{
+ struct dri2_egl_display *dri2_dpy = disp->DriverData;
+ const __DRIextension **extensions;
+
+ dri2_dpy->driver_name = "swrast";
+ extensions = dri2_open_driver(disp);
+ if (!extensions)
+ return EGL_FALSE;
+
+ if (!dri2_bind_extensions(dri2_dpy, swrast_driver_extensions, extensions)) {
+ dlclose(dri2_dpy->driver);
+ return EGL_FALSE;
+ }
return EGL_TRUE;
}
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 97f541b5e83..dd9eb94cf7a 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -183,6 +183,9 @@ EGLBoolean
dri2_load_driver(_EGLDisplay *disp);
EGLBoolean
+dri2_load_driver_swrast(_EGLDisplay *disp);
+
+EGLBoolean
dri2_create_screen(_EGLDisplay *disp);
struct dri2_egl_config *
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 2e26ff00b67..8bff294c9e6 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -906,9 +906,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
goto cleanup_dpy;
}
- dri2_dpy->driver_name = dri2_strndup("swrast", strlen("swrast"));
-
- if (!dri2_load_driver(disp))
+ if (!dri2_load_driver_swrast(disp))
goto cleanup_conn;
dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER;