From b3bcd33f7a8b32ce4ea6e979e9cc764d0f903ae9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 18:13:50 +0800 Subject: egl: Add _eglPreloadDrivers. It can be used to load the user driver specified by EGL_DRIVER, or a set of drivers specified by EGL_DISPLAY, or the default driver, and in that order. --- src/egl/main/egldriver.c | 211 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 205 insertions(+), 6 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 018b06d3be..5d603419a8 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -22,6 +22,8 @@ #if defined(_EGL_PLATFORM_X) #include +#include +#include #endif @@ -49,6 +51,13 @@ close_library(HMODULE lib) } +static const char * +library_suffix(void) +{ + return "dll"; +} + + #elif defined(_EGL_PLATFORM_X) @@ -68,6 +77,14 @@ close_library(void *lib) dlclose(lib); } + +static const char * +library_suffix(void) +{ + return "so"; +} + + #else /* _EGL_PLATFORM_NO_OS */ static const char DefaultDriverName[] = "builtin"; @@ -86,6 +103,13 @@ close_library(void *lib) } +static const char * +library_suffix(void) +{ + return NULL; +} + + #endif @@ -208,11 +232,10 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) /** - * Load the named driver. The path and args passed will be - * owned by the driver and freed. + * Load the named driver. */ static _EGLDriver * -_eglLoadDriver(char *path, char *args) +_eglLoadDriver(const char *path, const char *args) { _EGLMain_t mainFunc; lib_handle lib; @@ -234,8 +257,19 @@ _eglLoadDriver(char *path, char *args) drv->Name = "UNNAMED"; } - drv->Path = path; - drv->Args = args; + drv->Path = _eglstrdup(path); + drv->Args = (args) ? _eglstrdup(args) : NULL; + if (!drv->Path || (args && !drv->Args)) { + if (drv->Path) + free((char *) drv->Path); + if (drv->Args) + free((char *) drv->Args); + drv->Unload(drv); + if (lib) + close_library(lib); + return NULL; + } + drv->LibHandle = lib; return drv; @@ -300,8 +334,12 @@ _eglPreloadDriver(_EGLDisplay *dpy) } drv = _eglLoadDriver(path, args); - if (!drv) + if (!drv) { + free(path); + if (args) + free(args); return NULL; + } _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; @@ -330,6 +368,167 @@ _eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) } +/** + * Preload a user driver. + * + * A user driver can be specified by EGL_DRIVER. + */ +static EGLBoolean +_eglPreloadUserDriver(void) +{ +#if defined(_EGL_PLATFORM_X) || defined(_EGL_PLATFORM_WINDOWS) + _EGLDriver *drv; + char *env, *path; + const char *suffix, *p; + + env = getenv("EGL_DRIVER"); + if (!env) + return EGL_FALSE; + + path = env; + suffix = library_suffix(); + + /* append suffix if there isn't */ + p = strrchr(path, '.'); + if (!p && suffix) { + size_t len = strlen(path); + char *tmp = malloc(len + strlen(suffix) + 2); + if (tmp) { + memcpy(tmp, path, len); + tmp[len++] = '.'; + tmp[len] = '\0'; + strcat(tmp + len, suffix); + + path = tmp; + } + } + + drv = _eglLoadDriver(path, NULL); + if (path != env) + free(path); + if (!drv) + return EGL_FALSE; + + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + + return EGL_TRUE; +#else /* _EGL_PLATFORM_X || _EGL_PLATFORM_WINDOWS */ + return EGL_FALSE; +#endif +} + + +/** + * Preload display drivers. + * + * Display drivers are a set of drivers that support a certain display system. + * The display system may be specified by EGL_DISPLAY. + * + * FIXME This makes libEGL a memory hog if an user driver is not specified and + * there are many display drivers. + */ +static EGLBoolean +_eglPreloadDisplayDrivers(void) +{ +#if defined(_EGL_PLATFORM_X) + const char *dpy, *suffix; + char path[1024], prefix[32]; + DIR *dirp; + struct dirent *dirent; + + dpy = getenv("EGL_DISPLAY"); + if (!dpy || !dpy[0]) + dpy = _EGL_DEFAULT_DISPLAY; + if (!dpy || !dpy[0]) + return EGL_FALSE; + + snprintf(prefix, sizeof(prefix), "egl_%s_", dpy); + suffix = library_suffix(); + + dirp = opendir(_EGL_DRIVER_SEARCH_DIR); + if (!dirp) + return EGL_FALSE; + + while ((dirent = readdir(dirp))) { + _EGLDriver *drv; + const char *p; + + /* match the prefix */ + if (strncmp(dirent->d_name, prefix, strlen(prefix)) != 0) + continue; + + /* match the suffix */ + p = strrchr(dirent->d_name, '.'); + if ((p && !suffix) || (!p && suffix)) + continue; + else if (p && suffix && strcmp(p + 1, suffix) != 0) + continue; + + snprintf(path, sizeof(path), + _EGL_DRIVER_SEARCH_DIR"/%s", dirent->d_name); + + drv = _eglLoadDriver(path, NULL); + if (drv) + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + } + + closedir(dirp); + + return (_eglGlobal.NumDrivers > 0); +#else /* _EGL_PLATFORM_X */ + return EGL_FALSE; +#endif +} + + +/** + * Preload the default driver. + */ +static EGLBoolean +_eglPreloadDefaultDriver(void) +{ + _EGLDriver *drv; + char path[1024]; + const char *suffix = library_suffix(); + + if (suffix) + snprintf(path, sizeof(path), "%s.%s", DefaultDriverName, suffix); + else + snprintf(path, sizeof(path), DefaultDriverName); + + drv = _eglLoadDriver(path, NULL); + if (!drv) + return EGL_FALSE; + + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + + return EGL_TRUE; +} + + +/** + * Preload drivers. + * + * This function loads the driver modules and creates the corresponding + * _EGLDriver objects. + */ +EGLBoolean +_eglPreloadDrivers(void) +{ + EGLBoolean loaded; + + /* already preloaded */ + if (_eglGlobal.NumDrivers) + return EGL_TRUE; + + loaded = (_eglPreloadUserDriver() || + _eglPreloadDisplayDrivers() || + _eglPreloadDefaultDriver()); + + return loaded; +} + + /** * Unload preloaded drivers. */ -- cgit v1.2.3 From f0c2871bf4f6fa89339347bb9767bb2c19fda6d0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 17:39:34 +0800 Subject: egl: Remove unused driver and display functions. Remove _eglPreloadDriver, _eglLookupDriver, and _eglSplitDisplayString. --- src/egl/main/egldisplay.c | 30 ------------ src/egl/main/egldisplay.h | 4 -- src/egl/main/egldriver.c | 114 ---------------------------------------------- src/egl/main/egldriver.h | 8 ---- 4 files changed, 156 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index a65ac6e969..eb82af4884 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -39,36 +39,6 @@ _eglFiniDisplay(void) } -/** - * If the first character is '!' we interpret it as specific driver name - * (i.e. "!r200" or "!i830"). Whatever follows ':' is interpreted as - * arguments. - * - * The caller may free() the returned driver name. - */ -char * -_eglSplitDisplayString(const char *dpyString, const char **args) -{ - char *drv, *p; - - if (!dpyString || dpyString[0] != '!') - return NULL; - drv = _eglstrdup(dpyString + 1); - if (!drv) - return NULL; - - p = strchr(dpyString, ':'); - if (p) { - drv[p - dpyString] = '\0'; - p++; - } - if (args) - *args = p; - - return drv; -} - - /** * Allocate a new _EGLDisplay object for the given nativeDisplay handle. * We'll also try to determine the device driver name at this time. diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 4f619e5371..ddd9806985 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -58,10 +58,6 @@ extern void _eglFiniDisplay(void); -extern char * -_eglSplitDisplayString(const char *dpyString, const char **args); - - extern _EGLDisplay * _eglNewDisplay(NativeDisplayType displayName); diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 5d603419a8..873dac02bf 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -113,66 +113,6 @@ library_suffix(void) #endif -/** - * Choose a driver for a given display. - * The caller may free() the returned strings. - */ -static char * -_eglChooseDriver(_EGLDisplay *dpy, char **argsRet) -{ - char *path = NULL; - const char *args = NULL; - const char *suffix = NULL; - const char *p; - - path = getenv("EGL_DRIVER"); - if (path) - path = _eglstrdup(path); - -#if defined(_EGL_PLATFORM_X) - if (!path && dpy && dpy->NativeDisplay) { - /* assume (wrongly!) that the native display is a display string */ - path = _eglSplitDisplayString((const char *) dpy->NativeDisplay, &args); - } - suffix = "so"; -#elif defined(_EGL_PLATFORM_WINDOWS) - suffix = "dll"; -#else /* _EGL_PLATFORM_NO_OS */ - if (path) { - /* force the use of the default driver */ - _eglLog(_EGL_DEBUG, "ignore EGL_DRIVER"); - free(path); - path = NULL; - } - suffix = NULL; -#endif - - if (!path) - path = _eglstrdup(DefaultDriverName); - - /* append suffix if there isn't */ - p = strrchr(path, '.'); - if (!p && suffix) { - size_t len = strlen(path); - char *tmp = malloc(len + strlen(suffix) + 2); - if (tmp) { - memcpy(tmp, path, len); - tmp[len++] = '.'; - tmp[len] = '\0'; - strcat(tmp + len, suffix); - - free(path); - path = tmp; - } - } - - if (argsRet) - *argsRet = (args) ? _eglstrdup(args) : NULL; - - return path; -} - - /** * Open the named driver and find its bootstrap function: _eglMain(). */ @@ -307,46 +247,6 @@ _eglMatchDriver(_EGLDisplay *dpy) } -/** - * Load a driver and save it. - */ -const char * -_eglPreloadDriver(_EGLDisplay *dpy) -{ - char *path, *args; - _EGLDriver *drv; - EGLint i; - - path = _eglChooseDriver(dpy, &args); - if (!path) - return NULL; - - for (i = 0; i < _eglGlobal.NumDrivers; i++) { - drv = _eglGlobal.Drivers[i]; - if (strcmp(drv->Path, path) == 0) { - _eglLog(_EGL_DEBUG, "Driver %s is already preloaded", - drv->Name); - free(path); - if (args) - free(args); - return drv->Name; - } - } - - drv = _eglLoadDriver(path, args); - if (!drv) { - free(path); - if (args) - free(args); - return NULL; - } - - _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; - - return drv->Name; -} - - /** * Open a preloaded driver. */ @@ -558,20 +458,6 @@ _eglUnloadDrivers(void) } -/** - * Given a display handle, return the _EGLDriver for that display. - */ -_EGLDriver * -_eglLookupDriver(EGLDisplay dpy) -{ - _EGLDisplay *d = _eglLookupDisplay(dpy); - if (d) - return d->Driver; - else - return NULL; -} - - /** * 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 a474fa6871..eca96fce61 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -29,10 +29,6 @@ PUBLIC _EGLDriver * _eglMain(const char *args); -extern const char * -_eglPreloadDriver(_EGLDisplay *dpy); - - extern _EGLDriver * _eglOpenDriver(_EGLDisplay *dpy); @@ -49,10 +45,6 @@ extern void _eglUnloadDrivers(void); -extern _EGLDriver * -_eglLookupDriver(EGLDisplay d); - - PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); -- cgit v1.2.3 From 925f8113beba03e956351cee6780b1c7ab76add8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 17:42:33 +0800 Subject: egl: Rename _EGL_PLATFORM_X to _EGL_PLATFORM_POSIX. The macro is used to determine if dlfcn.h or dirent.h is available. POSIX is a better name than X in such case. --- src/egl/main/Makefile | 2 +- src/egl/main/egldriver.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 7386f6ea73..66f8f01b8e 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -47,7 +47,7 @@ OBJECTS = $(SOURCES:.c=.o) # use dl*() to load drivers -LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +LOCAL_CFLAGS = -D_EGL_PLATFORM_POSIX=1 EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 873dac02bf..dd363a18f4 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -20,7 +20,7 @@ #include "eglstring.h" #include "eglsurface.h" -#if defined(_EGL_PLATFORM_X) +#if defined(_EGL_PLATFORM_POSIX) #include #include #include @@ -58,7 +58,7 @@ library_suffix(void) } -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) static const char DefaultDriverName[] = "egl_softpipe"; @@ -132,7 +132,7 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) /* XXX untested */ if (lib) mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) if (lib) { mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); if (!mainFunc) @@ -276,7 +276,7 @@ _eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) static EGLBoolean _eglPreloadUserDriver(void) { -#if defined(_EGL_PLATFORM_X) || defined(_EGL_PLATFORM_WINDOWS) +#if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS) _EGLDriver *drv; char *env, *path; const char *suffix, *p; @@ -312,7 +312,7 @@ _eglPreloadUserDriver(void) _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; return EGL_TRUE; -#else /* _EGL_PLATFORM_X || _EGL_PLATFORM_WINDOWS */ +#else /* _EGL_PLATFORM_POSIX || _EGL_PLATFORM_WINDOWS */ return EGL_FALSE; #endif } @@ -330,7 +330,7 @@ _eglPreloadUserDriver(void) static EGLBoolean _eglPreloadDisplayDrivers(void) { -#if defined(_EGL_PLATFORM_X) +#if defined(_EGL_PLATFORM_POSIX) const char *dpy, *suffix; char path[1024], prefix[32]; DIR *dirp; @@ -375,7 +375,7 @@ _eglPreloadDisplayDrivers(void) closedir(dirp); return (_eglGlobal.NumDrivers > 0); -#else /* _EGL_PLATFORM_X */ +#else /* _EGL_PLATFORM_POSIX */ return EGL_FALSE; #endif } @@ -532,7 +532,7 @@ _eglFindAPIs(void) const char *es2_libname = "libGLESv2.dll"; const char *gl_libname = "OpenGL32.dll"; const char *vg_libname = "libOpenVG.dll"; -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) const char *es1_libname = "libGLESv1_CM.so"; const char *es2_libname = "libGLESv2.so"; const char *gl_libname = "libGL.so"; -- cgit v1.2.3 From cf22fd5e5b13ccdb02ba0368ea722ede3bbc6de0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 18:39:59 +0800 Subject: egl: Improve driver matching. Make drv->Probe return a score so that the matching can be done by finding the driver with the highest score. --- src/egl/main/egldisplay.h | 1 - src/egl/main/egldriver.c | 35 +++++++++++++++++++---------------- src/egl/main/egldriver.h | 19 ++++++++++++++++--- 3 files changed, 35 insertions(+), 20 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index ddd9806985..a69813196f 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -26,7 +26,6 @@ struct _egl_display EGLNativeDisplayType NativeDisplay; - const char *DriverName; _EGLDriver *Driver; void *DriverData; /* private to driver */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index dd363a18f4..ef1c366b30 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -218,32 +218,35 @@ _eglLoadDriver(const char *path, const char *args) /** * Match a display to a preloaded driver. + * + * The matching is done by finding the driver with the highest score. */ static _EGLDriver * _eglMatchDriver(_EGLDisplay *dpy) { - _EGLDriver *defaultDriver = NULL; - EGLint i; + _EGLDriver *best_drv = NULL; + EGLint best_score = -1, i; for (i = 0; i < _eglGlobal.NumDrivers; i++) { _EGLDriver *drv = _eglGlobal.Drivers[i]; - - /* display specifies a driver */ - if (dpy->DriverName) { - if (strcmp(dpy->DriverName, drv->Name) == 0) - return drv; - } - else if (drv->Probe) { - if (drv->Probe(drv, dpy)) - return drv; - } - else { - if (!defaultDriver) - defaultDriver = drv; + EGLint score; + + score = (drv->Probe) ? drv->Probe(drv, dpy) : 0; + if (score > best_score) { + if (best_drv) { + _eglLog(_EGL_DEBUG, "driver %s has higher score than %s", + drv->Name, best_drv->Name); + } + + best_drv = drv; + best_score = score; + /* perfect match */ + if (score >= 100) + break; } } - return defaultDriver; + return best_drv; } diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index eca96fce61..808b1c3fb7 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -16,9 +16,22 @@ struct _egl_driver const char *Args; /**< args to load this driver */ const char *Name; /**< name of this driver */ - /**< probe a display to see if it is supported */ - EGLBoolean (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy); - /**< called before dlclose to release this driver */ + + /** + * Probe a display and return a score. + * + * Roughly, + * 50 means the driver supports the display; + * 90 means the driver can accelerate the display; + * 100 means a perfect match. + */ + EGLint (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy); + + /** + * Release the driver resource. + * + * It is called before dlclose(). + */ void (*Unload)(_EGLDriver *drv); _EGLAPI API; /**< EGL API dispatch table */ -- cgit v1.2.3 From c5766c4ae39b4190965abd65eaf67b478a9ad028 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 14:35:50 +0800 Subject: egl: Add a simple cache for driver probe. In current design, multiple drivers will probe the same display and the best driver is determined. The cache can be used by the drivers to store and share the probed data. --- src/egl/main/egldriver.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/egldriver.h | 8 ++++++++ 2 files changed, 56 insertions(+) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index ef1c366b30..0574f83f45 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -113,6 +113,13 @@ library_suffix(void) #endif +#define NUM_PROBE_CACHE_SLOTS 8 +static struct { + EGLint keys[NUM_PROBE_CACHE_SLOTS]; + const void *values[NUM_PROBE_CACHE_SLOTS]; +} _eglProbeCache; + + /** * Open the named driver and find its bootstrap function: _eglMain(). */ @@ -569,3 +576,44 @@ _eglFindAPIs(void) return mask; } + + +/** + * Set the probe cache at the given key. + * + * A key, instead of a _EGLDriver, is used to allow the probe cache to be share + * by multiple drivers. + */ +void +_eglSetProbeCache(EGLint key, const void *val) +{ + EGLint idx; + + for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) { + if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key) + break; + } + assert(key > 0); + assert(idx < NUM_PROBE_CACHE_SLOTS); + + _eglProbeCache.keys[idx] = key; + _eglProbeCache.values[idx] = val; +} + + +/** + * Return the probe cache at the given key. + */ +const void * +_eglGetProbeCache(EGLint key) +{ + EGLint idx; + + for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) { + if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key) + break; + } + + return (idx < NUM_PROBE_CACHE_SLOTS && _eglProbeCache.keys[idx] == key) ? + _eglProbeCache.values[idx] : NULL; +} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 808b1c3fb7..d9d61297c1 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -66,4 +66,12 @@ PUBLIC EGLint _eglFindAPIs(void); +PUBLIC void +_eglSetProbeCache(EGLint key, const void *val); + + +PUBLIC const void * +_eglGetProbeCache(EGLint key); + + #endif /* EGLDRIVER_INCLUDED */ -- cgit v1.2.3 From 3b0ffd5a36c4626b44eafc43f5eaebb7c758bfbd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 16:02:39 +0800 Subject: egl: Remove egl_softpipe. With the addition egl_x11_swrast, egl_softpipe is sort of deprecated. The new driver serves the same purpose as egl_softpipe does. It is based on egl_g3d and provides more features. --- configs/default | 2 +- configs/linux-opengl-es | 8 +- docs/sourcetree.html | 1 - src/egl/main/egldriver.c | 2 +- src/gallium/winsys/egl_xlib/Makefile | 84 ---- src/gallium/winsys/egl_xlib/egl_xlib.c | 853 -------------------------------- src/gallium/winsys/egl_xlib/sw_winsys.c | 231 --------- src/gallium/winsys/egl_xlib/sw_winsys.h | 40 -- 8 files changed, 5 insertions(+), 1216 deletions(-) delete mode 100644 src/gallium/winsys/egl_xlib/Makefile delete mode 100644 src/gallium/winsys/egl_xlib/egl_xlib.c delete mode 100644 src/gallium/winsys/egl_xlib/sw_winsys.c delete mode 100644 src/gallium/winsys/egl_xlib/sw_winsys.h (limited to 'src/egl/main/egldriver.c') diff --git a/configs/default b/configs/default index 2665f5296a..3aa136b9c5 100644 --- a/configs/default +++ b/configs/default @@ -100,7 +100,7 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = drm xlib egl_xlib +GALLIUM_WINSYS_DIRS = drm xlib GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index e013658716..af784551a7 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -18,13 +18,11 @@ EGL_DRIVERS_DIRS = GALLIUM_DRIVERS_DIRS = softpipe -# build egl_softpipe.so -GALLIUM_WINSYS_DIRS = egl_xlib -# and libGLES*.so +# build libGLES*.so GALLIUM_STATE_TRACKERS_DIRS = es -# build egl_i915.so +# build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 GALLIUM_STATE_TRACKERS_DIRS += egl_g3d GALLIUM_WINSYS_DIRS += drm -GALLIUM_WINSYS_DRM_DIRS = intel +GALLIUM_WINSYS_DRM_DIRS += intel swrast diff --git a/docs/sourcetree.html b/docs/sourcetree.html index bc4ce71bee..41f40351eb 100644 --- a/docs/sourcetree.html +++ b/docs/sourcetree.html @@ -136,7 +136,6 @@ each directory.
  • winsys -
    • drm - -
    • egl_xlib -
    • g3dvl -
    • gdi -
    • xlib - diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 0574f83f45..f890df1bb1 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -61,7 +61,7 @@ library_suffix(void) #elif defined(_EGL_PLATFORM_POSIX) -static const char DefaultDriverName[] = "egl_softpipe"; +static const char DefaultDriverName[] = "egl_glx"; typedef void * lib_handle; diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile deleted file mode 100644 index 06c1fb0b91..0000000000 --- a/src/gallium/winsys/egl_xlib/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# src/gallium/winsys/egl_xlib/Makefile - -# Build softpipe/xlib/EGL driver library/object: "egl_softpipe.so" - - -TOP = ../../../.. -include $(TOP)/configs/current - - -DRIVER_NAME = egl_softpipe.so - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/auxiliary - -WINSYS_SOURCES = \ - egl_xlib.c \ - sw_winsys.c - -WINSYS_OBJECTS = $(WINSYS_SOURCES:.c=.o) - - -LIBS = \ - $(GALLIUM_DRIVERS) \ - $(GALLIUM_AUXILIARIES) -LIB_DEPS = $(EGL_LIB_DEPS) -lm -lX11 - -LOCAL_CFLAGS = - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ - - -.PHONY: library - - -default: depend library Makefile - - -library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) - - -# Make the egl_softpipe.so library -$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS) - $(TOP)/bin/mklib -o $(DRIVER_NAME) \ - -linker "$(CC)" \ - -noprefix \ - -install $(TOP)/$(LIB_DIR) \ - $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) \ - -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive \ - $(LIB_DEPS) - - -depend: $(WINSYS_SOURCES) - @ echo "running $(MKDEP)" - @ rm -f depend # workaround oops on gutsy?!? - @ touch depend - @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(WINSYS_SOURCES) \ - > /dev/null 2>/dev/null - - -install: default - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - @if [ -e $(TOP)/$(LIB_DIR) ]; then \ - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ - fi - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h - -clean: - -rm -f *.o *~ *.bak - - -include depend diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c deleted file mode 100644 index 1d9bac3871..0000000000 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ /dev/null @@ -1,853 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - -/** - * EGL / softpipe / xlib winsys module - * - * Authors: Brian Paul - */ - - -#include -#include -#include - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_state.h" -#include "pipe/internal/p_winsys_screen.h" -#include "util/u_memory.h" -#include "util/u_math.h" -#include "softpipe/sp_winsys.h" -#include "softpipe/sp_texture.h" - -#include "eglconfig.h" -#include "eglconfigutil.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" -#include "eglsurface.h" - -#include "state_tracker/st_public.h" - -#include "sw_winsys.h" - - -/** subclass of _EGLDriver */ -struct xlib_egl_driver -{ - _EGLDriver Base; /**< base class */ - EGLint apis; -}; - - -/** driver data of _EGLDisplay */ -struct xlib_egl_display -{ - Display *Dpy; - - struct pipe_winsys *winsys; - struct pipe_screen *screen; -}; - - -/** subclass of _EGLContext */ -struct xlib_egl_context -{ - _EGLContext Base; /**< base class */ - - struct pipe_context *pipe; /**< Gallium driver context */ - struct st_context *Context; /**< Mesa/gallium state tracker context */ -}; - - -/** subclass of _EGLSurface */ -struct xlib_egl_surface -{ - _EGLSurface Base; /**< base class */ - - /* These are set for window surface */ - Display *Dpy; /**< The X Display of the window */ - Window Win; /**< The user-created window ID */ - GC Gc; - XVisualInfo VisInfo; - - struct pipe_winsys *winsys; - - struct st_framebuffer *Framebuffer; -}; - - -static void -flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *psurf, - void *context_private); - - -/** cast wrapper */ -static INLINE struct xlib_egl_driver * -xlib_egl_driver(_EGLDriver *drv) -{ - return (struct xlib_egl_driver *) drv; -} - - -static INLINE struct xlib_egl_display * -xlib_egl_display(_EGLDisplay *dpy) -{ - return (struct xlib_egl_display *) dpy->DriverData; -} - - -static INLINE struct xlib_egl_surface * -lookup_surface(_EGLSurface *surf) -{ - return (struct xlib_egl_surface *) surf; -} - - -static INLINE struct xlib_egl_context * -lookup_context(_EGLContext *ctx) -{ - return (struct xlib_egl_context *) ctx; -} - - -/** - * Create the EGLConfigs. (one per X visual) - */ -static void -create_configs(struct xlib_egl_display *xdpy, _EGLDisplay *disp) -{ - static const EGLint all_apis = (EGL_OPENGL_ES_BIT | - EGL_OPENGL_ES2_BIT | - EGL_OPENVG_BIT | - EGL_OPENGL_BIT); - XVisualInfo *visInfo, visTemplate; - int num_visuals, i; - - /* get list of all X visuals, create an EGL config for each */ - visTemplate.screen = DefaultScreen(xdpy->Dpy); - visInfo = XGetVisualInfo(xdpy->Dpy, VisualScreenMask, - &visTemplate, &num_visuals); - if (!visInfo) { - printf("egl_xlib.c: couldn't get any X visuals\n"); - abort(); - } - - for (i = 0; i < num_visuals; i++) { - _EGLConfig *config = calloc(1, sizeof(_EGLConfig)); - int id = i + 1; - int rbits = util_bitcount(visInfo[i].red_mask); - int gbits = util_bitcount(visInfo[i].green_mask); - int bbits = util_bitcount(visInfo[i].blue_mask); - int abits = bbits == 8 ? 8 : 0; - int zbits = 24; - int sbits = 8; - int visid = visInfo[i].visualid; -#if defined(__cplusplus) || defined(c_plusplus) - int vistype = visInfo[i].c_class; -#else - int vistype = visInfo[i].class; -#endif - - _eglInitConfig(config, id); - SET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE, rbits + gbits + bbits + abits); - SET_CONFIG_ATTRIB(config, EGL_RED_SIZE, rbits); - SET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE, gbits); - SET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE, bbits); - SET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE, abits); - SET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE, zbits); - 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); - SET_CONFIG_ATTRIB(config, EGL_CONFORMANT, all_apis); - SET_CONFIG_ATTRIB(config, EGL_RENDERABLE_TYPE, all_apis); - SET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); - SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); - SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); - - _eglAddConfig(disp, config); - } - - XFree(visInfo); -} - - -/** - * Called via eglInitialize(), drv->API.Initialize(). - */ -static EGLBoolean -xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, - EGLint *major, EGLint *minor) -{ - struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); - struct xlib_egl_display *xdpy; - - xdpy = CALLOC_STRUCT(xlib_egl_display); - if (!xdpy) - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - - xdpy->Dpy = (Display *) dpy->NativeDisplay; - if (!xdpy->Dpy) { - xdpy->Dpy = XOpenDisplay(NULL); - if (!xdpy->Dpy) { - free(xdpy); - return EGL_FALSE; - } - } - - /* create winsys and pipe screen */ - xdpy->winsys = create_sw_winsys(); - if (!xdpy->winsys) { - free(xdpy); - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - } - xdpy->winsys->flush_frontbuffer = flush_frontbuffer; - xdpy->screen = softpipe_create_screen(xdpy->winsys); - if (!xdpy->screen) { - free(xdpy->winsys); - free(xdpy); - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - } - - dpy->DriverData = (void *) xdpy; - dpy->ClientAPIsMask = xdrv->apis; - - create_configs(xdpy, dpy); - - /* we're supporting EGL 1.4 */ - *major = 1; - *minor = 4; - - return EGL_TRUE; -} - - -/** - * Called via eglTerminate(), drv->API.Terminate(). - */ -static EGLBoolean -xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(dpy); - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - xdpy->screen->destroy(xdpy->screen); - free(xdpy->winsys); - - if (!dpy->NativeDisplay) - XCloseDisplay(xdpy->Dpy); - free(xdpy); - - return EGL_TRUE; -} - - -static _EGLProc -xlib_eglGetProcAddress(_EGLDriver *drv, const char *procname) -{ - return (_EGLProc) st_get_proc_address(procname); -} - - -static void -get_drawable_visual_info(Display *dpy, Drawable d, XVisualInfo *visInfo) -{ - XWindowAttributes attr; - XVisualInfo visTemp, *vis; - int num_visuals; - - XGetWindowAttributes(dpy, d, &attr); - - visTemp.screen = DefaultScreen(dpy); - visTemp.visualid = attr.visual->visualid; - vis = XGetVisualInfo(dpy, - (VisualScreenMask | VisualIDMask), - &visTemp, &num_visuals); - if (vis) - *visInfo = *vis; - - XFree(vis); -} - - - -/** 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; -} - - -static void -check_and_update_buffer_size(struct xlib_egl_surface *surface) -{ - uint width, height; - if (surface->Base.Type == EGL_PBUFFER_BIT) { - width = surface->Base.Width; - height = surface->Base.Height; - } - else { - get_drawable_size(surface->Dpy, surface->Win, &width, &height); - } - st_resize_framebuffer(surface->Framebuffer, width, height); - surface->Base.Width = width; - surface->Base.Height = height; -} - - - -static void -display_surface(struct pipe_winsys *pws, - struct pipe_surface *psurf, - struct xlib_egl_surface *xsurf) -{ - struct softpipe_texture *spt = softpipe_texture(psurf->texture); - XImage *ximage; - void *data; - - if (xsurf->Base.Type == EGL_PBUFFER_BIT) - return; - - ximage = XCreateImage(xsurf->Dpy, - xsurf->VisInfo.visual, - xsurf->VisInfo.depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ - - - assert(ximage->format); - assert(ximage->bitmap_unit); - - data = pws->buffer_map(pws, spt->buffer, 0); - - /* update XImage's fields */ - ximage->data = data; - ximage->width = psurf->width; - ximage->height = psurf->height; - ximage->bytes_per_line = spt->stride[psurf->level]; - - XPutImage(xsurf->Dpy, xsurf->Win, xsurf->Gc, - ximage, 0, 0, 0, 0, psurf->width, psurf->height); - - XSync(xsurf->Dpy, 0); - - ximage->data = NULL; - XDestroyImage(ximage); - - pws->buffer_unmap(pws, spt->buffer); -} - - - -/** Display gallium surface in X window */ -static void -flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *psurf, - void *context_private) -{ - struct xlib_egl_surface *xsurf = (struct xlib_egl_surface *) context_private; - display_surface(pws, psurf, xsurf); -} - - - -/** - * Called via eglCreateContext(), drv->API.CreateContext(). - */ -static _EGLContext * -xlib_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - _EGLContext *share_list, const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(dpy); - struct xlib_egl_context *ctx; - struct st_context *share_ctx = NULL; /* XXX fix */ - __GLcontextModes visual; - - ctx = CALLOC_STRUCT(xlib_egl_context); - if (!ctx) - return NULL; - - /* let EGL lib init the common stuff */ - if (!_eglInitContext(drv, &ctx->Base, conf, attrib_list)) { - free(ctx); - return NULL; - } - - /* API-dependent context creation */ - switch (ctx->Base.ClientAPI) { - case EGL_OPENVG_API: - case EGL_OPENGL_ES_API: - _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n", - ctx->Base.ClientVersion); - /* fall-through */ - case EGL_OPENGL_API: - /* create a softpipe context */ - ctx->pipe = softpipe_create(xdpy->screen); - /* Now do xlib / state tracker inits here */ - _eglConfigToContextModesRec(conf, &visual); - ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx); - break; - default: - _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)"); - free(ctx); - return NULL; - } - - return &ctx->Base; -} - - -static EGLBoolean -xlib_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct xlib_egl_context *context = lookup_context(ctx); - - if (!_eglIsContextBound(&context->Base)) { - /* API-dependent clean-up */ - switch (context->Base.ClientAPI) { - case EGL_OPENGL_ES_API: - case EGL_OPENVG_API: - /* fall-through */ - case EGL_OPENGL_API: - st_destroy_context(context->Context); - break; - default: - assert(0); - } - free(context); - } - return EGL_TRUE; -} - - -/** - * Called via eglMakeCurrent(), drv->API.MakeCurrent(). - */ -static EGLBoolean -xlib_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) -{ - struct xlib_egl_context *context = lookup_context(ctx); - struct xlib_egl_surface *draw_surf = lookup_surface(draw); - struct xlib_egl_surface *read_surf = lookup_surface(read); - struct st_context *oldcontext = NULL; - _EGLContext *oldctx; - - oldctx = _eglGetCurrentContext(); - if (oldctx && _eglIsContextLinked(oldctx)) - oldcontext = st_get_current(); - - if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) - return EGL_FALSE; - - /* Flush before switching context. Check client API? */ - if (oldcontext) - st_flush(oldcontext, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - st_make_current((context ? context->Context : NULL), - (draw_surf ? draw_surf->Framebuffer : NULL), - (read_surf ? read_surf->Framebuffer : NULL)); - - if (draw_surf) - check_and_update_buffer_size(draw_surf); - if (read_surf && read_surf != draw_surf) - check_and_update_buffer_size(draw_surf); - - return EGL_TRUE; -} - - -static enum pipe_format -choose_color_format(const __GLcontextModes *visual) -{ - if (visual->redBits == 8 && - visual->greenBits == 8 && - visual->blueBits == 8 && - visual->alphaBits == 8) { - /* XXX this really also depends on the ordering of R,G,B,A */ - return PIPE_FORMAT_A8R8G8B8_UNORM; - } - else { - assert(0); - return PIPE_FORMAT_NONE; - } -} - - -static enum pipe_format -choose_depth_format(const __GLcontextModes *visual) -{ - if (visual->depthBits > 0) - return PIPE_FORMAT_S8Z24_UNORM; - else - return PIPE_FORMAT_NONE; -} - - -static enum pipe_format -choose_stencil_format(const __GLcontextModes *visual) -{ - if (visual->stencilBits > 0) - return PIPE_FORMAT_S8Z24_UNORM; - else - return PIPE_FORMAT_NONE; -} - - -/** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). - */ -static _EGLSurface * -xlib_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - NativeWindowType window, const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(disp); - struct xlib_egl_surface *surf; - __GLcontextModes visual; - uint width, height; - - surf = CALLOC_STRUCT(xlib_egl_surface); - if (!surf) - return NULL; - - /* Let EGL lib init the common stuff */ - if (!_eglInitSurface(drv, &surf->Base, EGL_WINDOW_BIT, - conf, attrib_list)) { - free(surf); - return NULL; - } - - /* - * Now init the Xlib and gallium stuff - */ - surf->Win = (Window) window; /* The X window ID */ - surf->Dpy = xdpy->Dpy; /* The X display */ - surf->Gc = XCreateGC(surf->Dpy, surf->Win, 0, NULL); - - surf->winsys = xdpy->winsys; - - _eglConfigToContextModesRec(conf, &visual); - get_drawable_size(surf->Dpy, surf->Win, &width, &height); - get_drawable_visual_info(surf->Dpy, surf->Win, &surf->VisInfo); - - surf->Base.Width = width; - surf->Base.Height = height; - - /* Create GL statetracker framebuffer */ - surf->Framebuffer = st_create_framebuffer(&visual, - choose_color_format(&visual), - choose_depth_format(&visual), - choose_stencil_format(&visual), - width, height, - (void *) surf); - - st_resize_framebuffer(surf->Framebuffer, width, height); - - return &surf->Base; -} - - -static _EGLSurface * -xlib_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(disp); - struct xlib_egl_surface *surf; - __GLcontextModes visual; - uint width, height; - EGLBoolean bind_texture; - - surf = CALLOC_STRUCT(xlib_egl_surface); - if (!surf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, - conf, attrib_list)) { - free(surf); - return NULL; - } - if (surf->Base.Width < 0 || surf->Base.Height < 0) { - _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - - bind_texture = (surf->Base.TextureFormat != EGL_NO_TEXTURE); - width = (uint) surf->Base.Width; - height = (uint) surf->Base.Height; - if ((surf->Base.TextureTarget == EGL_NO_TEXTURE && bind_texture) || - (surf->Base.TextureTarget != EGL_NO_TEXTURE && !bind_texture)) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - /* a framebuffer of zero width or height confuses st */ - if (width == 0 || height == 0) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - /* no mipmap generation */ - if (surf->Base.MipmapTexture) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - - surf->winsys = xdpy->winsys; - - _eglConfigToContextModesRec(conf, &visual); - - /* Create GL statetracker framebuffer */ - surf->Framebuffer = st_create_framebuffer(&visual, - choose_color_format(&visual), - choose_depth_format(&visual), - choose_stencil_format(&visual), - width, height, - (void *) surf); - st_resize_framebuffer(surf->Framebuffer, width, height); - - return &surf->Base; -} - - -static EGLBoolean -xlib_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) -{ - struct xlib_egl_surface *surf = lookup_surface(surface); - if (!_eglIsSurfaceBound(&surf->Base)) { - if (surf->Base.Type != EGL_PBUFFER_BIT) - XFreeGC(surf->Dpy, surf->Gc); - st_unreference_framebuffer(surf->Framebuffer); - free(surf); - } - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surface, EGLint buffer) -{ - struct xlib_egl_surface *xsurf = lookup_surface(surface); - struct xlib_egl_context *xctx; - struct pipe_surface *psurf; - enum pipe_format format; - int target; - - if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT) - return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - if (xsurf->Base.BoundToTexture) - return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); - - /* this should be updated when choose_color_format is */ - switch (xsurf->Base.TextureFormat) { - case EGL_TEXTURE_RGB: - format = PIPE_FORMAT_R8G8B8_UNORM; - break; - case EGL_TEXTURE_RGBA: - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - switch (xsurf->Base.TextureTarget) { - case EGL_TEXTURE_2D: - target = ST_TEXTURE_2D; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - /* flush properly */ - if (eglGetCurrentSurface(EGL_DRAW) == surface) { - xctx = lookup_context(_eglGetCurrentContext()); - st_flush(xctx->Context, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, - NULL); - } - else if (_eglIsSurfaceBound(&xsurf->Base)) { - xctx = lookup_context(xsurf->Base.Binding); - if (xctx) - st_finish(xctx->Context); - } - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - st_bind_texture_surface(psurf, target, xsurf->Base.MipmapLevel, format); - xsurf->Base.BoundToTexture = EGL_TRUE; - - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, - EGLint buffer) -{ - struct xlib_egl_surface *xsurf = lookup_surface(surface); - struct pipe_surface *psurf; - - if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT || - !xsurf->Base.BoundToTexture) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - st_unbind_texture_surface(psurf, ST_TEXTURE_2D, xsurf->Base.MipmapLevel); - xsurf->Base.BoundToTexture = EGL_FALSE; - - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) -{ - struct xlib_egl_surface *xsurf = lookup_surface(draw); - struct pipe_winsys *pws = xsurf->winsys; - struct pipe_surface *psurf; - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - - st_notify_swapbuffers(xsurf->Framebuffer); - - display_surface(pws, psurf, xsurf); - - check_and_update_buffer_size(xsurf); - - return EGL_TRUE; -} - - -/** - * Determine which API(s) is(are) present by looking for some specific - * global symbols. - */ -static EGLint -find_supported_apis(void) -{ - EGLint mask = 0; - void *handle; - - handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); - if(!handle) - return mask; - - if (dlsym(handle, "st_api_OpenGL_ES1")) - mask |= EGL_OPENGL_ES_BIT; - - if (dlsym(handle, "st_api_OpenGL_ES2")) - mask |= EGL_OPENGL_ES2_BIT; - - if (dlsym(handle, "st_api_OpenGL")) - mask |= EGL_OPENGL_BIT; - - if (dlsym(handle, "st_api_OpenVG")) - mask |= EGL_OPENVG_BIT; - - dlclose(handle); - - return mask; -} - - -static void -xlib_Unload(_EGLDriver *drv) -{ - struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); - free(xdrv); -} - - -/** - * This is the main entrypoint into the driver. - * Called by libEGL to instantiate an _EGLDriver object. - */ -_EGLDriver * -_eglMain(const char *args) -{ - struct xlib_egl_driver *xdrv; - - _eglLog(_EGL_INFO, "Entering EGL/Xlib _eglMain(%s)", args); - - xdrv = CALLOC_STRUCT(xlib_egl_driver); - if (!xdrv) - return NULL; - - _eglInitDriverFallbacks(&xdrv->Base); - xdrv->Base.API.Initialize = xlib_eglInitialize; - xdrv->Base.API.Terminate = xlib_eglTerminate; - xdrv->Base.API.GetProcAddress = xlib_eglGetProcAddress; - xdrv->Base.API.CreateContext = xlib_eglCreateContext; - xdrv->Base.API.DestroyContext = xlib_eglDestroyContext; - xdrv->Base.API.CreateWindowSurface = xlib_eglCreateWindowSurface; - xdrv->Base.API.CreatePbufferSurface = xlib_eglCreatePbufferSurface; - xdrv->Base.API.DestroySurface = xlib_eglDestroySurface; - xdrv->Base.API.BindTexImage = xlib_eglBindTexImage; - xdrv->Base.API.ReleaseTexImage = xlib_eglReleaseTexImage; - xdrv->Base.API.MakeCurrent = xlib_eglMakeCurrent; - xdrv->Base.API.SwapBuffers = xlib_eglSwapBuffers; - - xdrv->apis = find_supported_apis(); - if (xdrv->apis == 0x0) { - /* the app isn't directly linked with any EGL-supprted APIs - * (such as libGLESv2.so) so use an EGL utility to see what - * APIs might be loaded dynamically on this system. - */ - xdrv->apis = _eglFindAPIs(); - } - - xdrv->Base.Name = "Xlib/softpipe"; - xdrv->Base.Unload = xlib_Unload; - - return &xdrv->Base; -} diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c deleted file mode 100644 index 6ee3ede38c..0000000000 --- a/src/gallium/winsys/egl_xlib/sw_winsys.c +++ /dev/null @@ -1,231 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - -/** - * Totally software-based winsys layer. - * Note that the one winsys function that we can't implement here - * is flush_frontbuffer(). - * Whoever uses this code will have to provide that. - * - * Authors: Brian Paul - */ - - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_state.h" -#include "pipe/p_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "sw_winsys.h" - - - -/** Subclass of pipe_winsys */ -struct sw_pipe_winsys -{ - struct pipe_winsys Base; - /* no extra fields for now */ -}; - - -/** subclass of pipe_buffer */ -struct sw_pipe_buffer -{ - struct pipe_buffer Base; - boolean UserBuffer; /** Is this a user-space buffer? */ - void *Data; - void *Mapped; -}; - - -/** cast wrapper */ -static INLINE struct sw_pipe_buffer * -sw_pipe_buffer(struct pipe_buffer *b) -{ - return (struct sw_pipe_buffer *) b; -} - - -static const char * -get_name(struct pipe_winsys *pws) -{ - return "software"; -} - - -/** Create new pipe_buffer and allocate storage of given size */ -static struct pipe_buffer * -buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.alignment = alignment; - buffer->Base.usage = usage; - buffer->Base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->Data = align_malloc(size, MAX2(alignment, 16)); - - return &buffer->Base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.size = bytes; - buffer->UserBuffer = TRUE; - buffer->Data = ptr; - - return &buffer->Base; -} - - -static void * -buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = buffer->Data; - return buffer->Mapped; -} - - -static void -buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = NULL; -} - - -static void -buffer_destroy(struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - - if (buffer->Data && !buffer->UserBuffer) { - align_free(buffer->Data); - buffer->Data = NULL; - } - - free(buffer); -} - - -static struct pipe_buffer * -surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - /* no-op */ -} - - -static int -fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -static int -fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -/** - * Create/return a new pipe_winsys object. - */ -struct pipe_winsys * -create_sw_winsys(void) -{ - struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); - if (!ws) - return NULL; - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->Base.buffer_create = buffer_create; - ws->Base.user_buffer_create = user_buffer_create; - ws->Base.buffer_map = buffer_map; - ws->Base.buffer_unmap = buffer_unmap; - ws->Base.buffer_destroy = buffer_destroy; - - ws->Base.surface_buffer_create = surface_buffer_create; - - ws->Base.fence_reference = fence_reference; - ws->Base.fence_signalled = fence_signalled; - ws->Base.fence_finish = fence_finish; - - ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ - - ws->Base.get_name = get_name; - - return &ws->Base; -} diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.h b/src/gallium/winsys/egl_xlib/sw_winsys.h deleted file mode 100644 index f96c5a14b0..0000000000 --- a/src/gallium/winsys/egl_xlib/sw_winsys.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - - -#ifndef SW_WINSYS_H -#define SW_WINSYS_H - - -struct pipe_winsys; - - -extern struct pipe_winsys * -create_sw_winsys(void); - - -#endif /* SW_WINSYS_H */ -- cgit v1.2.3 From cecc33cd4f2b3ae1fa590a450eeaefc9b761fb30 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:53:41 +0800 Subject: egl: Remove _eglFindAPIs. This function is not used and should have been removed by last commit. My mistake. --- src/egl/main/egldriver.c | 52 ------------------------------------------------ src/egl/main/egldriver.h | 4 ---- 2 files changed, 56 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index f890df1bb1..97550ea27c 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -526,58 +526,6 @@ _eglInitDriverFallbacks(_EGLDriver *drv) } - -/** - * Try to determine which EGL APIs (OpenGL, OpenGL ES, OpenVG, etc) - * are supported on the system by looking for standard library names. - */ -EGLint -_eglFindAPIs(void) -{ - EGLint mask = 0x0; - lib_handle lib; -#if defined(_EGL_PLATFORM_WINDOWS) - /* XXX not sure about these names */ - const char *es1_libname = "libGLESv1_CM.dll"; - const char *es2_libname = "libGLESv2.dll"; - const char *gl_libname = "OpenGL32.dll"; - const char *vg_libname = "libOpenVG.dll"; -#elif defined(_EGL_PLATFORM_POSIX) - const char *es1_libname = "libGLESv1_CM.so"; - const char *es2_libname = "libGLESv2.so"; - const char *gl_libname = "libGL.so"; - const char *vg_libname = "libOpenVG.so"; -#else /* _EGL_PLATFORM_NO_OS */ - const char *es1_libname = NULL; - const char *es2_libname = NULL; - const char *gl_libname = NULL; - const char *vg_libname = NULL; -#endif - - if ((lib = open_library(es1_libname))) { - close_library(lib); - mask |= EGL_OPENGL_ES_BIT; - } - - if ((lib = open_library(es2_libname))) { - close_library(lib); - mask |= EGL_OPENGL_ES2_BIT; - } - - if ((lib = open_library(gl_libname))) { - close_library(lib); - mask |= EGL_OPENGL_BIT; - } - - if ((lib = open_library(vg_libname))) { - close_library(lib); - mask |= EGL_OPENVG_BIT; - } - - return mask; -} - - /** * Set the probe cache at the given key. * diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index d9d61297c1..4a1a7ece8c 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -62,10 +62,6 @@ PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); -PUBLIC EGLint -_eglFindAPIs(void); - - PUBLIC void _eglSetProbeCache(EGLint key, const void *val); -- cgit v1.2.3 From 21b2c0a6e5ecb6d542bd7d3750c5a0b745104edd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 21:04:35 +0800 Subject: egl: Add and use make_library_path. Add a platform specific function to turn a library name to a library path. It is used to convert EGL_DRIVER or the default driver to a library path that can be loaded. --- src/egl/main/egldriver.c | 76 +++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 27 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 97550ea27c..d997326729 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -58,6 +58,20 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + EGLBoolean need_suffix; + const char *suffix = ".dll"; + int ret; + + need_suffix = (strchr(name, '.') == NULL); + ret = snprintf(buf, size, "%s%s", name, (need_suffix) ? suffix : ""); + + return ((unsigned int) ret < size); +} + + #elif defined(_EGL_PLATFORM_POSIX) @@ -85,6 +99,24 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + EGLBoolean need_dir, need_suffix; + const char *suffix = ".so"; + int ret; + + need_dir = (strchr(name, '/') == NULL); + need_suffix = (strchr(name, '.') == NULL); + + ret = snprintf(buf, size, "%s%s%s", + (need_dir) ? _EGL_DRIVER_SEARCH_DIR"/" : "", name, + (need_suffix) ? suffix : ""); + + return ((unsigned int) ret < size); +} + + #else /* _EGL_PLATFORM_NO_OS */ static const char DefaultDriverName[] = "builtin"; @@ -110,6 +142,14 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + int ret = snprintf(buf, size, name); + return ((unsigned int) ret < size); +} + + #endif @@ -288,36 +328,21 @@ _eglPreloadUserDriver(void) { #if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS) _EGLDriver *drv; - char *env, *path; - const char *suffix, *p; + char path[1024]; + char *env; env = getenv("EGL_DRIVER"); if (!env) return EGL_FALSE; - path = env; - suffix = library_suffix(); - - /* append suffix if there isn't */ - p = strrchr(path, '.'); - if (!p && suffix) { - size_t len = strlen(path); - char *tmp = malloc(len + strlen(suffix) + 2); - if (tmp) { - memcpy(tmp, path, len); - tmp[len++] = '.'; - tmp[len] = '\0'; - strcat(tmp + len, suffix); - - path = tmp; - } - } + if (!make_library_path(path, sizeof(path), env)) + return EGL_FALSE; drv = _eglLoadDriver(path, NULL); - if (path != env) - free(path); - if (!drv) + if (!drv) { + _eglLog(_EGL_WARNING, "EGL_DRIVER is set to an invalid driver"); return EGL_FALSE; + } _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; @@ -399,12 +424,9 @@ _eglPreloadDefaultDriver(void) { _EGLDriver *drv; char path[1024]; - const char *suffix = library_suffix(); - if (suffix) - snprintf(path, sizeof(path), "%s.%s", DefaultDriverName, suffix); - else - snprintf(path, sizeof(path), DefaultDriverName); + if (!make_library_path(path, sizeof(path), DefaultDriverName)) + return EGL_FALSE; drv = _eglLoadDriver(path, NULL); if (!drv) -- cgit v1.2.3 From a1c4a8a3c855d52fbfef10023b9a8f116e163a97 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 15 Aug 2009 22:58:13 +0800 Subject: egl: Add support for EGL_KHR_image. Individual drivers still need to implement the API hooks. --- src/egl/main/Makefile | 2 + src/egl/main/eglapi.c | 54 ++++++++++++++++++++++++++ src/egl/main/eglapi.h | 13 ++++++- src/egl/main/egldisplay.h | 3 ++ src/egl/main/egldriver.c | 6 +++ src/egl/main/eglimage.c | 51 +++++++++++++++++++++++++ src/egl/main/eglimage.h | 95 ++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglmisc.c | 8 ++++ src/egl/main/egltypedefs.h | 2 + 9 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 src/egl/main/eglimage.c create mode 100644 src/egl/main/eglimage.h (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 20614d8753..5b83b43bc2 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -19,6 +19,7 @@ HEADERS = \ egldisplay.h \ egldriver.h \ eglglobals.h \ + eglimage.h \ egllog.h \ eglmisc.h \ eglmode.h \ @@ -36,6 +37,7 @@ SOURCES = \ egldisplay.c \ egldriver.c \ eglglobals.c \ + eglimage.c \ egllog.c \ eglmisc.c \ eglmode.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index e57ce211b8..218de3ab6b 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -65,6 +65,7 @@ #include "eglconfig.h" #include "eglscreen.h" #include "eglmode.h" +#include "eglimage.h" /** @@ -700,6 +701,10 @@ eglGetProcAddress(const char *procname) { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA }, { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA }, #endif /* EGL_MESA_screen_surface */ +#ifdef EGL_KHR_image_base + { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, + { "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, +#endif /* EGL_KHR_image_base */ { NULL, NULL } }; EGLint i; @@ -995,3 +1000,52 @@ eglReleaseThread(void) #endif /* EGL_VERSION_1_2 */ + + +#ifdef EGL_KHR_image_base + + +EGLImageKHR +eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, + EGLClientBuffer buffer, const EGLint *attr_list) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + _EGLContext *context = _eglLookupContext(ctx, disp); + _EGLDriver *drv; + _EGLImage *img; + + drv = _eglCheckDisplay(disp, __FUNCTION__); + if (!drv) + return EGL_NO_IMAGE_KHR; + if (!context && ctx != EGL_NO_CONTEXT) { + _eglError(EGL_BAD_CONTEXT, __FUNCTION__); + return EGL_NO_IMAGE_KHR; + } + + img = drv->API.CreateImageKHR(drv, + disp, context, target, buffer, attr_list); + if (img) + return _eglLinkImage(img, disp); + else + return EGL_NO_IMAGE_KHR; +} + + +EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + _EGLImage *img = _eglLookupImage(image, disp); + _EGLDriver *drv; + + drv = _eglCheckDisplay(disp, __FUNCTION__); + if (!drv) + return EGL_FALSE; + if (!img) + return _eglError(EGL_BAD_PARAMETER, __FUNCTION__); + + _eglUnlinkImage(img); + return drv->API.DestroyImageKHR(drv, disp, img); +} + + +#endif /* EGL_KHR_image_base */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 080f2155e3..bd3c3b4875 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -69,6 +69,11 @@ typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDis #endif /* EGL_VERSION_1_2 */ +#ifdef EGL_KHR_image_base +typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); +typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); +#endif /* EGL_KHR_image_base */ + /** * The API dispatcher jumps through these functions @@ -104,7 +109,7 @@ struct _egl_api WaitNative_t WaitNative; GetProcAddress_t GetProcAddress; - /* EGL_MESA_screen extension */ +#ifdef EGL_MESA_screen_surface ChooseModeMESA_t ChooseModeMESA; GetModesMESA_t GetModesMESA; GetModeAttribMESA_t GetModeAttribMESA; @@ -117,10 +122,16 @@ struct _egl_api QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA; QueryScreenModeMESA_t QueryScreenModeMESA; QueryModeStringMESA_t QueryModeStringMESA; +#endif /* EGL_MESA_screen_surface */ #ifdef EGL_VERSION_1_2 CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; #endif + +#ifdef EGL_KHR_image_base + CreateImageKHR_t CreateImageKHR; + DestroyImageKHR_t DestroyImageKHR; +#endif /* EGL_KHR_image_base */ }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index b13ce08261..70fe29513c 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -8,6 +8,7 @@ enum _egl_resource_type { _EGL_RESOURCE_CONTEXT, _EGL_RESOURCE_SURFACE, + _EGL_RESOURCE_IMAGE, _EGL_NUM_RESOURCES }; @@ -30,6 +31,8 @@ struct _egl_extensions { EGLBoolean MESA_screen_surface; EGLBoolean MESA_copy_context; + EGLBoolean KHR_image_base; + EGLBoolean KHR_image_pixmap; char String[_EGL_MAX_EXTENSIONS_LEN]; }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index d997326729..b820b966f9 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -19,6 +19,7 @@ #include "eglscreen.h" #include "eglstring.h" #include "eglsurface.h" +#include "eglimage.h" #if defined(_EGL_PLATFORM_POSIX) #include @@ -545,6 +546,11 @@ _eglInitDriverFallbacks(_EGLDriver *drv) #ifdef EGL_VERSION_1_2 drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer; #endif /* EGL_VERSION_1_2 */ + +#ifdef EGL_KHR_image_base + drv->API.CreateImageKHR = _eglCreateImageKHR; + drv->API.DestroyImageKHR = _eglDestroyImageKHR; +#endif /* EGL_KHR_image_base */ } diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c new file mode 100644 index 0000000000..5044112fa8 --- /dev/null +++ b/src/egl/main/eglimage.c @@ -0,0 +1,51 @@ +#include + +#include "eglimage.h" +#include "egldisplay.h" + + +#ifdef EGL_KHR_image_base + + +EGLBoolean +_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list) +{ + EGLint i; + + img->Preserved = EGL_FALSE; + + for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { + switch (attrib_list[i]) { + case EGL_IMAGE_PRESERVED_KHR: + i++; + img->Preserved = attrib_list[i]; + break; + default: + /* not an error */ + break; + } + } + + return EGL_TRUE; +} + + +_EGLImage * +_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, + const EGLint *attr_list) +{ + /* driver should override this function */ + return NULL; +} + + +EGLBoolean +_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image) +{ + /* driver should override this function */ + return EGL_FALSE; +} + + +#endif /* EGL_KHR_image_base */ diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h new file mode 100644 index 0000000000..026b10307d --- /dev/null +++ b/src/egl/main/eglimage.h @@ -0,0 +1,95 @@ +#ifndef EGLIMAGE_INCLUDED +#define EGLIMAGE_INCLUDED + + +#include "egltypedefs.h" +#include "egldisplay.h" + + +/** + * "Base" class for device driver images. + */ +struct _egl_image +{ + /* An image is a display resource */ + _EGLResource Resource; + + EGLBoolean Preserved; +}; + + +PUBLIC EGLBoolean +_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list); + + +extern _EGLImage * +_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); + + +extern EGLBoolean +_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); + + +/** + * Link an image to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +static INLINE EGLImageKHR +_eglLinkImage(_EGLImage *img, _EGLDisplay *dpy) +{ + _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy); + return (EGLImageKHR) img; +} + + +/** + * Unlink a linked image from its display. + * Accessing an unlinked image should generate EGL_BAD_PARAMETER error. + */ +static INLINE void +_eglUnlinkImage(_EGLImage *img) +{ + _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); +} + + +/** + * Lookup a handle to find the linked image. + * Return NULL if the handle has no corresponding linked image. + */ +static INLINE _EGLImage * +_eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) +{ + _EGLResource *res = (_EGLResource *) image; + _EGLImage *img = (_EGLImage *) image; + if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_IMAGE, dpy)) + img = NULL; + return img; +} + + +/** + * Return the handle of a linked image, or EGL_NO_IMAGE_KHR. + */ +static INLINE EGLImageKHR +_eglGetImageHandle(_EGLImage *img) +{ + _EGLResource *res = (_EGLResource *) img; + return (res && _eglIsResourceLinked(res)) ? + (EGLImageKHR) img : EGL_NO_IMAGE_KHR; +} + + +/** + * Return true if the image is linked to a display. + */ +static INLINE EGLBoolean +_eglIsImageLinked(_EGLImage *img) +{ + _EGLResource *res = (_EGLResource *) img; + return (res && _eglIsResourceLinked(res)); +} + + +#endif /* EGLIMAGE_INCLUDED */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index e66913320b..5726f5bca8 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -54,6 +54,14 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) strcat(exts, "EGL_MESA_screen_surface "); if (dpy->Extensions.MESA_copy_context) strcat(exts, "EGL_MESA_copy_context "); + + if (dpy->Extensions.KHR_image_base) + strcat(exts, "EGL_KHR_image_base "); + if (dpy->Extensions.KHR_image_pixmap) + strcat(exts, "EGL_KHR_image_pixmap "); + if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap) + strcat(exts, "EGL_KHR_image "); + assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN); } diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index a49ffbb0cd..e6b19b35d0 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -22,6 +22,8 @@ typedef struct _egl_driver _EGLDriver; typedef struct _egl_extensions _EGLExtensions; +typedef struct _egl_image _EGLImage; + typedef struct _egl_mode _EGLMode; typedef struct _egl_resource _EGLResource; -- cgit v1.2.3 From 092b1ca989ba3bdc3f4d421b83b3943af260b7db Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 18:41:15 +0800 Subject: egl: Remove _eglOpenDriver and _eglCloseDriver. _eglCloseDriver is no-op and _eglOpenDriver does nothing but call _eglMatchDriver. Export _eglMatchDriver directly. --- src/egl/main/eglapi.c | 7 ++----- src/egl/main/egldriver.c | 23 +---------------------- src/egl/main/egldriver.h | 6 +----- 3 files changed, 4 insertions(+), 32 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 492a14180a..90828bd3e9 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -104,15 +104,13 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) if (!drv) { _eglPreloadDrivers(); - drv = _eglOpenDriver(disp); + drv = _eglMatchDriver(disp); if (!drv) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); /* Initialize the particular display now */ - if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) { - _eglCloseDriver(drv, disp); + if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); - } disp->APImajor = major_int; disp->APIminor = minor_int; @@ -150,7 +148,6 @@ eglTerminate(EGLDisplay dpy) drv = disp->Driver; if (drv) { drv->API.Terminate(drv, disp); - _eglCloseDriver(drv, disp); disp->Driver = NULL; } diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index b820b966f9..1dadbf783b 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -269,7 +269,7 @@ _eglLoadDriver(const char *path, const char *args) * * The matching is done by finding the driver with the highest score. */ -static _EGLDriver * +_EGLDriver * _eglMatchDriver(_EGLDisplay *dpy) { _EGLDriver *best_drv = NULL; @@ -298,27 +298,6 @@ _eglMatchDriver(_EGLDisplay *dpy) } -/** - * Open a preloaded driver. - */ -_EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy) -{ - _EGLDriver *drv = _eglMatchDriver(dpy); - return drv; -} - - -/** - * Close a preloaded driver. - */ -EGLBoolean -_eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) -{ - return EGL_TRUE; -} - - /** * Preload a user driver. * diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 4a1a7ece8c..6ebb60a8f1 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -43,11 +43,7 @@ _eglMain(const char *args); extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy); - - -extern EGLBoolean -_eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy); +_eglMatchDriver(_EGLDisplay *dpy); extern EGLBoolean -- cgit v1.2.3 From 94cb321b5d246185abf71d89968d472a626f1a23 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 29 Jan 2010 09:00:30 +0800 Subject: egl: Clean up header inclusions. Mainly to remove eglcurrent.h and egldisplay.h from eglglobals.h. --- src/egl/drivers/glx/egl_glx.c | 2 +- src/egl/drivers/xdri/egl_xdri.c | 2 +- src/egl/main/eglapi.c | 1 + src/egl/main/eglapi.h | 2 +- src/egl/main/eglconfig.c | 3 +-- src/egl/main/eglconfigutil.c | 1 - src/egl/main/eglcontext.c | 2 +- src/egl/main/eglcontext.h | 1 - src/egl/main/eglcurrent.c | 4 ++-- src/egl/main/eglcurrent.h | 1 + src/egl/main/egldisplay.c | 1 + src/egl/main/egldisplay.h | 1 + src/egl/main/egldriver.c | 1 + src/egl/main/egldriver.h | 3 +++ src/egl/main/eglglobals.c | 1 + src/egl/main/eglglobals.h | 3 +-- src/egl/main/egllog.h | 2 ++ src/egl/main/eglmisc.c | 2 +- src/egl/main/eglmisc.h | 3 ++- src/egl/main/eglmode.c | 3 +-- src/egl/main/eglscreen.c | 1 + src/egl/main/eglscreen.h | 3 +++ src/egl/main/eglsurface.c | 2 +- src/egl/main/egltypedefs.h | 4 ---- 24 files changed, 28 insertions(+), 21 deletions(-) (limited to 'src/egl/main/egldriver.c') diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 1c38db6491..af653b86ee 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -43,7 +43,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 2ca9ea8a5b..10f7a31f5b 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -52,7 +52,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 7e77ef1f03..364ad9c458 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -60,6 +60,7 @@ #include "egldisplay.h" #include "egltypedefs.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "egldriver.h" #include "eglsurface.h" #include "eglconfig.h" diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index a7600820f3..c3676ec56a 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -4,7 +4,7 @@ /** * A generic function ptr type */ -typedef void (*_EGLProc)(); +typedef void (*_EGLProc)(void); /** diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 2db9b9401a..b974e40cce 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -4,12 +4,11 @@ #include -#include #include #include #include "eglconfig.h" #include "egldisplay.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index ddb886c54d..e416b190f0 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -4,7 +4,6 @@ #include -#include #include #include "eglconfigutil.h" diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 4496f76ece..ee9d60e17a 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -5,7 +5,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglsurface.h" diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 4811e3bb7a..ebb50aa60e 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -1,4 +1,3 @@ - #ifndef EGLCONTEXT_INCLUDED #define EGLCONTEXT_INCLUDED diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 696d04e8ba..a19dcf4096 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -1,10 +1,10 @@ #include #include -#include "eglcurrent.h" +#include "eglglobals.h" #include "eglcontext.h" #include "egllog.h" #include "eglmutex.h" -#include "eglglobals.h" +#include "eglcurrent.h" /* This should be kept in sync with _eglInitThreadInfo() */ diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index c169c93e94..e5c94ce60a 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -1,6 +1,7 @@ #ifndef EGLCURRENT_INCLUDED #define EGLCURRENT_INCLUDED + #include "egltypedefs.h" diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index d7a8d14292..5897372fc5 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -10,6 +10,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "eglmutex.h" #include "egllog.h" diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 4aea10c3eb..b04b094d84 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -1,6 +1,7 @@ #ifndef EGLDISPLAY_INCLUDED #define EGLDISPLAY_INCLUDED + #include "egltypedefs.h" #include "egldefines.h" diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 1dadbf783b..df36369ac2 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -13,6 +13,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglmisc.h" #include "eglmode.h" diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 6ebb60a8f1..5149acd964 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -6,6 +6,9 @@ #include "eglapi.h" +typedef _EGLDriver *(*_EGLMain_t)(const char *args); + + /** * Base class for device drivers. */ diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 9c4902621f..5182b18e22 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -1,6 +1,7 @@ #include #include #include "eglglobals.h" +#include "egldisplay.h" #include "egldriver.h" #include "eglmutex.h" diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 5ebb914ca7..cd1dd5851b 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -1,9 +1,8 @@ #ifndef EGLGLOBALS_INCLUDED #define EGLGLOBALS_INCLUDED + #include "egltypedefs.h" -#include "egldisplay.h" -#include "eglcurrent.h" #include "eglmutex.h" diff --git a/src/egl/main/egllog.h b/src/egl/main/egllog.h index 3a99bfea4b..03bef2670f 100644 --- a/src/egl/main/egllog.h +++ b/src/egl/main/egllog.h @@ -1,8 +1,10 @@ #ifndef EGLLOG_INCLUDED #define EGLLOG_INCLUDED + #include "egltypedefs.h" + #define _EGL_FATAL 0 /* unrecoverable error */ #define _EGL_WARNING 1 /* recoverable error/problem */ #define _EGL_INFO 2 /* just useful info */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 5726f5bca8..907a057b44 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -33,7 +33,7 @@ #include #include -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglmisc.h" #include "egldisplay.h" diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h index 829d4cde79..5e6a2d41df 100644 --- a/src/egl/main/eglmisc.h +++ b/src/egl/main/eglmisc.h @@ -29,7 +29,8 @@ #ifndef EGLMISC_INCLUDED #define EGLMISC_INCLUDED -#include "egldriver.h" + +#include "egltypedefs.h" extern const char * diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 0f3ba6e5c0..503b9e595e 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,7 +5,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglmode.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglscreen.h" diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 14a1e9f8fe..1079a1cbe6 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -17,6 +17,7 @@ #include "egldisplay.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "eglmode.h" #include "eglconfig.h" #include "eglsurface.h" diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h index d52e5388c3..c400ac3d15 100644 --- a/src/egl/main/eglscreen.h +++ b/src/egl/main/eglscreen.h @@ -2,6 +2,9 @@ #define EGLSCREEN_INCLUDED +#include "egltypedefs.h" + + /** * Per-screen information. * Note that an EGL screen doesn't have a size. A screen may be set to diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 3219231ed2..8f87239fe2 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -9,7 +9,7 @@ #include "egldisplay.h" #include "eglcontext.h" #include "eglconfig.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index e6b19b35d0..e0c95762c6 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -34,8 +34,4 @@ typedef struct _egl_surface _EGLSurface; typedef struct _egl_thread_info _EGLThreadInfo; - -typedef _EGLDriver *(*_EGLMain_t)(const char *args); - - #endif /* EGLTYPEDEFS_INCLUDED */ -- cgit v1.2.3