From 6f0871222f04dfeb479d37fe9753d491e3150e42 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 23 Sep 2010 16:38:38 -0700 Subject: [PATCH] better fix for [3028370] GL get error should return a valid error if no context is bound. it turns out that we cannot return INVALID_OPERATION from glGetError() because the GL spec says that it must be called in a loop until it returns GL_NO_ERROR. now, we always return 0 from GL functions called from a thread with no context bound. This means that glGetError() will return NO_ERROR in this case, which is better than returning a random value (which could trap the app in a loop). if this happens in the main thread of a process, we LOG an error message once. Change-Id: Id59620e675a890286ef62a257c02b06e0fdcaf69 --- opengl/libs/EGL/egl.cpp | 11 ++--------- opengl/libs/GLES2/gl2.cpp | 1 + opengl/libs/GLES_CM/gl.cpp | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index 043726300..2d1a2786a 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -428,19 +428,14 @@ static void(*findProcAddress(const char* name, // ---------------------------------------------------------------------------- -static void gl_no_context() { +static int gl_no_context() { tls_t* tls = getTLS(); if (tls->logCallWithNoContext == EGL_TRUE) { tls->logCallWithNoContext = EGL_FALSE; LOGE("call to OpenGL ES API with no current context " "(logged once per thread)"); } -} - -// Always return GL_INVALID_OPERATION from glGetError() when called from -// a thread without a bound context. -static GLenum gl_no_context_glGetError() { - return GL_INVALID_OPERATION; + return 0; } static void early_egl_init(void) @@ -454,8 +449,6 @@ static void early_egl_init(void) addr, sizeof(gHooksNoContext)); - gHooksNoContext.gl.glGetError = gl_no_context_glGetError; - setGlThreadSpecific(&gHooksNoContext); } diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp index 924737e69..18dd4834f 100644 --- a/opengl/libs/GLES2/gl2.cpp +++ b/opengl/libs/GLES2/gl2.cpp @@ -58,6 +58,7 @@ using namespace android; "ldr r12, [r12, %[tls]] \n" \ "cmp r12, #0 \n" \ "ldrne pc, [r12, %[api]] \n" \ + "mov r0, #0 \n" \ "bx lr \n" \ : \ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \ diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp index d71ff7620..ee29f12fa 100644 --- a/opengl/libs/GLES_CM/gl.cpp +++ b/opengl/libs/GLES_CM/gl.cpp @@ -114,6 +114,7 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, "ldr r12, [r12, %[tls]] \n" \ "cmp r12, #0 \n" \ "ldrne pc, [r12, %[api]] \n" \ + "mov r0, #0 \n" \ "bx lr \n" \ : \ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \