From 1ed1027e886980b9b0f48fa6bfcf3d6e209c7787 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 13:45:41 -0600 Subject: assorted changes to compile with new EGL 1.4 headers (untested) --- src/egl/main/eglcontext.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/egl/main/eglcontext.c') diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 374c006dae..bf26c1faa4 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -32,7 +32,7 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, /* no attribs defined for now */ default: _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; + return EGL_FALSE; } } @@ -53,9 +53,10 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, void _eglSaveContext(_EGLContext *ctx) { + EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); assert(ctx); - ctx->Handle = _eglHashGenKey(_eglGlobal.Contexts); - _eglHashInsert(_eglGlobal.Contexts, ctx->Handle, ctx); + ctx->Handle = (EGLContext) key; + _eglHashInsert(_eglGlobal.Contexts, key, ctx); } @@ -65,7 +66,8 @@ _eglSaveContext(_EGLContext *ctx) void _eglRemoveContext(_EGLContext *ctx) { - _eglHashRemove(_eglGlobal.Contexts, ctx->Handle); + EGLuint key = (EGLuint) ctx->Handle; + _eglHashRemove(_eglGlobal.Contexts, key); } @@ -76,7 +78,8 @@ _eglRemoveContext(_EGLContext *ctx) _EGLContext * _eglLookupContext(EGLContext ctx) { - _EGLContext *c = (_EGLContext *) _eglHashLookup(_eglGlobal.Contexts, ctx); + EGLuint key = (EGLuint) ctx; + _EGLContext *c = (_EGLContext *) _eglHashLookup(_eglGlobal.Contexts, key); return c; } @@ -126,7 +129,8 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { _EGLContext *context = _eglLookupContext(ctx); if (context) { - _eglHashRemove(_eglGlobal.Contexts, ctx); + EGLuint key = (EGLuint) ctx; + _eglHashRemove(_eglGlobal.Contexts, key); if (context->IsBound) { context->DeletePending = EGL_TRUE; } -- cgit v1.2.3 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/eglapi.c | 5 +---- src/egl/main/eglcontext.c | 53 ++++++++++++++++++++++++++++------------------- src/egl/main/eglcontext.h | 6 ++++-- src/egl/main/eglglobals.c | 2 -- src/egl/main/eglglobals.h | 1 - 5 files changed, 37 insertions(+), 30 deletions(-) (limited to 'src/egl/main/eglcontext.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index f9b3f5921a..c57d29dda6 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -280,10 +280,7 @@ EGLContext EGLAPIENTRY eglGetCurrentContext(void) { _EGLContext *ctx = _eglGetCurrentContext(); - if (ctx) - return ctx->Handle; - else - return EGL_NO_CONTEXT; + return _eglGetContextHandle(ctx); } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index bf26c1faa4..86d1d84334 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -6,12 +6,12 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" -#include "eglhash.h" #include "eglsurface.h" /** - * Initialize the given _EGLContext object to defaults. + * Initialize the given _EGLContext object to defaults and/or the values + * in the attrib_list. */ EGLBoolean _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, @@ -23,15 +23,17 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, conf = _eglLookupConfig(drv, dpy, config); if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreateContext"); + _eglError(EGL_BAD_CONFIG, "_eglInitContext"); return EGL_FALSE; } for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { - /* no attribs defined for now */ + case EGL_CONTEXT_CLIENT_VERSION: + /* xxx todo */ + break; default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); + _eglError(EGL_BAD_ATTRIBUTE, "_eglInitContext"); return EGL_FALSE; } } @@ -46,17 +48,15 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, } -/* - * Assign an EGLContext handle to the _EGLContext object then put it into - * the hash table. +/** + * Save a new _EGLContext into the hash table. */ void _eglSaveContext(_EGLContext *ctx) { - EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); - assert(ctx); - ctx->Handle = (EGLContext) key; - _eglHashInsert(_eglGlobal.Contexts, key, ctx); + /* no-op. + * Public EGLContext handle and private _EGLContext are the same. + */ } @@ -66,21 +66,34 @@ _eglSaveContext(_EGLContext *ctx) void _eglRemoveContext(_EGLContext *ctx) { - EGLuint key = (EGLuint) ctx->Handle; - _eglHashRemove(_eglGlobal.Contexts, key); + /* no-op. + * Public EGLContext handle and private _EGLContext are the same. + */ +} + + +/** + * Return the public handle for the given private context ptr. + * This is the inverse of _eglLookupContext(). + */ +EGLContext +_eglGetContextHandle(_EGLContext *ctx) +{ + /* just a cast! */ + return (EGLContext) ctx; } /** * Return the _EGLContext object that corresponds to the given * EGLContext handle. + * This is the inverse of _eglGetContextHandle(). */ _EGLContext * _eglLookupContext(EGLContext ctx) { - EGLuint key = (EGLuint) ctx; - _EGLContext *c = (_EGLContext *) _eglHashLookup(_eglGlobal.Contexts, key); - return c; + /* just a cast since EGLContext is just a void ptr */ + return (_EGLContext *) ctx; } @@ -115,7 +128,7 @@ _eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, } _eglSaveContext(context); - return context->Handle; + return (EGLContext) context; #endif return EGL_NO_CONTEXT; } @@ -129,8 +142,6 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { _EGLContext *context = _eglLookupContext(ctx); if (context) { - EGLuint key = (EGLuint) ctx; - _eglHashRemove(_eglGlobal.Contexts, key); if (context->IsBound) { context->DeletePending = EGL_TRUE; } @@ -243,7 +254,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, ctx = NULL; } /* really delete context now */ - drv->API.DestroyContext(drv, dpy, oldContext->Handle); + drv->API.DestroyContext(drv, dpy, _eglGetContextHandle(oldContext)); } } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 82bfde151f..093f65fbfb 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -11,8 +11,6 @@ */ struct _egl_context { - EGLContext Handle; /* The public/opaque handle which names this object */ - _EGLDisplay *Display; /* who do I belong to? */ _EGLConfig *Config; @@ -41,6 +39,10 @@ extern void _eglRemoveContext(_EGLContext *ctx); +extern EGLContext +_eglGetContextHandle(_EGLContext *ctx); + + extern _EGLContext * _eglLookupContext(EGLContext ctx); diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 608311d749..4bdc0329bf 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -15,7 +15,6 @@ _eglInitGlobals(void) { if (!_eglGlobal.Initialized) { _eglGlobal.Displays = _eglNewHashTable(); - _eglGlobal.Contexts = _eglNewHashTable(); _eglGlobal.Surfaces = _eglNewHashTable(); _eglGlobal.FreeScreenHandle = 1; _eglGlobal.Initialized = EGL_TRUE; @@ -37,7 +36,6 @@ _eglDestroyGlobals(void) { /* XXX TODO walk over table entries, deleting each */ _eglDeleteHashTable(_eglGlobal.Displays); - _eglDeleteHashTable(_eglGlobal.Contexts); _eglDeleteHashTable(_eglGlobal.Surfaces); } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index c16baa2d6b..4fccd226b7 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 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/eglcontext.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 367787b243..aacbb6b08e 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 86d1d84334..bf1addf241 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 093f65fbfb..34fee9c637 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 e155f5fb98..681be47202 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 e0cedb22c3..09d7755f5d 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 4bdc0329bf..9a077edbd7 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 6b858b6b08..ac85f8b8a4 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 fb32544b15..b5bdc3ea4b 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 a8533d54930f8fa989036c197ad20b0778ec0cac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 19 Jun 2008 16:06:56 -0600 Subject: egl: clean up prototype code, new _eglFindAPIs() function. --- src/egl/main/eglcontext.c | 2 + src/egl/main/egldriver.c | 118 +++++++++++++++++++++++++++++++++++----------- src/egl/main/egldriver.h | 4 ++ src/egl/main/eglmisc.c | 52 -------------------- 4 files changed, 97 insertions(+), 79 deletions(-) (limited to 'src/egl/main/eglcontext.c') diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index bf1addf241..15847ef2da 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -33,6 +33,8 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, return EGL_FALSE; } + ctx->ClientVersion = 1; /* the default, per EGL spec */ + for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { case EGL_CONTEXT_CLIENT_VERSION: diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 4a611b9fc9..edf85abe01 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -35,6 +35,44 @@ static const char *SysFS = "/sys/class"; +/** + * Wrappers for dlopen/dlclose() + */ +#if defined(_EGL_PLATFORM_WINDOWS) + + typedef HMODULE lib_handle; + + static HMODULE + open_library(const char *filename) + { + return LoadLibrary(filename); + } + + static void + close_library(HMODULE lib) + { + FreeLibrary(lib); + } + +#elif defined(_EGL_PLATFORM_X) + + typedef void * lib_handle; + + static void * + open_library(const char *filename) + { + return dlopen(filename, RTLD_LAZY); + } + + static void + close_library(void *lib) + { + dlclose(lib); + } + +#endif + + /** * Given a card number, use sysfs to determine the DRI driver name. @@ -165,11 +203,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) { _EGLDriver *drv; _EGLMain_t mainFunc; -#if defined(_EGL_PLATFORM_WINDOWS) - HMODULE lib; -#elif defined(_EGL_PLATFORM_X) - void *lib; -#endif + lib_handle lib; char driverFilename[1000]; assert(driverName); @@ -178,13 +212,12 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) /* XXX untested */ sprintf(driverFilename, "%s.dll", driverName); _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); - lib = LoadLibrary(driverFilename); #elif defined(_EGL_PLATFORM_X) /* XXX also prepend a directory path??? */ sprintf(driverFilename, "%s.so", driverName); _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); - lib = dlopen(driverFilename, RTLD_LAZY); #endif + lib = open_library(driverFilename); if (!lib) { _eglLog(_EGL_WARNING, "Could not open %s (%s)", @@ -200,21 +233,13 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) if (!mainFunc) { _eglLog(_EGL_WARNING, "_eglMain not found in %s", driverFilename); -#if defined(_EGL_PLATFORM_WINDOWS) - FreeLibrary(lib); -#elif defined(_EGL_PLATFORM_X) - dlclose(lib); -#endif + close_library(lib); return NULL; } drv = mainFunc(dpy, args); if (!drv) { -#if defined(_EGL_PLATFORM_WINDOWS) - FreeLibrary(lib); -#elif defined(_EGL_PLATFORM_X) - dlclose(lib); -#endif + close_library(lib); return NULL; } @@ -223,11 +248,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) drv->LibHandle = lib; } else { -#if defined(_EGL_PLATFORM_WINDOWS) - FreeLibrary(lib); -#elif defined(_EGL_PLATFORM_X) - dlclose(lib); -#endif + close_library(lib); } /* update the global notion of supported APIs */ @@ -253,11 +274,7 @@ _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy) b = drv->API.Terminate(drv, dpy); -#if defined(_EGL_PLATFORM_WINDOWS) - FreeLibrary(handle); -#elif defined(_EGL_PLATFORM_X) - dlclose(handle); -#endif + close_library(handle); return b; } @@ -343,3 +360,50 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer; #endif /* EGL_VERSION_1_2 */ } + + + +/** + * 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_X) + 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"; +#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; +} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 1eae6f8034..7827ca3ae3 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -72,4 +72,8 @@ extern void _eglInitDriverFallbacks(_EGLDriver *drv); +extern EGLint +_eglFindAPIs(void); + + #endif /* EGLDRIVER_INCLUDED */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index e79223657d..b5bdc3ea4b 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -54,58 +54,6 @@ _eglUpdateExtensionsString(_EGLDriver *drv) } -#if 0 /* prototype code */ - -#include - -static EGLint -_eglFindAPIs_by_sym(void) -{ - EGLint mask = 0x0; - - if (dlsym(NULL, "glBegin")) - mask |= EGL_OPENGL_BIT; - if (dlsym(NULL, "glGetFixedv")) - mask |= EGL_OPENGL_ES_BIT; - if (dlsym(NULL, "vgSetf")) - mask |= EGL_OPENVG_BIT; - - return mask; -} - -static EGLint -_eglFindAPIs_by_lib(void) -{ - EGLint mask = 0x0; - int flag = RTLD_NOW; - void *h; - - if ((h = dlopen("libGLESv1_CM.so", flag))) { - dlclose(h); - mask |= EGL_OPENGL_ES_BIT; - } - - if ((h = dlopen("libGLESv2.so", flag))) { - dlclose(h); - mask |= EGL_OPENGL_ES2_BIT; - } - - if ((h = dlopen("libGL.so", flag))) { - dlclose(h); - mask |= EGL_OPENGL_BIT; - } - - if ((h = dlopen("libOpenVG.so", flag))) { - dlclose(h); - mask |= EGL_OPENVG_BIT; - } - - return mask; -} - -#endif - - static void _eglUpdateAPIsString(_EGLDriver *drv) { -- cgit v1.2.3 From 9f6a4e2a65ff872bc27e7081df7d6205393a1180 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 19 Jun 2008 21:19:33 -0600 Subject: egl: fix assorted context-related bugs Move memset() to proper place. Added EGL_CONTEXT_CLIENT_VERSION query. Fix bad return EGL_FALSE -> EGL_TRUE. --- src/egl/main/eglcontext.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/egl/main/eglcontext.c') diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 15847ef2da..461679db09 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -33,6 +33,8 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, return EGL_FALSE; } + memset(ctx, 0, sizeof(_EGLContext)); + ctx->ClientVersion = 1; /* the default, per EGL spec */ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { @@ -47,7 +49,6 @@ _eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, } } - memset(ctx, 0, sizeof(_EGLContext)); ctx->Display = display; ctx->Config = conf; ctx->DrawSurface = EGL_NO_SURFACE; @@ -188,8 +189,11 @@ _eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx, #ifdef EGL_VERSION_1_2 case EGL_CONTEXT_CLIENT_TYPE: *value = c->ClientAPI; - return EGL_FALSE; + return EGL_TRUE; #endif /* EGL_VERSION_1_2 */ + case EGL_CONTEXT_CLIENT_VERSION: + *value = c->ClientVersion; + return EGL_TRUE; default: _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext"); return EGL_FALSE; -- cgit v1.2.3