diff options
author | Gary King <gking@nvidia.com> | 2010-02-08 21:47:23 -0800 |
---|---|---|
committer | Brint E. Kriebel <github@bekit.net> | 2010-11-14 22:24:07 -0700 |
commit | d22010744720577f147da001bf257dcddaed00da (patch) | |
tree | 341fc3d5a51f28e5bcc79369a151c79e35dae68a /opengl | |
parent | 53369231ca8e5d44a58d03617e82436c2c45538c (diff) | |
download | frameworks_base-d22010744720577f147da001bf257dcddaed00da.zip frameworks_base-d22010744720577f147da001bf257dcddaed00da.tar.gz frameworks_base-d22010744720577f147da001bf257dcddaed00da.tar.bz2 |
[egl] add support for vendor-specific GL extensions
on implementations which have a single EGL backend, it is straight-
forward to query the EGL implementation for the supported GL extensions
the mechanism added in this commit will only work on implementations
which have a single EGL backend; on implementations which have
multiple backends, this feature should be disabled at compile-time
for EGLImage extensions, call into a wrapper layer implementation to
translate the meta-EGL object into the vendor object before calling into
the vendor's EGLImage implementation
Change-Id: I4c930a506a743b6ea88c4b2e769a9ea5ebf8e0d0
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index de740a3..eeb587a 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -42,6 +42,14 @@ #include "egl_impl.h" #include "Loader.h" +// Enable this define to allow querying vendor-specific GL extensions. This +// currently will only work correctly for implementations which have a single +// EGL backend; multiple EGL backends are not supported. +// There's also an extra subtlety with the EGLimage entry points in GL, which +// can't work properly if they're called directly (they have to go through +// a wrapper). +#define ENABLE_VENDOR_EXTENSIONS + #define MAKE_CONFIG(_impl, _index) ((EGLConfig)(((_impl)<<24) | (_index))) #define setError(_e, _r) setErrorEtc(__FUNCTION__, __LINE__, _e, _r) @@ -58,6 +66,11 @@ static char const * const gExtensionString = "EGL_KHR_image " "EGL_KHR_image_base " "EGL_KHR_image_pixmap " +#ifdef ENABLE_VENDOR_EXTENSIONS + "EGL_KHR_gl_texture_2D_image " + "EGL_KHR_gl_texture_cubemap_image " + "EGL_KHR_gl_renderbuffer_image " +#endif "EGL_ANDROID_image_native_buffer " "EGL_ANDROID_swap_rectangle " "EGL_ANDROID_get_render_buffer " @@ -1315,6 +1328,31 @@ EGLint eglGetError(void) return result; } +#ifdef ENABLE_VENDOR_EXTENSIONS +// Note: Similar implementations of this function also exist in gl2.cpp and +// gl.cpp, and are used by applications that call the exported entry points +// directly. +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); + +static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_impl = NULL; +static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_impl = NULL; + +static void glEGLImageTargetTexture2DOES_wrapper(GLenum target, GLeglImageOES image) +{ + GLeglImageOES implImage = + (GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image); + glEGLImageTargetTexture2DOES_impl(target, implImage); +} + +static void glEGLImageTargetRenderbufferStorageOES_wrapper(GLenum target, GLeglImageOES image) +{ + GLeglImageOES implImage = + (GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image); + glEGLImageTargetRenderbufferStorageOES_impl(target, implImage); +} +#endif + __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) { // eglGetProcAddress() could be the very first function called @@ -1330,6 +1368,30 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap)); if (addr) return addr; +#ifdef ENABLE_VENDOR_EXTENSIONS + addr = 0; + for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) { + egl_connection_t* const cnx = &gEGLImpl[i]; + if (cnx->dso) { + if (cnx->egl.eglGetProcAddress) { + addr = cnx->egl.eglGetProcAddress(procname); + if (addr) { + if (!strcmp(procname, "glEGLImageTargetTexture2DOES")) { + glEGLImageTargetTexture2DOES_impl = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)addr; + return (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES_wrapper; + } + if (!strcmp(procname, "glEGLImageTargetRenderbufferStorageOES")) { + glEGLImageTargetRenderbufferStorageOES_impl = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)addr; + return (__eglMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES_wrapper; + } + + return addr; + } + } + } + } +#endif + return NULL; // TODO: finish implementation below addr = findProcAddress(procname, gGLExtentionMap, NELEM(gGLExtentionMap)); |