From 5e7dba541298a29f175f9d077bf6f63030465d94 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:21:25 -0600 Subject: eliminate the context hash table In EGL 1.4 the opaque EGLContext type is a pointer so we can just cast between public EGLContext handles and private _EGLContext pointers. --- src/egl/main/eglglobals.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/egl/main/eglglobals.h') diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index c16baa2d6bd..4fccd226b7a 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -24,7 +24,6 @@ struct _egl_global EGLBoolean Initialized; _EGLHashtable *Displays; - _EGLHashtable *Contexts; _EGLHashtable *Surfaces; EGLScreenMESA FreeScreenHandle; -- cgit v1.2.3 From 5f8a4f3e5e8fe78f1abe9ca6dd1131ad53d3d943 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:23:56 -0600 Subject: added EGL_OPENGL_API case --- src/egl/main/eglapi.c | 11 ++++++++++- src/egl/main/eglglobals.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/egl/main/eglglobals.h') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index c57d29dda67..4df31cc03ff 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -511,6 +511,15 @@ eglBindAPI(EGLenum api) _EGLThreadInfo *t = _eglGetCurrentThread(); switch (api) { +#ifdef EGL_VERSION_1_4 + case EGL_OPENGL_API: + if (_eglGlobal.OpenGLAPISupported) { + t->CurrentAPI = api; + return EGL_TRUE; + } + _eglError(EGL_BAD_PARAMETER, "eglBindAPI"); + return EGL_FALSE; +#endif case EGL_OPENGL_ES_API: if (_eglGlobal.OpenGLESAPISupported) { t->CurrentAPI = api; @@ -546,7 +555,7 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLenum eglQueryAPI(void) { - /* returns one of EGL_OPENGL_ES_API or EGL_OPENVG_API */ + /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */ _EGLThreadInfo *t = _eglGetCurrentThread(); return t->CurrentAPI; } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 4fccd226b7a..6b858b6b089 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -29,6 +29,7 @@ struct _egl_global EGLScreenMESA FreeScreenHandle; /* XXX these may be temporary */ + EGLBoolean OpenGLAPISupported; EGLBoolean OpenGLESAPISupported; EGLBoolean OpenVGAPISupported; -- cgit v1.2.3 From d5078b94323241a6482f54797756116b1c864327 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 13:45:40 -0600 Subject: egl: clean-up re-org of the client API state --- src/egl/main/eglapi.c | 39 +++++++++++++++++++++++++++------------ src/egl/main/eglcontext.c | 10 +++++++++- src/egl/main/eglcontext.h | 6 +++--- src/egl/main/egldriver.c | 7 +++++-- src/egl/main/egldriver.h | 3 ++- src/egl/main/eglglobals.c | 3 +-- src/egl/main/eglglobals.h | 8 ++++---- src/egl/main/eglmisc.c | 25 +++++++++++++++++++++++-- 8 files changed, 74 insertions(+), 27 deletions(-) (limited to 'src/egl/main/eglglobals.h') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 367787b243d..aacbb6b08e3 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -517,6 +517,18 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode) #ifdef EGL_VERSION_1_2 + +/** + * Specify the client API to use for subsequent calls including: + * eglCreateContext() + * eglGetCurrentContext() + * eglGetCurrentDisplay() + * eglGetCurrentSurface() + * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT) + * eglWaitClient() + * eglWaitNative() + * See section 3.7 "Rendering Context" in the EGL specification for details. + */ EGLBoolean eglBindAPI(EGLenum api) { @@ -525,7 +537,7 @@ eglBindAPI(EGLenum api) switch (api) { #ifdef EGL_VERSION_1_4 case EGL_OPENGL_API: - if (_eglGlobal.OpenGLAPISupported) { + if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) { t->CurrentAPI = api; return EGL_TRUE; } @@ -533,14 +545,14 @@ eglBindAPI(EGLenum api) return EGL_FALSE; #endif case EGL_OPENGL_ES_API: - if (_eglGlobal.OpenGLESAPISupported) { + if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) { t->CurrentAPI = api; return EGL_TRUE; } _eglError(EGL_BAD_PARAMETER, "eglBindAPI"); return EGL_FALSE; case EGL_OPENVG_API: - if (_eglGlobal.OpenVGAPISupported) { + if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) { t->CurrentAPI = api; return EGL_TRUE; } @@ -553,6 +565,18 @@ eglBindAPI(EGLenum api) } +/** + * Return the last value set with eglBindAPI(). + */ +EGLenum +eglQueryAPI(void) +{ + /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */ + _EGLThreadInfo *t = _eglGetCurrentThread(); + return t->CurrentAPI; +} + + EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, @@ -564,15 +588,6 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, } -EGLenum -eglQueryAPI(void) -{ - /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */ - _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentAPI; -} - - EGLBoolean eglReleaseThread(void) { diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 86d1d843347..bf1addf241b 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -20,6 +20,12 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, _EGLConfig *conf; _EGLDisplay *display = _eglLookupDisplay(dpy); EGLint i; + const EGLenum api = eglQueryAPI(); + + if (api == EGL_NONE) { + _eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)"); + return EGL_FALSE; + } conf = _eglLookupConfig(drv, dpy, config); if (!conf) { @@ -30,7 +36,8 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { case EGL_CONTEXT_CLIENT_VERSION: - /* xxx todo */ + i++; + ctx->ClientVersion = attrib_list[i]; break; default: _eglError(EGL_BAD_ATTRIBUTE, "_eglInitContext"); @@ -43,6 +50,7 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, ctx->Config = conf; ctx->DrawSurface = EGL_NO_SURFACE; ctx->ReadSurface = EGL_NO_SURFACE; + ctx->ClientAPI = api; return EGL_TRUE; } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 093f65fbfb9..34fee9c6376 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -20,9 +20,9 @@ struct _egl_context EGLBoolean IsBound; EGLBoolean DeletePending; -#ifdef EGL_VERSION_1_2 - EGLint ClientAPI; /* Either EGL_OPENGL_ES_API or EGL_OPENVG_API */ -#endif /* EGL_VERSION_1_2 */ + + EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */ + EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */ }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index e155f5fb982..681be472027 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -97,12 +97,12 @@ _eglChooseDriver(_EGLDisplay *dpy) if (driverName) return _eglstrdup(driverName); - +#if 0 if (!displayString) { /* choose a default */ displayString = DefaultDriverName; } - +#endif /* extract default DriverArgs = whatever follows ':' */ if (displayString && (displayString[0] == '!' || @@ -192,6 +192,9 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) else dlclose(lib); + /* update the global notion of supported APIs */ + _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; + return drv; } diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index e0cedb22c35..09d7755f5de 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -33,7 +33,8 @@ struct _egl_driver int APImajor, APIminor; /**< as returned by eglInitialize() */ char Version[1000]; /**< initialized from APImajor/minor, Name */ - const char *ClientAPIs; + /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ + EGLint ClientAPIsMask; _EGLAPI API; /**< EGL API dispatch table */ diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 4bdc0329bfd..9a077edbd7c 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -19,8 +19,7 @@ _eglInitGlobals(void) _eglGlobal.FreeScreenHandle = 1; _eglGlobal.Initialized = EGL_TRUE; - _eglGlobal.OpenGLESAPISupported = EGL_TRUE; - _eglGlobal.OpenVGAPISupported = EGL_FALSE; + _eglGlobal.ClientAPIsMask = 0x0; /* XXX temporary */ _eglGlobal.ThreadInfo = _eglNewThreadInfo(); diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 6b858b6b089..ac85f8b8a4f 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -28,10 +28,10 @@ struct _egl_global EGLScreenMESA FreeScreenHandle; - /* XXX these may be temporary */ - EGLBoolean OpenGLAPISupported; - EGLBoolean OpenGLESAPISupported; - EGLBoolean OpenVGAPISupported; + /* bitmaks of supported APIs (supported by _some_ driver) */ + EGLint ClientAPIsMask; + + char ClientAPIs[1000]; /**< updated by eglQueryString */ /* XXX temporary - should be thread-specific data (TSD) */ _EGLThreadInfo *ThreadInfo; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index fb32544b15d..b5bdc3ea4bf 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -54,6 +54,27 @@ _eglUpdateExtensionsString(_EGLDriver *drv) } +static void +_eglUpdateAPIsString(_EGLDriver *drv) +{ + _eglGlobal.ClientAPIs[0] = 0; + + if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) + strcat(_eglGlobal.ClientAPIs, "OpenGL "); + + if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES_BIT) + strcat(_eglGlobal.ClientAPIs, "OpenGL_ES "); + + if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES2_BIT) + strcat(_eglGlobal.ClientAPIs, "OpenGL_ES2 "); + + if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) + strcat(_eglGlobal.ClientAPIs, "OpenVG "); + + assert(strlen(_eglGlobal.ClientAPIs) < sizeof(_eglGlobal.ClientAPIs)); +} + + const char * _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) @@ -70,8 +91,8 @@ _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) return drv->Extensions.String; #ifdef EGL_VERSION_1_2 case EGL_CLIENT_APIS: - /* XXX need to initialize somewhere */ - return drv->ClientAPIs; + _eglUpdateAPIsString(drv); + return _eglGlobal.ClientAPIs; #endif default: _eglError(EGL_BAD_PARAMETER, "eglQueryString"); -- cgit v1.2.3 From e3805cad0d15ed25ce8f6c5a1f1ea913e5d0986a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 14:50:33 -0600 Subject: egl: new eglGetProcAddress() code The idea is to pass the call down to the device driver where an API-specific query can be made. Untested. --- src/egl/main/eglapi.c | 13 ++++++++----- src/egl/main/eglapi.h | 11 ++++++++++- src/egl/main/egldriver.c | 23 +++++++++++++++++++++-- src/egl/main/egldriver.h | 4 ++++ src/egl/main/eglglobals.h | 3 +++ src/egl/main/egltypedefs.h | 2 -- 6 files changed, 46 insertions(+), 10 deletions(-) (limited to 'src/egl/main/eglglobals.h') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index aacbb6b08e3..49d1f3d0eb4 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -385,12 +385,15 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))() return (genericFunc) egl_functions[i].function; } } -#if 0 - /* XXX enable this code someday */ - return (genericFunc) _glapi_get_proc_address(procname); -#else + + /* now loop over drivers to query their procs */ + for (i = 0; i < _eglGlobal.NumDrivers; i++) { + _EGLProc p = _eglGlobal.Drivers[i]->API.GetProcAddress(procname); + if (p) + return p; + } + return NULL; -#endif } diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 555aa5dd9ef..f6163a0c7a8 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -2,10 +2,15 @@ #define EGLAPI_INCLUDED /** - * Typedefs for all EGL API entrypoint functions. + * A generic function ptr type */ +typedef void (*_EGLProc)(); +/** + * Typedefs for all EGL API entrypoint functions. + */ + /* driver funcs */ typedef EGLBoolean (*Initialize_t)(_EGLDriver *, EGLDisplay dpy, EGLint *major, EGLint *minor); typedef EGLBoolean (*Terminate_t)(_EGLDriver *, EGLDisplay dpy); @@ -39,6 +44,9 @@ typedef const char *(*QueryString_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint nam typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, EGLDisplay dpy); typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint engine); +typedef _EGLProc (*GetProcAddress_t)(const char *procname); + + #ifdef EGL_MESA_screen_surface typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes); @@ -95,6 +103,7 @@ struct _egl_api QueryString_t QueryString; WaitGL_t WaitGL; WaitNative_t WaitNative; + GetProcAddress_t GetProcAddress; /* EGL_MESA_screen extension */ ChooseModeMESA_t ChooseModeMESA; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 681be472027..80fa49b7ab5 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -30,8 +30,8 @@ #endif -const char *DefaultDriverName = ":0"; -const char *SysFS = "/sys/class"; +static const char *DefaultDriverName = ":0"; +static const char *SysFS = "/sys/class"; @@ -72,6 +72,9 @@ _eglChooseDRMDriver(int card) /** + * XXX this function is totally subject change!!! + * + * * Determine/return the name of the driver to use for the given _EGLDisplay. * * Try to be clever and determine if nativeDisplay is an Xlib Display @@ -92,6 +95,8 @@ _eglChooseDriver(_EGLDisplay *dpy) const char *displayString = (const char *) dpy->NativeDisplay; const char *driverName = NULL; + (void) DefaultDriverName; + /* First, if the EGL_DRIVER env var is set, use that */ driverName = getenv("EGL_DRIVER"); if (driverName) @@ -139,6 +144,8 @@ _eglChooseDriver(_EGLDisplay *dpy) driverName = _weglChooseDriver(dpy); #elif defined(_EGL_PLATFORM_WINCE) /* XXX to do */ +#else + driverName = DefaultDriverName; #endif } @@ -195,6 +202,8 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) /* update the global notion of supported APIs */ _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; + _eglSaveDriver(drv); + return drv; } @@ -217,6 +226,16 @@ _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy) } +/** + * Save the given driver pointer in the list of all known drivers. + */ +void +_eglSaveDriver(_EGLDriver *drv) +{ + _eglGlobal.Drivers[ _eglGlobal.NumDrivers++ ] = drv; +} + + /** * Given a display handle, return the _EGLDriver for that display. */ diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 09d7755f5de..af028eaf22f 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -57,6 +57,10 @@ extern EGLBoolean _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy); +extern void +_eglSaveDriver(_EGLDriver *drv); + + extern _EGLDriver * _eglLookupDriver(EGLDisplay d); diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index ac85f8b8a4f..14d8ea487af 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -35,6 +35,9 @@ struct _egl_global /* XXX temporary - should be thread-specific data (TSD) */ _EGLThreadInfo *ThreadInfo; + + EGLint NumDrivers; + _EGLDriver *Drivers[10]; }; diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index b1c8ec1f02e..efbb17a4dc1 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -28,8 +28,6 @@ typedef struct _egl_surface _EGLSurface; typedef struct _egl_thread_info _EGLThreadInfo; -typedef void (*_EGLProc)(); - typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args); -- cgit v1.2.3