summaryrefslogtreecommitdiff
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2010-01-22 14:15:14 +0800
committerChia-I Wu <olvaffe@gmail.com>2010-01-22 15:03:45 +0800
commit18b63b55d5626dec86e3470bdf8c9996faf28384 (patch)
tree188683252fd9c466de6545ba3dc172beabbc5d8c /src/egl/drivers
parentcaa75a7ce07e4a5d89b0d7cf8823fe02034c1b3b (diff)
egl_xdri: Add support for DRISW.
Try DRISW if both DRI2 and DRI fail. It can also be forced by setting EGL_SOFTWARE. When DRISW is used, single-buffered modes are ignored.
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/xdri/Makefile2
-rw-r--r--src/egl/drivers/xdri/driinit.c34
-rw-r--r--src/egl/drivers/xdri/egl_xdri.c21
3 files changed, 42 insertions, 15 deletions
diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile
index 8e748b71cd..9120620dc5 100644
--- a/src/egl/drivers/xdri/Makefile
+++ b/src/egl/drivers/xdri/Makefile
@@ -6,7 +6,7 @@ include $(TOP)/configs/current
EGL_DRIVER = egl_xdri.so
# steal sources from GLX
-GLX_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c
+GLX_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c drisw_glx.c
GLX_SOURCES := $(addprefix ../../../glx/x11/,$(GLX_SOURCES))
GLX_INCLUDES = \
$(shell pkg-config --cflags-only-I libdrm) \
diff --git a/src/egl/drivers/xdri/driinit.c b/src/egl/drivers/xdri/driinit.c
index 12da1bcd24..3e54f0bd4d 100644
--- a/src/egl/drivers/xdri/driinit.c
+++ b/src/egl/drivers/xdri/driinit.c
@@ -2,6 +2,7 @@
* DRI initialization. The DRI loaders are defined in src/glx/x11/.
*/
+#include <stdlib.h>
#include <sys/time.h>
#include "glxclient.h"
@@ -42,18 +43,26 @@ __glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name)
_X_HIDDEN __GLXDRIdisplay *
__driCreateDisplay(__GLXdisplayPrivate *dpyPriv, int *version)
{
- __GLXDRIdisplay *driDisplay;
+ __GLXDRIdisplay *driDisplay = NULL;
int ver = 0;
+ char *env;
+ int force_sw;
+
+ env = getenv("EGL_SOFTWARE");
+ force_sw = (env && *env != '0');
/* try DRI2 first */
- driDisplay = dri2CreateDisplay(dpyPriv->dpy);
- if (driDisplay) {
- /* fill in the required field */
- dpyPriv->dri2Display = driDisplay;
- ver = 2;
+ if (!force_sw) {
+ driDisplay = dri2CreateDisplay(dpyPriv->dpy);
+ if (driDisplay) {
+ /* fill in the required field */
+ dpyPriv->dri2Display = driDisplay;
+ ver = 2;
+ }
}
- else {
- /* try DRI */
+
+ /* and then DRI */
+ if (!force_sw && !driDisplay) {
driDisplay = driCreateDisplay(dpyPriv->dpy);
if (driDisplay) {
dpyPriv->driDisplay = driDisplay;
@@ -61,6 +70,15 @@ __driCreateDisplay(__GLXdisplayPrivate *dpyPriv, int *version)
}
}
+ /* and then DRISW */
+ if (!driDisplay) {
+ driDisplay = driswCreateDisplay(dpyPriv->dpy);
+ if (driDisplay) {
+ dpyPriv->driDisplay = driDisplay;
+ ver = 0;
+ }
+ }
+
if (version)
*version = ver;
return driDisplay;
diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c
index f83da6652f..b133939155 100644
--- a/src/egl/drivers/xdri/egl_xdri.c
+++ b/src/egl/drivers/xdri/egl_xdri.c
@@ -72,6 +72,7 @@ struct xdri_egl_display
Display *dpy;
__GLXdisplayPrivate *dpyPriv;
__GLXDRIdisplay *driDisplay;
+ int driVersion;
__GLXscreenConfigs *psc;
EGLint scr;
@@ -212,6 +213,7 @@ convert_config(_EGLConfig *conf, EGLint id, const __GLcontextModes *m)
static EGLint
create_configs(_EGLDisplay *disp, const __GLcontextModes *m, EGLint first_id)
{
+ struct xdri_egl_display *xdri_dpy = lookup_display(disp);
int id = first_id;
for (; m; m = m->next) {
@@ -221,8 +223,15 @@ create_configs(_EGLDisplay *disp, const __GLcontextModes *m, EGLint first_id)
if (!convert_config(&conf, id, m))
continue;
-
- rb = (m->doubleBufferMode) ? EGL_BACK_BUFFER : EGL_SINGLE_BUFFER;
+ if (m->doubleBufferMode) {
+ rb = EGL_BACK_BUFFER;
+ }
+ else {
+ /* ignore single-buffered mode for DRISW */
+ if (xdri_dpy->driVersion == 0)
+ continue;
+ rb = EGL_SINGLE_BUFFER;
+ }
xdri_conf = CALLOC_STRUCT(xdri_egl_config);
if (xdri_conf) {
@@ -272,7 +281,7 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
return _eglError(EGL_NOT_INITIALIZED, "eglInitialize");
}
- driDisplay = __driCreateDisplay(dpyPriv, NULL);
+ driDisplay = __driCreateDisplay(dpyPriv, &xdri_dpy->driVersion);
if (!driDisplay) {
_eglLog(_EGL_WARNING, "failed to create DRI display");
free(xdri_dpy);
@@ -294,13 +303,13 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
return _eglError(EGL_NOT_INITIALIZED, "eglInitialize");
}
+ dpy->DriverData = xdri_dpy;
+ dpy->ClientAPIsMask = EGL_OPENGL_BIT;
+
/* add visuals and fbconfigs */
first_id = create_configs(dpy, psc->visuals, first_id);
create_configs(dpy, psc->configs, first_id);
- dpy->DriverData = xdri_dpy;
- dpy->ClientAPIsMask = EGL_OPENGL_BIT;
-
/* we're supporting EGL 1.4 */
*minor = 1;
*major = 4;