[Mesa-dev] [PATCH 1/2] egl_dri2: add dri2_load_driver_swrast
Chia-I Wu
olvaffe at gmail.com
Wed Jun 8 01:37:13 PDT 2011
From: Chia-I Wu <olv at lunarg.com>
Refactor dri2_load_driver and add dri2_load_driver_swrast for loading
swrast DRI driver.
---
src/egl/drivers/dri2/egl_dri2.c | 56 +++++++++++++++++++++++++----------
src/egl/drivers/dri2/egl_dri2.h | 3 ++
src/egl/drivers/dri2/platform_x11.c | 4 +--
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 013cfe7..2559ac1 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -322,8 +322,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;
@@ -362,9 +362,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);
@@ -373,20 +373,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 97f541b..dd9eb94 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 cf908ab..392b35d 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;
--
1.7.5.3
More information about the mesa-dev
mailing list