From 90ee7a41443a971d6ff2e0a6e90997806c28d11b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Aug 2007 10:18:04 +0100 Subject: Gutsy oopses on touch of existing file. Workaround. --- src/egl/drivers/dri/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index cb11971c64..fa3720a16b 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -52,6 +52,7 @@ clean: depend: $(SOURCES) $(HEADERS) @ echo "running $(MKDEP)" + @ rm -f depend @ touch depend $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ $(SOURCES) $(HEADERS) > /dev/null -- cgit v1.2.3 From fcce6c068cf53fd394a2c82080338860dae8777b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 13:47:44 -0600 Subject: s/GLuint/unsigned/ --- src/egl/drivers/demo/demo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 45545755c0..0a13de6d87 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -21,7 +21,7 @@ typedef struct demo_driver { _EGLDriver Base; /* base class/object */ - GLuint DemoStuff; + unsigned DemoStuff; } DemoDriver; #define DEMO_DRIVER(D) ((DemoDriver *) (D)) @@ -33,7 +33,7 @@ typedef struct demo_driver typedef struct demo_surface { _EGLSurface Base; /* base class/object */ - GLuint DemoStuff; + unsigned DemoStuff; } DemoSurface; @@ -43,7 +43,7 @@ typedef struct demo_surface typedef struct demo_context { _EGLContext Base; /* base class/object */ - GLuint DemoStuff; + unsigned DemoStuff; } DemoContext; -- cgit v1.2.3 From 07e92b174214e6bdaa22eecc0ed87cf1dbc8fc10 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 16:49:11 -0600 Subject: misc updates, clean-ups, remove dependency on mtypes.h --- src/egl/drivers/dri/Makefile | 2 +- src/egl/drivers/dri/egldri.c | 28 +++++++++++++++++----------- src/egl/drivers/dri/egldri.h | 8 +++++--- 3 files changed, 23 insertions(+), 15 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index fa3720a16b..13aacd4389 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -55,7 +55,7 @@ depend: $(SOURCES) $(HEADERS) @ rm -f depend @ touch depend $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) > /dev/null + $(SOURCES) $(HEADERS) >/dev/null 2>/dev/null include depend # DO NOT DELETE diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index cab0be2bd1..81c12b7ca6 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -32,7 +32,7 @@ #include "egldri.h" const char *sysfs = "/sys/class"; -#define None 0 + static const int empty_attribute_list[1] = { None }; @@ -62,10 +62,11 @@ _eglMain(_EGLDisplay *dpy) if (strncmp(&dirent->d_name[0], "card", 4) != 0) continue; - if (strcmp(&dirent->d_name[4], &dpy->Name[1]) != 0) + if (strcmp(&dirent->d_name[4], &dpy->DriverName[1]) != 0) continue; - snprintf(path, sizeof(path), "%s/drm/card%s/dri_library_name", sysfs, &dpy->Name[1]); + snprintf(path, sizeof(path), "%s/drm/card%s/dri_library_name", + sysfs, &dpy->DriverName[1]); _eglLog(_EGL_INFO, "Opening %s", path); #if 1 file = fopen(path, "r"); @@ -141,7 +142,7 @@ _eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, /* generate handle and insert into hash table */ _eglSaveContext(&c->Base); - return c->Base.Handle; + return _eglGetContextHandle(&c->Base); } @@ -152,13 +153,15 @@ _eglDRIMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, driDisplay *disp = Lookup_driDisplay(dpy); driContext *ctx = Lookup_driContext(context); EGLBoolean b; + __DRIid drawBuf = (__DRIid) draw; + __DRIid readBuf = (__DRIid) read; b = _eglMakeCurrent(drv, dpy, draw, read, context); if (!b) return EGL_FALSE; if (ctx) { - ctx->driContext.bindContext(disp, 0, read, draw, &ctx->driContext); + ctx->driContext.bindContext(disp, 0, drawBuf, readBuf, &ctx->driContext); } else { /* what's this??? */ @@ -190,7 +193,7 @@ _eglDRICreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, #if 0 GLcontext *ctx = NULL; /* this _should_ be OK */ #endif - GLvisual visMode; + __GLcontextModes visMode; _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); assert(conf); /* bad config should be caught earlier */ _eglConfigToContextModesRec(conf, &visMode); @@ -267,7 +270,8 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, _EGLConfig *config = _eglLookupConfig(drv, dpy, cfg); driDisplay *disp = Lookup_driDisplay(dpy); driSurface *surface; - GLvisual visMode; + __GLcontextModes visMode; + __DRIid drawBuf; surface = (driSurface *) calloc(1, sizeof(*surface)); if (!surface) { @@ -292,8 +296,10 @@ _eglDRICreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, /* convert EGLConfig to GLvisual */ _eglConfigToContextModesRec(config, &visMode); + drawBuf = (__DRIid) _eglGetSurfaceHandle(&surface->Base); + /* Create a new DRI drawable */ - if (!disp->driScreen.createNewDrawable(disp, &visMode, surface->Base.Handle, + if (!disp->driScreen.createNewDrawable(disp, &visMode, drawBuf, &surface->drawable, GLX_WINDOW_BIT, empty_attribute_list)) { _eglRemoveSurface(&surface->Base); @@ -715,7 +721,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable, { __DRIscreen *pDRIScreen; __DRIscreenPrivate *psp; - driSurface *surf = Lookup_driSurface(drawable); + driSurface *surf = Lookup_driSurface((EGLSurface) drawable); pDRIScreen = __eglFindDRIScreen(ndpy, screen); @@ -1088,13 +1094,13 @@ _eglDRIInitialize(_EGLDriver *drv, EGLDisplay dpy, */ display = calloc(1, sizeof(*display)); display->Base = *disp; - _eglHashInsert(_eglGlobal.Displays, disp->Handle, display); + _eglSaveDisplay(&display->Base); free(disp); *major = 1; *minor = 0; - sscanf(&disp->Name[1], "%d", &display->minor); + sscanf(&disp->DriverName[1], "%d", &display->minor); drv->Initialized = EGL_TRUE; return EGL_TRUE; diff --git a/src/egl/drivers/dri/egldri.h b/src/egl/drivers/dri/egldri.h index 34b12d64fc..49e1cf4d99 100644 --- a/src/egl/drivers/dri/egldri.h +++ b/src/egl/drivers/dri/egldri.h @@ -1,11 +1,13 @@ #ifndef EGLDRI_INCLUDED #define EGLDRI_INCLUDED +#include +#include #include "egldisplay.h" #include "eglscreen.h" #include "eglsurface.h" #include "eglcontext.h" -#include "mtypes.h" + #include "dri_util.h" #include "drm_sarea.h" @@ -14,7 +16,7 @@ */ typedef struct dri_display { - _EGLDisplay Base; /* base class/object */ + _EGLDisplay Base; /**< base class */ void *pFB; int drmFD; /**< \brief DRM device file descriptor */ int minor; @@ -32,7 +34,7 @@ typedef struct dri_display unsigned long FBStart; /**< \brief physical address of the framebuffer */ void *driverClientMsg; int driverClientMsgSize; - int chipset; + unsigned chipset; void *driverPrivate; drm_magic_t magic; -- cgit v1.2.3 From 96a40345bb3b7c87d9742d0b5683355f42596823 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 16:58:23 -0600 Subject: include eglconfigutil.h --- src/egl/drivers/dri/egldri.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 81c12b7ca6..79a2eda3ae 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -23,6 +23,7 @@ #include "egldisplay.h" #include "eglcontext.h" #include "eglconfig.h" +#include "eglconfigutil.h" #include "eglsurface.h" #include "eglscreen.h" #include "eglglobals.h" -- cgit v1.2.3 From 003afbe5bdb3d3c45e0f4f06d0b4239237df934c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 28 May 2008 11:32:18 +0200 Subject: egl: Make demo driver compile --- src/egl/drivers/demo/demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 0a13de6d87..1033f1b4ed 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -152,9 +152,9 @@ demoCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext /* generate handle and insert into hash table */ _eglSaveContext(&c->Base); - assert(c->Base.Handle); + assert(_eglGetContextHandle(&c->Base)); - return c->Base.Handle; + return _eglGetContextHandle(&c->Base); } -- cgit v1.2.3 From 68ff873c20a6e32eef0fa4c6d259a5a415308be5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 28 May 2008 11:33:52 +0200 Subject: egl: Make dri driver compile --- src/egl/drivers/dri/egldri.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.h b/src/egl/drivers/dri/egldri.h index 49e1cf4d99..54a9a4ea26 100644 --- a/src/egl/drivers/dri/egldri.h +++ b/src/egl/drivers/dri/egldri.h @@ -3,6 +3,7 @@ #include #include +#include #include "egldisplay.h" #include "eglscreen.h" #include "eglsurface.h" -- cgit v1.2.3 From aa4ca9119d1dbaf542cf5971f845b434ef008aa0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 11:44:47 -0600 Subject: link libEGLdri.so with libdrm --- src/egl/drivers/dri/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index 13aacd4389..bdc683a0c1 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -29,6 +29,8 @@ SOURCES = egldri.c OBJECTS = $(SOURCES:.c=.o) +DRM_LIB = `pkg-config --libs libdrm` + .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ @@ -43,7 +45,7 @@ library: $(TOP)/$(LIB_DIR)/libEGLdri.so $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS) $(TOP)/bin/mklib -o EGLdri -major 1 -minor 0 \ - -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) + -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(DRM_LIB) clean: -- cgit v1.2.3 From 17ec3b3cc5100deb6ef96977d87b2a7f05814f72 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 11:45:50 -0600 Subject: prototype new code to map card number to driver name --- src/egl/drivers/dri/egldri.c | 66 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 79a2eda3ae..f00625a059 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -1,5 +1,6 @@ /** - * Generic EGL driver for DRI. + * Generic EGL driver for DRI. This is basically an "adaptor" driver + * that allows libEGL to load/use regular DRI drivers. * * This file contains all the code needed to interface DRI-based drivers * with libEGL. @@ -37,6 +38,41 @@ const char *sysfs = "/sys/class"; static const int empty_attribute_list[1] = { None }; + +/** + * Given a card number, return the name of the DRI driver to use. + * This generally means reading the contents of + * /sys/class/drm/cardX/dri_library_name, where X is the card number + */ +static EGLBoolean +driver_name_from_card_number(int card, char *driverName, int maxDriverName) +{ + char path[2000]; + FILE *f; + int length; + + snprintf(path, sizeof(path), "%s/drm/card%d/dri_library_name", sysfs, card); + + f = fopen(path, "r"); + if (!f) + return EGL_FALSE; + + fgets(driverName, maxDriverName, f); + fclose(f); + + if ((length = strlen(driverName)) > 1) { + /* remove the trailing newline from sysfs */ + driverName[length - 1] = '\0'; + strncat(driverName, "_dri", maxDriverName); + return EGL_TRUE; + } + else { + return EGL_FALSE; + } +} + + + /** * The bootstrap function. * Return a new driDriver object and plug in API functions. @@ -45,6 +81,26 @@ static const int empty_attribute_list[1] = { None }; _EGLDriver * _eglMain(_EGLDisplay *dpy) { +#if 1 + const char *displayString = (const char *) dpy->NativeDisplay; + const int card = atoi(displayString + 1); + _EGLDriver *driver = NULL; + char driverName[1000]; + + if (!driver_name_from_card_number(card, driverName, sizeof(driverName))) { + _eglLog(_EGL_WARNING, + "Unable to determine driver name for card %d\n", card); + return NULL; + } + + _eglLog(_EGL_DEBUG, "Driver name: %s\n", driverName); + + driver = _eglOpenDriver(dpy, driverName); + + return driver; + +#else + int length; char path[NAME_MAX]; struct dirent *dirent; @@ -63,11 +119,11 @@ _eglMain(_EGLDisplay *dpy) if (strncmp(&dirent->d_name[0], "card", 4) != 0) continue; - if (strcmp(&dirent->d_name[4], &dpy->DriverName[1]) != 0) + if (strcmp(&dirent->d_name[4], &driverName[1]) != 0) continue; snprintf(path, sizeof(path), "%s/drm/card%s/dri_library_name", - sysfs, &dpy->DriverName[1]); + sysfs, &driverName[1]); _eglLog(_EGL_INFO, "Opening %s", path); #if 1 file = fopen(path, "r"); @@ -91,6 +147,7 @@ _eglMain(_EGLDisplay *dpy) closedir(dir); return driver; +#endif } @@ -1087,6 +1144,7 @@ _eglDRIInitialize(_EGLDriver *drv, EGLDisplay dpy, { _EGLDisplay *disp = _eglLookupDisplay(dpy); driDisplay *display; + const char *driverName = (const char *) disp->NativeDisplay; assert(disp); @@ -1101,7 +1159,7 @@ _eglDRIInitialize(_EGLDriver *drv, EGLDisplay dpy, *major = 1; *minor = 0; - sscanf(&disp->DriverName[1], "%d", &display->minor); + sscanf(driverName + 1, "%d", &display->minor); drv->Initialized = EGL_TRUE; return EGL_TRUE; -- cgit v1.2.3 From 0c8908c411c434eda318b41b4f2a370a1e794831 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 12:56:36 -0600 Subject: egl: added args string to _eglMain() --- src/egl/drivers/demo/demo.c | 2 +- src/egl/drivers/dri/egldri.c | 4 ++-- src/egl/main/eglapi.c | 4 +++- src/egl/main/egldisplay.c | 19 ++++--------------- src/egl/main/egldisplay.h | 1 + src/egl/main/egldriver.c | 35 +++++++++++++++++++++++++---------- src/egl/main/egldriver.h | 4 ++-- src/egl/main/egltypedefs.h | 2 +- 8 files changed, 39 insertions(+), 32 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 1033f1b4ed..6b8b71d16b 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -286,7 +286,7 @@ demoMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea * plug in API functions. */ _EGLDriver * -_eglMain(_EGLDisplay *dpy) +_eglMain(_EGLDisplay *dpy, const char *args) { DemoDriver *demo; diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index f00625a059..677073fb3a 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -79,11 +79,11 @@ driver_name_from_card_number(int card, char *driverName, int maxDriverName) * This function, in turn, loads a specific DRI driver (ex: r200_dri.so). */ _EGLDriver * -_eglMain(_EGLDisplay *dpy) +_eglMain(_EGLDisplay *dpy, const char *args) { #if 1 const char *displayString = (const char *) dpy->NativeDisplay; - const int card = atoi(displayString + 1); + const int card = atoi(args); _EGLDriver *driver = NULL; char driverName[1000]; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index fe63d36b80..984af4ea22 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -68,7 +68,9 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) if (!dpyPriv) { return EGL_FALSE; } - dpyPriv->Driver = _eglOpenDriver(dpyPriv, dpyPriv->DriverName); + dpyPriv->Driver = _eglOpenDriver(dpyPriv, + dpyPriv->DriverName, + dpyPriv->DriverArgs); if (!dpyPriv->Driver) { return EGL_FALSE; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 9c42194c61..b2d30d4274 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -11,25 +11,14 @@ #include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" - - -static char * -my_strdup(const char *s) -{ - if (s) { - int l = strlen(s); - char *s2 = malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - return NULL; -} +#include "eglstring.h" /** * Allocate a new _EGLDisplay object for the given nativeDisplay handle. * We'll also try to determine the device driver name at this time. + * + * Note that nativeDisplay may be an X Display ptr, or a string. */ _EGLDisplay * _eglNewDisplay(NativeDisplayType nativeDisplay) @@ -46,7 +35,7 @@ _eglNewDisplay(NativeDisplayType nativeDisplay) dpy->Xdpy = (Display *) nativeDisplay; #endif - dpy->DriverName = my_strdup(_eglChooseDriver(dpy)); + dpy->DriverName = _eglstrdup(_eglChooseDriver(dpy)); if (!dpy->DriverName) { free(dpy); return NULL; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index be134374ca..e2ebab0b21 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -14,6 +14,7 @@ struct _egl_display EGLDisplay Handle; const char *DriverName; + const char *DriverArgs; _EGLDriver *Driver; EGLint NumScreens; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index cbdd47948d..599077190a 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "eglconfig.h" #include "eglcontext.h" @@ -15,6 +16,7 @@ #include "egllog.h" #include "eglmode.h" #include "eglscreen.h" +#include "eglstring.h" #include "eglsurface.h" #if defined(_EGL_PLATFORM_X) @@ -25,7 +27,7 @@ /* XXX to do */ #endif -const char *DefaultDriverName = "demodriver"; +const char *DefaultDriverName = ":0"; /** @@ -44,23 +46,36 @@ const char *DefaultDriverName = "demodriver"; const char * _eglChooseDriver(_EGLDisplay *dpy) { - const char *name = (const char *) dpy->NativeDisplay; + const char *displayString = (const char *) dpy->NativeDisplay; const char *driverName = NULL; - if (!dpy->NativeDisplay) { + if (!displayString) { /* choose a default */ - driverName = DefaultDriverName; + displayString = DefaultDriverName; } - else if (name && name[0] == ':' && - (name[1] >= '0' && name[1] <= '9') && !name[2]) { + + /* extract default DriverArgs = whatever follows ':' */ + if (displayString[0] == '!' || + displayString[0] == ':') { + const char *args = strchr(displayString, ':'); + if (args) + dpy->DriverArgs = _eglstrdup(args + 1); + } + + + if (displayString && displayString[0] == ':' && + (displayString[1] >= '0' && displayString[1] <= '9') && + !displayString[2]) { /* XXX probe hardware here to determine which driver to open */ driverName = "libEGLdri"; } - else if (name && name[0] == '!') { + else if (displayString && displayString[0] == '!') { /* use specified driver name */ - driverName = name + 1; + driverName = displayString + 1; } else { + /* NativeDisplay is not a string! */ + #if defined(_EGL_PLATFORM_X) driverName = _xeglChooseDriver(dpy); #elif defined(_EGL_PLATFORM_WINDOWS) @@ -83,7 +98,7 @@ _eglChooseDriver(_EGLDisplay *dpy) * \return new _EGLDriver object. */ _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *driverName) +_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) { _EGLDriver *drv; _EGLMain_t mainFunc; @@ -110,7 +125,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName) return NULL; } - drv = mainFunc(dpy); + drv = mainFunc(dpy, args); if (!drv) { dlclose(lib); return NULL; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index bde726e25e..9c505880b7 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -42,7 +42,7 @@ struct _egl_driver }; -extern _EGLDriver *_eglMain(_EGLDisplay *dpy); +extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args); extern const char * @@ -50,7 +50,7 @@ _eglChooseDriver(_EGLDisplay *dpy); extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *DriverName); +_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args); extern EGLBoolean diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index 53810a5a44..b1c8ec1f02 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -30,7 +30,7 @@ typedef struct _egl_thread_info _EGLThreadInfo; typedef void (*_EGLProc)(); -typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy); +typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args); #endif /* EGLTYPEDEFS_INCLUDED */ -- cgit v1.2.3 From aa6e350bed8e6930bef761fb85ad524e5a4aa3a3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 13:03:59 -0600 Subject: egl: pass args to _eglOpenDriver() --- src/egl/drivers/dri/egldri.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 677073fb3a..35b6d0d3d1 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -82,7 +82,6 @@ _EGLDriver * _eglMain(_EGLDisplay *dpy, const char *args) { #if 1 - const char *displayString = (const char *) dpy->NativeDisplay; const int card = atoi(args); _EGLDriver *driver = NULL; char driverName[1000]; @@ -95,7 +94,7 @@ _eglMain(_EGLDisplay *dpy, const char *args) _eglLog(_EGL_DEBUG, "Driver name: %s\n", driverName); - driver = _eglOpenDriver(dpy, driverName); + driver = _eglOpenDriver(dpy, driverName, args); return driver; -- cgit v1.2.3 From 31e70fa275a48b8020c14017919e08d21f5e982f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 10:40:25 -0600 Subject: comments in _eglMain() --- src/egl/drivers/dri/egldri.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 35b6d0d3d1..1a922a7471 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -114,6 +114,10 @@ _eglMain(_EGLDisplay *dpy, const char *args) _eglLog(_EGL_WARNING, "%s DRM devices not found.", path); return EGL_FALSE; } + + /* loop over dir entries looking for cardX where "X" is in the + * dpy->DriverName ":X" string. + */ while ((dirent = readdir(dir))) { if (strncmp(&dirent->d_name[0], "card", 4) != 0) -- cgit v1.2.3 From f6bb2f87b96bd05661020cf8e73e80f5ef25353a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Jun 2008 11:50:18 -0600 Subject: egl: minor tweaks --- src/egl/drivers/dri/egldri.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index 1a922a7471..57661cc3ab 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -82,7 +82,7 @@ _EGLDriver * _eglMain(_EGLDisplay *dpy, const char *args) { #if 1 - const int card = atoi(args); + const int card = args ? atoi(args) : 0; _EGLDriver *driver = NULL; char driverName[1000]; @@ -1086,8 +1086,10 @@ _eglDRICreateDisplay(driDisplay *dpy, __DRIframebuffer *framebuffer) api_ver, & interface_methods, NULL); - if (!dpy->driScreen.private) + if (!dpy->driScreen.private) { + _eglLog(_EGL_WARNING, "egldri.c: DRI create new screen failed"); return EGL_FALSE; + } DRM_UNLOCK( dpy->drmFD, dpy->pSAREA, dpy->serverContext ); -- cgit v1.2.3 From d5cf57de2de9692e9dc194bea1bbf8abfd446770 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 5 Jun 2008 14:11:39 -0600 Subject: egl: new src/egl/drivers/Makefile --- src/egl/drivers/Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/egl/drivers/Makefile (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/Makefile b/src/egl/drivers/Makefile new file mode 100644 index 0000000000..837626e3d6 --- /dev/null +++ b/src/egl/drivers/Makefile @@ -0,0 +1,42 @@ +# src/egl/drivers/Makefile + +TOP = ../../.. + +SUBDIRS = demo dri + + +default: conditional_subdirs + + +# depending on $DRIVER_DIRS... +conditional_subdirs: + @echo "DRIVER_DIRS = " $(DRIVER_DIRS) + @case "$$DRIVER_DIRS" in \ + dri) $(MAKE) dri_subdir || exit 1 ;; \ + *) ;; \ + esac; + + +dri_subdir: + (cd dri ; $(MAKE)) || exit 1 ; \ + + +demo_subdir: + (cd demo ; $(MAKE)) || exit 1 ; \ + + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir ; $(MAKE)) || exit 1 ; \ + fi \ + done + + +clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir ; $(MAKE) clean) ; \ + fi \ + done -- cgit v1.2.3 From 8dafe470fc29cada5f3beab114e2be19fd01dabe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 6 Jun 2008 15:52:33 -0600 Subject: egl: EGL->DRI adaptor/driver Allows regular DRI drivers to work with libEGL. --- src/egl/drivers/xdri/Makefile | 67 ++++ src/egl/drivers/xdri/egl_xdri.c | 833 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 900 insertions(+) create mode 100644 src/egl/drivers/xdri/Makefile create mode 100644 src/egl/drivers/xdri/egl_xdri.c (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile new file mode 100644 index 0000000000..477a75184a --- /dev/null +++ b/src/egl/drivers/xdri/Makefile @@ -0,0 +1,67 @@ +# src/egl/drivers/xdri/Makefile + +# Build XEGL DRI driver loader library: egl_xdri.so + + +TOP = ../../../.. +include $(TOP)/configs/current + + +DRIVER_NAME = egl_xdri.so + + +INCLUDE_DIRS = \ + -I. \ + -I/usr/include \ + -I/usr/include/drm \ + -I$(TOP)/include \ + -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/mesa/glapi \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/src/glx/x11 + +SOURCES = egl_xdri.c + +OBJECTS = $(SOURCES:.c=.o) + +DRM_LIB = `pkg-config --libs libdrm` + + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + + +.PHONY: library + + +default: depend library Makefile + + +library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) + + +# Make the egl_xdri.so library +$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) + $(TOP)/bin/mklib -o $(DRIVER_NAME) \ + -noprefix \ + -major 1 -minor 0 \ + -install $(TOP)/$(LIB_DIR) \ + -ldl $(OBJECTS) $(DRM_LIB) + + +clean: + rm -f *.o + rm -f *.so + rm -f depend depend.bak + + +depend: $(SOURCES) $(HEADERS) + @ echo "running $(MKDEP)" + @ rm -f depend + @ touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ + $(SOURCES) $(HEADERS) >/dev/null 2>/dev/null + +include depend +# DO NOT DELETE diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c new file mode 100644 index 0000000000..4c8511fbbf --- /dev/null +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -0,0 +1,833 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +/** + * Code to interface a DRI driver to libEGL. + * Note that unlike previous DRI/EGL interfaces, this one is meant to + * be used _with_ X. Applications will use eglCreateWindowSurface() + * to render into X-created windows. + * + * This is an EGL driver that, in turn, loads a regular DRI driver. + * There are some dependencies on code in libGL, but those coudl be + * removed with some effort. + * + * Authors: Brian Paul + */ + + +#include +#include +#include +#include +#include +#include "dlfcn.h" +#include +#include +#include "xf86dri.h" +#include "glxclient.h" +#include "dri_util.h" +#include "drm_sarea.h" + +#define _EGL_PLATFORM_X + +#include "eglconfig.h" +#include "eglcontext.h" +#include "egldisplay.h" +#include "egldriver.h" +#include "eglglobals.h" +#include "eglhash.h" +#include "egllog.h" +#include "eglsurface.h" + + + +#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) + + +/** subclass of _EGLDriver */ +struct xdri_egl_driver +{ + _EGLDriver Base; /**< base class */ + + const char *dri_driver_name; /**< name of DRI driver to load */ + void *dri_driver_handle; /**< returned by dlopen(dri_driver_name) */ + + int chipset; + int minor; + int drmFD; + + __DRIscreen driScreen; + __DRIframebuffer framebuffer; + drm_handle_t hSAREA; + drmAddress pSAREA; + char *busID; + drm_magic_t magic; +}; + + +/** subclass of _EGLContext */ +struct xdri_egl_context +{ + _EGLContext Base; /**< base class */ + + __DRIcontext driContext; +}; + + +/** subclass of _EGLSurface */ +struct xdri_egl_surface +{ + _EGLSurface Base; /**< base class */ + + __DRIid driDrawable; /**< DRI surface */ + drm_drawable_t hDrawable; +}; + + +/** subclass of _EGLConfig */ +struct xdri_egl_config +{ + _EGLConfig Base; /**< base class */ + + const __GLcontextModes *mode; /**< corresponding GLX mode */ +}; + + +/** cast wrapper */ +static struct xdri_egl_driver * +xdri_egl_driver(_EGLDriver *drv) +{ + return (struct xdri_egl_driver *) drv; +} + + +/** Map EGLSurface handle to xdri_egl_surface object */ +static struct xdri_egl_surface * +lookup_surface(EGLSurface surf) +{ + _EGLSurface *surface = _eglLookupSurface(surf); + return (struct xdri_egl_surface *) surface; +} + + +/** Map EGLContext handle to xdri_egl_context object */ +static struct xdri_egl_context * +lookup_context(EGLContext c) +{ + _EGLContext *context = _eglLookupContext(c); + return (struct xdri_egl_context *) context; +} + + +/** Map EGLConfig handle to xdri_egl_config object */ +static struct xdri_egl_config * +lookup_config(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) +{ + _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); + return (struct xdri_egl_config *) conf; +} + + + +/** + * Produce a set of EGL configs. + * Note that we get the list of GLcontextModes from the GLX library. + * This dependency on GLX lib will be removed someday. + */ +static void +create_configs(_EGLDisplay *disp) +{ + const __GLcontextModes *m; + __GLXdisplayPrivate *priv = __glXInitialize(disp->Xdpy); + __GLXscreenConfigs *scrn = priv->screenConfigs; + int id = 1; + + for (m = scrn->configs; m; m = m->next) { + /* EGL requires double-buffered configs */ + if (m->doubleBufferMode) { + struct xdri_egl_config *config = CALLOC_STRUCT(xdri_egl_config); + + _eglInitConfig(&config->Base, id++); + + SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, m->rgbBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, m->redBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, m->greenBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, m->blueBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, m->alphaBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, m->depthBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, m->stencilBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, m->visualID); + SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_TYPE, m->visualType); + /* XXX possibly other things to init... */ + + /* Ptr from EGL config to GLcontextMode. Used in CreateContext(). */ + config->mode = m; + + _eglAddConfig(disp, &config->Base); + } + } +} + + +/** + * Called via __DRIinterfaceMethods object + */ +static __DRIfuncPtr +dri_get_proc_address(const char * proc_name) +{ + return NULL; +} + + +static void +dri_context_modes_destroy(__GLcontextModes *modes) +{ + _eglLog(_EGL_DEBUG, "%s", __FUNCTION__); + + while (modes) { + __GLcontextModes * const next = modes->next; + free(modes); + modes = next; + } +} + + +/** + * Create a linked list of 'count' GLcontextModes. + * These are used during the client/server visual negotiation phase, + * then discarded. + */ +static __GLcontextModes * +dri_context_modes_create(unsigned count, size_t minimum_size) +{ + /* This code copied from libGLX, and modified */ + const size_t size = (minimum_size > sizeof(__GLcontextModes)) + ? minimum_size : sizeof(__GLcontextModes); + __GLcontextModes * head = NULL; + __GLcontextModes ** next; + unsigned i; + + next = & head; + for (i = 0 ; i < count ; i++) { + *next = (__GLcontextModes *) calloc(1, size); + if (*next == NULL) { + dri_context_modes_destroy(head); + head = NULL; + break; + } + + (*next)->doubleBufferMode = 1; + (*next)->visualID = GLX_DONT_CARE; + (*next)->visualType = GLX_DONT_CARE; + (*next)->visualRating = GLX_NONE; + (*next)->transparentPixel = GLX_NONE; + (*next)->transparentRed = GLX_DONT_CARE; + (*next)->transparentGreen = GLX_DONT_CARE; + (*next)->transparentBlue = GLX_DONT_CARE; + (*next)->transparentAlpha = GLX_DONT_CARE; + (*next)->transparentIndex = GLX_DONT_CARE; + (*next)->xRenderable = GLX_DONT_CARE; + (*next)->fbconfigID = GLX_DONT_CARE; + (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; + (*next)->bindToTextureRgb = GLX_DONT_CARE; + (*next)->bindToTextureRgba = GLX_DONT_CARE; + (*next)->bindToMipmapTexture = GLX_DONT_CARE; + (*next)->bindToTextureTargets = 0; + (*next)->yInverted = GLX_DONT_CARE; + + next = & ((*next)->next); + } + + return head; +} + + +static __DRIscreen * +dri_find_dri_screen(__DRInativeDisplay *ndpy, int scrn) +{ + /* unused? */ + return NULL; +} + + +static GLboolean +dri_window_exists(__DRInativeDisplay *dpy, __DRIid draw) +{ + return EGL_TRUE; +} + + +static GLboolean +dri_create_context(__DRInativeDisplay *dpy, int screenNum, int configID, + void * contextID, drm_context_t * hw_context) +{ + assert(configID >= 0); + return XF86DRICreateContextWithConfig(dpy, screenNum, + configID, contextID, hw_context); +} + + +static GLboolean +dri_destroy_context(__DRInativeDisplay * ndpy, int screen, __DRIid context) +{ + return XF86DRIDestroyContext(ndpy, screen, context); +} + + +static GLboolean +dri_create_drawable(__DRInativeDisplay * ndpy, int screen, + __DRIid drawable, drm_drawable_t * hHWDrawable) +{ + _eglLog(_EGL_DEBUG, "XDRI: %s", __FUNCTION__); + + /* Create DRI drawable for given window ID (drawable) */ + if (!XF86DRICreateDrawable(ndpy, screen, drawable, hHWDrawable)) + return EGL_FALSE; + + return EGL_TRUE; +} + + +static GLboolean +dri_destroy_drawable(__DRInativeDisplay * ndpy, int screen, __DRIid drawable) +{ + _eglLog(_EGL_DEBUG, "XDRI: %s", __FUNCTION__); + return XF86DRIDestroyDrawable(ndpy, screen, drawable); +} + + +static GLboolean +dri_get_drawable_info(__DRInativeDisplay *dpy, int scrn, + __DRIid draw, unsigned int * index, unsigned int * stamp, + int * x, int * y, int * width, int * height, + int * numClipRects, drm_clip_rect_t ** pClipRects, + int * backX, int * backY, + int * numBackClipRects, + drm_clip_rect_t ** pBackClipRects) +{ + _eglLog(_EGL_DEBUG, "XDRI: %s", __FUNCTION__); + + if (!XF86DRIGetDrawableInfo(dpy, scrn, draw, index, stamp, + x, y, width, height, + numClipRects, pClipRects, + backX, backY, + numBackClipRects, pBackClipRects)) { + return EGL_FALSE; + } + + return EGL_TRUE; +} + + +/** + * Table of functions exported by the loader to the driver. + */ +static const __DRIinterfaceMethods interface_methods = { + dri_get_proc_address, + + dri_context_modes_create, + dri_context_modes_destroy, + + dri_find_dri_screen, + dri_window_exists, + + dri_create_context, + dri_destroy_context, + + dri_create_drawable, + dri_destroy_drawable, + dri_get_drawable_info, + + NULL,/*__eglGetUST,*/ + NULL,/*__eglGetMSCRate,*/ +}; + + + +static EGLBoolean +init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) +{ + static const char createNewScreenName[] = "__driCreateNewScreen_20050727"; + PFNCREATENEWSCREENFUNC createNewScreen; + int api_ver = 0;/*__glXGetInternalVersion();*/ + __DRIversion ddx_version; + __DRIversion dri_version; + __DRIversion drm_version; + drmVersionPtr version; + drm_handle_t hFB; + int newlyopened; + int status; + __GLcontextModes *modes; + int scrn = DefaultScreen(disp->Xdpy); + + createNewScreen = (PFNCREATENEWSCREENFUNC) + dlsym(xdri_drv->dri_driver_handle, createNewScreenName); + if (!createNewScreen) { + _eglLog(_EGL_WARNING, "XDRI: Couldn't find %s function in the driver.", + createNewScreenName); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: Found %s", createNewScreenName); + } + + /* + * Get the DRI X extension version. + */ + dri_version.major = 4; + dri_version.minor = 0; + dri_version.patch = 0; + + + if (!XF86DRIOpenConnection(disp->Xdpy, scrn, + &xdri_drv->hSAREA, &xdri_drv->busID)) { + _eglLog(_EGL_WARNING, "XF86DRIOpenConnection failed"); + } + + xdri_drv->drmFD = drmOpenOnce(NULL, xdri_drv->busID, &newlyopened); + if (xdri_drv->drmFD < 0) { + perror("drmOpenOnce failed: "); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: drmOpenOnce returned %d", xdri_drv->drmFD); + } + + + if (drmGetMagic(xdri_drv->drmFD, &xdri_drv->magic)) { + perror("drmGetMagic failed: "); + return EGL_FALSE; + } + + version = drmGetVersion(xdri_drv->drmFD); + if (version) { + drm_version.major = version->version_major; + drm_version.minor = version->version_minor; + drm_version.patch = version->version_patchlevel; + drmFreeVersion(version); + _eglLog(_EGL_DEBUG, "XDRI: Got DRM version %d.%d.%d", + drm_version.major, + drm_version.minor, + drm_version.patch); + } + else { + drm_version.major = -1; + drm_version.minor = -1; + drm_version.patch = -1; + _eglLog(_EGL_WARNING, "XDRI: drmGetVersion() failed"); + return EGL_FALSE; + } + + /* Authenticate w/ server. + */ + if (!XF86DRIAuthConnection(disp->Xdpy, scrn, xdri_drv->magic)) { + _eglLog(_EGL_WARNING, "XDRI: XF86DRIAuthConnection() failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: XF86DRIAuthConnection() success"); + } + + /* Get ddx version. + */ + { + char *driverName; + + /* + * Get device name (like "tdfx") and the ddx version + * numbers. We'll check the version in each DRI driver's + * "createNewScreen" function. + */ + if (!XF86DRIGetClientDriverName(disp->Xdpy, scrn, + &ddx_version.major, + &ddx_version.minor, + &ddx_version.patch, + &driverName)) { + _eglLog(_EGL_WARNING, "XDRI: XF86DRIGetClientDriverName failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: XF86DRIGetClientDriverName returned %s", driverName); + } + } + + /* Get framebuffer info. + */ + { + int junk; + if (!XF86DRIGetDeviceInfo(disp->Xdpy, scrn, + &hFB, + &junk, + &xdri_drv->framebuffer.size, + &xdri_drv->framebuffer.stride, + &xdri_drv->framebuffer.dev_priv_size, + &xdri_drv->framebuffer.dev_priv)) { + _eglLog(_EGL_WARNING, "XDRI: XF86DRIGetDeviceInfo() failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: XF86DRIGetDeviceInfo() success"); + } + xdri_drv->framebuffer.width = DisplayWidth(disp->Xdpy, scrn); + xdri_drv->framebuffer.height = DisplayHeight(disp->Xdpy, scrn); + } + + /* Map the framebuffer region. (this may not be needed) + */ + status = drmMap(xdri_drv->drmFD, hFB, xdri_drv->framebuffer.size, + (drmAddressPtr) &xdri_drv->framebuffer.base); + if (status != 0) { + _eglLog(_EGL_WARNING, "XDRI: drmMap(framebuffer) failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: drmMap(framebuffer) success"); + } + + /* Map the SAREA region. + */ + status = drmMap(xdri_drv->drmFD, xdri_drv->hSAREA, SAREA_MAX, &xdri_drv->pSAREA); + if (status != 0) { + _eglLog(_EGL_WARNING, "XDRI: drmMap(sarea) failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: drmMap(sarea) success"); + } + + /* Create the DRI screen. + */ + xdri_drv->driScreen.private = createNewScreen(disp->Xdpy, + scrn, /* screen number */ + &xdri_drv->driScreen, + NULL, /* visuals */ + &ddx_version, + &dri_version, + &drm_version, + &xdri_drv->framebuffer, + xdri_drv->pSAREA, + xdri_drv->drmFD, + api_ver, + &interface_methods, + &modes); + if (!xdri_drv->driScreen.private) { + _eglLog(_EGL_WARNING, "XDRI: create new screen failed"); + return EGL_FALSE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: create new screen success"); + } + + create_configs(disp); + + /* print modes / debug */ + if (0) { + __GLcontextModes *m; + + for (m = modes; m; m = m->next) { + _eglLog(_EGL_DEBUG, + "mode ID 0x%x rgba %d %d %d %d z %d s %d db %d\n", m->visualID, + m->redBits, m->greenBits, m->blueBits, m->alphaBits, + m->depthBits, m->stencilBits, m->doubleBufferMode); + } + } + + return EGL_TRUE; +} + + +static EGLBoolean +load_dri_driver(struct xdri_egl_driver *xdri_drv) +{ + char filename[100]; + int flags = RTLD_NOW; + + snprintf(filename, sizeof(filename), "%s.so", xdri_drv->dri_driver_name); + _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s)", filename); + + xdri_drv->dri_driver_handle = dlopen(filename, flags); + if (!xdri_drv->dri_driver_handle) { + _eglLog(_EGL_WARNING, "XDRI Could not open %s (%s)", + filename, dlerror()); + + return EGL_FALSE; + } + return EGL_TRUE; +} + + +/** + * Called via eglInitialize(), xdri_drv->API.Initialize(). + */ +static EGLBoolean +xdri_eglInitialize(_EGLDriver *drv, EGLDisplay dpy, + EGLint *minor, EGLint *major) +{ + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + _EGLDisplay *disp = _eglLookupDisplay(dpy); + static char name[100]; + + _eglLog(_EGL_DEBUG, "XDRI: eglInitialize"); + + if (!disp->Xdpy) { + disp->Xdpy = XOpenDisplay(NULL); + if (!disp->Xdpy) { + _eglLog(_EGL_WARNING, "XDRI: XOpenDisplay failed"); + return EGL_FALSE; + } + } + + /* choose the DRI driver to load */ + xdri_drv->dri_driver_name = _eglChooseDRMDriver(0); + if (!load_dri_driver(xdri_drv)) + return EGL_FALSE; + + if (!init_drm(xdri_drv, disp)) + return EGL_FALSE; + + xdri_drv->Base.Initialized = EGL_TRUE; + + snprintf(name, sizeof(name), "X/DRI:%s", xdri_drv->dri_driver_name); + xdri_drv->Base.Name = name; + + /* we're supporting EGL 1.4 */ + *minor = 1; + *major = 4; + + return EGL_TRUE; +} + + +/** + * Called via eglTerminate(), drv->API.Terminate(). + */ +static EGLBoolean +xdri_eglTerminate(_EGLDriver *drv, EGLDisplay dpy) +{ + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + + _eglLog(_EGL_DEBUG, "XDRI: eglTerminate"); + + _eglLog(_EGL_DEBUG, "XDRI: Closing %s", xdri_drv->dri_driver_name); + dlclose(xdri_drv->dri_driver_handle); + xdri_drv->dri_driver_handle = NULL; + + free((void*) xdri_drv->dri_driver_name); + + return EGL_TRUE; +} + + +/** + * Called via eglCreateContext(), drv->API.CreateContext(). + */ +static EGLContext +xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, + EGLContext share_list, const EGLint *attrib_list) +{ + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + _EGLDisplay *disp = _eglLookupDisplay(dpy); + struct xdri_egl_config *xdri_config = lookup_config(drv, dpy, config); + void *shared = NULL; + int renderType = GLX_RGBA_BIT; + + struct xdri_egl_context *xdri_ctx = CALLOC_STRUCT(xdri_egl_context); + if (!xdri_ctx) + return EGL_NO_CONTEXT; + + if (!_eglInitContext(drv, dpy, &xdri_ctx->Base, config, attrib_list)) { + free(xdri_ctx); + return EGL_NO_CONTEXT; + } + + assert(xdri_config); + + xdri_ctx->driContext.private = + xdri_drv->driScreen.createNewContext(disp->Xdpy, + xdri_config->mode, renderType, + shared, &xdri_ctx->driContext); + if (!xdri_ctx->driContext.private) { + free(xdri_ctx); + return EGL_NO_CONTEXT; + } + + xdri_ctx->driContext.mode = xdri_config->mode; + + return _eglGetContextHandle(&xdri_ctx->Base); +} + + +/** + * Called via eglMakeCurrent(), drv->API.MakeCurrent(). + */ +static EGLBoolean +xdri_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, + EGLSurface r, EGLContext context) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + struct xdri_egl_context *xdri_ctx = lookup_context(context); + struct xdri_egl_surface *xdri_draw = lookup_surface(d); + struct xdri_egl_surface *xdri_read = lookup_surface(r); + __DRIid draw = xdri_draw->driDrawable; + __DRIid read = xdri_read->driDrawable; + int scrn = DefaultScreen(disp->Xdpy); + + if (!_eglMakeCurrent(drv, dpy, d, r, context)) + return EGL_FALSE; + + + if (!xdri_ctx->driContext.bindContext(disp->Xdpy, scrn, draw, read, + &xdri_ctx->driContext)) { + return EGL_FALSE; + } + + return EGL_TRUE; +} + + +/** + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + */ +static EGLSurface +xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, + NativeWindowType window, const EGLint *attrib_list) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + struct xdri_egl_surface *xdri_surf; + int scrn = DefaultScreen(disp->Xdpy); + + xdri_surf = CALLOC_STRUCT(xdri_egl_surface); + if (!xdri_surf) + return EGL_NO_SURFACE; + + if (!_eglInitSurface(drv, dpy, &xdri_surf->Base, EGL_WINDOW_BIT, + config, attrib_list)) { + free(xdri_surf); + return EGL_FALSE; + } + + if (!XF86DRICreateDrawable(disp->Xdpy, scrn, window, &xdri_surf->hDrawable)) { + free(xdri_surf); + return EGL_FALSE; + } + + xdri_surf->driDrawable = window; + + _eglSaveSurface(&xdri_surf->Base); + + _eglLog(_EGL_DEBUG, + "XDRI: CreateWindowSurface win 0x%x handle %d hDrawable %d", + (int) window, _eglGetSurfaceHandle(&xdri_surf->Base), + (int) xdri_surf->hDrawable); + + return _eglGetSurfaceHandle(&xdri_surf->Base); +} + + +static EGLBoolean +xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) +{ + struct xdri_egl_surface *xdri_surf = lookup_surface(surface); + if (xdri_surf) { + _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); + if (xdri_surf->Base.IsBound) { + xdri_surf->Base.DeletePending = EGL_TRUE; + } + else { + /* + st_unreference_framebuffer(&surf->Framebuffer); + */ + free(xdri_surf); + } + return EGL_TRUE; + } + else { + _eglError(EGL_BAD_SURFACE, "eglDestroySurface"); + return EGL_FALSE; + } +} + + +static EGLBoolean +xdri_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + + _eglLog(_EGL_DEBUG, "XDRI: EGL SwapBuffers"); + + /* error checking step: */ + if (!_eglSwapBuffers(drv, dpy, draw)) + return EGL_FALSE; + + { + struct xdri_egl_surface *xdri_surf = lookup_surface(draw); + __GLXdisplayPrivate *priv = __glXInitialize(disp->Xdpy); + __GLXscreenConfigs *scrn = priv->screenConfigs; + __DRIscreen *psc = &scrn->driScreen; + __DRIdrawable * const pdraw = psc->getDrawable(disp->Xdpy, + xdri_surf->driDrawable, + psc->private); + + if (pdraw) + pdraw->swapBuffers(disp->Xdpy, pdraw->private); + else + _eglLog(_EGL_WARNING, "pdraw is null in SwapBuffers"); + } + + return EGL_TRUE; +} + + +/** + * This is the main entrypoint into the driver, called by libEGL. + * Create a new _EGLDriver object and init its dispatch table. + */ +_EGLDriver * +_eglMain(_EGLDisplay *disp, const char *args) +{ + struct xdri_egl_driver *xdri_drv = CALLOC_STRUCT(xdri_egl_driver); + if (!xdri_drv) + return NULL; + + _eglInitDriverFallbacks(&xdri_drv->Base); + xdri_drv->Base.API.Initialize = xdri_eglInitialize; + xdri_drv->Base.API.Terminate = xdri_eglTerminate; + + xdri_drv->Base.API.CreateContext = xdri_eglCreateContext; + xdri_drv->Base.API.MakeCurrent = xdri_eglMakeCurrent; + xdri_drv->Base.API.CreateWindowSurface = xdri_eglCreateWindowSurface; + xdri_drv->Base.API.DestroySurface = xdri_eglDestroySurface; + xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers; + + xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; + xdri_drv->Base.Name = "X/DRI"; + + _eglLog(_EGL_DEBUG, "XDRI: main(%s)", args); + + return &xdri_drv->Base; +} -- cgit v1.2.3 From f374734d61011acc2d7b4e5f390d806603a833bd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 6 Jun 2008 15:59:54 -0600 Subject: egl: improved Makefile --- src/egl/drivers/Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/Makefile b/src/egl/drivers/Makefile index 837626e3d6..a2d67ca5a8 100644 --- a/src/egl/drivers/Makefile +++ b/src/egl/drivers/Makefile @@ -1,8 +1,10 @@ # src/egl/drivers/Makefile TOP = ../../.. +include $(TOP)/configs/current -SUBDIRS = demo dri + +SUBDIRS = demo dri xdri default: conditional_subdirs @@ -10,19 +12,17 @@ default: conditional_subdirs # depending on $DRIVER_DIRS... conditional_subdirs: - @echo "DRIVER_DIRS = " $(DRIVER_DIRS) - @case "$$DRIVER_DIRS" in \ - dri) $(MAKE) dri_subdir || exit 1 ;; \ - *) ;; \ - esac; - + @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ + $(MAKE) dri_subdirs ; \ + fi -dri_subdir: - (cd dri ; $(MAKE)) || exit 1 ; \ +dri_subdirs: + @ (cd dri ; $(MAKE)) || exit 1 + @ (cd xdri ; $(MAKE)) || exit 1 demo_subdir: - (cd demo ; $(MAKE)) || exit 1 ; \ + @ (cd demo ; $(MAKE)) || exit 1 -- cgit v1.2.3 From e9b6ed395a69be90cbf1e2481a9da6fa4079e88e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Jun 2008 16:14:35 -0600 Subject: egl: only windows are renderable at this time --- src/egl/drivers/xdri/egl_xdri.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 4c8511fbbf..60753a1c1f 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -183,6 +183,9 @@ create_configs(_EGLDisplay *disp) SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, m->stencilBits); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, m->visualID); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_TYPE, m->visualType); + /* XXX only window rendering allowed ATM */ + SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT); + /* XXX possibly other things to init... */ /* Ptr from EGL config to GLcontextMode. Used in CreateContext(). */ -- cgit v1.2.3 From be16f04e76be28dd0bab039b21b63ce0752de336 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 13 Jun 2008 13:56:31 -0600 Subject: egl: added a debug msg --- src/egl/drivers/xdri/egl_xdri.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 60753a1c1f..df80c6a1c4 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -675,6 +675,7 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, xdri_config->mode, renderType, shared, &xdri_ctx->driContext); if (!xdri_ctx->driContext.private) { + _eglLog(_EGL_DEBUG, "driScreen.createNewContext failed"); free(xdri_ctx); return EGL_NO_CONTEXT; } -- cgit v1.2.3 From a1fb565ea7ac9f86beb4deece6a24d79e7b7860e Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Thu, 26 Jun 2008 08:55:00 -0600 Subject: egl: These changes allow an eglBindAPI(EGL_OPENGL_ES_API) to succeed, and to work correctly with GLES1 and GLES2. - egl_xdri.c just sets the EGL_OPENGL_ES_BIT as well as the EGL_OPENGL_BIT in ClientAPIsMask - eglconfig.c allows the renderable type to include EGL_OPENGL_ES2_BIT as well as EGL_OPENGL_ES_BIT. - egl_xlib.c sets the EGL_NATIVE_RENDERABLE attribute to EGL_FALSE for all softpipe configurations. (Otherwise, an eglChooseConfig() that looks for particular values of EGL_NATIVE_RENDERABLE will fail.) --- src/egl/drivers/xdri/egl_xdri.c | 2 +- src/egl/main/eglconfig.c | 2 +- src/gallium/winsys/egl_xlib/egl_xlib.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index df80c6a1c4..71d4f15371 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -828,7 +828,7 @@ _eglMain(_EGLDisplay *disp, const char *args) xdri_drv->Base.API.DestroySurface = xdri_eglDestroySurface; xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers; - xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; + xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT; xdri_drv->Base.Name = "X/DRI"; _eglLog(_EGL_DEBUG, "XDRI: main(%s)", args); diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 3ef0564a54..b6846d4928 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -147,7 +147,7 @@ _eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list) } else if (attr == EGL_RENDERABLE_TYPE) { EGLint renType = attrib_list[++i]; - if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT)) { + if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT)) { _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); return EGL_FALSE; } diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index eeb15e30a9..8045c0d0ca 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -172,6 +172,7 @@ create_configs(_EGLDriver *drv, EGLDisplay dpy) SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, sbits); SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_ID, visid); SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, vistype); + SET_CONFIG_ATTRIB(config, EGL_NATIVE_RENDERABLE, EGL_FALSE); _eglAddConfig(disp, config); } -- cgit v1.2.3 From 28f3d390ddf87f796a9a9f3dc28b0b05c19e40fa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 3 Jul 2008 12:10:36 +0200 Subject: egl: Fix demodriver --- src/egl/drivers/demo/demo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 6b8b71d16b..1750e976b8 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -67,22 +67,22 @@ demoInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) /* Create the display's visual configs - silly example */ for (i = 0; i < 4; i++) { - _EGLConfig config; - _eglInitConfig(&config, i + 1); - _eglSetConfigAttrib(&config, EGL_RED_SIZE, 8); - _eglSetConfigAttrib(&config, EGL_GREEN_SIZE, 8); - _eglSetConfigAttrib(&config, EGL_BLUE_SIZE, 8); - _eglSetConfigAttrib(&config, EGL_ALPHA_SIZE, 8); - _eglSetConfigAttrib(&config, EGL_BUFFER_SIZE, 32); + _EGLConfig *config = calloc(1, sizeof(_EGLConfig)); + _eglInitConfig(config, i + 1); + _eglSetConfigAttrib(config, EGL_RED_SIZE, 8); + _eglSetConfigAttrib(config, EGL_GREEN_SIZE, 8); + _eglSetConfigAttrib(config, EGL_BLUE_SIZE, 8); + _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, 8); + _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, 32); if (i & 1) { - _eglSetConfigAttrib(&config, EGL_DEPTH_SIZE, 32); + _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, 32); } if (i & 2) { - _eglSetConfigAttrib(&config, EGL_STENCIL_SIZE, 8); + _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, 8); } - _eglSetConfigAttrib(&config, EGL_SURFACE_TYPE, + _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, (EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT)); - _eglAddConfig(disp, &config); + _eglAddConfig(disp, config); } drv->Initialized = EGL_TRUE; -- cgit v1.2.3 From 70b0a949b0af9954359be452febaa44f08052056 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Jul 2008 15:47:27 -0600 Subject: egl: misc updates/fixes Set surface size when created. Implement dri_find_dri_screen(). Look for "egl_xxx_dri.so" library before regular DRI driver. --- src/egl/drivers/xdri/egl_xdri.c | 93 +++++++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 17 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 71d4f15371..5e50d6034a 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -118,6 +118,10 @@ struct xdri_egl_config }; +/* XXX temp hack */ +static struct xdri_egl_driver *TheDriver = NULL; + + /** cast wrapper */ static struct xdri_egl_driver * xdri_egl_driver(_EGLDriver *drv) @@ -154,6 +158,21 @@ lookup_config(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) +/** Get size of given window */ +static Status +get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) +{ + Window root; + Status stat; + int xpos, ypos; + unsigned int w, h, bw, depth; + stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth); + *width = w; + *height = h; + return stat; +} + + /** * Produce a set of EGL configs. * Note that we get the list of GLcontextModes from the GLX library. @@ -273,24 +292,25 @@ dri_context_modes_create(unsigned count, size_t minimum_size) static __DRIscreen * dri_find_dri_screen(__DRInativeDisplay *ndpy, int scrn) { - /* unused? */ - return NULL; + assert(TheDriver); + + return &TheDriver->driScreen; } static GLboolean -dri_window_exists(__DRInativeDisplay *dpy, __DRIid draw) +dri_window_exists(__DRInativeDisplay *ndpy, __DRIid draw) { return EGL_TRUE; } static GLboolean -dri_create_context(__DRInativeDisplay *dpy, int screenNum, int configID, +dri_create_context(__DRInativeDisplay *ndpy, int screenNum, int configID, void * contextID, drm_context_t * hw_context) { assert(configID >= 0); - return XF86DRICreateContextWithConfig(dpy, screenNum, + return XF86DRICreateContextWithConfig(ndpy, screenNum, configID, contextID, hw_context); } @@ -325,7 +345,7 @@ dri_destroy_drawable(__DRInativeDisplay * ndpy, int screen, __DRIid drawable) static GLboolean -dri_get_drawable_info(__DRInativeDisplay *dpy, int scrn, +dri_get_drawable_info(__DRInativeDisplay *ndpy, int scrn, __DRIid draw, unsigned int * index, unsigned int * stamp, int * x, int * y, int * width, int * height, int * numClipRects, drm_clip_rect_t ** pClipRects, @@ -335,7 +355,7 @@ dri_get_drawable_info(__DRInativeDisplay *dpy, int scrn, { _eglLog(_EGL_DEBUG, "XDRI: %s", __FUNCTION__); - if (!XF86DRIGetDrawableInfo(dpy, scrn, draw, index, stamp, + if (!XF86DRIGetDrawableInfo(ndpy, scrn, draw, index, stamp, x, y, width, height, numClipRects, pClipRects, backX, backY, @@ -570,17 +590,29 @@ load_dri_driver(struct xdri_egl_driver *xdri_drv) char filename[100]; int flags = RTLD_NOW; - snprintf(filename, sizeof(filename), "%s.so", xdri_drv->dri_driver_name); + /* try "egl_xxx_dri.so" first */ + snprintf(filename, sizeof(filename), "egl_%s.so", xdri_drv->dri_driver_name); _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s)", filename); - xdri_drv->dri_driver_handle = dlopen(filename, flags); - if (!xdri_drv->dri_driver_handle) { - _eglLog(_EGL_WARNING, "XDRI Could not open %s (%s)", - filename, dlerror()); + if (xdri_drv->dri_driver_handle) { + _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) OK", filename); + return EGL_TRUE; + } + else { + _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) fail (%s)", filename, dlerror()); + } - return EGL_FALSE; + /* try regular "xxx_dri.so" next */ + snprintf(filename, sizeof(filename), "%s.so", xdri_drv->dri_driver_name); + _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s)", filename); + xdri_drv->dri_driver_handle = dlopen(filename, flags); + if (xdri_drv->dri_driver_handle) { + _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) OK", filename); + return EGL_TRUE; } - return EGL_TRUE; + + _eglLog(_EGL_WARNING, "XDRI Could not open %s (%s)", filename, dlerror()); + return EGL_FALSE; } @@ -646,6 +678,24 @@ xdri_eglTerminate(_EGLDriver *drv, EGLDisplay dpy) } +static _EGLProc +xdri_eglGetProcAddress(const char *procname) +{ +#if 0 + _EGLDriver *drv = NULL; + + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + /*_EGLDisplay *disp = _eglLookupDisplay(dpy);*/ + _EGLProc *proc = xdri_drv->driScreen.getProcAddress(procname); + return proc; +#elif 0 + return (_EGLProc) st_get_proc_address(procname); +#else + return NULL; +#endif +} + + /** * Called via eglCreateContext(), drv->API.CreateContext(). */ @@ -724,6 +774,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, _EGLDisplay *disp = _eglLookupDisplay(dpy); struct xdri_egl_surface *xdri_surf; int scrn = DefaultScreen(disp->Xdpy); + uint width, height; xdri_surf = CALLOC_STRUCT(xdri_egl_surface); if (!xdri_surf) @@ -744,6 +795,10 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, _eglSaveSurface(&xdri_surf->Base); + get_drawable_size(disp->Xdpy, window, &width, &height); + xdri_surf->Base.Width = width; + xdri_surf->Base.Height = height; + _eglLog(_EGL_DEBUG, "XDRI: CreateWindowSurface win 0x%x handle %d hDrawable %d", (int) window, _eglGetSurfaceHandle(&xdri_surf->Base), @@ -790,9 +845,8 @@ xdri_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) { struct xdri_egl_surface *xdri_surf = lookup_surface(draw); - __GLXdisplayPrivate *priv = __glXInitialize(disp->Xdpy); - __GLXscreenConfigs *scrn = priv->screenConfigs; - __DRIscreen *psc = &scrn->driScreen; + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + __DRIscreen *psc = &xdri_drv->driScreen; __DRIdrawable * const pdraw = psc->getDrawable(disp->Xdpy, xdri_surf->driDrawable, psc->private); @@ -818,10 +872,15 @@ _eglMain(_EGLDisplay *disp, const char *args) if (!xdri_drv) return NULL; + /* XXX temp hack */ + TheDriver = xdri_drv; + _eglInitDriverFallbacks(&xdri_drv->Base); xdri_drv->Base.API.Initialize = xdri_eglInitialize; xdri_drv->Base.API.Terminate = xdri_eglTerminate; + xdri_drv->Base.API.GetProcAddress = xdri_eglGetProcAddress; + xdri_drv->Base.API.CreateContext = xdri_eglCreateContext; xdri_drv->Base.API.MakeCurrent = xdri_eglMakeCurrent; xdri_drv->Base.API.CreateWindowSurface = xdri_eglCreateWindowSurface; -- cgit v1.2.3 From e3b13dba4df0522cce11c55c34a9e3e7d0f3a32c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Jul 2008 15:49:59 -0600 Subject: egl: link libEGL w/ additional libs --- src/egl/drivers/xdri/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile index 477a75184a..252d00b6c2 100644 --- a/src/egl/drivers/xdri/Makefile +++ b/src/egl/drivers/xdri/Makefile @@ -27,6 +27,8 @@ OBJECTS = $(SOURCES:.c=.o) DRM_LIB = `pkg-config --libs libdrm` +MISC_LIBS = -ldl -lXext -lGL + .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ @@ -47,7 +49,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) -noprefix \ -major 1 -minor 0 \ -install $(TOP)/$(LIB_DIR) \ - -ldl $(OBJECTS) $(DRM_LIB) + $(OBJECTS) $(DRM_LIB) $(MISC_LIBS) clean: -- cgit v1.2.3 From fb3867aec018ba0c0aa548db541236528400d934 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Jul 2008 10:48:28 -0600 Subject: egl: implement xdri_eglGetProcAddress() for gallium Plus comments, clean-ups. --- src/egl/drivers/xdri/egl_xdri.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 5e50d6034a..9d95c850d0 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -574,7 +574,8 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) for (m = modes; m; m = m->next) { _eglLog(_EGL_DEBUG, - "mode ID 0x%x rgba %d %d %d %d z %d s %d db %d\n", m->visualID, + "mode ID 0x%x rgba %d %d %d %d z %d s %d db %d\n", + m->visualID, m->redBits, m->greenBits, m->blueBits, m->alphaBits, m->depthBits, m->stencilBits, m->doubleBufferMode); } @@ -584,6 +585,15 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) } +/** + * Load the DRI driver named by "xdri_drv->dri_driver_name". + * Basically, dlopen() the library to set "xdri_drv->dri_driver_handle". + * + * Later, we'll call dlsym(createNewScreenName) to get a pointer to + * the driver's createNewScreen() function which is the bootstrap function. + * + * \return EGL_TRUE for success, EGL_FALSE for failure + */ static EGLBoolean load_dri_driver(struct xdri_egl_driver *xdri_drv) { @@ -678,6 +688,9 @@ xdri_eglTerminate(_EGLDriver *drv, EGLDisplay dpy) } +/* + * Called from eglGetProcAddress() via drv->API.GetProcAddress(). + */ static _EGLProc xdri_eglGetProcAddress(const char *procname) { @@ -688,8 +701,17 @@ xdri_eglGetProcAddress(const char *procname) /*_EGLDisplay *disp = _eglLookupDisplay(dpy);*/ _EGLProc *proc = xdri_drv->driScreen.getProcAddress(procname); return proc; -#elif 0 - return (_EGLProc) st_get_proc_address(procname); +#elif 1 + /* This is a bit of a hack to get at the gallium/Mesa state tracker + * function st_get_proc_address(). This will probably change at + * some point. + */ + _EGLProc (*st_get_proc_addr)(const char *procname); + st_get_proc_addr = dlsym(NULL, "st_get_proc_address"); + if (st_get_proc_addr) { + return st_get_proc_addr(procname); + } + return NULL; #else return NULL; #endif -- cgit v1.2.3 From b101890c150d2ba17a42f5164f0de86914b9b28b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Jul 2008 13:29:42 -0600 Subject: egl: add all EGL_*_BITs to ClientAPIsMask --- src/egl/drivers/xdri/egl_xdri.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 9d95c850d0..0f8496c0fb 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -909,7 +909,10 @@ _eglMain(_EGLDisplay *disp, const char *args) xdri_drv->Base.API.DestroySurface = xdri_eglDestroySurface; xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers; - xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT; + xdri_drv->Base.ClientAPIsMask = (EGL_OPENGL_BIT | + EGL_OPENGL_ES_BIT | + EGL_OPENGL_ES2_BIT | + EGL_OPENVG_BIT); xdri_drv->Base.Name = "X/DRI"; _eglLog(_EGL_DEBUG, "XDRI: main(%s)", args); -- cgit v1.2.3 From 7986baf7cf5434c0ff8210eedd0be366ab5e8f14 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Jul 2008 15:11:01 -0600 Subject: build egl subdirs --- configs/linux-dri | 12 +----------- src/egl/drivers/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src/egl/drivers') diff --git a/configs/linux-dri b/configs/linux-dri index 9fd3721265..380cd3812f 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -46,18 +46,8 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ $(LIBDRM_LIB) -# This is now 0 by default since it seems to confuse the hell out of people -# and generate a lot of extra noise on bugzilla. If you need to build with -# EGL, do 'make linux-dri USING_EGL=1' - -USING_EGL=0 - # Directories -SRC_DIRS := glx/x11 $(SRC_DIRS) -ifeq ($(USING_EGL), 1) -SRC_DIRS := egl $(SRC_DIRS) -PROGRAM_DIRS = egl -endif +SRC_DIRS := glx/x11 egl $(SRC_DIRS) diff --git a/src/egl/drivers/Makefile b/src/egl/drivers/Makefile index a2d67ca5a8..6ce0e6b66d 100644 --- a/src/egl/drivers/Makefile +++ b/src/egl/drivers/Makefile @@ -7,10 +7,10 @@ include $(TOP)/configs/current SUBDIRS = demo dri xdri -default: conditional_subdirs +default: dri_subdirs -# depending on $DRIVER_DIRS... +# (UNUSED) depending on $DRIVER_DIRS... conditional_subdirs: @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ $(MAKE) dri_subdirs ; \ -- cgit v1.2.3 From 80b24166a51f26e7bb341a731ceeb4f85c6cc4cf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 11 Jul 2008 15:44:46 -0600 Subject: egl: a minor overhauld of egl_xdri.c Rely more on the libGL code to avoid duplicated efforts. Also fix confusion arising from multiple __DRIscreen objects. --- src/egl/drivers/xdri/egl_xdri.c | 104 ++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 62 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 0f8496c0fb..dfb491958b 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -33,7 +33,7 @@ * to render into X-created windows. * * This is an EGL driver that, in turn, loads a regular DRI driver. - * There are some dependencies on code in libGL, but those coudl be + * There are some dependencies on code in libGL, but those could be * removed with some effort. * * Authors: Brian Paul @@ -77,11 +77,14 @@ struct xdri_egl_driver const char *dri_driver_name; /**< name of DRI driver to load */ void *dri_driver_handle; /**< returned by dlopen(dri_driver_name) */ + __GLXdisplayPrivate *glx_priv; + + + /* XXX we're not actually using these at this time: */ int chipset; int minor; int drmFD; - __DRIscreen driScreen; __DRIframebuffer framebuffer; drm_handle_t hSAREA; drmAddress pSAREA; @@ -118,9 +121,6 @@ struct xdri_egl_config }; -/* XXX temp hack */ -static struct xdri_egl_driver *TheDriver = NULL; - /** cast wrapper */ static struct xdri_egl_driver * @@ -179,11 +179,10 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) * This dependency on GLX lib will be removed someday. */ static void -create_configs(_EGLDisplay *disp) +create_configs(_EGLDisplay *disp, __GLXdisplayPrivate *glx_priv) { + __GLXscreenConfigs *scrn = glx_priv->screenConfigs; const __GLcontextModes *m; - __GLXdisplayPrivate *priv = __glXInitialize(disp->Xdpy); - __GLXscreenConfigs *scrn = priv->screenConfigs; int id = 1; for (m = scrn->configs; m; m = m->next) { @@ -292,9 +291,9 @@ dri_context_modes_create(unsigned count, size_t minimum_size) static __DRIscreen * dri_find_dri_screen(__DRInativeDisplay *ndpy, int scrn) { - assert(TheDriver); - - return &TheDriver->driScreen; + __GLXdisplayPrivate *priv = __glXInitialize(ndpy); + __GLXscreenConfigs *scrnConf = priv->screenConfigs; + return &scrnConf->driScreen; } @@ -395,9 +394,6 @@ static const __DRIinterfaceMethods interface_methods = { static EGLBoolean init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) { - static const char createNewScreenName[] = "__driCreateNewScreen_20050727"; - PFNCREATENEWSCREENFUNC createNewScreen; - int api_ver = 0;/*__glXGetInternalVersion();*/ __DRIversion ddx_version; __DRIversion dri_version; __DRIversion drm_version; @@ -405,9 +401,9 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) drm_handle_t hFB; int newlyopened; int status; - __GLcontextModes *modes; int scrn = DefaultScreen(disp->Xdpy); +#if 0 createNewScreen = (PFNCREATENEWSCREENFUNC) dlsym(xdri_drv->dri_driver_handle, createNewScreenName); if (!createNewScreen) { @@ -418,6 +414,7 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) else { _eglLog(_EGL_DEBUG, "XDRI: Found %s", createNewScreenName); } +#endif /* * Get the DRI X extension version. @@ -426,7 +423,6 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) dri_version.minor = 0; dri_version.patch = 0; - if (!XF86DRIOpenConnection(disp->Xdpy, scrn, &xdri_drv->hSAREA, &xdri_drv->busID)) { _eglLog(_EGL_WARNING, "XF86DRIOpenConnection failed"); @@ -543,44 +539,6 @@ init_drm(struct xdri_egl_driver *xdri_drv, _EGLDisplay *disp) _eglLog(_EGL_DEBUG, "XDRI: drmMap(sarea) success"); } - /* Create the DRI screen. - */ - xdri_drv->driScreen.private = createNewScreen(disp->Xdpy, - scrn, /* screen number */ - &xdri_drv->driScreen, - NULL, /* visuals */ - &ddx_version, - &dri_version, - &drm_version, - &xdri_drv->framebuffer, - xdri_drv->pSAREA, - xdri_drv->drmFD, - api_ver, - &interface_methods, - &modes); - if (!xdri_drv->driScreen.private) { - _eglLog(_EGL_WARNING, "XDRI: create new screen failed"); - return EGL_FALSE; - } - else { - _eglLog(_EGL_DEBUG, "XDRI: create new screen success"); - } - - create_configs(disp); - - /* print modes / debug */ - if (0) { - __GLcontextModes *m; - - for (m = modes; m; m = m->next) { - _eglLog(_EGL_DEBUG, - "mode ID 0x%x rgba %d %d %d %d z %d s %d db %d\n", - m->visualID, - m->redBits, m->greenBits, m->blueBits, m->alphaBits, - m->depthBits, m->stencilBits, m->doubleBufferMode); - } - } - return EGL_TRUE; } @@ -647,13 +605,30 @@ xdri_eglInitialize(_EGLDriver *drv, EGLDisplay dpy, } } +#if 0 /* choose the DRI driver to load */ xdri_drv->dri_driver_name = _eglChooseDRMDriver(0); if (!load_dri_driver(xdri_drv)) return EGL_FALSE; +#else + (void) load_dri_driver; +#endif +#if 0 if (!init_drm(xdri_drv, disp)) return EGL_FALSE; +#else + (void) init_drm; +#endif + + /* + * NOTE: this call to __glXInitialize() bootstraps the whole GLX/DRI + * interface, loads the DRI driver, etc. + * This replaces the load_dri_driver() and init_drm() code above. + */ + xdri_drv->glx_priv = __glXInitialize(disp->Xdpy); + + create_configs(disp, xdri_drv->glx_priv); xdri_drv->Base.Initialized = EGL_TRUE; @@ -725,7 +700,6 @@ static EGLContext xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) { - struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); struct xdri_egl_config *xdri_config = lookup_config(drv, dpy, config); void *shared = NULL; @@ -742,10 +716,15 @@ xdri_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, assert(xdri_config); - xdri_ctx->driContext.private = - xdri_drv->driScreen.createNewContext(disp->Xdpy, - xdri_config->mode, renderType, - shared, &xdri_ctx->driContext); + { + struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); + __GLXscreenConfigs *scrnConf = xdri_drv->glx_priv->screenConfigs; + xdri_ctx->driContext.private = + scrnConf->driScreen.createNewContext(disp->Xdpy, + xdri_config->mode, renderType, + shared, &xdri_ctx->driContext); + } + if (!xdri_ctx->driContext.private) { _eglLog(_EGL_DEBUG, "driScreen.createNewContext failed"); free(xdri_ctx); @@ -868,7 +847,8 @@ xdri_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) { struct xdri_egl_surface *xdri_surf = lookup_surface(draw); struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv); - __DRIscreen *psc = &xdri_drv->driScreen; + __GLXscreenConfigs *scrnConf = xdri_drv->glx_priv->screenConfigs; + __DRIscreen *psc = &scrnConf->driScreen; __DRIdrawable * const pdraw = psc->getDrawable(disp->Xdpy, xdri_surf->driDrawable, psc->private); @@ -894,8 +874,8 @@ _eglMain(_EGLDisplay *disp, const char *args) if (!xdri_drv) return NULL; - /* XXX temp hack */ - TheDriver = xdri_drv; + /* Tell libGL to prefer the EGL drivers over regular DRI drivers */ + __glXPreferEGL(1); _eglInitDriverFallbacks(&xdri_drv->Base); xdri_drv->Base.API.Initialize = xdri_eglInitialize; -- cgit v1.2.3 From e59086ab91281cafcae094164bf4d8454df337ae Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 13 Jul 2008 18:04:49 +0200 Subject: EGL: Only build EGL dri based drivers under linux-dri based configs --- configs/default | 2 ++ configs/linux-dri | 2 ++ src/egl/drivers/Makefile | 21 ++------------------- 3 files changed, 6 insertions(+), 19 deletions(-) (limited to 'src/egl/drivers') diff --git a/configs/default b/configs/default index ef9c5fda1e..1b203b00d2 100644 --- a/configs/default +++ b/configs/default @@ -66,6 +66,8 @@ DRIVER_DIRS = # Which subdirs under $(TOP)/progs/ to enter: PROGRAM_DIRS = demos redbook samples glsl xdemos +# EGL directories +EGL_DRIVERS_DIRS = demo # Gallium directories and GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util diff --git a/configs/linux-dri b/configs/linux-dri index 380cd3812f..7613d41ea1 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -50,6 +50,8 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ SRC_DIRS := glx/x11 egl $(SRC_DIRS) +# EGL directories +EGL_DRIVERS_DIRS = demo dri xdri DRIVER_DIRS = WINDOW_SYSTEM = dri diff --git a/src/egl/drivers/Makefile b/src/egl/drivers/Makefile index 6ce0e6b66d..f0538f563f 100644 --- a/src/egl/drivers/Makefile +++ b/src/egl/drivers/Makefile @@ -3,27 +3,10 @@ TOP = ../../.. include $(TOP)/configs/current +SUBDIRS = $(EGL_DRIVERS_DIRS) -SUBDIRS = demo dri xdri - - -default: dri_subdirs - - -# (UNUSED) depending on $DRIVER_DIRS... -conditional_subdirs: - @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ - $(MAKE) dri_subdirs ; \ - fi - - -dri_subdirs: - @ (cd dri ; $(MAKE)) || exit 1 - @ (cd xdri ; $(MAKE)) || exit 1 - -demo_subdir: - @ (cd demo ; $(MAKE)) || exit 1 +default: subdirs subdirs: -- cgit v1.2.3 From e7fd3de9277a0c5efe52966908da8e4e7f1995ee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 14 Jul 2008 12:09:07 -0600 Subject: egl: set EGL_CONFORMANT, EGL_RENDERABLE_TYPE config fields, fix null ptr crashes in MakeCurrent --- src/egl/drivers/xdri/egl_xdri.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index dfb491958b..2471c0425c 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -181,6 +181,10 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) static void create_configs(_EGLDisplay *disp, __GLXdisplayPrivate *glx_priv) { + static const EGLint all_apis = (EGL_OPENGL_ES_BIT | + EGL_OPENGL_ES2_BIT | + EGL_OPENVG_BIT | + EGL_OPENGL_BIT); __GLXscreenConfigs *scrn = glx_priv->screenConfigs; const __GLcontextModes *m; int id = 1; @@ -201,6 +205,8 @@ create_configs(_EGLDisplay *disp, __GLXdisplayPrivate *glx_priv) SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, m->stencilBits); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, m->visualID); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_TYPE, m->visualType); + SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis); + SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis); /* XXX only window rendering allowed ATM */ SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, EGL_WINDOW_BIT); @@ -654,7 +660,9 @@ xdri_eglTerminate(_EGLDriver *drv, EGLDisplay dpy) _eglLog(_EGL_DEBUG, "XDRI: eglTerminate"); _eglLog(_EGL_DEBUG, "XDRI: Closing %s", xdri_drv->dri_driver_name); +#if 0 dlclose(xdri_drv->dri_driver_handle); +#endif xdri_drv->dri_driver_handle = NULL; free((void*) xdri_drv->dri_driver_name); @@ -748,15 +756,16 @@ xdri_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, struct xdri_egl_context *xdri_ctx = lookup_context(context); struct xdri_egl_surface *xdri_draw = lookup_surface(d); struct xdri_egl_surface *xdri_read = lookup_surface(r); - __DRIid draw = xdri_draw->driDrawable; - __DRIid read = xdri_read->driDrawable; + __DRIid draw = xdri_draw ? xdri_draw->driDrawable : 0; + __DRIid read = xdri_read ? xdri_read->driDrawable : 0; int scrn = DefaultScreen(disp->Xdpy); if (!_eglMakeCurrent(drv, dpy, d, r, context)) return EGL_FALSE; - if (!xdri_ctx->driContext.bindContext(disp->Xdpy, scrn, draw, read, + if (xdri_ctx && + !xdri_ctx->driContext.bindContext(disp->Xdpy, scrn, draw, read, &xdri_ctx->driContext)) { return EGL_FALSE; } -- cgit v1.2.3 From 26df49cd7a67aa9dc26e9cf271d6ed121f08f95d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 16 Jul 2008 10:34:50 -0600 Subject: egl: set EGL_SAMPLES, EGL_SAMPLE_BUFFERS config attribs --- src/egl/drivers/xdri/egl_xdri.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 2471c0425c..3681d9879a 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -203,6 +203,8 @@ create_configs(_EGLDisplay *disp, __GLXdisplayPrivate *glx_priv) SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, m->alphaBits); SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, m->depthBits); SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, m->stencilBits); + SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, m->samples); + SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, m->sampleBuffers); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, m->visualID); SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_TYPE, m->visualType); SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis); -- cgit v1.2.3 From a88de345cd2e8d79de5f5da36223b1db6adf1b3e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Aug 2008 16:12:39 -0600 Subject: egl: don't put the example/demo driver in the lib/ dir --- src/egl/drivers/demo/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/egl/drivers') diff --git a/src/egl/drivers/demo/Makefile b/src/egl/drivers/demo/Makefile index 5c05633df5..e5a7be2438 100644 --- a/src/egl/drivers/demo/Makefile +++ b/src/egl/drivers/demo/Makefile @@ -21,8 +21,7 @@ default: $(TOP)/$(LIB_DIR)/demodriver.so $(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS) - $(TOP)/bin/mklib -o demodriver.so -noprefix \ - -install $(TOP)/$(LIB_DIR) $(OBJECTS) + $(TOP)/bin/mklib -o demodriver.so -noprefix $(OBJECTS) -- cgit v1.2.3