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/eglapi.c | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index bfa580e6c3..f9b3f5921a 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -47,7 +47,7 @@ * This will probably change! * See _eglChooseDriver() for details! */ -EGLDisplay APIENTRY +EGLDisplay EGLAPIENTRY eglGetDisplay(NativeDisplayType displayName) { _EGLDisplay *dpy; @@ -60,7 +60,7 @@ eglGetDisplay(NativeDisplayType displayName) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { if (dpy) { @@ -72,7 +72,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -83,7 +83,7 @@ eglTerminate(EGLDisplay dpy) } -const char * APIENTRY +const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -94,7 +94,7 @@ eglQueryString(EGLDisplay dpy, EGLint name) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -103,7 +103,7 @@ eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *nu } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -111,7 +111,7 @@ eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, E } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -119,7 +119,7 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *v } -EGLContext APIENTRY +EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -127,7 +127,7 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, const } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -135,7 +135,7 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -143,7 +143,7 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -151,7 +151,7 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) } -EGLSurface APIENTRY +EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -159,7 +159,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window } -EGLSurface APIENTRY +EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -167,7 +167,7 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap } -EGLSurface APIENTRY +EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -175,7 +175,7 @@ eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_l } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -183,7 +183,7 @@ eglDestroySurface(EGLDisplay dpy, EGLSurface surface) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -191,7 +191,7 @@ eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *va } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -199,7 +199,7 @@ eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint va } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -207,7 +207,7 @@ eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -215,7 +215,7 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -223,7 +223,7 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -231,7 +231,7 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -239,7 +239,7 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglWaitGL(void) { EGLDisplay dpy = eglGetCurrentDisplay(); @@ -252,7 +252,7 @@ eglWaitGL(void) } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { EGLDisplay dpy = eglGetCurrentDisplay(); @@ -265,7 +265,7 @@ eglWaitNative(EGLint engine) } -EGLDisplay APIENTRY +EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { _EGLDisplay *dpy = _eglGetCurrentDisplay(); @@ -276,7 +276,7 @@ eglGetCurrentDisplay(void) } -EGLContext APIENTRY +EGLContext EGLAPIENTRY eglGetCurrentContext(void) { _EGLContext *ctx = _eglGetCurrentContext(); @@ -287,7 +287,7 @@ eglGetCurrentContext(void) } -EGLSurface APIENTRY +EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { _EGLSurface *s = _eglGetCurrentSurface(readdraw); @@ -298,7 +298,7 @@ eglGetCurrentSurface(EGLint readdraw) } -EGLint APIENTRY +EGLint EGLAPIENTRY eglGetError(void) { _EGLThreadInfo *t = _eglGetCurrentThread(); @@ -308,7 +308,7 @@ eglGetError(void) } -void (* APIENTRY eglGetProcAddress(const char *procname))() +void (* EGLAPIENTRY eglGetProcAddress(const char *procname))() { typedef void (*genericFunc)(); struct name_function { @@ -389,7 +389,7 @@ void (* APIENTRY eglGetProcAddress(const char *procname))() * EGL_MESA_screen extension */ -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes) @@ -402,7 +402,7 @@ eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -413,7 +413,7 @@ eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value) { _EGLDriver *drv = _eglLookupDriver(dpy); @@ -424,7 +424,7 @@ eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint } -EGLBoolean APIENTRY +EGLBoolean EGLAPIENTRY eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask) { _EGLDriver *drv = _eglLookupDriver(dpy); -- 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/eglapi.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 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/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index c57d29dda6..4df31cc03f 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 4fccd226b7..6b858b6b08 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 721ba15bf4596b2e9589e7656005b387724875c3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:33:54 -0600 Subject: added _eglGet*Handle() functions These are the inverse of the _eglLookup*() functions. Returns the public handle for a private surface/config/display/etc. Removes glapi.c's direct access of private fields. --- src/egl/main/eglapi.c | 15 +++------------ src/egl/main/eglconfig.c | 12 ++++++++++++ src/egl/main/eglconfig.h | 4 ++++ src/egl/main/egldisplay.c | 15 +++++++++++++++ src/egl/main/egldisplay.h | 4 ++++ src/egl/main/eglsurface.c | 20 ++++++++++++++++++++ src/egl/main/eglsurface.h | 4 ++++ 7 files changed, 62 insertions(+), 12 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 4df31cc03f..e4eec26de0 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -53,10 +53,7 @@ eglGetDisplay(NativeDisplayType displayName) _EGLDisplay *dpy; _eglInitGlobals(); dpy = _eglNewDisplay(displayName); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; + return _eglGetDisplayHandle(dpy); } @@ -269,10 +266,7 @@ EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { _EGLDisplay *dpy = _eglGetCurrentDisplay(); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; + return _eglGetDisplayHandle(dpy); } @@ -288,10 +282,7 @@ EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { _EGLSurface *s = _eglGetCurrentSurface(readdraw); - if (s) - return s->Handle; - else - return EGL_NO_SURFACE; + return _eglGetSurfaceHandle(s); } diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index a74cd23113..1b49f7afd9 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -101,8 +101,20 @@ _eglInitConfig(_EGLConfig *config, EGLint id) } +/** + * Return the public handle for an internal _EGLConfig. + * This is the inverse of _eglLookupConfig(). + */ +EGLConfig +_eglGetConfigHandle(_EGLConfig *config) +{ + return config ? config->Handle : 0; +} + + /** * Given an EGLConfig handle, return the corresponding _EGLConfig object. + * This is the inverse of _eglGetConfigHandle(). */ _EGLConfig * _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 88e44dfc7d..4a80612980 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -27,6 +27,10 @@ extern void _eglInitConfig(_EGLConfig *config, EGLint id); +extern EGLConfig +_eglGetConfigHandle(_EGLConfig *config); + + extern _EGLConfig * _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config); diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 59d0bd3dc3..fd24f22273 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -39,9 +39,24 @@ _eglNewDisplay(NativeDisplayType displayName) } +/** + * Return the public handle for an internal _EGLDisplay. + * This is the inverse of _eglLookupDisplay(). + */ +EGLDisplay +_eglGetDisplayHandle(_EGLDisplay *display) +{ + if (display) + return display->Handle; + else + return EGL_NO_DISPLAY; +} + + /** * Return the _EGLDisplay object that corresponds to the given public/ * opaque display handle. + * This is the inverse of _eglGetDisplayHandle(). */ _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 1a03fdd4ad..fe7b788455 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -24,6 +24,10 @@ extern _EGLDisplay * _eglNewDisplay(NativeDisplayType displayName); +EGLDisplay +_eglGetDisplayHandle(_EGLDisplay *display); + + extern _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy); diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 134afa7cbd..1dbb12ecfe 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -223,6 +223,26 @@ _eglRemoveSurface(_EGLSurface *surf) } + +/** + * Return the public handle for an internal _EGLSurface. + * This is the inverse of _eglLookupSurface(). + */ +EGLSurface +_eglGetSurfaceHandle(_EGLSurface *surface) +{ + if (surface) + return surface->Handle; + else + return EGL_NO_SURFACE; +} + + +/** + * Return the private _EGLSurface which corresponds to a public EGLSurface + * handle. + * This is the inverse of _eglGetSurfaceHandle(). + */ _EGLSurface * _eglLookupSurface(EGLSurface surf) { diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index 79abeca0b2..df1e70122e 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -51,6 +51,10 @@ extern void _eglRemoveSurface(_EGLSurface *surf); +extern EGLSurface +_eglGetSurfaceHandle(_EGLSurface *surface); + + extern _EGLSurface * _eglLookupSurface(EGLSurface surf); -- cgit v1.2.3 From 6052af172f0241e6678cd16efac0a0f14f40146c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 16:48:23 -0600 Subject: minor overhaul/re-org of driver selection/loading code --- src/egl/main/Makefile | 11 ++++++--- src/egl/main/eglapi.c | 27 ++++++++++++++------- src/egl/main/eglconfig.c | 4 +--- src/egl/main/eglconfig.h | 6 ++--- src/egl/main/egldisplay.c | 57 ++++++++++++++++++++++++++++++++----------- src/egl/main/egldisplay.h | 14 ++++++++++- src/egl/main/egldriver.c | 61 +++++++++++++++++++++++++++-------------------- src/egl/main/egldriver.h | 6 ++--- 8 files changed, 124 insertions(+), 62 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index e1058a23f7..0efcd4e605 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -16,7 +16,8 @@ HEADERS = \ eglhash.h \ eglmode.h \ eglscreen.h \ - eglsurface.h + eglsurface.h \ + eglx.h SOURCES = \ eglapi.c \ @@ -29,13 +30,17 @@ SOURCES = \ eglhash.c \ eglmode.c \ eglscreen.c \ - eglsurface.c + eglsurface.c \ + eglx.c OBJECTS = $(SOURCES:.c=.o) +LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 + + .c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index e4eec26de0..fe63d36b80 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -43,27 +43,38 @@ /** - * NOTE: displayName is treated as a string in _eglChooseDriver()!!! - * This will probably change! - * See _eglChooseDriver() for details! + * This is typically the first EGL function that an application calls. + * We initialize our global vars and create a private _EGLDisplay object. */ EGLDisplay EGLAPIENTRY -eglGetDisplay(NativeDisplayType displayName) +eglGetDisplay(NativeDisplayType nativeDisplay) { _EGLDisplay *dpy; _eglInitGlobals(); - dpy = _eglNewDisplay(displayName); + dpy = _eglNewDisplay(nativeDisplay); return _eglGetDisplayHandle(dpy); } +/** + * This is typically the second EGL function that an application calls. + * Here we load/initialize the actual hardware driver. + */ EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { if (dpy) { - _EGLDriver *drv = _eglChooseDriver(dpy); - if (drv) - return drv->API.Initialize(drv, dpy, major, minor); + _EGLDisplay *dpyPriv = _eglLookupDisplay(dpy); + if (!dpyPriv) { + return EGL_FALSE; + } + dpyPriv->Driver = _eglOpenDriver(dpyPriv, dpyPriv->DriverName); + if (!dpyPriv->Driver) { + return EGL_FALSE; + } + /* Initialize the particular driver now */ + return dpyPriv->Driver->API.Initialize(dpyPriv->Driver, dpy, + major, minor); } return EGL_FALSE; } diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 1b49f7afd9..eb2c34a802 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -17,7 +17,6 @@ #define MIN2(A, B) (((A) < (B)) ? (A) : (B)) -#if 0 /** * Convert an _EGLConfig to a __GLcontextModes object. * NOTE: This routine may be incomplete - we're only making sure that @@ -58,7 +57,6 @@ _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) mode->visualType = GLX_TRUE_COLOR; mode->renderType = GLX_RGBA_BIT; } -#endif void @@ -445,6 +443,7 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, } +#if 0 /** * Creates a set of \c __GLcontextModes that a driver will expose. * @@ -512,7 +511,6 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32, * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it. */ -#if 0 GLboolean _eglFillInConfigs(_EGLConfig * configs, GLenum fb_format, GLenum fb_type, diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 4a80612980..e025f7f845 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -3,9 +3,8 @@ #include "egltypedefs.h" -#if 0 +#include #include "GL/internal/glcore.h" -#endif #define MAX_ATTRIBS 100 @@ -68,10 +67,9 @@ _eglFillInConfigs( _EGLConfig *configs, int visType ); #endif -#if 0 + extern void _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); -#endif #endif /* EGLCONFIG_INCLUDED */ diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index fd24f22273..9c42194c61 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -1,7 +1,14 @@ + +/** + * Functions related to EGLDisplay. + */ + +#include #include #include #include "eglcontext.h" #include "egldisplay.h" +#include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" @@ -9,31 +16,41 @@ static char * my_strdup(const char *s) { - int l = strlen(s); - char *s2 = malloc(l + 1); - strcpy(s2, s); - return s2; + if (s) { + int l = strlen(s); + char *s2 = malloc(l + 1); + if (s2) + strcpy(s2, s); + return s2; + } + return NULL; } /** - * We're assuming that the NativeDisplayType parameter is actually - * a string. - * Return a new _EGLDisplay object for the given displayName + * Allocate a new _EGLDisplay object for the given nativeDisplay handle. + * We'll also try to determine the device driver name at this time. */ _EGLDisplay * -_eglNewDisplay(NativeDisplayType displayName) +_eglNewDisplay(NativeDisplayType nativeDisplay) { _EGLDisplay *dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { EGLuint key = _eglHashGenKey(_eglGlobal.Displays); + dpy->Handle = (EGLDisplay) key; _eglHashInsert(_eglGlobal.Displays, key, dpy); - if (displayName) - dpy->Name = my_strdup((char *) displayName); - else - dpy->Name = NULL; - dpy->Driver = NULL; /* this gets set later */ + + dpy->NativeDisplay = nativeDisplay; +#if defined(_EGL_PLATFORM_X) + dpy->Xdpy = (Display *) nativeDisplay; +#endif + + dpy->DriverName = my_strdup(_eglChooseDriver(dpy)); + if (!dpy->DriverName) { + free(dpy); + return NULL; + } } return dpy; } @@ -67,6 +84,18 @@ _eglLookupDisplay(EGLDisplay dpy) } +void +_eglSaveDisplay(_EGLDisplay *dpy) +{ + EGLuint key = _eglHashGenKey(_eglGlobal.Displays); + assert(dpy); + assert(!dpy->Handle); + dpy->Handle = (EGLDisplay) key; + assert(dpy->Handle); + _eglHashInsert(_eglGlobal.Displays, key, dpy); +} + + _EGLDisplay * _eglGetCurrentDisplay(void) { @@ -83,6 +112,6 @@ _eglCleanupDisplay(_EGLDisplay *disp) { /* XXX incomplete */ free(disp->Configs); - free(disp->Name); + free((void *) disp->DriverName); /* driver deletes _EGLDisplay */ } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index fe7b788455..be134374ca 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -1,15 +1,19 @@ #ifndef EGLDISPLAY_INCLUDED #define EGLDISPLAY_INCLUDED +#ifdef _EGL_PLATFORM_X +#include +#endif #include "egltypedefs.h" struct _egl_display { + EGLNativeDisplayType NativeDisplay; EGLDisplay Handle; - char *Name; + const char *DriverName; _EGLDriver *Driver; EGLint NumScreens; @@ -17,6 +21,10 @@ struct _egl_display EGLint NumConfigs; _EGLConfig *Configs; /* array [NumConfigs] */ + +#ifdef _EGL_PLATFORM_X + Display *Xdpy; +#endif }; @@ -32,6 +40,10 @@ extern _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy); +extern void +_eglSaveDisplay(_EGLDisplay *dpy); + + extern _EGLDisplay * _eglGetCurrentDisplay(void); diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index bda06dd827..50c466c258 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -1,3 +1,8 @@ +/** + * Functions for choosing and opening/loading device drivers. + */ + + #include #include #include @@ -11,62 +16,64 @@ #include "eglmode.h" #include "eglscreen.h" #include "eglsurface.h" +#include "eglx.h" const char *DefaultDriverName = "demodriver"; /** - * Choose and open/init the hardware driver for the given EGLDisplay. - * Previously, the EGLDisplay was created with _eglNewDisplay() where - * we recorded the user's NativeDisplayType parameter. + * Determine/return the name of the driver to use for the given _EGLDisplay. * - * Now we'll use the NativeDisplayType value. + * Try to be clever and determine if nativeDisplay is an Xlib Display + * ptr or a string (naming a driver or screen number, etc). * - * Currently, the native display value is treated as a string. * If the first character is ':' we interpret it as a screen or card index * number (i.e. ":0" or ":1", etc) * Else if the first character is '!' we interpret it as specific driver name * (i.e. "!r200" or "!i830". + * + * The caller should make a copy of the returned string. */ -_EGLDriver * -_eglChooseDriver(EGLDisplay display) +const char * +_eglChooseDriver(_EGLDisplay *dpy) { - _EGLDisplay *dpy = _eglLookupDisplay(display); - _EGLDriver *drv; - const char *driverName = DefaultDriverName; - const char *name; + const char *name = (const char *) dpy->NativeDisplay; + const char *driverName = NULL; - assert(dpy); - - name = dpy->Name; - if (!name) { - /* use default */ + if (!dpy->NativeDisplay) { + /* choose a default */ + driverName = DefaultDriverName; } - else if (name[0] == ':' && (name[1] >= '0' && name[1] <= '9') && !name[2]) { + else if (name && name[0] == ':' && + (name[1] >= '0' && name[1] <= '9') && !name[2]) { /* XXX probe hardware here to determine which driver to open */ driverName = "libEGLdri"; } - else if (name[0] == '!') { + else if (name && name[0] == '!') { /* use specified driver name */ driverName = name + 1; } else { - /* Maybe display was returned by XOpenDisplay? */ - _eglLog(_EGL_FATAL, "eglChooseDriver() bad name"); +#if defined(_EGL_PLATFORM_X) + driverName = _xeglChooseDriver(dpy); +#elif defined(_EGL_PLATFORM_WINDOWS) + /* XXX to do */ + driverName = _weglChooseDriver(dpy); +#elif defined(_EGL_PLATFORM_WINCE) + /* XXX to do */ +#endif } - _eglLog(_EGL_INFO, "eglChooseDriver() choosing %s", driverName); - - drv = _eglOpenDriver(dpy, driverName); - dpy->Driver = drv; - - return drv; + return driverName; } /** * Open/load the named driver and call its bootstrap function: _eglMain(). + * By the time this function is called, the dpy->DriverName should have + * been determined. + * * \return new _EGLDriver object. */ _EGLDriver * @@ -77,6 +84,8 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName) void *lib; char driverFilename[1000]; + assert(driverName); + /* XXX also prepend a directory path??? */ sprintf(driverFilename, "%s.so", driverName); diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 88526e973d..bde726e25e 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -45,12 +45,12 @@ struct _egl_driver extern _EGLDriver *_eglMain(_EGLDisplay *dpy); -extern _EGLDriver * -_eglChooseDriver(EGLDisplay dpy); +extern const char * +_eglChooseDriver(_EGLDisplay *dpy); extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *driverName); +_eglOpenDriver(_EGLDisplay *dpy, const char *DriverName); extern EGLBoolean -- cgit v1.2.3 From 0c8908c411c434eda318b41b4f2a370a1e794831 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 12:56:36 -0600 Subject: egl: added args string to _eglMain() --- src/egl/drivers/demo/demo.c | 2 +- src/egl/drivers/dri/egldri.c | 4 ++-- src/egl/main/eglapi.c | 4 +++- src/egl/main/egldisplay.c | 19 ++++--------------- src/egl/main/egldisplay.h | 1 + src/egl/main/egldriver.c | 35 +++++++++++++++++++++++++---------- src/egl/main/egldriver.h | 4 ++-- src/egl/main/egltypedefs.h | 2 +- 8 files changed, 39 insertions(+), 32 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 1033f1b4ed..6b8b71d16b 100644 --- a/src/egl/drivers/demo/demo.c +++ b/src/egl/drivers/demo/demo.c @@ -286,7 +286,7 @@ demoMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea * plug in API functions. */ _EGLDriver * -_eglMain(_EGLDisplay *dpy) +_eglMain(_EGLDisplay *dpy, const char *args) { DemoDriver *demo; diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index f00625a059..677073fb3a 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -79,11 +79,11 @@ driver_name_from_card_number(int card, char *driverName, int maxDriverName) * This function, in turn, loads a specific DRI driver (ex: r200_dri.so). */ _EGLDriver * -_eglMain(_EGLDisplay *dpy) +_eglMain(_EGLDisplay *dpy, const char *args) { #if 1 const char *displayString = (const char *) dpy->NativeDisplay; - const int card = atoi(displayString + 1); + const int card = atoi(args); _EGLDriver *driver = NULL; char driverName[1000]; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index fe63d36b80..984af4ea22 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -68,7 +68,9 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) if (!dpyPriv) { return EGL_FALSE; } - dpyPriv->Driver = _eglOpenDriver(dpyPriv, dpyPriv->DriverName); + dpyPriv->Driver = _eglOpenDriver(dpyPriv, + dpyPriv->DriverName, + dpyPriv->DriverArgs); if (!dpyPriv->Driver) { return EGL_FALSE; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 9c42194c61..b2d30d4274 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -11,25 +11,14 @@ #include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" - - -static char * -my_strdup(const char *s) -{ - if (s) { - int l = strlen(s); - char *s2 = malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - return NULL; -} +#include "eglstring.h" /** * Allocate a new _EGLDisplay object for the given nativeDisplay handle. * We'll also try to determine the device driver name at this time. + * + * Note that nativeDisplay may be an X Display ptr, or a string. */ _EGLDisplay * _eglNewDisplay(NativeDisplayType nativeDisplay) @@ -46,7 +35,7 @@ _eglNewDisplay(NativeDisplayType nativeDisplay) dpy->Xdpy = (Display *) nativeDisplay; #endif - dpy->DriverName = my_strdup(_eglChooseDriver(dpy)); + dpy->DriverName = _eglstrdup(_eglChooseDriver(dpy)); if (!dpy->DriverName) { free(dpy); return NULL; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index be134374ca..e2ebab0b21 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -14,6 +14,7 @@ struct _egl_display EGLDisplay Handle; const char *DriverName; + const char *DriverArgs; _EGLDriver *Driver; EGLint NumScreens; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index cbdd47948d..599077190a 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "eglconfig.h" #include "eglcontext.h" @@ -15,6 +16,7 @@ #include "egllog.h" #include "eglmode.h" #include "eglscreen.h" +#include "eglstring.h" #include "eglsurface.h" #if defined(_EGL_PLATFORM_X) @@ -25,7 +27,7 @@ /* XXX to do */ #endif -const char *DefaultDriverName = "demodriver"; +const char *DefaultDriverName = ":0"; /** @@ -44,23 +46,36 @@ const char *DefaultDriverName = "demodriver"; const char * _eglChooseDriver(_EGLDisplay *dpy) { - const char *name = (const char *) dpy->NativeDisplay; + const char *displayString = (const char *) dpy->NativeDisplay; const char *driverName = NULL; - if (!dpy->NativeDisplay) { + if (!displayString) { /* choose a default */ - driverName = DefaultDriverName; + displayString = DefaultDriverName; } - else if (name && name[0] == ':' && - (name[1] >= '0' && name[1] <= '9') && !name[2]) { + + /* extract default DriverArgs = whatever follows ':' */ + if (displayString[0] == '!' || + displayString[0] == ':') { + const char *args = strchr(displayString, ':'); + if (args) + dpy->DriverArgs = _eglstrdup(args + 1); + } + + + if (displayString && displayString[0] == ':' && + (displayString[1] >= '0' && displayString[1] <= '9') && + !displayString[2]) { /* XXX probe hardware here to determine which driver to open */ driverName = "libEGLdri"; } - else if (name && name[0] == '!') { + else if (displayString && displayString[0] == '!') { /* use specified driver name */ - driverName = name + 1; + driverName = displayString + 1; } else { + /* NativeDisplay is not a string! */ + #if defined(_EGL_PLATFORM_X) driverName = _xeglChooseDriver(dpy); #elif defined(_EGL_PLATFORM_WINDOWS) @@ -83,7 +98,7 @@ _eglChooseDriver(_EGLDisplay *dpy) * \return new _EGLDriver object. */ _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *driverName) +_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) { _EGLDriver *drv; _EGLMain_t mainFunc; @@ -110,7 +125,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName) return NULL; } - drv = mainFunc(dpy); + drv = mainFunc(dpy, args); if (!drv) { dlclose(lib); return NULL; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index bde726e25e..9c505880b7 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -42,7 +42,7 @@ struct _egl_driver }; -extern _EGLDriver *_eglMain(_EGLDisplay *dpy); +extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args); extern const char * @@ -50,7 +50,7 @@ _eglChooseDriver(_EGLDisplay *dpy); extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *DriverName); +_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args); extern EGLBoolean diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index 53810a5a44..b1c8ec1f02 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -30,7 +30,7 @@ typedef struct _egl_thread_info _EGLThreadInfo; typedef void (*_EGLProc)(); -typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy); +typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args); #endif /* EGLTYPEDEFS_INCLUDED */ -- cgit v1.2.3 From c56e15b093c367e7e17ebd2e153baab8cafd213a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 15:43:41 -0600 Subject: egl: make sure EGL_VERSION_STRING query returns same version as eglInitialize() --- src/egl/main/eglapi.c | 11 +++++++++-- src/egl/main/egldefines.h | 2 -- src/egl/main/egldriver.c | 2 +- src/egl/main/egldriver.h | 11 ++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 984af4ea22..3151b35156 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -64,6 +64,7 @@ EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { if (dpy) { + EGLBoolean retVal; _EGLDisplay *dpyPriv = _eglLookupDisplay(dpy); if (!dpyPriv) { return EGL_FALSE; @@ -75,8 +76,14 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) return EGL_FALSE; } /* Initialize the particular driver now */ - return dpyPriv->Driver->API.Initialize(dpyPriv->Driver, dpy, - major, minor); + retVal = dpyPriv->Driver->API.Initialize(dpyPriv->Driver, dpy, + major, minor); + + dpyPriv->Driver->APImajor = *major; + dpyPriv->Driver->APIminor = *minor; + sprintf(dpyPriv->Driver->Version, "%d.%d", *major, *minor); + + return retVal; } return EGL_FALSE; } diff --git a/src/egl/main/egldefines.h b/src/egl/main/egldefines.h index f5d37a2fc0..8fc2301b79 100644 --- a/src/egl/main/egldefines.h +++ b/src/egl/main/egldefines.h @@ -38,8 +38,6 @@ #define _EGL_MAX_EXTENSIONS_LEN 1000 -#define _EGL_VERSION_STRING "1.4" - #define _EGL_VENDOR_STRING "Mesa Project" diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 6d533625b7..2257a68630 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -306,7 +306,7 @@ _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) case EGL_VENDOR: return _EGL_VENDOR_STRING; case EGL_VERSION: - return _EGL_VERSION_STRING; + return drv->Version; case EGL_EXTENSIONS: _eglUpdateExtensionsString(drv); return drv->Extensions.String; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 67cfb02f46..9395a667ab 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -24,17 +24,18 @@ struct _egl_extensions */ struct _egl_driver { - EGLBoolean Initialized; /* set by driver after initialized */ + EGLBoolean Initialized; /**< set by driver after initialized */ - void *LibHandle; /* dlopen handle */ + void *LibHandle; /**< dlopen handle */ _EGLDisplay *Display; - int ABIversion; - int APImajor, APIminor; /* returned through eglInitialize */ + int APImajor, APIminor; /**< as returned by eglInitialize() */ + char Version[10]; /**< initialized from APImajor/minor */ + const char *ClientAPIs; - _EGLAPI API; + _EGLAPI API; /**< EGL API dispatch table */ _EGLExtensions Extensions; }; -- cgit v1.2.3 From 1c73b4ba86b424ba66a16c4006a57db505bd3ca3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 29 May 2008 17:02:31 -0600 Subject: egl: added Name field to _EGLDriver so a driver name string can propogate up through EGL_VERSION string --- src/egl/main/eglapi.c | 3 ++- src/egl/main/egldriver.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 3151b35156..367787b243 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -81,7 +81,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) dpyPriv->Driver->APImajor = *major; dpyPriv->Driver->APIminor = *minor; - sprintf(dpyPriv->Driver->Version, "%d.%d", *major, *minor); + snprintf(dpyPriv->Driver->Version, sizeof(dpyPriv->Driver->Version), + "%d.%d (%s)", *major, *minor, dpyPriv->Driver->Name); return retVal; } diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index b0a5fadf64..e0cedb22c3 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -28,8 +28,10 @@ struct _egl_driver void *LibHandle; /**< dlopen handle */ + const char *Name; /**< name of this driver */ + int APImajor, APIminor; /**< as returned by eglInitialize() */ - char Version[10]; /**< initialized from APImajor/minor */ + char Version[1000]; /**< initialized from APImajor/minor, Name */ const char *ClientAPIs; -- 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/eglapi.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 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/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index aacbb6b08e..49d1f3d0eb 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 555aa5dd9e..f6163a0c7a 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 681be47202..80fa49b7ab 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 09d7755f5d..af028eaf22 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 ac85f8b8a4..14d8ea487a 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 b1c8ec1f02..efbb17a4dc 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 From 7e2458c7b55b2662067d8cce8a962d8c2bbd3a43 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Wed, 6 Aug 2008 13:40:03 -0600 Subject: egl: fix version handling --- src/egl/main/eglapi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/egl/main/eglapi.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 49d1f3d0eb..9df938e188 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -63,6 +63,8 @@ eglGetDisplay(NativeDisplayType nativeDisplay) EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { + EGLint major_int, minor_int; + if (dpy) { EGLBoolean retVal; _EGLDisplay *dpyPriv = _eglLookupDisplay(dpy); @@ -77,12 +79,19 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) } /* Initialize the particular driver now */ retVal = dpyPriv->Driver->API.Initialize(dpyPriv->Driver, dpy, - major, minor); + &major_int, &minor_int); - dpyPriv->Driver->APImajor = *major; - dpyPriv->Driver->APIminor = *minor; + dpyPriv->Driver->APImajor = major_int; + dpyPriv->Driver->APIminor = minor_int; snprintf(dpyPriv->Driver->Version, sizeof(dpyPriv->Driver->Version), - "%d.%d (%s)", *major, *minor, dpyPriv->Driver->Name); + "%d.%d (%s)", major_int, minor_int, dpyPriv->Driver->Name); + + /* Update applications version of major and minor if not NULL */ + if((major != NULL) && (minor != NULL)) + { + *major = major_int; + *minor = minor_int; + } return retVal; } -- cgit v1.2.3