diff options
-rw-r--r-- | src/egl/drivers/demo/demo.c | 19 | ||||
-rw-r--r-- | src/egl/drivers/glx/egl_glx.c | 18 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 13 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 25 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 9 | ||||
-rw-r--r-- | src/egl/main/egldriver.h | 27 | ||||
-rw-r--r-- | src/egl/main/eglglobals.c | 1 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 2 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 54 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 2 | ||||
-rw-r--r-- | src/egl/main/egltypedefs.h | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_tracker.c | 25 | ||||
-rw-r--r-- | src/gallium/winsys/egl_xlib/egl_xlib.c | 36 |
13 files changed, 138 insertions, 95 deletions
diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index e9e6bac5b1..aea4894448 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -84,7 +84,9 @@ demoInitialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) _eglAddConfig(disp, config); } - drv->Initialized = EGL_TRUE; + /* enable supported extensions */ + disp->Extensions.MESA_screen_surface = EGL_TRUE; + disp->Extensions.MESA_copy_context = EGL_TRUE; *major = 1; *minor = 0; @@ -97,7 +99,6 @@ static EGLBoolean demoTerminate(_EGLDriver *drv, _EGLDisplay *dpy) { /*DemoDriver *demo = DEMO_DRIVER(dpy);*/ - free(drv); return EGL_TRUE; } @@ -247,12 +248,19 @@ demoMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *drawSurf, _EGLSu } +static void +demoUnload(_EGLDriver *drv) +{ + free(drv); +} + + /** * The bootstrap function. Return a new DemoDriver object and * plug in API functions. */ _EGLDriver * -_eglMain(_EGLDisplay *dpy, const char *args) +_eglMain(const char *args) { DemoDriver *demo; @@ -274,9 +282,8 @@ _eglMain(_EGLDisplay *dpy, const char *args) demo->Base.API.DestroySurface = demoDestroySurface; demo->Base.API.DestroyContext = demoDestroyContext; - /* enable supported extensions */ - demo->Base.Extensions.MESA_screen_surface = EGL_TRUE; - demo->Base.Extensions.MESA_copy_context = EGL_TRUE; + demo->Base.Name = "egl/demo"; + demo->Base.Unload = demoUnload; return &demo->Base; } diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 607e649e5c..9d80bc1a84 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -462,10 +462,10 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp, } } + disp->ClientAPIsMask = all_apis; + glXQueryVersion(disp->Xdpy, &GLX_drv->glx_maj, &GLX_drv->glx_min); - GLX_drv->Base.Initialized = EGL_TRUE; - GLX_drv->Base.Name = "GLX"; /* we're supporting EGL 1.4 */ @@ -513,7 +513,9 @@ GLX_eglTerminate(_EGLDriver *drv, _EGLDisplay *disp) { _eglLog(_EGL_DEBUG, "GLX: eglTerminate"); + _eglReleaseDisplayResources(drv, disp); FreeDisplayExt(disp->Xdpy); + _eglCleanupDisplay(disp); return EGL_TRUE; } @@ -797,12 +799,20 @@ GLX_eglGetProcAddress(const char *procname) } +static void +GLX_Unload(_EGLDriver *drv) +{ + struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); + free(GLX_drv); +} + + /** * 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) +_eglMain(const char *args) { struct GLX_egl_driver *GLX_drv = CALLOC_STRUCT(GLX_egl_driver); char *env; @@ -831,8 +841,8 @@ _eglMain(_EGLDisplay *disp, const char *args) GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers; GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress; - GLX_drv->Base.ClientAPIsMask = all_apis; GLX_drv->Base.Name = "GLX"; + GLX_drv->Base.Unload = GLX_Unload; _eglLog(_EGL_DEBUG, "GLX: main(%s)", args); diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 464da00fe2..a23b57120c 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -87,15 +87,18 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); } - drv->APImajor = major_int; - drv->APIminor = minor_int; - snprintf(drv->Version, sizeof(drv->Version), + disp->APImajor = major_int; + disp->APIminor = minor_int; + snprintf(disp->Version, sizeof(disp->Version), "%d.%d (%s)", major_int, minor_int, drv->Name); + /* update the global notion of supported APIs */ + _eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask; + disp->Driver = drv; } else { - major_int = drv->APImajor; - minor_int = drv->APIminor; + major_int = disp->APImajor; + minor_int = disp->APIminor; } /* Update applications version of major and minor if not NULL */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 78fbf5b840..e1cbbac837 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -7,6 +7,19 @@ #include "egltypedefs.h" #include "eglhash.h" +#include "egldefines.h" + + +/** + * Optional EGL extensions info. + */ +struct _egl_extensions +{ + EGLBoolean MESA_screen_surface; + EGLBoolean MESA_copy_context; + + char String[_EGL_MAX_EXTENSIONS_LEN]; +}; struct _egl_display @@ -16,6 +29,18 @@ struct _egl_display const char *DriverName; _EGLDriver *Driver; + void *DriverData; /* private to driver */ + + int APImajor, APIminor; /**< as returned by eglInitialize() */ + char Version[1000]; /**< initialized from APImajor/minor, DriverName */ + + /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ + EGLint ClientAPIsMask; + char ClientAPIs[1000]; /**< updated by eglQueryString */ + + _EGLExtensions Extensions; + + int LargestPbuffer; EGLint NumScreens; _EGLScreen **Screens; /* array [NumScreens] */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 36cc2948c0..0e6b294385 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -245,7 +245,7 @@ _eglOpenLibrary(const char *driverName, lib_handle *handle) * owned by the driver and freed. */ static _EGLDriver * -_eglLoadDriver(_EGLDisplay *dpy, char *path, char *args) +_eglLoadDriver(char *path, char *args) { _EGLMain_t mainFunc; lib_handle lib; @@ -255,7 +255,7 @@ _eglLoadDriver(_EGLDisplay *dpy, char *path, char *args) if (!mainFunc) return NULL; - drv = mainFunc(dpy, args); + drv = mainFunc(args); if (!drv) { if (lib) close_library(lib); @@ -332,13 +332,10 @@ _eglPreloadDriver(_EGLDisplay *dpy) } } - drv = _eglLoadDriver(dpy, path, args); + drv = _eglLoadDriver(path, args); if (!drv) return NULL; - /* update the global notion of supported APIs */ - _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; - _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; return drv->Name; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 430c0949d4..7fba938085 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -4,19 +4,6 @@ #include "egltypedefs.h" #include "eglapi.h" -#include "egldefines.h" - - -/** - * Optional EGL extensions info. - */ -struct _egl_extensions -{ - EGLBoolean MESA_screen_surface; - EGLBoolean MESA_copy_context; - - char String[_EGL_MAX_EXTENSIONS_LEN]; -}; /** @@ -24,8 +11,6 @@ struct _egl_extensions */ struct _egl_driver { - EGLBoolean Initialized; /**< set by driver after initialized */ - void *LibHandle; /**< dlopen handle */ const char *Path; /**< path to this driver */ const char *Args; /**< args to load this driver */ @@ -36,21 +21,11 @@ struct _egl_driver /**< called before dlclose to release this driver */ void (*Unload)(_EGLDriver *drv); - int APImajor, APIminor; /**< as returned by eglInitialize() */ - char Version[1000]; /**< initialized from APImajor/minor, Name */ - - /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ - EGLint ClientAPIsMask; - _EGLAPI API; /**< EGL API dispatch table */ - - _EGLExtensions Extensions; - - int LargestPbuffer; }; -extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args); +extern _EGLDriver *_eglMain(const char *args); extern const char * diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index a532f142b7..8c14f9c4bf 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -15,7 +15,6 @@ struct _egl_global _eglGlobal = &_eglGlobalMutex, /* Mutex */ 1, /* FreeScreenHandle */ 0x0, /* ClientAPIsMask */ - { 0x0 }, /* ClientAPIs */ 0, /* NumDrivers */ { NULL }, /* Drivers */ 1, /* NumAtExitCalls */ diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 1e2c674263..d00d12afd8 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -18,8 +18,6 @@ struct _egl_global /* bitmaks of supported APIs (supported by _some_ driver) */ EGLint ClientAPIsMask; - char ClientAPIs[1000]; /**< updated by eglQueryString */ - EGLint NumDrivers; _EGLDriver *Drivers[10]; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 3440b77dd9..b37213faf1 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -35,6 +35,7 @@ #include <string.h> #include "eglglobals.h" #include "eglmisc.h" +#include "egldisplay.h" /** @@ -42,38 +43,43 @@ * the driver's Extensions string. */ static void -_eglUpdateExtensionsString(_EGLDriver *drv) +_eglUpdateExtensionsString(_EGLDisplay *dpy) { - drv->Extensions.String[0] = 0; + char *exts = dpy->Extensions.String; - if (drv->Extensions.MESA_screen_surface) - strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); - if (drv->Extensions.MESA_copy_context) - strcat(drv->Extensions.String, "EGL_MESA_copy_context "); - assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN); + if (exts[0]) + return; + + if (dpy->Extensions.MESA_screen_surface) + strcat(exts, "EGL_MESA_screen_surface "); + if (dpy->Extensions.MESA_copy_context) + strcat(exts, "EGL_MESA_copy_context "); + assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN); } static void -_eglUpdateAPIsString(_EGLDriver *drv) +_eglUpdateAPIsString(_EGLDisplay *dpy) { - _eglGlobal.ClientAPIs[0] = 0; + char *apis = dpy->ClientAPIs; - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL "); + if (apis[0] || !dpy->ClientAPIsMask) + return; - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL_ES "); + if (dpy->ClientAPIsMask & EGL_OPENGL_BIT) + strcat(apis, "OpenGL "); - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES2_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL_ES2 "); + if (dpy->ClientAPIsMask & EGL_OPENGL_ES_BIT) + strcat(apis, "OpenGL_ES "); - if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenVG "); + if (dpy->ClientAPIsMask & EGL_OPENGL_ES2_BIT) + strcat(apis, "OpenGL_ES2 "); - assert(strlen(_eglGlobal.ClientAPIs) < sizeof(_eglGlobal.ClientAPIs)); -} + if (dpy->ClientAPIsMask & EGL_OPENVG_BIT) + strcat(apis, "OpenVG "); + assert(strlen(apis) < sizeof(dpy->ClientAPIs)); +} const char * @@ -85,14 +91,14 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) case EGL_VENDOR: return _EGL_VENDOR_STRING; case EGL_VERSION: - return drv->Version; + return dpy->Version; case EGL_EXTENSIONS: - _eglUpdateExtensionsString(drv); - return drv->Extensions.String; + _eglUpdateExtensionsString(dpy); + return dpy->Extensions.String; #ifdef EGL_VERSION_1_2 case EGL_CLIENT_APIS: - _eglUpdateAPIsString(drv); - return _eglGlobal.ClientAPIs; + _eglUpdateAPIsString(dpy); + return dpy->ClientAPIs; #endif default: _eglError(EGL_BAD_PARAMETER, "eglQueryString"); diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 056288c850..adf125f88a 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -243,7 +243,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); return EGL_TRUE; case EGL_LARGEST_PBUFFER: - *value = drv->LargestPbuffer; + *value = dpy->LargestPbuffer; return EGL_TRUE; case EGL_SURFACE_TYPE: *value = surface->Type; diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index 0a770dec0c..4461440b9b 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -29,7 +29,7 @@ typedef struct _egl_surface _EGLSurface; typedef struct _egl_thread_info _EGLThreadInfo; -typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args); +typedef _EGLDriver *(*_EGLMain_t)(const char *args); #endif /* EGLTYPEDEFS_INCLUDED */ diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index 107f45cbcb..ced002c535 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -21,12 +21,20 @@ extern const struct dri_extension card_extensions[]; * Exported functions */ +static void +drm_unload(_EGLDriver *drv) +{ + struct drm_device *dev = (struct drm_device *)drv; + dev->api->destroy(dev->api); + free(dev); +} + /** * The bootstrap function. Return a new drm_driver object and * plug in API functions. */ _EGLDriver * -_eglMain(_EGLDisplay *dpy, const char *args) +_eglMain(const char *args) { struct drm_device *drm; @@ -53,12 +61,8 @@ _eglMain(_EGLDisplay *dpy, const char *args) drm->base.API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa; drm->base.API.SwapBuffers = drm_swap_buffers; - drm->base.ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; drm->base.Name = "DRM/Gallium/Win"; - - /* enable supported extensions */ - drm->base.Extensions.MESA_screen_surface = EGL_TRUE; - drm->base.Extensions.MESA_copy_context = EGL_TRUE; + drm->base.Unload = drm_unload; return &drm->base; } @@ -199,7 +203,10 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT); _eglAddConfig(disp, config); - drv->Initialized = EGL_TRUE; + disp->ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; + /* enable supported extensions */ + disp->Extensions.MESA_screen_surface = EGL_TRUE; + disp->Extensions.MESA_copy_context = EGL_TRUE; *major = 1; *minor = 4; @@ -219,6 +226,8 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy) struct drm_screen *screen; int i = 0; + _eglReleaseDisplayResources(drv, dpy); + drmFreeVersion(dev->version); for (i = 0; i < dev->count_screens; i++) { @@ -235,12 +244,10 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy) dev->screen->destroy(dev->screen); dev->winsys = NULL; - dev->api->destroy(dev->api); drmClose(dev->drmFD); _eglCleanupDisplay(dpy); - free(dev); return EGL_TRUE; } diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index ed7eab50dd..7a667568b8 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -62,6 +62,7 @@ struct xlib_egl_driver { _EGLDriver Base; /**< base class */ + EGLint apis; struct pipe_winsys *winsys; struct pipe_screen *screen; }; @@ -194,9 +195,15 @@ static EGLBoolean xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *minor, EGLint *major) { + struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); + create_configs(drv, dpy); - drv->Initialized = EGL_TRUE; + if (!dpy->Xdpy) { + dpy->Xdpy = XOpenDisplay(NULL); + } + + dpy->ClientAPIsMask = xdrv->apis; /* we're supporting EGL 1.4 */ *minor = 1; @@ -212,6 +219,8 @@ xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, static EGLBoolean xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy) { + _eglReleaseDisplayResources(drv, dpy); + _eglCleanupDisplay(dpy); return EGL_TRUE; } @@ -744,12 +753,22 @@ find_supported_apis(void) } +static void +xlib_Unload(_EGLDriver *drv) +{ + struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); + xdrv->screen->destroy(xdrv->screen); + free(xdrv->winsys); + free(xdrv); +} + + /** * This is the main entrypoint into the driver. * Called by libEGL to instantiate an _EGLDriver object. */ _EGLDriver * -_eglMain(_EGLDisplay *dpy, const char *args) +_eglMain(const char *args) { struct xlib_egl_driver *xdrv; @@ -759,10 +778,6 @@ _eglMain(_EGLDisplay *dpy, const char *args) if (!xdrv) return NULL; - if (!dpy->Xdpy) { - dpy->Xdpy = XOpenDisplay(NULL); - } - _eglInitDriverFallbacks(&xdrv->Base); xdrv->Base.API.Initialize = xlib_eglInitialize; xdrv->Base.API.Terminate = xlib_eglTerminate; @@ -777,16 +792,17 @@ _eglMain(_EGLDisplay *dpy, const char *args) xdrv->Base.API.MakeCurrent = xlib_eglMakeCurrent; xdrv->Base.API.SwapBuffers = xlib_eglSwapBuffers; - xdrv->Base.ClientAPIsMask = find_supported_apis(); - if (xdrv->Base.ClientAPIsMask == 0x0) { + 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->Base.ClientAPIsMask = _eglFindAPIs(); - } + xdrv->apis = _eglFindAPIs(); + } xdrv->Base.Name = "Xlib/softpipe"; + xdrv->Base.Unload = xlib_Unload; /* create one winsys and use it for all contexts/surfaces */ xdrv->winsys = create_sw_winsys(); |