diff options
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/libs/Android.mk | 3 | ||||
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 32 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_display.cpp | 263 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_display.h | 4 | ||||
-rw-r--r-- | opengl/tests/EGLTest/EGL_test.cpp | 2 | ||||
-rwxr-xr-x | opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp | 3 | ||||
-rw-r--r-- | opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp | 2 | ||||
-rw-r--r-- | opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp | 6 |
8 files changed, 158 insertions, 157 deletions
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk index 2c66f3d..4da9f92 100644 --- a/opengl/libs/Android.mk +++ b/opengl/libs/Android.mk @@ -47,9 +47,6 @@ LOCAL_CFLAGS += -DEGL_TRACE=1 ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true) LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION endif -ifeq ($(TARGET_BOARD_PLATFORM), omap4) - LOCAL_CFLAGS += -DWORKAROUND_BUG_10194508=1 -endif ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) endif diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 6e77e45..ff08a6b 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -421,35 +421,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config, // of our native format. So if sRGB gamma is requested, we have to // modify the EGLconfig's format before setting the native window's // format. -#if WORKAROUND_BUG_10194508 -#warning "WORKAROUND_10194508 enabled" - EGLint format; - if (!cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_NATIVE_VISUAL_ID, - &format)) { - ALOGE("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID) failed: %#x", - eglGetError()); - format = 0; - } - if (attrib_list) { - for (const EGLint* attr = attrib_list; *attr != EGL_NONE; - attr += 2) { - if (*attr == EGL_GL_COLORSPACE_KHR && - dp->haveExtension("EGL_KHR_gl_colorspace")) { - if (ENABLE_EGL_KHR_GL_COLORSPACE) { - format = modifyFormatColorspace(format, *(attr+1)); - } else { - // Normally we'd pass through unhandled attributes to - // the driver. But in case the driver implements this - // extension but we're disabling it, we want to prevent - // it getting through -- support will be broken without - // our help. - ALOGE("sRGB window surfaces not supported"); - return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); - } - } - } - } -#else + // by default, just pick RGBA_8888 EGLint format = HAL_PIXEL_FORMAT_RGBA_8888; @@ -490,7 +462,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config, } } } -#endif + if (format != 0) { int err = native_window_set_buffers_format(window, format); if (err != 0) { diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 7784ca6..ec59235 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -57,7 +57,7 @@ static bool findExtension(const char* exts, const char* name, size_t nameLen) { egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS]; egl_display_t::egl_display_t() : - magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0) { + magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0), eglIsInitialized(false) { } egl_display_t::~egl_display_t() { @@ -120,163 +120,188 @@ EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) { EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { - Mutex::Autolock _l(lock); + { + Mutex::Autolock _rf(refLock); - if (refs > 0) { - if (major != NULL) - *major = VERSION_MAJOR; - if (minor != NULL) - *minor = VERSION_MINOR; refs++; - return EGL_TRUE; + if (refs > 1) { + if (major != NULL) + *major = VERSION_MAJOR; + if (minor != NULL) + *minor = VERSION_MINOR; + while(!eglIsInitialized) refCond.wait(refLock); + return EGL_TRUE; + } + + while(eglIsInitialized) refCond.wait(refLock); } + { + Mutex::Autolock _l(lock); + #if EGL_TRACE - // Called both at early_init time and at this time. (Early_init is pre-zygote, so - // the information from that call may be stale.) - initEglTraceLevel(); - initEglDebugLevel(); + // Called both at early_init time and at this time. (Early_init is pre-zygote, so + // the information from that call may be stale.) + initEglTraceLevel(); + initEglDebugLevel(); #endif - setGLHooksThreadSpecific(&gHooksNoContext); - - // initialize each EGL and - // build our own extension string first, based on the extension we know - // and the extension supported by our client implementation + setGLHooksThreadSpecific(&gHooksNoContext); - egl_connection_t* const cnx = &gEGLImpl; - cnx->major = -1; - cnx->minor = -1; - if (cnx->dso) { - EGLDisplay idpy = disp.dpy; - if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) { - //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p", - // idpy, cnx->major, cnx->minor, cnx); - - // display is now initialized - disp.state = egl_display_t::INITIALIZED; - - // get the query-strings for this display for each implementation - disp.queryString.vendor = cnx->egl.eglQueryString(idpy, - EGL_VENDOR); - disp.queryString.version = cnx->egl.eglQueryString(idpy, - EGL_VERSION); - disp.queryString.extensions = cnx->egl.eglQueryString(idpy, - EGL_EXTENSIONS); - disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, - EGL_CLIENT_APIS); + // initialize each EGL and + // build our own extension string first, based on the extension we know + // and the extension supported by our client implementation - } else { - ALOGW("eglInitialize(%p) failed (%s)", idpy, - egl_tls_t::egl_strerror(cnx->egl.eglGetError())); + egl_connection_t* const cnx = &gEGLImpl; + cnx->major = -1; + cnx->minor = -1; + if (cnx->dso) { + EGLDisplay idpy = disp.dpy; + if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) { + //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p", + // idpy, cnx->major, cnx->minor, cnx); + + // display is now initialized + disp.state = egl_display_t::INITIALIZED; + + // get the query-strings for this display for each implementation + disp.queryString.vendor = cnx->egl.eglQueryString(idpy, + EGL_VENDOR); + disp.queryString.version = cnx->egl.eglQueryString(idpy, + EGL_VERSION); + disp.queryString.extensions = cnx->egl.eglQueryString(idpy, + EGL_EXTENSIONS); + disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, + EGL_CLIENT_APIS); + + } else { + ALOGW("eglInitialize(%p) failed (%s)", idpy, + egl_tls_t::egl_strerror(cnx->egl.eglGetError())); + } } - } - // the query strings are per-display - mVendorString.setTo(sVendorString); - mVersionString.setTo(sVersionString); - mClientApiString.setTo(sClientApiString); - - mExtensionString.setTo(gBuiltinExtensionString); - char const* start = gExtensionString; - char const* end; - do { - // find the space separating this extension for the next one - end = strchr(start, ' '); - if (end) { - // length of the extension string - const size_t len = end - start; - if (len) { - // NOTE: we could avoid the copy if we had strnstr. - const String8 ext(start, len); - if (findExtension(disp.queryString.extensions, ext.string(), - len)) { - mExtensionString.append(start, len+1); + // the query strings are per-display + mVendorString.setTo(sVendorString); + mVersionString.setTo(sVersionString); + mClientApiString.setTo(sClientApiString); + + mExtensionString.setTo(gBuiltinExtensionString); + char const* start = gExtensionString; + char const* end; + do { + // find the space separating this extension for the next one + end = strchr(start, ' '); + if (end) { + // length of the extension string + const size_t len = end - start; + if (len) { + // NOTE: we could avoid the copy if we had strnstr. + const String8 ext(start, len); + if (findExtension(disp.queryString.extensions, ext.string(), + len)) { + mExtensionString.append(start, len+1); + } } + // process the next extension string, and skip the space. + start = end + 1; } - // process the next extension string, and skip the space. - start = end + 1; + } while (end); + + egl_cache_t::get()->initialize(this); + + char value[PROPERTY_VALUE_MAX]; + property_get("debug.egl.finish", value, "0"); + if (atoi(value)) { + finishOnSwap = true; } - } while (end); - egl_cache_t::get()->initialize(this); + property_get("debug.egl.traceGpuCompletion", value, "0"); + if (atoi(value)) { + traceGpuCompletion = true; + } - char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.finish", value, "0"); - if (atoi(value)) { - finishOnSwap = true; - } + if (major != NULL) + *major = VERSION_MAJOR; + if (minor != NULL) + *minor = VERSION_MINOR; - property_get("debug.egl.traceGpuCompletion", value, "0"); - if (atoi(value)) { - traceGpuCompletion = true; + mHibernation.setDisplayValid(true); } - refs++; - if (major != NULL) - *major = VERSION_MAJOR; - if (minor != NULL) - *minor = VERSION_MINOR; - - mHibernation.setDisplayValid(true); + { + Mutex::Autolock _rf(refLock); + eglIsInitialized = true; + refCond.broadcast(); + } return EGL_TRUE; } EGLBoolean egl_display_t::terminate() { - Mutex::Autolock _l(lock); - - if (refs == 0) { - /* - * From the EGL spec (3.2): - * "Termination of a display that has already been terminated, - * (...), is allowed, but the only effect of such a call is - * to return EGL_TRUE (...) - */ - return EGL_TRUE; - } + { + Mutex::Autolock _rl(refLock); + if (refs == 0) { + /* + * From the EGL spec (3.2): + * "Termination of a display that has already been terminated, + * (...), is allowed, but the only effect of such a call is + * to return EGL_TRUE (...) + */ + return EGL_TRUE; + } - // this is specific to Android, display termination is ref-counted. - if (refs > 1) { + // this is specific to Android, display termination is ref-counted. refs--; - return EGL_TRUE; + if (refs > 0) { + return EGL_TRUE; + } } EGLBoolean res = EGL_FALSE; - egl_connection_t* const cnx = &gEGLImpl; - if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { - if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { - ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, - egl_tls_t::egl_strerror(cnx->egl.eglGetError())); + + { + Mutex::Autolock _l(lock); + + egl_connection_t* const cnx = &gEGLImpl; + if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { + if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { + ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, + egl_tls_t::egl_strerror(cnx->egl.eglGetError())); + } + // REVISIT: it's unclear what to do if eglTerminate() fails + disp.state = egl_display_t::TERMINATED; + res = EGL_TRUE; } - // REVISIT: it's unclear what to do if eglTerminate() fails - disp.state = egl_display_t::TERMINATED; - res = EGL_TRUE; - } - mHibernation.setDisplayValid(false); + mHibernation.setDisplayValid(false); - // Reset the extension string since it will be regenerated if we get - // reinitialized. - mExtensionString.setTo(""); + // Reset the extension string since it will be regenerated if we get + // reinitialized. + mExtensionString.setTo(""); - // Mark all objects remaining in the list as terminated, unless - // there are no reference to them, it which case, we're free to - // delete them. - size_t count = objects.size(); - ALOGW_IF(count, "eglTerminate() called w/ %d objects remaining", count); - for (size_t i=0 ; i<count ; i++) { - egl_object_t* o = objects.itemAt(i); - o->destroy(); + // Mark all objects remaining in the list as terminated, unless + // there are no reference to them, it which case, we're free to + // delete them. + size_t count = objects.size(); + ALOGW_IF(count, "eglTerminate() called w/ %d objects remaining", count); + for (size_t i=0 ; i<count ; i++) { + egl_object_t* o = objects.itemAt(i); + o->destroy(); + } + + // this marks all object handles are "terminated" + objects.clear(); } - // this marks all object handles are "terminated" - objects.clear(); + { + Mutex::Autolock _rl(refLock); + eglIsInitialized = false; + refCond.broadcast(); + } - refs--; return res; } diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h index 0a6e425..2d86295 100644 --- a/opengl/libs/EGL/egl_display.h +++ b/opengl/libs/EGL/egl_display.h @@ -131,7 +131,9 @@ private: void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); } uint32_t refs; - mutable Mutex lock; + bool eglIsInitialized; + mutable Mutex lock, refLock; + mutable Condition refCond; SortedVector<egl_object_t*> objects; String8 mVendorString; String8 mVersionString; diff --git a/opengl/tests/EGLTest/EGL_test.cpp b/opengl/tests/EGLTest/EGL_test.cpp index a4364c6..d69a275 100644 --- a/opengl/tests/EGLTest/EGL_test.cpp +++ b/opengl/tests/EGLTest/EGL_test.cpp @@ -101,7 +101,7 @@ TEST_F(EGLTest, EGLTerminateSucceedsWithRemainingObjects) { EXPECT_TRUE(eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs)); struct DummyConsumer : public BnConsumerListener { - virtual void onFrameAvailable() {} + virtual void onFrameAvailable(const BufferItem& /* item */) {} virtual void onBuffersReleased() {} virtual void onSidebandStreamChanged() {} }; diff --git a/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp index 003efd3..2abc916 100755 --- a/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp +++ b/opengl/tools/glgen/stubs/egl/eglGetDisplay.cpp @@ -14,7 +14,8 @@ static jobject android_eglGetDisplayInt (JNIEnv *_env, jobject _this, jint display_id) { - if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) { + if (static_cast<uintptr_t>(display_id) != + reinterpret_cast<uintptr_t>(EGL_DEFAULT_DISPLAY)) { jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay"); return 0; } diff --git a/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp b/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp index 41df486..d844152 100644 --- a/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp +++ b/opengl/tools/glgen/stubs/gles11/glDrawElementsInstanced.cpp @@ -32,7 +32,7 @@ android_glDrawElementsInstanced__IIIII (GLenum)mode, (GLsizei)count, (GLenum)type, - (GLvoid *)indicesOffset, + (GLvoid *)static_cast<uintptr_t>(indicesOffset), (GLsizei)instanceCount ); } diff --git a/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp b/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp index 0514fe9..a977693 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetTransformFeedbackVarying.cpp @@ -157,7 +157,11 @@ android_glGetTransformFeedbackVarying__IIILjava_nio_IntBuffer_2Ljava_nio_IntBuff (GLsizei *)length, (GLint *)size, (GLenum *)type, - (char *)name + // The cast below is incorrect. The driver will end up writing to the + // address specified by name, which will always crash the process since + // it is guaranteed to be in low memory. The additional static_cast + // suppresses the warning for now. http://b/19478262 + (char *)static_cast<uintptr_t>(name) ); if (_typeArray) { releasePointer(_env, _typeArray, type, JNI_TRUE); |