From 90ee7a41443a971d6ff2e0a6e90997806c28d11b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Aug 2007 10:18:04 +0100 Subject: Gutsy oopses on touch of existing file. Workaround. --- src/egl/main/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 431eda4197f..e6844d48524 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -58,6 +58,7 @@ clean: depend: $(SOURCES) $(HEADERS) @ echo "running $(MKDEP)" + @ rm -f depend @ touch depend $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ $(SOURCES) $(HEADERS) > /dev/null -- cgit v1.2.3 From 3e4128963d4e1a27ef29658a3aa260f492091628 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 13:45:16 -0600 Subject: pipe stderr to /dev/null --- src/egl/main/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index e6844d48524..e1058a23f70 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -61,7 +61,8 @@ depend: $(SOURCES) $(HEADERS) @ rm -f depend @ touch depend $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) > /dev/null + $(SOURCES) $(HEADERS) > /dev/null 2>/dev/null + include depend # DO NOT DELETE -- cgit v1.2.3 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 +++++++++++++++++++++++----------------------- src/egl/main/eglconfig.c | 8 ++++-- src/egl/main/eglconfig.h | 20 +++++++++----- src/egl/main/eglcontext.c | 16 ++++++----- src/egl/main/egldisplay.c | 10 ++++--- src/egl/main/eglmode.h | 3 +++ src/egl/main/eglsurface.c | 12 +++++---- src/egl/main/egltypedefs.h | 2 ++ 8 files changed, 80 insertions(+), 57 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index bfa580e6c3f..f9b3f5921a7 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); diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index c180e30d7fa..a74cd23113d 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -17,6 +17,7 @@ #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 @@ -57,6 +58,7 @@ _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) mode->visualType = GLX_TRUE_COLOR; mode->renderType = GLX_RGBA_BIT; } +#endif void @@ -76,7 +78,7 @@ void _eglInitConfig(_EGLConfig *config, EGLint id) { memset(config, 0, sizeof(*config)); - config->Handle = id; + config->Handle = (EGLConfig) id; _eglSetConfigAttrib(config, EGL_CONFIG_ID, id); _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGB, EGL_DONT_CARE); _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_DONT_CARE); @@ -132,7 +134,7 @@ _eglAddConfig(_EGLDisplay *display, const _EGLConfig *config) if (newConfigs) { display->Configs = newConfigs; display->Configs[n] = *config; /* copy struct */ - display->Configs[n].Handle = n; + display->Configs[n].Handle = (EGLConfig) n; display->NumConfigs++; return display->Configs + n; } @@ -498,6 +500,7 @@ _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, @@ -636,3 +639,4 @@ _eglFillInConfigs(_EGLConfig * configs, } return GL_TRUE; } +#endif diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 1fb976e5b4b..88e44dfc7d3 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -3,7 +3,9 @@ #include "egltypedefs.h" +#if 0 #include "GL/internal/glcore.h" +#endif #define MAX_ATTRIBS 100 @@ -52,16 +54,20 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, EGLint confi extern void _eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val); -extern GLboolean +#if 0 +extern EGLBoolean _eglFillInConfigs( _EGLConfig *configs, - GLenum fb_format, GLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const GLenum * db_modes, unsigned num_db_modes, - int visType ); - + EGLenum fb_format, EGLenum fb_type, + const u_int8_t * depth_bits, const u_int8_t * stencil_bits, + unsigned num_depth_stencil_bits, + const EGLenum * db_modes, unsigned num_db_modes, + int visType ); +#endif + +#if 0 extern void _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); +#endif #endif /* EGLCONFIG_INCLUDED */ diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 374c006dae7..bf26c1faa49 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; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 074a85bf26b..59d0bd3dc3e 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -26,10 +26,11 @@ _eglNewDisplay(NativeDisplayType displayName) { _EGLDisplay *dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { - dpy->Handle = _eglHashGenKey(_eglGlobal.Displays); - _eglHashInsert(_eglGlobal.Displays, dpy->Handle, dpy); + EGLuint key = _eglHashGenKey(_eglGlobal.Displays); + dpy->Handle = (EGLDisplay) key; + _eglHashInsert(_eglGlobal.Displays, key, dpy); if (displayName) - dpy->Name = my_strdup(displayName); + dpy->Name = my_strdup((char *) displayName); else dpy->Name = NULL; dpy->Driver = NULL; /* this gets set later */ @@ -45,7 +46,8 @@ _eglNewDisplay(NativeDisplayType displayName) _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy) { - _EGLDisplay *d = (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, dpy); + EGLuint key = (EGLuint) dpy; + _EGLDisplay *d = (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key); return d; } diff --git a/src/egl/main/eglmode.h b/src/egl/main/eglmode.h index e70da857595..52d4875676d 100644 --- a/src/egl/main/eglmode.h +++ b/src/egl/main/eglmode.h @@ -4,6 +4,9 @@ #include "egltypedefs.h" +#define EGL_NO_MODE_MESA 0 + + /** * Data structure which corresponds to an EGLModeMESA. */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 874f318e966..cd5d9757f9b 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -207,25 +207,27 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, void _eglSaveSurface(_EGLSurface *surf) { + EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); assert(surf); assert(!surf->Handle); - surf->Handle = _eglHashGenKey(_eglGlobal.Contexts); + surf->Handle = (EGLSurface) key; assert(surf->Handle); - _eglHashInsert(_eglGlobal.Surfaces, surf->Handle, surf); + _eglHashInsert(_eglGlobal.Surfaces, key, surf); } void _eglRemoveSurface(_EGLSurface *surf) { - _eglHashRemove(_eglGlobal.Surfaces, surf->Handle); + _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle); } _EGLSurface * _eglLookupSurface(EGLSurface surf) { - _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, surf); + _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, + (EGLuint) surf); return c; } @@ -439,7 +441,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { _EGLSurface *surf = _eglLookupSurface(surface); if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, surface); + _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); if (surf->IsBound) { surf->DeletePending = EGL_TRUE; } diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index fa8cb496f8d..53810a5a440 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -1,8 +1,10 @@ #ifndef EGLTYPEDEFS_INCLUDED #define EGLTYPEDEFS_INCLUDED +#define EGL_EGLEXT_PROTOTYPES #include +#include typedef struct _egl_api _EGLAPI; -- cgit v1.2.3 From 209a557574b9833da3d6ac299c83f4cddfff6910 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:17:40 -0600 Subject: fix typo: s/Contexts/Surfaces/ --- src/egl/main/eglsurface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index cd5d9757f9b..134afa7cbd8 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -207,7 +207,7 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, void _eglSaveSurface(_EGLSurface *surf) { - EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); + EGLuint key = _eglHashGenKey(_eglGlobal.Surfaces); assert(surf); assert(!surf->Handle); surf->Handle = (EGLSurface) key; -- 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') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index f9b3f5921a7..c57d29dda67 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 bf26c1faa49..86d1d843347 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 82bfde151f3..093f65fbfb9 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 608311d7494..4bdc0329bfd 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 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') 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 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') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 4df31cc03ff..e4eec26de0a 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 a74cd23113d..1b49f7afd92 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 88e44dfc7d3..4a806129805 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 59d0bd3dc3e..fd24f222739 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 1a03fdd4ad9..fe7b7884555 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 134afa7cbd8..1dbb12ecfe0 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 79abeca0b2a..df1e70122e2 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') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index e1058a23f70..0efcd4e605b 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 e4eec26de0a..fe63d36b803 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 1b49f7afd92..eb2c34a8028 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 4a806129805..e025f7f8451 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 fd24f222739..9c42194c611 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 fe7b7884555..be134374ca4 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 bda06dd827d..50c466c2582 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 88526e973d1..bde726e25e0 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 a772bbb16ec91a8714a498e8089f96f45730153c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 16:57:49 -0600 Subject: Move some config-related utility functions into new eglconfigutil.c file. --- src/egl/main/Makefile | 2 + src/egl/main/eglconfig.c | 253 +---------------------------------------- src/egl/main/eglconfig.h | 15 --- src/egl/main/eglconfigutil.c | 260 +++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglconfigutil.h | 23 ++++ 5 files changed, 286 insertions(+), 267 deletions(-) create mode 100644 src/egl/main/eglconfigutil.c create mode 100644 src/egl/main/eglconfigutil.h (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 0efcd4e605b..4fb0344e63f 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -8,6 +8,7 @@ INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi HEADERS = \ eglconfig.h \ + eglconfigutil.h \ eglcontext.h \ egldisplay.h \ egldriver.h \ @@ -22,6 +23,7 @@ HEADERS = \ SOURCES = \ eglapi.c \ eglconfig.c \ + eglconfigutil.c \ eglcontext.c \ egldisplay.c \ egldriver.c \ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index eb2c34a8028..c6369e7adfa 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -17,48 +17,6 @@ #define MIN2(A, B) (((A) < (B)) ? (A) : (B)) -/** - * Convert an _EGLConfig to a __GLcontextModes object. - * NOTE: This routine may be incomplete - we're only making sure that - * the fields needed by Mesa (for _mesa_create_context/framebuffer) are - * set correctly. - */ -void -_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) -{ - memset(mode, 0, sizeof(*mode)); - - mode->rgbMode = GL_TRUE; /* no color index */ - mode->colorIndexMode = GL_FALSE; - mode->doubleBufferMode = GL_TRUE; /* always DB for now */ - mode->stereoMode = GL_FALSE; - - mode->redBits = GET_CONFIG_ATTRIB(config, EGL_RED_SIZE); - mode->greenBits = GET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE); - mode->blueBits = GET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE); - mode->alphaBits = GET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE); - mode->rgbBits = GET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE); - - /* no rgba masks - fix? */ - - mode->depthBits = GET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE); - mode->haveDepthBuffer = mode->depthBits > 0; - - mode->stencilBits = GET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE); - mode->haveStencilBuffer = mode->stencilBits > 0; - - /* no accum */ - - mode->level = GET_CONFIG_ATTRIB(config, EGL_LEVEL); - mode->samples = GET_CONFIG_ATTRIB(config, EGL_SAMPLES); - mode->sampleBuffers = GET_CONFIG_ATTRIB(config, EGL_SAMPLE_BUFFERS); - - /* surface type - not really needed */ - mode->visualType = GLX_TRUE_COLOR; - mode->renderType = GLX_RGBA_BIT; -} - - void _eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val) { @@ -106,7 +64,7 @@ _eglInitConfig(_EGLConfig *config, EGLint id) EGLConfig _eglGetConfigHandle(_EGLConfig *config) { - return config ? config->Handle : 0; + return config ? config->Handle : 0; } @@ -441,212 +399,3 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, return EGL_TRUE; } - - -#if 0 -/** - * Creates a set of \c __GLcontextModes that a driver will expose. - * - * A set of \c __GLcontextModes will be created based on the supplied - * parameters. The number of modes processed will be 2 * - * \c num_depth_stencil_bits * \c num_db_modes. - * - * For the most part, data is just copied from \c depth_bits, \c stencil_bits, - * \c db_modes, and \c visType into each \c __GLcontextModes element. - * However, the meanings of \c fb_format and \c fb_type require further - * explanation. The \c fb_format specifies which color components are in - * each pixel and what the default order is. For example, \c GL_RGB specifies - * that red, green, blue are available and red is in the "most significant" - * position and blue is in the "least significant". The \c fb_type specifies - * the bit sizes of each component and the actual ordering. For example, if - * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11] - * are the blue value, bits [10:5] are the green value, and bits [4:0] are - * the red value. - * - * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either - * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the - * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or - * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as - * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8 - * still uses 32-bits. - * - * If in doubt, look at the tables used in the function. - * - * \param ptr_to_modes Pointer to a pointer to a linked list of - * \c __GLcontextModes. Upon completion, a pointer to - * the next element to be process will be stored here. - * If the function fails and returns \c GL_FALSE, this - * value will be unmodified, but some elements in the - * linked list may be modified. - * \param fb_format Format of the framebuffer. Currently only \c GL_RGB, - * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported. - * \param fb_type Type of the pixels in the framebuffer. Currently only - * \c GL_UNSIGNED_SHORT_5_6_5, - * \c GL_UNSIGNED_SHORT_5_6_5_REV, - * \c GL_UNSIGNED_INT_8_8_8_8, and - * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported. - * \param depth_bits Array of depth buffer sizes to be exposed. - * \param stencil_bits Array of stencil buffer sizes to be exposed. - * \param num_depth_stencil_bits Number of entries in both \c depth_bits and - * \c stencil_bits. - * \param db_modes Array of buffer swap modes. If an element has a - * value of \c GLX_NONE, then it represents a - * single-buffered mode. Other valid values are - * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and - * \c GLX_SWAP_UNDEFINED_OML. See the - * GLX_OML_swap_method extension spec for more details. - * \param num_db_modes Number of entries in \c db_modes. - * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or - * \c GLX_DIRECT_COLOR. - * - * \returns - * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only - * cause of failure is a bad parameter (i.e., unsupported \c fb_format or - * \c fb_type). - * - * \todo - * There is currently no way to support packed RGB modes (i.e., modes with - * exactly 3 bytes per pixel) or floating-point modes. This could probably - * be done by creating some new, private enums with clever names likes - * \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. - */ -GLboolean -_eglFillInConfigs(_EGLConfig * configs, - GLenum fb_format, GLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const GLenum * db_modes, unsigned num_db_modes, - int visType) -{ - static const u_int8_t bits_table[3][4] = { - /* R G B A */ - { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ - { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ - { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */ - }; - - /* The following arrays are all indexed by the fb_type masked with 0x07. - * Given the four supported fb_type values, this results in valid array - * indices of 3, 4, 5, and 7. - */ - static const u_int32_t masks_table_rgb[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000} /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_rgba[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_bgr[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000}, /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_bgra[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */ - }; - - static const u_int8_t bytes_per_pixel[8] = { - 0, 0, 0, 2, 2, 4, 0, 4 - }; - - const u_int8_t * bits; - const u_int32_t * masks; - const int index = fb_type & 0x07; - _EGLConfig *config; - unsigned i; - unsigned j; - unsigned k; - - if ( bytes_per_pixel[index] == 0 ) { - _eglLog(_EGL_INFO, - "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.", - __FUNCTION__, __LINE__, fb_type); - return GL_FALSE; - } - - /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and - * the _REV versions. - * - * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA. - */ - switch ( fb_format ) { - case GL_RGB: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_rgb[index]; - break; - - case GL_RGBA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_rgba[index]; - break; - - case GL_BGR: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_bgr[index]; - break; - - case GL_BGRA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_bgra[index]; - break; - - default: - _eglLog(_EGL_WARNING, - "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.", - __FUNCTION__, __LINE__, fb_format); - return GL_FALSE; - } - - config = configs; - for (k = 0; k < num_depth_stencil_bits; k++) { - for (i = 0; i < num_db_modes; i++) { - for (j = 0; j < 2; j++) { - _eglSetConfigAttrib(config, EGL_RED_SIZE, bits[0]); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, bits[1]); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, bits[2]); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, bits[3]); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, - bits[0] + bits[1] + bits[2] + bits[3]); - - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, stencil_bits[k]); - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, depth_bits[i]); - - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_SCREEN_BIT_MESA | - EGL_PBUFFER_BIT | EGL_PIXMAP_BIT | EGL_WINDOW_BIT); - - config++; - } - } - } - return GL_TRUE; -} -#endif diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index e025f7f8451..b10a61985d1 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -4,7 +4,6 @@ #include "egltypedefs.h" #include -#include "GL/internal/glcore.h" #define MAX_ATTRIBS 100 @@ -57,19 +56,5 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, EGLint confi extern void _eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val); -#if 0 -extern EGLBoolean -_eglFillInConfigs( _EGLConfig *configs, - EGLenum fb_format, EGLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const EGLenum * db_modes, unsigned num_db_modes, - int visType ); -#endif - - -extern void -_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); - #endif /* EGLCONFIG_INCLUDED */ diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c new file mode 100644 index 00000000000..b6585619a53 --- /dev/null +++ b/src/egl/main/eglconfigutil.c @@ -0,0 +1,260 @@ +/** + * Extra utility functions related to EGL configs. + */ + + +#include +#include +#include +#include "eglconfigutil.h" +#include "egllog.h" + + +/** + * Convert an _EGLConfig to a __GLcontextModes object. + * NOTE: This routine may be incomplete - we're only making sure that + * the fields needed by Mesa (for _mesa_create_context/framebuffer) are + * set correctly. + */ +void +_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) +{ + memset(mode, 0, sizeof(*mode)); + + mode->rgbMode = GL_TRUE; /* no color index */ + mode->colorIndexMode = GL_FALSE; + mode->doubleBufferMode = GL_TRUE; /* always DB for now */ + mode->stereoMode = GL_FALSE; + + mode->redBits = GET_CONFIG_ATTRIB(config, EGL_RED_SIZE); + mode->greenBits = GET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE); + mode->blueBits = GET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE); + mode->alphaBits = GET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE); + mode->rgbBits = GET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE); + + /* no rgba masks - fix? */ + + mode->depthBits = GET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE); + mode->haveDepthBuffer = mode->depthBits > 0; + + mode->stencilBits = GET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE); + mode->haveStencilBuffer = mode->stencilBits > 0; + + /* no accum */ + + mode->level = GET_CONFIG_ATTRIB(config, EGL_LEVEL); + mode->samples = GET_CONFIG_ATTRIB(config, EGL_SAMPLES); + mode->sampleBuffers = GET_CONFIG_ATTRIB(config, EGL_SAMPLE_BUFFERS); + + /* surface type - not really needed */ + mode->visualType = GLX_TRUE_COLOR; + mode->renderType = GLX_RGBA_BIT; +} + + + +/** + * Creates a set of \c _EGLConfigs that a driver will expose. + * + * A set of \c __GLcontextModes will be created based on the supplied + * parameters. The number of modes processed will be 2 * + * \c num_depth_stencil_bits * \c num_db_modes. + * + * For the most part, data is just copied from \c depth_bits, \c stencil_bits, + * \c db_modes, and \c visType into each \c __GLcontextModes element. + * However, the meanings of \c fb_format and \c fb_type require further + * explanation. The \c fb_format specifies which color components are in + * each pixel and what the default order is. For example, \c GL_RGB specifies + * that red, green, blue are available and red is in the "most significant" + * position and blue is in the "least significant". The \c fb_type specifies + * the bit sizes of each component and the actual ordering. For example, if + * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11] + * are the blue value, bits [10:5] are the green value, and bits [4:0] are + * the red value. + * + * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either + * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the + * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or + * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as + * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8 + * still uses 32-bits. + * + * If in doubt, look at the tables used in the function. + * + * \param configs the array of configs generated + * \param fb_format Format of the framebuffer. Currently only \c GL_RGB, + * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported. + * \param fb_type Type of the pixels in the framebuffer. Currently only + * \c GL_UNSIGNED_SHORT_5_6_5, + * \c GL_UNSIGNED_SHORT_5_6_5_REV, + * \c GL_UNSIGNED_INT_8_8_8_8, and + * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported. + * \param depth_bits Array of depth buffer sizes to be exposed. + * \param stencil_bits Array of stencil buffer sizes to be exposed. + * \param num_depth_stencil_bits Number of entries in both \c depth_bits and + * \c stencil_bits. + * \param db_modes Array of buffer swap modes. If an element has a + * value of \c GLX_NONE, then it represents a + * single-buffered mode. Other valid values are + * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and + * \c GLX_SWAP_UNDEFINED_OML. See the + * GLX_OML_swap_method extension spec for more details. + * \param num_db_modes Number of entries in \c db_modes. + * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or + * \c GLX_DIRECT_COLOR. + * + * \returns + * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only + * cause of failure is a bad parameter (i.e., unsupported \c fb_format or + * \c fb_type). + * + * \todo + * There is currently no way to support packed RGB modes (i.e., modes with + * exactly 3 bytes per pixel) or floating-point modes. This could probably + * be done by creating some new, private enums with clever names likes + * \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. + */ +EGLBoolean +_eglFillInConfigs(_EGLConfig * configs, + GLenum fb_format, GLenum fb_type, + const u_int8_t * depth_bits, const u_int8_t * stencil_bits, + unsigned num_depth_stencil_bits, + const GLenum * db_modes, unsigned num_db_modes, + int visType) +{ +#if 0 + static const u_int8_t bits_table[3][4] = { + /* R G B A */ + { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ + { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ + { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */ + }; + + /* The following arrays are all indexed by the fb_type masked with 0x07. + * Given the four supported fb_type values, this results in valid array + * indices of 3, 4, 5, and 7. + */ + static const u_int32_t masks_table_rgb[8][4] = { + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ + {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ + {0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000}, /* 8_8_8_8 */ + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000} /* 8_8_8_8_REV */ + }; + + static const u_int32_t masks_table_rgba[8][4] = { + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ + {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ + {0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF}, /* 8_8_8_8 */ + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */ + }; + + static const u_int32_t masks_table_bgr[8][4] = { + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ + {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ + {0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000}, /* 8_8_8_8 */ + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000}, /* 8_8_8_8_REV */ + }; + + static const u_int32_t masks_table_bgra[8][4] = { + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ + {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ + {0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF}, /* 8_8_8_8 */ + {0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */ + }; + + static const u_int8_t bytes_per_pixel[8] = { + 0, 0, 0, 2, 2, 4, 0, 4 + }; + + const u_int8_t * bits; + const u_int32_t * masks; + const int index = fb_type & 0x07; + _EGLConfig *config; + unsigned i; + unsigned j; + unsigned k; + + if ( bytes_per_pixel[index] == 0 ) { + _eglLog(_EGL_INFO, + "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.", + __FUNCTION__, __LINE__, fb_type); + return GL_FALSE; + } + + /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and + * the _REV versions. + * + * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA. + */ + switch ( fb_format ) { + case GL_RGB: + bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; + masks = masks_table_rgb[index]; + break; + + case GL_RGBA: + bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; + masks = masks_table_rgba[index]; + break; + + case GL_BGR: + bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; + masks = masks_table_bgr[index]; + break; + + case GL_BGRA: + bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; + masks = masks_table_bgra[index]; + break; + + default: + _eglLog(_EGL_WARNING, + "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.", + __FUNCTION__, __LINE__, fb_format); + return GL_FALSE; + } + + config = configs; + for (k = 0; k < num_depth_stencil_bits; k++) { + for (i = 0; i < num_db_modes; i++) { + for (j = 0; j < 2; j++) { + _eglSetConfigAttrib(config, EGL_RED_SIZE, bits[0]); + _eglSetConfigAttrib(config, EGL_GREEN_SIZE, bits[1]); + _eglSetConfigAttrib(config, EGL_BLUE_SIZE, bits[2]); + _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, bits[3]); + _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, + bits[0] + bits[1] + bits[2] + bits[3]); + + _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, stencil_bits[k]); + _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, depth_bits[i]); + + _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_SCREEN_BIT_MESA | + EGL_PBUFFER_BIT | EGL_PIXMAP_BIT | EGL_WINDOW_BIT); + + config++; + } + } + } + return GL_TRUE; +#else + return GL_FALSE; +#endif +} + diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h new file mode 100644 index 00000000000..5db906db651 --- /dev/null +++ b/src/egl/main/eglconfigutil.h @@ -0,0 +1,23 @@ + +#ifndef EGLCONFIGUTIL_INCLUDED +#define EGLCONFIGUTIL_INCLUDED + +#include "eglconfig.h" +#include "GL/internal/glcore.h" + + +extern void +_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); + + +extern EGLBoolean +_eglFillInConfigs( _EGLConfig *configs, + EGLenum fb_format, EGLenum fb_type, + const u_int8_t * depth_bits, const u_int8_t * stencil_bits, + unsigned num_depth_stencil_bits, + const EGLenum * db_modes, unsigned num_db_modes, + int visType ); + + + +#endif /* EGLCONFIGUTIL_INCLUDED */ -- cgit v1.2.3 From b870bf79b5387f26668285f44ccbf5812ad62e10 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 28 May 2008 11:40:41 +0200 Subject: egl: Temporarily disable eglx.[c|h] building --- src/egl/main/Makefile | 7 ++++--- src/egl/main/egldriver.c | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 4fb0344e63f..5f3d65f72a8 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -18,7 +18,7 @@ HEADERS = \ eglmode.h \ eglscreen.h \ eglsurface.h \ - eglx.h +# eglx.h SOURCES = \ eglapi.c \ @@ -33,12 +33,13 @@ SOURCES = \ eglmode.c \ eglscreen.c \ eglsurface.c \ - eglx.c +# eglx.c OBJECTS = $(SOURCES:.c=.o) -LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +# Undefined for now +#LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 .c.o: diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 50c466c2582..cbdd47948db 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -16,8 +16,14 @@ #include "eglmode.h" #include "eglscreen.h" #include "eglsurface.h" -#include "eglx.h" +#if defined(_EGL_PLATFORM_X) +#include "eglx.h" +#elif defined(_EGL_PLATFORM_WINDOWS) +/* XXX to do */ +#elif defined(_EGL_PLATFORM_WINCE) +/* XXX to do */ +#endif const char *DefaultDriverName = "demodriver"; -- cgit v1.2.3 From 95c917f7dd6e837cb1b280be617a795dd57c9f13 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 08:42:13 -0600 Subject: x-related EGL code (stub) --- src/egl/main/eglx.c | 37 +++++++++++++++++++++++++++++++++++++ src/egl/main/eglx.h | 12 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/egl/main/eglx.c create mode 100644 src/egl/main/eglx.h (limited to 'src/egl/main') diff --git a/src/egl/main/eglx.c b/src/egl/main/eglx.c new file mode 100644 index 00000000000..4b33080f1a6 --- /dev/null +++ b/src/egl/main/eglx.c @@ -0,0 +1,37 @@ + +/** + * X-specific EGL code. + * + * Any glue code needed to make EGL work with X is placed in this file. + */ + + +#include +#include +#include +#include "eglx.h" + + + +/** + * Given an X Display ptr (at dpy->Xdpy) try to determine the appropriate + * device driver. Return its name. + */ +const char * +_xeglChooseDriver(_EGLDisplay *dpy) +{ +#ifdef _EGL_PLATFORM_X + _XPrivDisplay xdpy = (_XPrivDisplay) dpy->Xdpy; + + assert(dpy); + assert(dpy->Xdpy); + + printf("%s\n", xdpy->display_name); + + return "foo"; /* XXX todo */ +#else + return NULL; +#endif +} + + diff --git a/src/egl/main/eglx.h b/src/egl/main/eglx.h new file mode 100644 index 00000000000..4323d558381 --- /dev/null +++ b/src/egl/main/eglx.h @@ -0,0 +1,12 @@ +#ifndef EGLX_INCLUDED +#define EGLX_INCLUDED + + +#include "egldisplay.h" + + +extern const char * +_xeglChooseDriver(_EGLDisplay *dpy); + + +#endif /* EGLX_INCLUDED */ -- cgit v1.2.3 From e94d383b9ba7964da9fefac2a55e10c00ee72392 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 12:54:33 -0600 Subject: egl: added eglstring.[ch] --- src/egl/main/Makefile | 6 ++++-- src/egl/main/eglstring.c | 24 ++++++++++++++++++++++++ src/egl/main/eglstring.h | 9 +++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/egl/main/eglstring.c create mode 100644 src/egl/main/eglstring.h (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 5f3d65f72a8..eabfb414501 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -17,8 +17,9 @@ HEADERS = \ eglhash.h \ eglmode.h \ eglscreen.h \ + eglstring.h \ eglsurface.h \ -# eglx.h + eglx.h SOURCES = \ eglapi.c \ @@ -32,8 +33,9 @@ SOURCES = \ eglhash.c \ eglmode.c \ eglscreen.c \ + eglstring.c \ eglsurface.c \ -# eglx.c + eglx.c OBJECTS = $(SOURCES:.c=.o) diff --git a/src/egl/main/eglstring.c b/src/egl/main/eglstring.c new file mode 100644 index 00000000000..ba7406158c4 --- /dev/null +++ b/src/egl/main/eglstring.c @@ -0,0 +1,24 @@ +/** + * String utils. + */ + +#include +#include +#include "eglstring.h" + + +char * +_eglstrdup(const char *s) +{ + if (s) { + int l = strlen(s); + char *s2 = malloc(l + 1); + if (s2) + strcpy(s2, s); + return s2; + } + return NULL; +} + + + diff --git a/src/egl/main/eglstring.h b/src/egl/main/eglstring.h new file mode 100644 index 00000000000..10468636e87 --- /dev/null +++ b/src/egl/main/eglstring.h @@ -0,0 +1,9 @@ +#ifndef EGLSTRING_INCLUDED +#define EGLSTRING_INCLUDED + + +extern char * +_eglstrdup(const char *s); + + +#endif /* EGLSTRING_INCLUDED */ -- 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') diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c index 1033f1b4ed6..6b8b71d16ba 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 f00625a0593..677073fb3a0 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 fe63d36b803..984af4ea22e 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 9c42194c611..b2d30d42749 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 be134374ca4..e2ebab0b218 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 cbdd47948db..599077190af 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 bde726e25e0..9c505880b7a 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 53810a5a440..b1c8ec1f02e 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 9843c6420d88db0c43b831cf79a3d1872c636225 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 14:51:40 -0600 Subject: egl: bring card->driver lookup code into egldriver.c --- src/egl/main/egldisplay.c | 2 +- src/egl/main/egldriver.c | 60 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 8 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index b2d30d42749..8fd29b84216 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -35,7 +35,7 @@ _eglNewDisplay(NativeDisplayType nativeDisplay) dpy->Xdpy = (Display *) nativeDisplay; #endif - dpy->DriverName = _eglstrdup(_eglChooseDriver(dpy)); + dpy->DriverName = _eglChooseDriver(dpy); if (!dpy->DriverName) { free(dpy); return NULL; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 599077190af..b58222e48e5 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -28,6 +28,44 @@ #endif const char *DefaultDriverName = ":0"; +const char *SysFS = "/sys/class"; + + + + +/** + * Given a card number, use sysfs to determine the DRI driver name. + */ +static const char * +_eglChooseDRMDriver(int card) +{ +#if 0 + return _eglstrdup("libEGLdri"); +#else + char path[2000], driverName[2000]; + FILE *f; + int length; + + snprintf(path, sizeof(path), "%s/drm/card%d/dri_library_name", SysFS, card); + + f = fopen(path, "r"); + if (!f) + return NULL; + + fgets(driverName, sizeof(driverName), f); + fclose(f); + + if ((length = strlen(driverName)) > 1) { + /* remove the trailing newline from sysfs */ + driverName[length - 1] = '\0'; + strncat(driverName, "_dri", sizeof(driverName)); + return _eglstrdup(driverName); + } + else { + return NULL; + } +#endif +} /** @@ -41,7 +79,9 @@ const char *DefaultDriverName = ":0"; * 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. + * Whatever follows ':' is copied and put into dpy->DriverArgs. + * + * The caller may free() the returned string. */ const char * _eglChooseDriver(_EGLDisplay *dpy) @@ -62,20 +102,26 @@ _eglChooseDriver(_EGLDisplay *dpy) dpy->DriverArgs = _eglstrdup(args + 1); } - + /* determine driver name now */ if (displayString && displayString[0] == ':' && (displayString[1] >= '0' && displayString[1] <= '9') && !displayString[2]) { - /* XXX probe hardware here to determine which driver to open */ - driverName = "libEGLdri"; + int card = atoi(displayString + 1); + driverName = _eglChooseDRMDriver(card); } else if (displayString && displayString[0] == '!') { - /* use specified driver name */ - driverName = displayString + 1; + /* use user-specified driver name */ + driverName = _eglstrdup(displayString + 1); + /* truncate driverName at ':' if present */ + { + char *args = strchr(driverName, ':'); + if (args) { + *args = 0; + } + } } else { /* NativeDisplay is not a string! */ - #if defined(_EGL_PLATFORM_X) driverName = _xeglChooseDriver(dpy); #elif defined(_EGL_PLATFORM_WINDOWS) -- cgit v1.2.3 From cf3c7d74ccee8e21ebfa04159ab64fec3b989d83 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 15:21:52 -0600 Subject: egl: added egldefines.h --- src/egl/main/Makefile | 1 + src/egl/main/egldefines.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/egl/main/egldefines.h (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index eabfb414501..1c395ec9286 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -10,6 +10,7 @@ HEADERS = \ eglconfig.h \ eglconfigutil.h \ eglcontext.h \ + egldefines.h \ egldisplay.h \ egldriver.h \ eglglobals.h \ diff --git a/src/egl/main/egldefines.h b/src/egl/main/egldefines.h new file mode 100644 index 00000000000..f5d37a2fc06 --- /dev/null +++ b/src/egl/main/egldefines.h @@ -0,0 +1,47 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + + +/** + * Internal EGL defines + */ + + +#ifndef EGLDEFINES_INCLUDED +#define EGLDEFINES_INCLUDED + + +#define _EGL_MAX_EXTENSIONS_LEN 1000 + +#define _EGL_VERSION_STRING "1.4" + +#define _EGL_VENDOR_STRING "Mesa Project" + + + +#endif /* EGLDEFINES_INCLUDED */ -- cgit v1.2.3 From e084fe54f93c9d51df99812b76d3299b0cff57a3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 15:22:17 -0600 Subject: egl: include egldefines.h --- src/egl/main/egldriver.c | 8 +++++--- src/egl/main/egldriver.h | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index b58222e48e5..6d533625b7d 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -10,6 +10,7 @@ #include #include "eglconfig.h" #include "eglcontext.h" +#include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" @@ -27,6 +28,7 @@ /* XXX to do */ #endif + const char *DefaultDriverName = ":0"; const char *SysFS = "/sys/class"; @@ -290,7 +292,7 @@ _eglUpdateExtensionsString(_EGLDriver *drv) strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); if (drv->Extensions.MESA_copy_context) strcat(drv->Extensions.String, "EGL_MESA_copy_context "); - assert(strlen(drv->Extensions.String) < MAX_EXTENSIONS_LEN); + assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN); } @@ -302,9 +304,9 @@ _eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) (void) dpy; switch (name) { case EGL_VENDOR: - return "Mesa Project"; + return _EGL_VENDOR_STRING; case EGL_VERSION: - return "1.0"; + return _EGL_VERSION_STRING; case EGL_EXTENSIONS: _eglUpdateExtensionsString(drv); return drv->Extensions.String; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 9c505880b7a..67cfb02f46a 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -4,9 +4,7 @@ #include "egltypedefs.h" #include "eglapi.h" - -/* should probably use a dynamic-length string, but this will do */ -#define MAX_EXTENSIONS_LEN 1000 +#include "egldefines.h" /** @@ -17,7 +15,7 @@ struct _egl_extensions EGLBoolean MESA_screen_surface; EGLBoolean MESA_copy_context; - char String[MAX_EXTENSIONS_LEN]; + char String[_EGL_MAX_EXTENSIONS_LEN]; }; -- 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') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 984af4ea22e..3151b35156c 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 f5d37a2fc06..8fc2301b795 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 6d533625b7d..2257a686307 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 67cfb02f46a..9395a667ab3 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 11a261ef4f1d4100c46f73ad51e7e4ed57cc1b5e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 15:50:58 -0600 Subject: egl: move a few small functions into new eglmisc.[ch] files --- src/egl/main/Makefile | 2 + src/egl/main/egldriver.c | 74 +------------------------------- src/egl/main/egldriver.h | 13 ------ src/egl/main/eglmisc.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglmisc.h | 47 +++++++++++++++++++++ 5 files changed, 159 insertions(+), 85 deletions(-) create mode 100644 src/egl/main/eglmisc.c create mode 100644 src/egl/main/eglmisc.h (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 1c395ec9286..6676e7e0317 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -16,6 +16,7 @@ HEADERS = \ eglglobals.h \ egllog.h \ eglhash.h \ + eglmisc.h \ eglmode.h \ eglscreen.h \ eglstring.h \ @@ -32,6 +33,7 @@ SOURCES = \ eglglobals.c \ egllog.c \ eglhash.c \ + eglmisc.c \ eglmode.c \ eglscreen.c \ eglstring.c \ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 2257a686307..9f3c52fd2f0 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -4,10 +4,10 @@ #include +#include #include #include #include -#include #include "eglconfig.h" #include "eglcontext.h" #include "egldefines.h" @@ -15,6 +15,7 @@ #include "egldriver.h" #include "eglglobals.h" #include "egllog.h" +#include "eglmisc.h" #include "eglmode.h" #include "eglscreen.h" #include "eglstring.h" @@ -277,74 +278,3 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer; #endif /* EGL_VERSION_1_2 */ } - - -/** - * Examine the individual extension enable/disable flags and recompute - * the driver's Extensions string. - */ -static void -_eglUpdateExtensionsString(_EGLDriver *drv) -{ - drv->Extensions.String[0] = 0; - - if (drv->Extensions.MESA_screen_surface) - strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); - if (drv->Extensions.MESA_copy_context) - strcat(drv->Extensions.String, "EGL_MESA_copy_context "); - assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN); -} - - - -const char * -_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) -{ - (void) drv; - (void) dpy; - switch (name) { - case EGL_VENDOR: - return _EGL_VENDOR_STRING; - case EGL_VERSION: - return drv->Version; - case EGL_EXTENSIONS: - _eglUpdateExtensionsString(drv); - return drv->Extensions.String; -#ifdef EGL_VERSION_1_2 - case EGL_CLIENT_APIS: - /* XXX need to initialize somewhere */ - return drv->ClientAPIs; -#endif - default: - _eglError(EGL_BAD_PARAMETER, "eglQueryString"); - return NULL; - } -} - - -EGLBoolean -_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy) -{ - /* just a placeholder */ - (void) drv; - (void) dpy; - return EGL_TRUE; -} - - -EGLBoolean -_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine) -{ - /* just a placeholder */ - (void) drv; - (void) dpy; - switch (engine) { - case EGL_CORE_NATIVE_ENGINE: - break; - default: - _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)"); - return EGL_FALSE; - } - - return EGL_TRUE; -} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 9395a667ab3..df0eb7fc4cb 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -64,17 +64,4 @@ extern void _eglInitDriverFallbacks(_EGLDriver *drv); -extern const char * -_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name); - - -extern EGLBoolean -_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy); - - -extern EGLBoolean -_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine); - - - #endif /* EGLDRIVER_INCLUDED */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c new file mode 100644 index 00000000000..fb32544b15d --- /dev/null +++ b/src/egl/main/eglmisc.c @@ -0,0 +1,108 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +/** + * Small/misc EGL functions + */ + + +#include +#include +#include "eglglobals.h" +#include "eglmisc.h" + + +/** + * Examine the individual extension enable/disable flags and recompute + * the driver's Extensions string. + */ +static void +_eglUpdateExtensionsString(_EGLDriver *drv) +{ + drv->Extensions.String[0] = 0; + + if (drv->Extensions.MESA_screen_surface) + strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); + if (drv->Extensions.MESA_copy_context) + strcat(drv->Extensions.String, "EGL_MESA_copy_context "); + assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN); +} + + + +const char * +_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) +{ + (void) drv; + (void) dpy; + switch (name) { + case EGL_VENDOR: + return _EGL_VENDOR_STRING; + case EGL_VERSION: + return drv->Version; + case EGL_EXTENSIONS: + _eglUpdateExtensionsString(drv); + return drv->Extensions.String; +#ifdef EGL_VERSION_1_2 + case EGL_CLIENT_APIS: + /* XXX need to initialize somewhere */ + return drv->ClientAPIs; +#endif + default: + _eglError(EGL_BAD_PARAMETER, "eglQueryString"); + return NULL; + } +} + + +EGLBoolean +_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy) +{ + /* just a placeholder */ + (void) drv; + (void) dpy; + return EGL_TRUE; +} + + +EGLBoolean +_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine) +{ + /* just a placeholder */ + (void) drv; + (void) dpy; + switch (engine) { + case EGL_CORE_NATIVE_ENGINE: + break; + default: + _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)"); + return EGL_FALSE; + } + + return EGL_TRUE; +} diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h new file mode 100644 index 00000000000..4e2a40ea991 --- /dev/null +++ b/src/egl/main/eglmisc.h @@ -0,0 +1,47 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef EGLMISC_INCLUDED +#define EGLMISC_INCLUDED + +#include "egldriver.h" + + +extern const char * +_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name); + + +extern EGLBoolean +_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy); + + +extern EGLBoolean +_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine); + + +#endif /* EGLMISC_INCLUDED */ -- cgit v1.2.3 From 260ac3c983644e1e51f705c00ceec1866a0c9611 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 16:08:50 -0600 Subject: egl: remove unused Display field --- src/egl/main/egldriver.c | 1 - src/egl/main/egldriver.h | 2 -- 2 files changed, 3 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 9f3c52fd2f0..32842933ce2 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -185,7 +185,6 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) else dlclose(lib); - drv->Display = dpy; return drv; } diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index df0eb7fc4cb..b0a5fadf647 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -28,8 +28,6 @@ struct _egl_driver void *LibHandle; /**< dlopen handle */ - _EGLDisplay *Display; - int APImajor, APIminor; /**< as returned by eglInitialize() */ char Version[10]; /**< initialized from APImajor/minor */ -- cgit v1.2.3 From f751371028cc425bef83418224c23ece67f5b8b7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 May 2008 16:48:35 -0600 Subject: egl: re-enable LOCAL_CFLAGS --- src/egl/main/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 6676e7e0317..5b341a19be2 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -44,7 +44,7 @@ OBJECTS = $(SOURCES:.c=.o) # Undefined for now -#LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 .c.o: -- cgit v1.2.3 From d1a0faffc3fde42b030f3eb18d6f31c10dfdc8f6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 29 May 2008 17:01:19 -0600 Subject: egl: use softpipe_egl driver by default --- src/egl/main/eglx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglx.c b/src/egl/main/eglx.c index 4b33080f1a6..085da33e7dc 100644 --- a/src/egl/main/eglx.c +++ b/src/egl/main/eglx.c @@ -12,6 +12,8 @@ #include "eglx.h" +static const char *DefaultXDriver = "softpipe_egl"; + /** * Given an X Display ptr (at dpy->Xdpy) try to determine the appropriate @@ -21,14 +23,24 @@ const char * _xeglChooseDriver(_EGLDisplay *dpy) { #ifdef _EGL_PLATFORM_X - _XPrivDisplay xdpy = (_XPrivDisplay) dpy->Xdpy; + _XPrivDisplay xdpy; assert(dpy); + + if (!dpy->Xdpy) { + dpy->Xdpy = XOpenDisplay(NULL); + if (!dpy->Xdpy) { + /* can't open X display -> can't use X-based driver */ + return NULL; + } + } + xdpy = (_XPrivDisplay) dpy->Xdpy; + assert(dpy->Xdpy); printf("%s\n", xdpy->display_name); - return "foo"; /* XXX todo */ + return DefaultXDriver; /* XXX temporary */ #else return NULL; #endif -- 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') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 3151b35156c..367787b243d 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 b0a5fadf647..e0cedb22c35 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 d0de5a2dafb5143f01a3c6dc367c85aa0800466b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 11:40:23 -0600 Subject: link libEGL with Xlib --- src/egl/main/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 5b341a19be2..96742bb4bc6 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -46,6 +46,8 @@ OBJECTS = $(SOURCES:.c=.o) # Undefined for now LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +LIBS = -lX11 + .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ @@ -60,7 +62,7 @@ library: $(TOP)/$(LIB_DIR)/libEGL.so $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS) $(TOP)/bin/mklib -o EGL -major 1 -minor 0 \ - -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) + -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(LIBS) -- cgit v1.2.3 From 274dd381a30072ecb8341cfc41e63bb6e39419ac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 11:40:48 -0600 Subject: egl: fix width/height tests --- src/egl/main/eglsurface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 1dbb12ecfe0..796d62f2b94 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -175,7 +175,7 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, } } - if (width <= 0 || height <= 0) { + if (width < 0 || height < 0) { _eglError(EGL_BAD_ATTRIBUTE, func); return EGL_FALSE; } -- cgit v1.2.3 From 834aa8cfbc25622256889624ee1768c10224feb2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 11:46:43 -0600 Subject: egl: check for EGL_DRIVER env var to override normal driver selection process --- src/egl/main/egldriver.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 32842933ce2..e155f5fb982 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -92,14 +92,21 @@ _eglChooseDriver(_EGLDisplay *dpy) const char *displayString = (const char *) dpy->NativeDisplay; const char *driverName = NULL; + /* First, if the EGL_DRIVER env var is set, use that */ + driverName = getenv("EGL_DRIVER"); + if (driverName) + return _eglstrdup(driverName); + + if (!displayString) { /* choose a default */ displayString = DefaultDriverName; } /* extract default DriverArgs = whatever follows ':' */ - if (displayString[0] == '!' || - displayString[0] == ':') { + if (displayString && + (displayString[0] == '!' || + displayString[0] == ':')) { const char *args = strchr(displayString, ':'); if (args) dpy->DriverArgs = _eglstrdup(args + 1); -- 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') 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') 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 From 19ca6ce573b409346a397453e7d4fa43a0f98368 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Jun 2008 10:09:49 -0600 Subject: egl: updated include paths (s/GLES/EGL/) --- src/egl/main/egltypedefs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index efbb17a4dc1..9fbc55352c2 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -3,8 +3,8 @@ #define EGL_EGLEXT_PROTOTYPES -#include -#include +#include +#include typedef struct _egl_api _EGLAPI; -- cgit v1.2.3 From 97035cb19aaf508aad45446651a80da9af1d0e8c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Jun 2008 11:34:10 -0600 Subject: egl: in _eglAddConfig() just save a pointer to the config; don't copy the config This allows subclassing by drivers. --- src/egl/main/eglconfig.c | 25 +++++++++++++------------ src/egl/main/eglconfig.h | 2 +- src/egl/main/egldisplay.c | 18 ++++++++++++++++-- src/egl/main/egldisplay.h | 2 +- 4 files changed, 31 insertions(+), 16 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index c6369e7adfa..794a783b9e2 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -78,8 +78,8 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) EGLint i; _EGLDisplay *disp = _eglLookupDisplay(dpy); for (i = 0; i < disp->NumConfigs; i++) { - if (disp->Configs[i].Handle == config) { - return disp->Configs + i; + if (disp->Configs[i]->Handle == config) { + return disp->Configs[i]; } } return NULL; @@ -88,23 +88,24 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) /** * Add the given _EGLConfig to the given display. + * Note that we just save the ptr to the config (we don't copy the config). */ _EGLConfig * -_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config) +_eglAddConfig(_EGLDisplay *display, _EGLConfig *config) { - _EGLConfig *newConfigs; + _EGLConfig **newConfigs; EGLint n; n = display->NumConfigs; - newConfigs = (_EGLConfig *) realloc(display->Configs, - (n + 1) * sizeof(_EGLConfig)); + /* realloc array of ptrs */ + newConfigs = (_EGLConfig **) realloc(display->Configs, + (n + 1) * sizeof(_EGLConfig *)); if (newConfigs) { display->Configs = newConfigs; - display->Configs[n] = *config; /* copy struct */ - display->Configs[n].Handle = (EGLConfig) n; + display->Configs[n] = config; display->NumConfigs++; - return display->Configs + n; + return config; } else { return NULL; @@ -330,8 +331,8 @@ _eglChooseConfig(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list, /* make array of pointers to qualifying configs */ for (i = count = 0; i < disp->NumConfigs && count < config_size; i++) { - if (_eglConfigQualifies(disp->Configs + i, &criteria)) { - configList[count++] = disp->Configs + i; + if (_eglConfigQualifies(disp->Configs[i], &criteria)) { + configList[count++] = disp->Configs[i]; } } @@ -389,7 +390,7 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, EGLint i; *num_config = MIN2(disp->NumConfigs, config_size); for (i = 0; i < *num_config; i++) { - configs[i] = disp->Configs[i].Handle; + configs[i] = disp->Configs[i]->Handle; } } else { diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index b10a61985d1..d12f66245c0 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -34,7 +34,7 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config); extern _EGLConfig * -_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config); +_eglAddConfig(_EGLDisplay *display, _EGLConfig *config); extern EGLBoolean diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 8fd29b84216..540efd4fee5 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -96,11 +96,25 @@ _eglGetCurrentDisplay(void) } +/** + * Free all the data hanging of an _EGLDisplay object, but not + * the object itself. + */ void _eglCleanupDisplay(_EGLDisplay *disp) { - /* XXX incomplete */ + EGLint i; + + for (i = 0; i < disp->NumConfigs; i++) { + free(disp->Configs[i]); + } free(disp->Configs); + disp->Configs = NULL; + + /* XXX incomplete */ + free((void *) disp->DriverName); - /* driver deletes _EGLDisplay */ + disp->DriverName = NULL; + + /* driver deletes the _EGLDisplay object */ } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index e2ebab0b218..ff623ee1c66 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -21,7 +21,7 @@ struct _egl_display _EGLScreen **Screens; /* array [NumScreens] */ EGLint NumConfigs; - _EGLConfig *Configs; /* array [NumConfigs] */ + _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */ #ifdef _EGL_PLATFORM_X Display *Xdpy; -- cgit v1.2.3 From f6e030f531f7292a373a7cd633e8af9f97726266 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 6 Jun 2008 15:10:22 -0600 Subject: egl: change default logging level to _EGL_WARNING --- src/egl/main/egllog.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index dc1daaa996a..23eb523eebe 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -1,5 +1,7 @@ /** * Logging facility for debug/info messages. + * _EGL_FATAL messages are printed to stderr + * The EGL_LOG_LEVEL var controls the output of other warning/info/debug msgs. */ @@ -10,37 +12,37 @@ #include "egllog.h" #define MAXSTRING 1000 -#define FALLBACK_LOG_LEVEL _EGL_DEBUG -#define FALLBACK_LOG_LEVEL_STR "debug" +#define FALLBACK_LOG_LEVEL _EGL_WARNING +#define FALLBACK_LOG_LEVEL_STR "warning" static EGLint ReportingLevel = -1; static void -log_level_initialize (void) +log_level_initialize(void) { - char *log_env = getenv ("EGL_LOG_LEVEL"); + char *log_env = getenv("EGL_LOG_LEVEL"); if (log_env == NULL) { ReportingLevel = FALLBACK_LOG_LEVEL; } - else if (strcasecmp (log_env, "fatal") == 0) { + else if (strcasecmp(log_env, "fatal") == 0) { ReportingLevel = _EGL_FATAL; } - else if (strcasecmp (log_env, "warning") == 0) { + else if (strcasecmp(log_env, "warning") == 0) { ReportingLevel = _EGL_WARNING; } - else if (strcasecmp (log_env, "info") == 0) { + else if (strcasecmp(log_env, "info") == 0) { ReportingLevel = _EGL_INFO; } - else if (strcasecmp (log_env, "debug") == 0) { + else if (strcasecmp(log_env, "debug") == 0) { ReportingLevel = _EGL_DEBUG; } else { - fprintf (stderr, "Unrecognized EGL_LOG_LEVEL environment variable value. " - "Expected one of \"fatal\", \"warning\", \"info\", \"debug\". " - "Got \"%s\". Falling back to \"%s\".\n", - log_env, FALLBACK_LOG_LEVEL_STR); + fprintf(stderr, "Unrecognized EGL_LOG_LEVEL environment variable value. " + "Expected one of \"fatal\", \"warning\", \"info\", \"debug\". " + "Got \"%s\". Falling back to \"%s\".\n", + log_env, FALLBACK_LOG_LEVEL_STR); ReportingLevel = FALLBACK_LOG_LEVEL; } } @@ -59,7 +61,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) static int log_level_initialized = 0; if (!log_level_initialized) { - log_level_initialize (); + log_level_initialize(); log_level_initialized = 1; } @@ -85,7 +87,7 @@ _eglLog(EGLint level, const char *fmtStr, ...) vsnprintf(msg, MAXSTRING, fmtStr, args); va_end(args); - fprintf(stderr, "EGL %s: %s\n", levelStr, msg); + fprintf(stderr, "libEGL %s: %s\n", levelStr, msg); if (level == _EGL_FATAL) { exit(1); /* or abort()? */ -- cgit v1.2.3 From 47ddcd2a7144ea456fcd52b9470e4e41b878af48 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 6 Jun 2008 15:10:42 -0600 Subject: egl: make _eglChooseDRMDriver() non-static --- src/egl/main/egldriver.c | 4 ++-- src/egl/main/egldriver.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 80fa49b7ab5..92c529911c1 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -39,7 +39,7 @@ static const char *SysFS = "/sys/class"; /** * Given a card number, use sysfs to determine the DRI driver name. */ -static const char * +const char * _eglChooseDRMDriver(int card) { #if 0 @@ -214,7 +214,7 @@ _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy) void *handle = drv->LibHandle; EGLBoolean b; - _eglLog(_EGL_INFO, "Closing driver"); + _eglLog(_EGL_DEBUG, "Closing %s", drv->Name); /* * XXX check for currently bound context/surfaces and delete them? diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index af028eaf22f..1eae6f8034c 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -45,6 +45,9 @@ struct _egl_driver extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args); +extern const char * +_eglChooseDRMDriver(int card); + extern const char * _eglChooseDriver(_EGLDisplay *dpy); -- cgit v1.2.3 From 50d59c8be1e409f0f96ba5c59d74eb5ff8c35b6a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 9 Jun 2008 11:47:18 -0600 Subject: egl: choose between DRI and softpipe drivers --- src/egl/main/eglx.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglx.c b/src/egl/main/eglx.c index 085da33e7dc..63ad5a7074f 100644 --- a/src/egl/main/eglx.c +++ b/src/egl/main/eglx.c @@ -1,3 +1,30 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + /** * X-specific EGL code. @@ -8,22 +35,34 @@ #include #include +#include #include + +#include "egldriver.h" +#include "egllog.h" +#include "eglstring.h" #include "eglx.h" -static const char *DefaultXDriver = "softpipe_egl"; +static const char *DefaultDRIDriver = "egl_xdri"; +static const char *DefaultSoftDriver = "softpipe_egl"; /** * Given an X Display ptr (at dpy->Xdpy) try to determine the appropriate * device driver. Return its name. + * + * This boils down to whether to use the egl_xdri.so driver which will + * load a DRI driver or the egl_softpipe.so driver that'll do software + * rendering on Xlib. */ const char * _xeglChooseDriver(_EGLDisplay *dpy) { #ifdef _EGL_PLATFORM_X _XPrivDisplay xdpy; + int screen; + const char *driverName; assert(dpy); @@ -38,9 +77,22 @@ _xeglChooseDriver(_EGLDisplay *dpy) assert(dpy->Xdpy); - printf("%s\n", xdpy->display_name); + screen = DefaultScreen(dpy->Xdpy); + + /* See if we can choose a DRI/DRM driver */ + driverName = _eglChooseDRMDriver(screen); + if (driverName) { + /* DRI is available */ + free((void *) driverName); + driverName = _eglstrdup(DefaultDRIDriver); + } + else { + driverName = _eglstrdup(DefaultSoftDriver); + } + + _eglLog(_EGL_DEBUG, "_xeglChooseDriver: %s", driverName); - return DefaultXDriver; /* XXX temporary */ + return driverName; #else return NULL; #endif -- cgit v1.2.3 From 6420a62cf0f5812708a4c649691ba62c573eaced Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 9 Jun 2008 12:26:20 -0600 Subject: egl: s/softpipe_egl.so/egl_softpipe.so/ --- src/egl/main/eglx.c | 2 +- src/gallium/winsys/egl_xlib/Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglx.c b/src/egl/main/eglx.c index 63ad5a7074f..1bba149f702 100644 --- a/src/egl/main/eglx.c +++ b/src/egl/main/eglx.c @@ -45,7 +45,7 @@ static const char *DefaultDRIDriver = "egl_xdri"; -static const char *DefaultSoftDriver = "softpipe_egl"; +static const char *DefaultSoftDriver = "egl_softpipe"; /** diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 46666650b06..d5595b819a9 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -1,13 +1,13 @@ # src/gallium/winsys/egl_xlib/Makefile -# Build softpipe/xlib/EGL driver library/object: "softpipe_egl.so" +# Build softpipe/xlib/EGL driver library/object: "egl_softpipe.so" TOP = ../../../.. include $(TOP)/configs/current -DRIVER_NAME = softpipe_egl.so +DRIVER_NAME = egl_softpipe.so INCLUDE_DIRS = \ @@ -49,7 +49,7 @@ default: depend library Makefile library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) -# Make the softpipe_egl.so library +# Make the egl_softpipe.so library $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS) $(TOP)/bin/mklib -o $(DRIVER_NAME) \ -linker "$(CC)" \ -- cgit v1.2.3 From b9c5b0bc4b0abbe12770824371c173ad1e8d1046 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Jun 2008 16:14:09 -0600 Subject: egl: some prototype API detection code --- src/egl/main/eglmisc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/egl/main') diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index b5bdc3ea4bf..e79223657dc 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -54,6 +54,58 @@ _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 6b389b5c2facc431af0ffb21e3a9bcd532765367 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Jun 2008 11:37:46 -0600 Subject: egl: some prototype Windows code (eq for dlopen,dlsym) --- src/egl/main/egldriver.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 92c529911c1..5ecfb9eb306 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include "eglconfig.h" @@ -22,6 +21,7 @@ #include "eglsurface.h" #if defined(_EGL_PLATFORM_X) +#include #include "eglx.h" #elif defined(_EGL_PLATFORM_WINDOWS) /* XXX to do */ @@ -165,39 +165,70 @@ _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 char driverFilename[1000]; assert(driverName); +#if defined(_EGL_PLATFORM_WINDOWS) + /* 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_NOW); +#endif + if (!lib) { _eglLog(_EGL_WARNING, "Could not open %s (%s)", driverFilename, dlerror()); return NULL; } +#if defined(_EGL_PLATFORM_WINDOWS) + mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); +#elif defined(_EGL_PLATFORM_X) mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); +#endif + 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 return NULL; } drv = mainFunc(dpy, args); if (!drv) { +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(lib); +#elif defined(_EGL_PLATFORM_X) dlclose(lib); +#endif return NULL; } + /* with a recurvise open you want the inner most handle */ - if (!drv->LibHandle) + if (!drv->LibHandle) { drv->LibHandle = lib; - else + } + else { +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(lib); +#elif defined(_EGL_PLATFORM_X) dlclose(lib); +#endif + } /* update the global notion of supported APIs */ _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; @@ -221,7 +252,13 @@ _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 + return b; } -- cgit v1.2.3 From f61923441f94439b9ca3c4304ce74fe4e13a14b4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Jun 2008 19:35:52 -0600 Subject: egl: some basic docs for libEGL --- src/egl/main/README.txt | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/egl/main/README.txt (limited to 'src/egl/main') diff --git a/src/egl/main/README.txt b/src/egl/main/README.txt new file mode 100644 index 00000000000..b3d253dd133 --- /dev/null +++ b/src/egl/main/README.txt @@ -0,0 +1,71 @@ + + +Notes about the EGL library: + + +The EGL code here basically consists of two things: + +1. An EGL API dispatcher. This directly routes all the eglFooBar() API + calls into driver-specific functions. + +2. Fallbacks for EGL API functions. A driver _could_ implement all the + EGL API calls from scratch. But in many cases, the fallbacks provided + in libEGL (such as eglChooseConfig()) will do the job. + + + +Bootstrapping: + +When the apps calls eglOpenDisplay() a device driver is selected and loaded +(look for dlsym() or LoadLibrary() in egldriver.c). + +The driver's _eglMain() function is then called. This driver function +allocates, initializes and returns a new _EGLDriver object (usually a +subclass of that type). + +As part of initialization, the dispatch table in _EGLDriver->API must be +populated with all the EGL entrypoints. Typically, _eglInitDriverFallbacks() +can be used to plug in default/fallback functions. Some functions like +driver->API.Initialize and driver->API.Terminate _must_ be implemented +with driver-specific code (no default/fallback function is possible). + + +A bit later, the app will call eglInitialize(). This will get routed +to the driver->API.Initialize() function. Any additional driver +initialization that wasn't done in _eglMain() should be done at this +point. Typically, this will involve setting up visual configs, etc. + + + +Special Functions: + +Certain EGL functions _must_ be implemented by the driver. This includes: + +eglCreateContext +eglCreateWindowSurface +eglCreatePixmapSurface +eglCreatePBufferSurface +eglMakeCurrent +eglSwapBuffers + +Most of the EGLConfig-related functions can be implemented with the +defaults/fallbacks. Same thing for the eglGet/Query functions. + + + + +Teardown: + +When eglTerminate() is called, the driver->API.Terminate() function is +called. The driver should clean up after itself. eglTerminate() will +then close/unload the driver (shared library). + + + + +Subclassing: + +The internal libEGL data structures such as _EGLDisplay, _EGLContext, +_EGLSurface, etc should be considered base classes from which drivers +will derive subclasses. + -- cgit v1.2.3 From a668b43568b99170e354c7e7cbb393e633765ec4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 18 Jun 2008 09:21:28 -0600 Subject: egl: use RTLD_LAZY --- src/egl/main/egldriver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 5ecfb9eb306..4a611b9fc97 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -183,7 +183,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) /* XXX also prepend a directory path??? */ sprintf(driverFilename, "%s.so", driverName); _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); - lib = dlopen(driverFilename, RTLD_NOW); + lib = dlopen(driverFilename, RTLD_LAZY); #endif if (!lib) { -- 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') diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index bf1addf241b..15847ef2da6 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 4a611b9fc97..edf85abe012 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 1eae6f8034c..7827ca3ae3d 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 e79223657dc..b5bdc3ea4bf 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') diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 15847ef2da6..461679db090 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 From cae4444fa179c9ed556f1d1d207967b4e72736e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 10:19:51 -0600 Subject: egl: default API should be ES --- src/egl/main/eglglobals.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 9a077edbd7c..5da59af91da 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -49,7 +49,7 @@ _eglNewThreadInfo(void) if (t) { t->CurrentContext = EGL_NO_CONTEXT; t->LastError = EGL_SUCCESS; - t->CurrentAPI = EGL_NONE; + t->CurrentAPI = EGL_OPENGL_ES_API; /* default, per EGL spec */ } return t; } -- cgit v1.2.3 From 8a75d109531755358708de5381eb912b7e2bf69c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 10:20:06 -0600 Subject: egl: added null ptr check --- src/egl/main/eglconfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 794a783b9e2..3ef0564a548 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -340,8 +340,10 @@ _eglChooseConfig(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list, qsort(configList, count, sizeof(_EGLConfig *), _eglCompareConfigs); /* copy config handles to output array */ - for (i = 0; i < count; i++) { - configs[i] = configList[i]->Handle; + if (configs) { + for (i = 0; i < count; i++) { + configs[i] = configList[i]->Handle; + } } free(configList); -- cgit v1.2.3 From fbd6e86b8f3c9bdeae7581d8d852b4df66e4b42c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 10:20:25 -0600 Subject: egl: implment EGL_LARGEST_PBUFFER query --- src/egl/main/egldriver.h | 2 ++ src/egl/main/eglsurface.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 7827ca3ae3d..4066c6ec1df 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -39,6 +39,8 @@ struct _egl_driver _EGLAPI API; /**< EGL API dispatch table */ _EGLExtensions Extensions; + + int LargestPbuffer; }; diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 796d62f2b94..3777049ca6d 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -8,6 +8,7 @@ #include #include "eglcontext.h" #include "eglconfig.h" +#include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" #include "egllog.h" @@ -319,7 +320,9 @@ _eglQuerySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, case EGL_CONFIG_ID: *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); return EGL_TRUE; - /*XXX case EGL_LARGEST_PBUFFER:*/ + case EGL_LARGEST_PBUFFER: + *value = drv->LargestPbuffer; + return EGL_TRUE; case EGL_SURFACE_TYPE: *value = surface->Type; return EGL_TRUE; -- cgit v1.2.3 From 677151ad71d7f0792fb79597e972e2cad2cfc7d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 14:28:59 -0600 Subject: egl: added null ptr check --- src/egl/main/egldisplay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 540efd4fee5..47a2323eafb 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -68,8 +68,9 @@ _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy) { EGLuint key = (EGLuint) dpy; - _EGLDisplay *d = (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key); - return d; + if (!_eglGlobal.Displays) + return NULL; + return (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key); } -- cgit v1.2.3 From 0d947674305a349662b3ab57733c54f9f4c1a8b3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Jun 2008 13:55:38 +0900 Subject: egl: Use standard integer types. --- src/egl/main/eglconfigutil.c | 18 +++++++++--------- src/egl/main/eglconfigutil.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index b6585619a53..db2ff1bfe8a 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -118,13 +118,13 @@ _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) EGLBoolean _eglFillInConfigs(_EGLConfig * configs, GLenum fb_format, GLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, + const uint8_t * depth_bits, const uint8_t * stencil_bits, unsigned num_depth_stencil_bits, const GLenum * db_modes, unsigned num_db_modes, int visType) { #if 0 - static const u_int8_t bits_table[3][4] = { + static const uint8_t bits_table[3][4] = { /* R G B A */ { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ @@ -135,7 +135,7 @@ _eglFillInConfigs(_EGLConfig * configs, * Given the four supported fb_type values, this results in valid array * indices of 3, 4, 5, and 7. */ - static const u_int32_t masks_table_rgb[8][4] = { + static const uint32_t masks_table_rgb[8][4] = { {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, @@ -146,7 +146,7 @@ _eglFillInConfigs(_EGLConfig * configs, {0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000} /* 8_8_8_8_REV */ }; - static const u_int32_t masks_table_rgba[8][4] = { + static const uint32_t masks_table_rgba[8][4] = { {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, @@ -157,7 +157,7 @@ _eglFillInConfigs(_EGLConfig * configs, {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */ }; - static const u_int32_t masks_table_bgr[8][4] = { + static const uint32_t masks_table_bgr[8][4] = { {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, @@ -168,7 +168,7 @@ _eglFillInConfigs(_EGLConfig * configs, {0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000}, /* 8_8_8_8_REV */ }; - static const u_int32_t masks_table_bgra[8][4] = { + static const uint32_t masks_table_bgra[8][4] = { {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000}, @@ -179,12 +179,12 @@ _eglFillInConfigs(_EGLConfig * configs, {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */ }; - static const u_int8_t bytes_per_pixel[8] = { + static const uint8_t bytes_per_pixel[8] = { 0, 0, 0, 2, 2, 4, 0, 4 }; - const u_int8_t * bits; - const u_int32_t * masks; + const uint8_t * bits; + const uint32_t * masks; const int index = fb_type & 0x07; _EGLConfig *config; unsigned i; diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h index 5db906db651..dff407231fe 100644 --- a/src/egl/main/eglconfigutil.h +++ b/src/egl/main/eglconfigutil.h @@ -13,7 +13,7 @@ _eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); extern EGLBoolean _eglFillInConfigs( _EGLConfig *configs, EGLenum fb_format, EGLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, + const uint8_t * depth_bits, const uint8_t * stencil_bits, unsigned num_depth_stencil_bits, const EGLenum * db_modes, unsigned num_db_modes, int visType ); -- cgit v1.2.3 From 72edcd171190f1d358abeb485582c87c104f5add Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 24 Jun 2008 14:30:38 +0200 Subject: egl: Stdint was missing from eglconfigutil.h --- src/egl/main/eglconfigutil.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h index dff407231fe..7fe875a7d01 100644 --- a/src/egl/main/eglconfigutil.h +++ b/src/egl/main/eglconfigutil.h @@ -4,6 +4,7 @@ #include "eglconfig.h" #include "GL/internal/glcore.h" +#include "stdint.h" extern void -- cgit v1.2.3 From a1fb565ea7ac9f86beb4deece6a24d79e7b7860e Mon Sep 17 00:00:00 2001 From: Robert Ellison Date: Thu, 26 Jun 2008 08:55:00 -0600 Subject: egl: These changes allow an eglBindAPI(EGL_OPENGL_ES_API) to succeed, and to work correctly with GLES1 and GLES2. - egl_xdri.c just sets the EGL_OPENGL_ES_BIT as well as the EGL_OPENGL_BIT in ClientAPIsMask - eglconfig.c allows the renderable type to include EGL_OPENGL_ES2_BIT as well as EGL_OPENGL_ES_BIT. - egl_xlib.c sets the EGL_NATIVE_RENDERABLE attribute to EGL_FALSE for all softpipe configurations. (Otherwise, an eglChooseConfig() that looks for particular values of EGL_NATIVE_RENDERABLE will fail.) --- src/egl/drivers/xdri/egl_xdri.c | 2 +- src/egl/main/eglconfig.c | 2 +- src/gallium/winsys/egl_xlib/egl_xlib.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index df80c6a1c4e..71d4f15371d 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -828,7 +828,7 @@ _eglMain(_EGLDisplay *disp, const char *args) xdri_drv->Base.API.DestroySurface = xdri_eglDestroySurface; xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers; - xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; + xdri_drv->Base.ClientAPIsMask = EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT; xdri_drv->Base.Name = "X/DRI"; _eglLog(_EGL_DEBUG, "XDRI: main(%s)", args); diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 3ef0564a548..b6846d49283 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -147,7 +147,7 @@ _eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list) } else if (attr == EGL_RENDERABLE_TYPE) { EGLint renType = attrib_list[++i]; - if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT)) { + if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT)) { _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); return EGL_FALSE; } diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c index eeb15e30a92..8045c0d0cad 100644 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c @@ -172,6 +172,7 @@ create_configs(_EGLDriver *drv, EGLDisplay dpy) SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, sbits); SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_ID, visid); SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, vistype); + SET_CONFIG_ATTRIB(config, EGL_NATIVE_RENDERABLE, EGL_FALSE); _eglAddConfig(disp, config); } -- cgit v1.2.3 From 8f91a83669b8626678eb38fbbdd304c72243b6fe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 28 Jun 2008 16:03:28 -0600 Subject: egl: fix default value of EGL_SURFACE_TYPE, added some sanity check assertions --- src/egl/main/eglconfig.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index b6846d49283..b19988f49a9 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -43,9 +43,7 @@ _eglInitConfig(_EGLConfig *config, EGLint id) _eglSetConfigAttrib(config, EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE); _eglSetConfigAttrib(config, EGL_MIN_SWAP_INTERVAL, EGL_DONT_CARE); _eglSetConfigAttrib(config, EGL_MAX_SWAP_INTERVAL, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, - EGL_SCREEN_BIT_MESA | EGL_PBUFFER_BIT | - EGL_PIXMAP_BIT | EGL_WINDOW_BIT); + _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_WINDOW_BIT); _eglSetConfigAttrib(config, EGL_TRANSPARENT_TYPE, EGL_NONE); _eglSetConfigAttrib(config, EGL_TRANSPARENT_RED_VALUE, EGL_DONT_CARE); _eglSetConfigAttrib(config, EGL_TRANSPARENT_GREEN_VALUE, EGL_DONT_CARE); @@ -96,6 +94,14 @@ _eglAddConfig(_EGLDisplay *display, _EGLConfig *config) _EGLConfig **newConfigs; EGLint n; + /* do some sanity checks on the config's attribs */ + assert(GET_CONFIG_ATTRIB(config, EGL_CONFIG_ID) > 0); + assert(GET_CONFIG_ATTRIB(config, EGL_RENDERABLE_TYPE) != 0x0); + assert(GET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE) != 0x0); + assert(GET_CONFIG_ATTRIB(config, EGL_RED_SIZE) > 0); + assert(GET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE) > 0); + assert(GET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE) > 0); + n = display->NumConfigs; /* realloc array of ptrs */ -- cgit v1.2.3 From de71e4741d8b4e3719e702431912374f1cb90034 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 7 Jul 2008 14:34:30 -0600 Subject: egl: bump up MAX_ATTRIBS, added assertion --- src/egl/main/eglconfig.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index d12f66245c0..db1c4c10e08 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -6,7 +6,7 @@ #include -#define MAX_ATTRIBS 100 +#define MAX_ATTRIBS 128 #define FIRST_ATTRIB EGL_BUFFER_SIZE @@ -17,7 +17,11 @@ struct _egl_config }; -#define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB] = VAL) +#define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) \ + assert((ATTR) - FIRST_ATTRIB < MAX_ATTRIBS); \ + ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB] = VAL) + + #define GET_CONFIG_ATTRIB(CONF, ATTR) ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB]) -- cgit v1.2.3 From 655ca5afad5f5d79f0ad60b5aa7fcafd35e97b62 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Mon, 4 Aug 2008 16:30:04 -0600 Subject: egl: fix _eglGlobal initialization for Windows --- src/egl/main/eglglobals.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 5da59af91da..b770e55dbdf 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -2,9 +2,10 @@ #include #include "eglglobals.h" - -struct _egl_global _eglGlobal = { .Initialized = EGL_FALSE }; - +struct _egl_global _eglGlobal = +{ + EGL_FALSE +}; /** * Init the fields in the _eglGlobal struct -- cgit v1.2.3 From 2eb4f86785ac7e4002904384b7ad0517e0bd6999 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 5 Aug 2008 08:13:50 -0600 Subject: egl: don't include stdint.h on Windows --- src/egl/main/eglconfigutil.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/egl/main') diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h index 7fe875a7d01..c477b94737d 100644 --- a/src/egl/main/eglconfigutil.h +++ b/src/egl/main/eglconfigutil.h @@ -4,7 +4,9 @@ #include "eglconfig.h" #include "GL/internal/glcore.h" +#if (!defined(WIN32) && !defined(_WIN32_WCE)) #include "stdint.h" +#endif extern void -- cgit v1.2.3 From ab0d13dd60c707f2c414fa9fe8e489a9e24a8aee Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 5 Aug 2008 19:22:09 -0600 Subject: egl: changes for Windows --- src/egl/main/egldriver.c | 65 +++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index edf85abe012..f5edb58f433 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -24,37 +24,45 @@ #include #include "eglx.h" #elif defined(_EGL_PLATFORM_WINDOWS) -/* XXX to do */ -#elif defined(_EGL_PLATFORM_WINCE) -/* XXX to do */ +/* Use static linking on Windows for now */ +#define WINDOWS_STATIC_LINK #endif - -static const char *DefaultDriverName = ":0"; -static const char *SysFS = "/sys/class"; - - - /** * Wrappers for dlopen/dlclose() */ #if defined(_EGL_PLATFORM_WINDOWS) - +#ifdef WINDOWS_STATIC_LINK + static const char *DefaultDriverName = "Windows EGL Static Library"; +#else + /* XXX Need to decide how to do dynamic name lookup on Windows */ + static const char *DefaultDriverName = "TBD"; +#endif + static const char *SysFS = NULL; typedef HMODULE lib_handle; static HMODULE open_library(const char *filename) { +#ifdef WINDOWS_STATIC_LINK + return 0; +#else return LoadLibrary(filename); +#endif } static void close_library(HMODULE lib) { +#ifdef WINDOWS_STATIC_LINK +#else FreeLibrary(lib); +#endif } - + #elif defined(_EGL_PLATFORM_X) + static const char *DefaultDriverName = ":0"; + static const char *SysFS = "/sys/class"; typedef void * lib_handle; @@ -72,8 +80,6 @@ static const char *SysFS = "/sys/class"; #endif - - /** * Given a card number, use sysfs to determine the DRI driver name. */ @@ -108,7 +114,6 @@ _eglChooseDRMDriver(int card) #endif } - /** * XXX this function is totally subject change!!! * @@ -130,7 +135,13 @@ _eglChooseDRMDriver(int card) const char * _eglChooseDriver(_EGLDisplay *dpy) { + /* Under Windows, the NativeDisplay is an HDC handle, therefore */ + /* it can't be interpreted as a string or a pointer. */ +#if defined(_EGL_PLATFORM_WINDOWS) + const char *displayString = NULL; +#else const char *displayString = (const char *) dpy->NativeDisplay; +#endif const char *driverName = NULL; (void) DefaultDriverName; @@ -173,15 +184,11 @@ _eglChooseDriver(_EGLDisplay *dpy) } } } - else { + else + { /* NativeDisplay is not a string! */ #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 */ #else driverName = DefaultDriverName; #endif @@ -209,25 +216,31 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) assert(driverName); #if defined(_EGL_PLATFORM_WINDOWS) +/* Use static linking on Windows for now */ +#ifdef WINDOWS_STATIC_LINK + mainFunc = (_EGLMain_t)_eglMain; +#else /* XXX untested */ sprintf(driverFilename, "%s.dll", driverName); _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); + lib = open_library(driverFilename); + if (!lib) { + _eglLog(_EGL_WARNING, "Could not open %s", + driverFilename); + return NULL; + } + mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); +#endif #elif defined(_EGL_PLATFORM_X) /* XXX also prepend a directory path??? */ sprintf(driverFilename, "%s.so", driverName); _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); -#endif lib = open_library(driverFilename); - if (!lib) { _eglLog(_EGL_WARNING, "Could not open %s (%s)", driverFilename, dlerror()); return NULL; } - -#if defined(_EGL_PLATFORM_WINDOWS) - mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); -#elif defined(_EGL_PLATFORM_X) mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); #endif -- 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') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 49d1f3d0eb4..9df938e1887 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 From bd953fdd549310638b6960f358b31a40c05ca680 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Wed, 6 Aug 2008 16:37:49 -0600 Subject: egl: fixes for Windows --- src/egl/main/egldriver.c | 5 ++++- src/egl/main/egllog.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/egl/main') diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index f5edb58f433..43b1f519034 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -146,10 +146,12 @@ _eglChooseDriver(_EGLDisplay *dpy) (void) DefaultDriverName; +#if defined(_EGL_PLATFORM_X) /* First, if the EGL_DRIVER env var is set, use that */ driverName = getenv("EGL_DRIVER"); if (driverName) return _eglstrdup(driverName); +#endif #if 0 if (!displayString) { @@ -217,7 +219,8 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) #if defined(_EGL_PLATFORM_WINDOWS) /* Use static linking on Windows for now */ -#ifdef WINDOWS_STATIC_LINK +#ifdef WINDOWS_STATIC_LINK + lib = 0; mainFunc = (_EGLMain_t)_eglMain; #else /* XXX untested */ diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index 23eb523eebe..1d7a0a388c6 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -21,7 +21,11 @@ static EGLint ReportingLevel = -1; static void log_level_initialize(void) { +#if defined(_EGL_PLATFORM_X) char *log_env = getenv("EGL_LOG_LEVEL"); +#else + char *log_env = NULL; +#endif if (log_env == NULL) { ReportingLevel = FALLBACK_LOG_LEVEL; -- cgit v1.2.3 From b36f90657370296b45c27d33d60c89fa31dc1d76 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 1 Sep 2008 13:08:12 -0600 Subject: egl: additional error checking in _eglBind/ReleaseTexImage() --- src/egl/main/eglsurface.c | 75 +++++++++++++++++++++++++++++++++++++++-------- src/egl/main/eglsurface.h | 1 + 2 files changed, 64 insertions(+), 12 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 3777049ca6d..6905acac50b 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -61,6 +61,12 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, return EGL_FALSE; } + if ((GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) & type) == 0) { + /* The config can't be used to create a surface of this type */ + _eglError(EGL_BAD_CONFIG, func); + return EGL_FALSE; + } + /* * Parse attribute list. Different kinds of surfaces support different * attributes. @@ -277,12 +283,7 @@ _eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) /* Basically just do error checking here. Drivers have to do the * actual buffer swap. */ - _EGLContext *context = _eglGetCurrentContext(); _EGLSurface *surface = _eglLookupSurface(draw); - if (context && context->DrawSurface != surface) { - _eglError(EGL_BAD_SURFACE, "eglSwapBuffers"); - return EGL_FALSE; - } if (surface == NULL) { _eglError(EGL_BAD_SURFACE, "eglSwapBuffers"); return EGL_FALSE; @@ -484,7 +485,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) * Default fallback routine - drivers might override this. */ EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attribute, EGLint value) +_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint attribute, EGLint value) { _EGLSurface *surface = _eglLookupSurface(surf); @@ -506,18 +508,67 @@ _eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attri EGLBoolean -_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) +_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint buffer) { - /* XXX unfinished */ - return EGL_FALSE; + /* Just do basic error checking and return success/fail. + * Drivers must implement the real stuff. + */ + _EGLSurface *surface = _eglLookupSurface(surf); + + if (!surface || surface->Type != EGL_PBUFFER_BIT) { + _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + return EGL_FALSE; + } + + if (surface->TextureFormat == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + + if (buffer != EGL_BACK_BUFFER) { + _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + return EGL_FALSE; + } + + surface->BoundToTexture = EGL_TRUE; + + return EGL_TRUE; } EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) +_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint buffer) { - /* XXX unfinished */ - return EGL_FALSE; + /* Just do basic error checking and return success/fail. + * Drivers must implement the real stuff. + */ + _EGLSurface *surface = _eglLookupSurface(surf); + + if (!surface || surface->Type != EGL_PBUFFER_BIT) { + _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + return EGL_FALSE; + } + + if (surface->TextureFormat == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + + if (buffer != EGL_BACK_BUFFER) { + _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + return EGL_FALSE; + } + + if (!surface->BoundToTexture) { + _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + return EGL_FALSE; + } + + surface->BoundToTexture = EGL_FALSE; + + return EGL_TRUE; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index df1e70122e2..50f965b5cb7 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -16,6 +16,7 @@ struct _egl_surface /* May need reference counting here */ EGLBoolean IsBound; EGLBoolean DeletePending; + EGLBoolean BoundToTexture; EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ EGLint Width, Height; -- cgit v1.2.3 From cc6bdf49ca19c08d0c7134d2cd881b9c166cdc8a Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 26 Sep 2008 12:18:59 +0100 Subject: egl: switch to egl_glx.so as the default EGL driver for X. --- src/egl/main/eglx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglx.c b/src/egl/main/eglx.c index 1bba149f702..50acc3a24f9 100644 --- a/src/egl/main/eglx.c +++ b/src/egl/main/eglx.c @@ -44,7 +44,7 @@ #include "eglx.h" -static const char *DefaultDRIDriver = "egl_xdri"; +static const char *DefaultGLXDriver = "egl_glx"; static const char *DefaultSoftDriver = "egl_softpipe"; @@ -52,7 +52,7 @@ static const char *DefaultSoftDriver = "egl_softpipe"; * Given an X Display ptr (at dpy->Xdpy) try to determine the appropriate * device driver. Return its name. * - * This boils down to whether to use the egl_xdri.so driver which will + * This boils down to whether to use the egl_glx.so driver which will * load a DRI driver or the egl_softpipe.so driver that'll do software * rendering on Xlib. */ @@ -82,9 +82,8 @@ _xeglChooseDriver(_EGLDisplay *dpy) /* See if we can choose a DRI/DRM driver */ driverName = _eglChooseDRMDriver(screen); if (driverName) { - /* DRI is available */ free((void *) driverName); - driverName = _eglstrdup(DefaultDRIDriver); + driverName = _eglstrdup(DefaultGLXDriver); } else { driverName = _eglstrdup(DefaultSoftDriver); -- cgit v1.2.3