summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-06-17 23:45:41 +0800
committerChia-I Wu <[email protected]>2010-06-29 17:16:19 +0800
commitea05299ce54ea0463626277907cab8e849884740 (patch)
tree427d55a566a49372dfe259bcdd6de3dabad900ad /src/egl
parentf66a4e20c19d55005854bbee312947ec16e287e3 (diff)
st/egl: One driver per hardware.
Merge multiple egl_<platform>_<pipe>.so into a single egl_gallium_<pipe>.so. The environment variable EGL_PLATFORM is now used to modify the return value of _eglGetNativePlatform.
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/main/Makefile3
-rw-r--r--src/egl/main/SConscript1
-rw-r--r--src/egl/main/egldisplay.c56
-rw-r--r--src/egl/main/egldisplay.h4
-rw-r--r--src/egl/main/egldriver.c42
-rw-r--r--src/egl/main/egldriver.h5
6 files changed, 66 insertions, 45 deletions
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile
index be27d9450f4..3834a5dbfa1 100644
--- a/src/egl/main/Makefile
+++ b/src/egl/main/Makefile
@@ -51,8 +51,6 @@ OBJECTS = $(SOURCES:.c=.o)
# use dl*() to load drivers
LOCAL_CFLAGS = -D_EGL_OS_UNIX=1
-EGL_DEFAULT_PLATFORM = $(firstword $(EGL_PLATFORMS))
-
# translate --with-egl-platforms to _EGLPlatformType
EGL_NATIVE_PLATFORM=_EGL_INVALID_PLATFORM
ifeq ($(firstword $(EGL_PLATFORMS)),x11)
@@ -67,7 +65,6 @@ endif
LOCAL_CFLAGS += \
-D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \
- -D_EGL_DEFAULT_PLATFORM=\"$(EGL_DEFAULT_PLATFORM)\" \
-D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\"
.c.o:
diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript
index fad0671f38a..69ad873bd66 100644
--- a/src/egl/main/SConscript
+++ b/src/egl/main/SConscript
@@ -10,7 +10,6 @@ if env['platform'] != 'winddk':
env.Append(CPPDEFINES = [
'_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS',
- '_EGL_DEFAULT_PLATFORM=\\"gdi\\"',
'_EGL_DRIVER_SEARCH_DIR=\\"\\"',
'_EGL_OS_WINDOWS',
'KHRONOS_DLL_EXPORTS',
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index d666bdabe02..9980356c4aa 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -15,6 +15,62 @@
/**
+ * Return the native platform by parsing EGL_PLATFORM.
+ */
+static _EGLPlatformType
+_eglGetNativePlatformFromEnv(void)
+{
+ /* map --with-egl-platforms names to platform types */
+ static const struct {
+ _EGLPlatformType platform;
+ const char *name;
+ } egl_platforms[_EGL_NUM_PLATFORMS] = {
+ { _EGL_PLATFORM_WINDOWS, "gdi" },
+ { _EGL_PLATFORM_X11, "x11" },
+ { _EGL_PLATFORM_DRM, "kms" },
+ { _EGL_PLATFORM_FBDEV, "fbdev" }
+ };
+ _EGLPlatformType plat = _EGL_INVALID_PLATFORM;
+ const char *plat_name;
+ EGLint i;
+
+ plat_name = getenv("EGL_PLATFORM");
+ /* try deprecated env variable */
+ if (!plat_name || !plat_name[0])
+ plat_name = getenv("EGL_DISPLAY");
+ if (!plat_name || !plat_name[0])
+ return _EGL_INVALID_PLATFORM;
+
+ for (i = 0; i < _EGL_NUM_PLATFORMS; i++) {
+ if (strcmp(egl_platforms[i].name, plat_name) == 0) {
+ plat = egl_platforms[i].platform;
+ break;
+ }
+ }
+
+ return plat;
+}
+
+
+/**
+ * Return the native platform. It is the platform of the EGL native types.
+ */
+_EGLPlatformType
+_eglGetNativePlatform(void)
+{
+ static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
+
+ if (native_platform == _EGL_INVALID_PLATFORM) {
+ native_platform = _eglGetNativePlatformFromEnv();
+ if (native_platform == _EGL_INVALID_PLATFORM)
+ native_platform = _EGL_NATIVE_PLATFORM;
+ }
+
+ return native_platform;
+}
+
+
+/**
* Finish display management.
*/
void
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 0b325f7cf03..5a1caa9cc65 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -101,6 +101,10 @@ struct _egl_display
};
+extern _EGLPlatformType
+_eglGetNativePlatform(void);
+
+
extern void
_eglFiniDisplay(void);
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index db7b4a7471e..c65df286454 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -39,7 +39,7 @@
/* XXX Need to decide how to do dynamic name lookup on Windows */
static const char *DefaultDriverNames[] = {
- "egl_gdi_swrast"
+ "egl_gallium_swrast"
};
typedef HMODULE lib_handle;
@@ -464,36 +464,16 @@ _eglPreloadUserDriver(void)
/**
- * Preload platform drivers.
- *
- * Platform drivers are a set of drivers that support a certain window system.
- * The window system may be specified by EGL_PLATFORM.
+ * Preload Gallium drivers.
*
* FIXME This makes libEGL a memory hog if an user driver is not specified and
- * there are many platform drivers.
+ * there are many Gallium drivers
*/
static EGLBoolean
-_eglPreloadPlatformDrivers(void)
+_eglPreloadGalliumDrivers(void)
{
- const char *dpy;
- char prefix[32];
- int ret;
-
- dpy = getenv("EGL_PLATFORM");
- /* try deprecated env variable */
- if (!dpy || !dpy[0])
- dpy = getenv("EGL_DISPLAY");
- if (!dpy || !dpy[0])
- dpy = _EGL_DEFAULT_PLATFORM;
- if (!dpy || !dpy[0])
- return EGL_FALSE;
-
- ret = _eglsnprintf(prefix, sizeof(prefix), "egl_%s_", dpy);
- if (ret < 0 || ret >= sizeof(prefix))
- return EGL_FALSE;
-
return (_eglPreloadForEach(_eglGetSearchPath(),
- _eglLoaderPattern, (void *) prefix) > 0);
+ _eglLoaderPattern, (void *) "egl_gallium_") > 0);
}
@@ -518,7 +498,7 @@ _eglPreloadDrivers(void)
}
loaded = (_eglPreloadUserDriver() ||
- _eglPreloadPlatformDrivers());
+ _eglPreloadGalliumDrivers());
_eglUnlockMutex(_eglGlobal.Mutex);
@@ -581,16 +561,6 @@ _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
/**
- * Return the native platform. It is the platform of the EGL native types.
- */
-_EGLPlatformType
-_eglGetNativePlatform(void)
-{
- return _EGL_NATIVE_PLATFORM;
-}
-
-
-/**
* Plug all the available fallback routines into the given driver's
* dispatch table.
*/
diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
index 6a523747647..8b34c43b924 100644
--- a/src/egl/main/egldriver.h
+++ b/src/egl/main/egldriver.h
@@ -3,7 +3,6 @@
#include "egltypedefs.h"
-#include "egldisplay.h"
#include "eglapi.h"
@@ -89,10 +88,6 @@ extern _EGLDriver *
_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor);
-extern _EGLPlatformType
-_eglGetNativePlatform(void);
-
-
PUBLIC void
_eglInitDriverFallbacks(_EGLDriver *drv);