diff options
Diffstat (limited to 'opengl/libs/EGL/eglApi.cpp')
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index c943ec1..c25612d 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -204,6 +204,59 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list, egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso) { + if (attrib_list) { + char value[PROPERTY_VALUE_MAX]; + property_get("debug.egl.force_msaa", value, "false"); + + if (!strcmp(value, "true")) { + size_t attribCount = 0; + EGLint attrib = attrib_list[0]; + + // Only enable MSAA if the context is OpenGL ES 2.0 and + // if no caveat is requested + const EGLint *attribRendererable = NULL; + const EGLint *attribCaveat = NULL; + + // Count the number of attributes and look for + // EGL_RENDERABLE_TYPE and EGL_CONFIG_CAVEAT + while (attrib != EGL_NONE) { + attrib = attrib_list[attribCount]; + switch (attrib) { + case EGL_RENDERABLE_TYPE: + attribRendererable = &attrib_list[attribCount]; + break; + case EGL_CONFIG_CAVEAT: + attribCaveat = &attrib_list[attribCount]; + break; + } + attribCount++; + } + + if (attribRendererable && attribRendererable[1] == EGL_OPENGL_ES2_BIT && + (!attribCaveat || attribCaveat[1] != EGL_NONE)) { + + // Insert 2 extra attributes to force-enable MSAA 4x + EGLint aaAttribs[attribCount + 4]; + aaAttribs[0] = EGL_SAMPLE_BUFFERS; + aaAttribs[1] = 1; + aaAttribs[2] = EGL_SAMPLES; + aaAttribs[3] = 4; + + memcpy(&aaAttribs[4], attrib_list, attribCount * sizeof(EGLint)); + + EGLint numConfigAA; + EGLBoolean resAA = cnx->egl.eglChooseConfig( + dp->disp.dpy, aaAttribs, configs, config_size, &numConfigAA); + + if (resAA == EGL_TRUE && numConfigAA > 0) { + ALOGD("Enabling MSAA 4x"); + *num_config = numConfigAA; + return resAA; + } + } + } + } + res = cnx->egl.eglChooseConfig( dp->disp.dpy, attrib_list, configs, config_size, num_config); } @@ -419,6 +472,12 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, GLTrace_eglCreateContext(version, c); #endif return c; + } else { + EGLint error = eglGetError(); + ALOGE_IF(error == EGL_SUCCESS, + "eglCreateContext(%p, %p, %p, %p) returned EGL_NO_CONTEXT " + "but no EGL error!", + dpy, config, share_list, attrib_list); } } return EGL_NO_CONTEXT; @@ -657,6 +716,8 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) // These extensions should not be exposed to applications. They're used // internally by the Android EGL layer. if (!strcmp(procname, "eglSetBlobCacheFuncsANDROID") || + !strcmp(procname, "eglDupNativeFenceFDANDROID") || + !strcmp(procname, "eglWaitSyncANDROID") || !strcmp(procname, "eglHibernateProcessIMG") || !strcmp(procname, "eglAwakenProcessIMG")) { return NULL; @@ -704,8 +765,8 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && cnx->egl.eglGetProcAddress) { - found = true; // Extensions are independent of the bound context + addr = cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] = cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = #if EGL_TRACE @@ -713,10 +774,13 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) gHooksTrace.ext.extensions[slot] = #endif cnx->egl.eglGetProcAddress(procname); + if (addr) found = true; } if (found) { +#if USE_FAST_TLS_KEY addr = gExtensionForwarders[slot]; +#endif sGLExtentionMap.add(name, addr); sGLExtentionSlot++; } @@ -1115,11 +1179,12 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) const egl_display_ptr dp = validate_display(dpy); if (!dp) return EGL_FALSE; + EGLBoolean result = EGL_FALSE; egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && cnx->egl.eglDestroyImageKHR) { - cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); + result = cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); } - return EGL_TRUE; + return result; } // ---------------------------------------------------------------------------- @@ -1195,7 +1260,35 @@ EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, // ANDROID extensions // ---------------------------------------------------------------------------- -/* ANDROID extensions entry-point go here */ +EGLint eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR sync) +{ + clearError(); + + const egl_display_ptr dp = validate_display(dpy); + if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID; + + EGLint result = EGL_NO_NATIVE_FENCE_FD_ANDROID; + egl_connection_t* const cnx = &gEGLImpl; + if (cnx->dso && cnx->egl.eglDupNativeFenceFDANDROID) { + result = cnx->egl.eglDupNativeFenceFDANDROID(dp->disp.dpy, sync); + } + return result; +} + +EGLint eglWaitSyncANDROID(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) +{ + clearError(); + + const egl_display_ptr dp = validate_display(dpy); + if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID; + + EGLint result = EGL_FALSE; + egl_connection_t* const cnx = &gEGLImpl; + if (cnx->dso && cnx->egl.eglWaitSyncANDROID) { + result = cnx->egl.eglWaitSyncANDROID(dp->disp.dpy, sync, flags); + } + return result; +} // ---------------------------------------------------------------------------- // NVIDIA extensions |