summaryrefslogtreecommitdiff
path: root/src/egl
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2011-01-13 04:40:38 +0800
committerChia-I Wu <olv@lunarg.com>2011-01-13 18:15:45 +0800
commita22a332fc7cc54d4d0973dcd21a90159cc51de1a (patch)
treeb27bd01fcc099bfb7623e3fd1e1ef3016b3ef399 /src/egl
parent655e4598927728a663f4cfcd6babdf7e5ad83f77 (diff)
egl: Improve driver selection.
The idea is to be able to match a driver using the following order try egl_gallium with hw renderer try egl_dri2 try egl_gallium with sw renderer try egl_glx given the module list egl_gallium egl_dri2 egl_glx For that, UseFallback initialization option is added. The module list is matched twice: with the option unset and with the option set. In the first pass, egl_gallium skips its sw renderer and egl_glx rejects to initialize since UseFallback is not set. In the second pass, egl_gallium skips its hw renderer and egl_dri2 rejects to initialize since UseFallback is set. The process stops at the first driver that initializes the display.
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c4
-rw-r--r--src/egl/drivers/glx/egl_glx.c4
-rw-r--r--src/egl/main/egldisplay.h1
-rw-r--r--src/egl/main/egldriver.c5
4 files changed, 14 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2e827f4f3e..6fc1e49e77 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1470,6 +1470,10 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
static EGLBoolean
dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
{
+ /* not until swrast_dri is supported */
+ if (disp->Options.UseFallback)
+ return EGL_FALSE;
+
switch (disp->Platform) {
case _EGL_PLATFORM_X11:
if (disp->Options.TestOnly)
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index aecebae40c..c3c11c7b6e 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -589,6 +589,10 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp)
if (disp->Platform != _EGL_PLATFORM_X11)
return EGL_FALSE;
+ /* this is a fallback driver */
+ if (!disp->Options.UseFallback)
+ return EGL_FALSE;
+
if (disp->Options.TestOnly)
return EGL_TRUE;
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index b42760befa..dbc5d32d91 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -93,6 +93,7 @@ struct _egl_display
/* options that affect how the driver initializes the display */
struct {
EGLBoolean TestOnly; /**< Driver should not set fields when true */
+ EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
} Options;
/* these fields are set by the driver during init */
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 7baa24fbf8..e133c220f5 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -585,8 +585,13 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only)
/* set options */
dpy->Options.TestOnly = test_only;
+ dpy->Options.UseFallback = EGL_FALSE;
best_drv = _eglMatchAndInitialize(dpy);
+ if (!best_drv) {
+ dpy->Options.UseFallback = EGL_TRUE;
+ best_drv = _eglMatchAndInitialize(dpy);
+ }
_eglUnlockMutex(&_eglModuleMutex);