diff options
author | Mathias Agopian <mathias@google.com> | 2012-01-30 15:23:47 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-01-30 15:23:47 -0800 |
commit | 818b4236586d0dda696f363f1065c8f8abd64862 (patch) | |
tree | 0f5f630929f8606a9419e99a32449de65becf685 /opengl | |
parent | a585e8dbcf33a9cfcca725b994a22e6d78d427f9 (diff) | |
parent | ea261a2e13c23f641d6caa38ce8d9f5ad94504da (diff) | |
download | frameworks_base-818b4236586d0dda696f363f1065c8f8abd64862.zip frameworks_base-818b4236586d0dda696f363f1065c8f8abd64862.tar.gz frameworks_base-818b4236586d0dda696f363f1065c8f8abd64862.tar.bz2 |
Merge "add support for GL_EXT_debug_marker"
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/libs/EGL/Loader.cpp | 13 | ||||
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 23 | ||||
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 9 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 36 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_object.h | 12 | ||||
-rw-r--r-- | opengl/libs/EGL/egldefs.h | 1 | ||||
-rw-r--r-- | opengl/libs/GLES2/gl2.cpp | 14 | ||||
-rw-r--r-- | opengl/libs/GLES2/gl2_api.in | 2 | ||||
-rw-r--r-- | opengl/libs/GLES_CM/gl.cpp | 14 | ||||
-rw-r--r-- | opengl/libs/GLES_CM/gl_api.in | 2 | ||||
-rw-r--r-- | opengl/libs/egl_impl.h | 1 | ||||
-rwxr-xr-x | opengl/libs/tools/glapigen | 3 |
12 files changed, 118 insertions, 12 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index 2fc6125..06be2ef 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -253,6 +253,19 @@ void Loader::init_api(void* dso, if (f == NULL) { //ALOGD("%s", name); f = (__eglMustCastToProperFunctionPointerType)gl_unimplemented; + + /* + * GL_EXT_debug_label is special, we always report it as + * supported, it's handled by GLES_trace. If GLES_trace is not + * enabled, then these are no-ops. + */ + if (!strcmp(name, "glInsertEventMarkerEXT")) { + f = (__eglMustCastToProperFunctionPointerType)gl_noop; + } else if (!strcmp(name, "glPushGroupMarkerEXT")) { + f = (__eglMustCastToProperFunctionPointerType)gl_noop; + } else if (!strcmp(name, "glPopGroupMarkerEXT")) { + f = (__eglMustCastToProperFunctionPointerType)gl_noop; + } } *curr++ = f; api++; diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index e053589..83933e5 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -233,6 +233,26 @@ EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image) // ---------------------------------------------------------------------------- +const GLubyte * egl_get_string_for_current_context(GLenum name) { + // NOTE: returning NULL here will fall-back to the default + // implementation. + + EGLContext context = egl_tls_t::getContext(); + if (context == EGL_NO_CONTEXT) + return NULL; + + egl_context_t const * const c = get_context(context); + if (c == NULL) // this should never happen, by construction + return NULL; + + if (name != GL_EXTENSIONS) + return NULL; + + return (const GLubyte *)c->gl_extensions.string(); +} + +// ---------------------------------------------------------------------------- + // this mutex protects: // d->disp[] // egl_init_drivers_locked() @@ -290,6 +310,9 @@ void gl_unimplemented() { ALOGE("called unimplemented OpenGL ES API"); } +void gl_noop() { +} + // ---------------------------------------------------------------------------- #if USE_FAST_TLS_KEY diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 8b37da5..9379c53 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -578,8 +578,7 @@ static void loseCurrent(egl_context_t * cur_c) SurfaceRef _cur_r(cur_r); SurfaceRef _cur_d(cur_d); - cur_c->read = NULL; - cur_c->draw = NULL; + cur_c->onLooseCurrent(); _cur_c.release(); _cur_r.release(); @@ -687,8 +686,7 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, _c.acquire(); _r.acquire(); _d.acquire(); - c->read = read; - c->draw = draw; + c->onMakeCurrent(draw, read); } else { setGLHooksThreadSpecific(&gHooksNoContext); egl_tls_t::setContext(EGL_NO_CONTEXT); @@ -924,7 +922,8 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] = cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] = #if EGL_TRACE - debugHooks->ext.extensions[slot] = gHooksTrace.ext.extensions[slot] = + debugHooks->ext.extensions[slot] = + gHooksTrace.ext.extensions[slot] = #endif cnx->egl.eglGetProcAddress(procname); } diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp index 26e8c3e..b660c53 100644 --- a/opengl/libs/EGL/egl_object.cpp +++ b/opengl/libs/EGL/egl_object.cpp @@ -62,5 +62,41 @@ bool egl_object_t::get(egl_display_t const* display, egl_object_t* object) { } // ---------------------------------------------------------------------------- + +egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config, + int impl, egl_connection_t const* cnx, int version) : + egl_object_t(get_display(dpy)), dpy(dpy), context(context), + config(config), read(0), draw(0), impl(impl), cnx(cnx), + version(version) +{ +} + +void egl_context_t::onLooseCurrent() { + read = NULL; + draw = NULL; +} + +void egl_context_t::onMakeCurrent(EGLSurface draw, EGLSurface read) { + this->read = read; + this->draw = draw; + + /* + * Here we cache the GL_EXTENSIONS string for this context and we + * add the extensions always handled by the wrapper + */ + + if (gl_extensions.isEmpty()) { + // call the implementation's glGetString(GL_EXTENSIONS) + const char* exts = (const char *)gEGLImpl[impl].hooks[version]->gl.glGetString(GL_EXTENSIONS); + gl_extensions.setTo(exts); + if (gl_extensions.find("GL_EXT_debug_marker") < 0) { + String8 temp("GL_EXT_debug_marker "); + temp.append(gl_extensions); + gl_extensions.setTo(temp); + } + } +} + +// ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h index 7106fa5..abd4cbb 100644 --- a/opengl/libs/EGL/egl_object.h +++ b/opengl/libs/EGL/egl_object.h @@ -28,6 +28,7 @@ #include <GLES/glext.h> #include <utils/threads.h> +#include <utils/String8.h> #include <system/window.h> @@ -158,11 +159,11 @@ public: typedef egl_object_t::LocalRef<egl_context_t, EGLContext> Ref; egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config, - int impl, egl_connection_t const* cnx, int version) : - egl_object_t(get_display(dpy)), dpy(dpy), context(context), - config(config), read(0), draw(0), impl(impl), cnx(cnx), - version(version) { - } + int impl, egl_connection_t const* cnx, int version); + + void onLooseCurrent(); + void onMakeCurrent(EGLSurface draw, EGLSurface read); + EGLDisplay dpy; EGLContext context; EGLConfig config; @@ -171,6 +172,7 @@ public: int impl; egl_connection_t const* cnx; int version; + String8 gl_extensions; }; class egl_image_t: public egl_object_t { diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h index 107acd9..ff20957 100644 --- a/opengl/libs/EGL/egldefs.h +++ b/opengl/libs/EGL/egldefs.h @@ -58,6 +58,7 @@ extern gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS]; extern gl_hooks_t gHooksNoContext; extern pthread_key_t gGLWrapperKey; extern "C" void gl_unimplemented(); +extern "C" void gl_noop(); extern char const * const gl_names[]; extern char const * const egl_names[]; diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp index df22b96..79aa3cd 100644 --- a/opengl/libs/GLES2/gl2.cpp +++ b/opengl/libs/GLES2/gl2.cpp @@ -110,6 +110,20 @@ extern "C" { #undef CALL_GL_API #undef CALL_GL_API_RETURN +/* + * glGetString() is special because we expose some extensions in the wrapper + */ + +extern "C" const GLubyte * __glGetString(GLenum name); + +const GLubyte * glGetString(GLenum name) +{ + const GLubyte * ret = egl_get_string_for_current_context(name); + if (ret == NULL) { + ret = __glGetString(name); + } + return ret; +} /* * These GL calls are special because they need to EGL to retrieve some diff --git a/opengl/libs/GLES2/gl2_api.in b/opengl/libs/GLES2/gl2_api.in index 5164450..9a89a52 100644 --- a/opengl/libs/GLES2/gl2_api.in +++ b/opengl/libs/GLES2/gl2_api.in @@ -211,7 +211,7 @@ void API_ENTRY(glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisionty void API_ENTRY(glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) { CALL_GL_API(glGetShaderSource, shader, bufsize, length, source); } -const GLubyte* API_ENTRY(glGetString)(GLenum name) { +const GLubyte* API_ENTRY(__glGetString)(GLenum name) { CALL_GL_API_RETURN(glGetString, name); } void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) { diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp index 2d31a35..adeaa5b 100644 --- a/opengl/libs/GLES_CM/gl.cpp +++ b/opengl/libs/GLES_CM/gl.cpp @@ -165,6 +165,20 @@ extern "C" { #undef CALL_GL_API #undef CALL_GL_API_RETURN +/* + * glGetString() is special because we expose some extensions in the wrapper + */ + +extern "C" const GLubyte * __glGetString(GLenum name); + +const GLubyte * glGetString(GLenum name) +{ + const GLubyte * ret = egl_get_string_for_current_context(name); + if (ret == NULL) { + ret = __glGetString(name); + } + return ret; +} /* * These GL calls are special because they need to EGL to retrieve some diff --git a/opengl/libs/GLES_CM/gl_api.in b/opengl/libs/GLES_CM/gl_api.in index 7f20c4f..c8f6b0c 100644 --- a/opengl/libs/GLES_CM/gl_api.in +++ b/opengl/libs/GLES_CM/gl_api.in @@ -262,7 +262,7 @@ void API_ENTRY(glGetMaterialxv)(GLenum face, GLenum pname, GLfixed *params) { void API_ENTRY(glGetPointerv)(GLenum pname, GLvoid **params) { CALL_GL_API(glGetPointerv, pname, params); } -const GLubyte * API_ENTRY(glGetString)(GLenum name) { +const GLubyte * API_ENTRY(__glGetString)(GLenum name) { CALL_GL_API_RETURN(glGetString, name); } void API_ENTRY(glGetTexEnviv)(GLenum env, GLenum pname, GLint *params) { diff --git a/opengl/libs/egl_impl.h b/opengl/libs/egl_impl.h index a809316..8ff51ec 100644 --- a/opengl/libs/egl_impl.h +++ b/opengl/libs/egl_impl.h @@ -29,6 +29,7 @@ namespace android { // ---------------------------------------------------------------------------- +EGLAPI const GLubyte * egl_get_string_for_current_context(GLenum name); EGLAPI EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image); // ---------------------------------------------------------------------------- diff --git a/opengl/libs/tools/glapigen b/opengl/libs/tools/glapigen index bd8dda3..9be40cf 100755 --- a/opengl/libs/tools/glapigen +++ b/opengl/libs/tools/glapigen @@ -43,6 +43,9 @@ while (my $line = <>) { if ($name eq "glEGLImageTargetRenderbufferStorageOES") { $prefix = "__"; } + if ($name eq "glGetString") { + $prefix = "__"; + } printf("%s API_ENTRY(%s%s)(%s)", $type, $prefix, $name, $args); |