summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libs/EGL')
-rw-r--r--opengl/libs/EGL/Loader.cpp17
-rw-r--r--opengl/libs/EGL/egl.cpp108
-rw-r--r--opengl/libs/EGL/eglApi.cpp285
-rw-r--r--opengl/libs/EGL/egl_cache.cpp3
-rw-r--r--opengl/libs/EGL/egl_display.cpp35
-rw-r--r--opengl/libs/EGL/egl_display.h22
-rw-r--r--opengl/libs/EGL/egl_entries.in18
-rw-r--r--opengl/libs/EGL/egl_object.cpp20
-rw-r--r--opengl/libs/EGL/egl_object.h20
-rw-r--r--opengl/libs/EGL/egl_tls.cpp4
-rw-r--r--opengl/libs/EGL/egl_tls.h1
-rw-r--r--opengl/libs/EGL/egldefs.h5
-rw-r--r--opengl/libs/EGL/getProcAddress.cpp13
-rw-r--r--opengl/libs/EGL/trace.cpp5
14 files changed, 358 insertions, 198 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 9ee3686..56550b3 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -27,9 +27,9 @@
#include <EGL/egl.h>
+#include "../glestrace.h"
+
#include "egldefs.h"
-#include "glestrace.h"
-#include "hooks.h"
#include "Loader.h"
// ----------------------------------------------------------------------------
@@ -175,6 +175,12 @@ Loader::~Loader()
GLTrace_stop();
}
+static void* load_wrapper(const char* path) {
+ void* so = dlopen(path, RTLD_NOW | RTLD_LOCAL);
+ ALOGE_IF(!so, "dlopen(\"%s\") failed: %s", path, dlerror());
+ return so;
+}
+
void* Loader::open(egl_connection_t* cnx)
{
void* dso;
@@ -200,7 +206,12 @@ void* Loader::open(egl_connection_t* cnx)
LOG_FATAL_IF(!index && !hnd,
"couldn't find the default OpenGL ES implementation "
"for default display");
-
+
+ cnx->libGles2 = load_wrapper("system/lib/libGLESv2.so");
+ cnx->libGles1 = load_wrapper("system/lib/libGLESv1_CM.so");
+ LOG_ALWAYS_FATAL_IF(!cnx->libGles2 || !cnx->libGles1,
+ "couldn't load system OpenGL ES wrapper libraries");
+
return (void*)hnd;
}
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 0d4bed5..6ac8724 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -1,16 +1,16 @@
-/*
+/*
** Copyright 2007, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -23,8 +23,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
@@ -34,11 +32,11 @@
#include <utils/CallStack.h>
#include <utils/String8.h>
-#include "egldefs.h"
-#include "egl_impl.h"
+#include "../egl_impl.h"
+#include "../glestrace.h"
+
#include "egl_tls.h"
-#include "glestrace.h"
-#include "hooks.h"
+#include "egldefs.h"
#include "Loader.h"
#include "egl_display.h"
@@ -84,13 +82,20 @@ static int sEGLApplicationTraceLevel;
static bool sEGLSystraceEnabled;
static bool sEGLGetErrorEnabled;
-int gEGLDebugLevel;
-static int sEGLApplicationDebugLevel;
+static volatile int sEGLDebugLevel;
extern gl_hooks_t gHooksTrace;
extern gl_hooks_t gHooksSystrace;
extern gl_hooks_t gHooksErrorTrace;
+int getEGLDebugLevel() {
+ return sEGLDebugLevel;
+}
+
+void setEGLDebugLevel(int level) {
+ sEGLDebugLevel = level;
+}
+
static inline void setGlTraceThreadSpecific(gl_hooks_t const *value) {
pthread_setspecific(gGLTraceKey, value);
}
@@ -122,36 +127,36 @@ void initEglTraceLevel() {
}
void initEglDebugLevel() {
- int propertyLevel = 0;
- char value[PROPERTY_VALUE_MAX];
-
- // check system property only on userdebug or eng builds
- property_get("ro.debuggable", value, "0");
- if (value[0] == '0')
- return;
+ if (getEGLDebugLevel() == 0) {
+ char value[PROPERTY_VALUE_MAX];
- property_get("debug.egl.debug_proc", value, "");
- if (strlen(value) > 0) {
- long pid = getpid();
- char procPath[128] = {};
- sprintf(procPath, "/proc/%ld/cmdline", pid);
- FILE * file = fopen(procPath, "r");
- if (file) {
- char cmdline[256] = {};
- if (fgets(cmdline, sizeof(cmdline) - 1, file)) {
- if (!strncmp(value, cmdline, strlen(value))) {
- // set EGL debug if the "debug.egl.debug_proc" property
- // matches the prefix of this application's command line
- propertyLevel = 1;
+ // check system property only on userdebug or eng builds
+ property_get("ro.debuggable", value, "0");
+ if (value[0] == '0')
+ return;
+
+ property_get("debug.egl.debug_proc", value, "");
+ if (strlen(value) > 0) {
+ FILE * file = fopen("/proc/self/cmdline", "r");
+ if (file) {
+ char cmdline[256];
+ if (fgets(cmdline, sizeof(cmdline), file)) {
+ if (!strncmp(value, cmdline, strlen(value))) {
+ // set EGL debug if the "debug.egl.debug_proc" property
+ // matches the prefix of this application's command line
+ setEGLDebugLevel(1);
+ }
}
+ fclose(file);
}
- fclose(file);
}
}
- gEGLDebugLevel = propertyLevel || sEGLApplicationDebugLevel;
- if (gEGLDebugLevel > 0) {
- GLTrace_start();
+ if (getEGLDebugLevel() > 0) {
+ if (GLTrace_start() < 0) {
+ ALOGE("Error starting Tracer for OpenGL ES. Disabling..");
+ setEGLDebugLevel(0);
+ }
}
}
@@ -165,10 +170,11 @@ void setGLHooksThreadSpecific(gl_hooks_t const *value) {
} else if (sEGLTraceLevel > 0) {
setGlTraceThreadSpecific(value);
setGlThreadSpecific(&gHooksTrace);
- } else if (gEGLDebugLevel > 0 && value != &gHooksNoContext) {
+ } else if (getEGLDebugLevel() > 0 && value != &gHooksNoContext) {
setGlTraceThreadSpecific(value);
setGlThreadSpecific(GLTrace_getGLHooks());
} else {
+ setGlTraceThreadSpecific(NULL);
setGlThreadSpecific(value);
}
}
@@ -186,9 +192,12 @@ void setGLTraceLevel(int level) {
* Global entry point to allow applications to modify their own debug level.
* Debugging is enabled if either the application requested it, or if the system property
* matches the application's name.
+ * Note that this only sets the debug level. The value is read and used either in
+ * initEglDebugLevel() if the application hasn't initialized its display yet, or when
+ * eglSwapBuffers() is called next.
*/
void EGLAPI setGLDebugLevel(int level) {
- sEGLApplicationDebugLevel = level;
+ setEGLDebugLevel(level);
}
#else
@@ -213,15 +222,13 @@ static int gl_no_context() {
char value[PROPERTY_VALUE_MAX];
property_get("debug.egl.callstack", value, "0");
if (atoi(value)) {
- CallStack stack;
- stack.update();
- stack.dump();
+ CallStack stack(LOG_TAG);
}
}
return 0;
}
-static void early_egl_init(void)
+static void early_egl_init(void)
{
#if !USE_FAST_TLS_KEY
pthread_key_create(&gGLWrapperKey, NULL);
@@ -229,12 +236,11 @@ static void early_egl_init(void)
#if EGL_TRACE
pthread_key_create(&gGLTraceKey, NULL);
initEglTraceLevel();
- initEglDebugLevel();
#endif
uint32_t addr = (uint32_t)((void*)gl_no_context);
android_memset32(
- (uint32_t*)(void*)&gHooksNoContext,
- addr,
+ (uint32_t*)(void*)&gHooksNoContext,
+ addr,
sizeof(gHooksNoContext));
setGLHooksThreadSpecific(&gHooksNoContext);
@@ -381,7 +387,7 @@ gl_hooks_t const* getGlThreadSpecific() {
#define EGL_ENTRY(_r, _api, ...) #_api,
char const * const gl_names[] = {
- #include "entries.in"
+ #include "../entries.in"
NULL
};
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index d1f7c57..f39c386 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -1,21 +1,22 @@
-/*
+/*
** Copyright 2007, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <dlfcn.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -25,8 +26,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
@@ -39,13 +38,11 @@
#include <utils/String8.h>
#include <utils/Trace.h>
-#include "egl_impl.h"
-#include "egl_tls.h"
-#include "glestrace.h"
-#include "hooks.h"
+#include "../egl_impl.h"
+#include "../glestrace.h"
+#include "../hooks.h"
#include "egl_display.h"
-#include "egl_impl.h"
#include "egl_object.h"
#include "egl_tls.h"
#include "egldefs.h"
@@ -54,28 +51,107 @@ using namespace android;
// ----------------------------------------------------------------------------
-#define EGL_VERSION_HW_ANDROID 0x3143
+namespace android {
struct extention_map_t {
const char* name;
__eglMustCastToProperFunctionPointerType address;
};
-static const extention_map_t sExtentionMap[] = {
+/*
+ * This is the list of EGL extensions exposed to applications,
+ * some of them are mandatory because used by the ANDROID system.
+ *
+ * Mandatory extensions are required per the CDD and not explicitly
+ * checked during EGL initialization. the system *assumes* these extensions
+ * are present. the system may not function properly if some mandatory
+ * extensions are missing.
+ *
+ * NOTE: gExtensionString MUST have a single space as the last character.
+ */
+extern char const * const gExtensionString =
+ "EGL_KHR_image " // mandatory
+ "EGL_KHR_image_base " // mandatory
+ "EGL_KHR_image_pixmap "
+ "EGL_KHR_lock_surface "
+ "EGL_KHR_gl_texture_2D_image "
+ "EGL_KHR_gl_texture_cubemap_image "
+ "EGL_KHR_gl_renderbuffer_image "
+ "EGL_KHR_reusable_sync "
+ "EGL_KHR_fence_sync "
+ "EGL_KHR_create_context "
+ "EGL_EXT_create_context_robustness "
+ "EGL_NV_system_time "
+ "EGL_ANDROID_image_native_buffer " // mandatory
+ "EGL_KHR_wait_sync " // strongly recommended
+ "EGL_ANDROID_presentation_time "
+ ;
+
+// extensions not exposed to applications but used by the ANDROID system
+// "EGL_ANDROID_blob_cache " // strongly recommended
+// "EGL_IMG_hibernate_process " // optional
+// "EGL_ANDROID_native_fence_sync " // strongly recommended
+// "EGL_ANDROID_framebuffer_target " // mandatory for HWC 1.1
+// "EGL_ANDROID_recordable " // mandatory
+
+
+/*
+ * EGL Extensions entry-points exposed to 3rd party applications
+ * (keep in sync with gExtensionString above)
+ *
+ */
+static const extention_map_t sExtensionMap[] = {
+ // EGL_KHR_lock_surface
{ "eglLockSurfaceKHR",
(__eglMustCastToProperFunctionPointerType)&eglLockSurfaceKHR },
{ "eglUnlockSurfaceKHR",
(__eglMustCastToProperFunctionPointerType)&eglUnlockSurfaceKHR },
+
+ // EGL_KHR_image, EGL_KHR_image_base
{ "eglCreateImageKHR",
(__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR },
{ "eglDestroyImageKHR",
(__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR },
+
+ // EGL_KHR_reusable_sync, EGL_KHR_fence_sync
+ { "eglCreateSyncKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR },
+ { "eglDestroySyncKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR },
+ { "eglClientWaitSyncKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR },
+ { "eglSignalSyncKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglSignalSyncKHR },
+ { "eglGetSyncAttribKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR },
+
+ // EGL_NV_system_time
{ "eglGetSystemTimeFrequencyNV",
(__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeFrequencyNV },
{ "eglGetSystemTimeNV",
(__eglMustCastToProperFunctionPointerType)&eglGetSystemTimeNV },
+
+ // EGL_KHR_wait_sync
+ { "eglWaitSyncKHR",
+ (__eglMustCastToProperFunctionPointerType)&eglWaitSyncKHR },
+
+ // EGL_ANDROID_presentation_time
+ { "eglPresentationTimeANDROID",
+ (__eglMustCastToProperFunctionPointerType)&eglPresentationTimeANDROID },
};
+/*
+ * These extensions entry-points should not be exposed to applications.
+ * They're used internally by the Android EGL layer.
+ */
+#define FILTER_EXTENSIONS(procname) \
+ (!strcmp((procname), "eglSetBlobCacheFuncsANDROID") || \
+ !strcmp((procname), "eglHibernateProcessIMG") || \
+ !strcmp((procname), "eglAwakenProcessIMG") || \
+ !strcmp((procname), "eglDupNativeFenceFDANDROID"))
+
+
+
// accesses protected by sExtensionMapMutex
static DefaultKeyedVector<String8, __eglMustCastToProperFunctionPointerType> sGLExtentionMap;
static int sGLExtentionSlot = 0;
@@ -93,14 +169,16 @@ static void(*findProcAddress(const char* name,
// ----------------------------------------------------------------------------
-namespace android {
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
extern EGLBoolean egl_init_drivers();
extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS];
-extern int gEGLDebugLevel;
+extern int getEGLDebugLevel();
+extern void setEGLDebugLevel(int level);
extern gl_hooks_t gHooksTrace;
+
} // namespace android;
+
// ----------------------------------------------------------------------------
static inline void clearError() { egl_tls_t::clearError(); }
@@ -153,7 +231,7 @@ EGLBoolean eglTerminate(EGLDisplay dpy)
if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);
EGLBoolean res = dp->terminate();
-
+
return res;
}
@@ -234,7 +312,7 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
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;
@@ -271,7 +349,7 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
egl_connection_t* cnx = NULL;
const egl_display_ptr dp = validate_display_connection(dpy, cnx);
if (!dp) return EGL_FALSE;
-
+
return cnx->egl.eglGetConfigAttrib(
dp->disp.dpy, config, attribute, value);
}
@@ -370,7 +448,7 @@ EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
}
return EGL_NO_SURFACE;
}
-
+
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
{
clearError();
@@ -459,7 +537,7 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
if (attr == EGL_CONTEXT_CLIENT_VERSION) {
if (value == 1) {
version = egl_connection_t::GLESv1_INDEX;
- } else if (value == 2) {
+ } else if (value == 2 || value == 3) {
version = egl_connection_t::GLESv2_INDEX;
}
}
@@ -468,7 +546,7 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
egl_context_t* c = new egl_context_t(dpy, context, config, cnx,
version);
#if EGL_TRACE
- if (gEGLDebugLevel > 0)
+ if (getEGLDebugLevel() > 0)
GLTrace_eglCreateContext(version, c);
#endif
return c;
@@ -494,7 +572,7 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
ContextRef _c(dp.get(), ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
-
+
egl_context_t * const c = get_context(ctx);
EGLBoolean result = c->cnx->egl.eglDestroyContext(dp->disp.dpy, c->context);
if (result == EGL_TRUE) {
@@ -542,7 +620,7 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
// these are the current objects structs
egl_context_t * cur_c = get_context(getContext());
-
+
if (ctx != EGL_NO_CONTEXT) {
c = get_context(ctx);
impl_ctx = c->context;
@@ -583,7 +661,7 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
setGLHooksThreadSpecific(c->cnx->hooks[c->version]);
egl_tls_t::setContext(ctx);
#if EGL_TRACE
- if (gEGLDebugLevel > 0)
+ if (getEGLDebugLevel() > 0)
GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx);
#endif
_c.acquire();
@@ -642,7 +720,7 @@ EGLSurface eglGetCurrentSurface(EGLint readdraw)
if (!c) return setError(EGL_BAD_CONTEXT, EGL_NO_SURFACE);
switch (readdraw) {
case EGL_READ: return c->read;
- case EGL_DRAW: return c->draw;
+ case EGL_DRAW: return c->draw;
default: return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
}
}
@@ -700,6 +778,20 @@ EGLint eglGetError(void)
return err;
}
+static __eglMustCastToProperFunctionPointerType findBuiltinGLWrapper(
+ const char* procname) {
+ const egl_connection_t* cnx = &gEGLImpl;
+ void* proc = NULL;
+
+ proc = dlsym(cnx->libGles2, procname);
+ if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
+
+ proc = dlsym(cnx->libGles1, procname);
+ if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
+
+ return NULL;
+}
+
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
// eglGetProcAddress() could be the very first function called
@@ -713,20 +805,16 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
return NULL;
}
- // 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")) {
+ if (FILTER_EXTENSIONS(procname)) {
return NULL;
}
__eglMustCastToProperFunctionPointerType addr;
- addr = findProcAddress(procname, sExtentionMap, NELEM(sExtentionMap));
+ addr = findProcAddress(procname, sExtensionMap, NELEM(sExtensionMap));
if (addr) return addr;
+ addr = findBuiltinGLWrapper(procname);
+ if (addr) return addr;
// this protects accesses to sGLExtentionMap and sGLExtentionSlot
pthread_mutex_lock(&sExtensionMapMutex);
@@ -866,12 +954,42 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
return setError(EGL_BAD_SURFACE, EGL_FALSE);
#if EGL_TRACE
- if (gEGLDebugLevel > 0)
+ gl_hooks_t const *trace_hooks = getGLTraceThreadSpecific();
+ if (getEGLDebugLevel() > 0) {
+ if (trace_hooks == NULL) {
+ if (GLTrace_start() < 0) {
+ ALOGE("Disabling Tracer for OpenGL ES");
+ setEGLDebugLevel(0);
+ } else {
+ // switch over to the trace version of hooks
+ EGLContext ctx = egl_tls_t::getContext();
+ egl_context_t * const c = get_context(ctx);
+ if (c) {
+ setGLHooksThreadSpecific(c->cnx->hooks[c->version]);
+ GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx);
+ }
+ }
+ }
+
GLTrace_eglSwapBuffers(dpy, draw);
+ } else if (trace_hooks != NULL) {
+ // tracing is now disabled, so switch back to the non trace version
+ EGLContext ctx = egl_tls_t::getContext();
+ egl_context_t * const c = get_context(ctx);
+ if (c) setGLHooksThreadSpecific(c->cnx->hooks[c->version]);
+ GLTrace_stop();
+ }
#endif
egl_surface_t const * const s = get_surface(draw);
+ if (CC_UNLIKELY(dp->traceGpuCompletion)) {
+ EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL);
+ if (sync != EGL_NO_SYNC_KHR) {
+ FrameCompletionThread::queueSync(sync);
+ }
+ }
+
if (CC_UNLIKELY(dp->finishOnSwap)) {
uint32_t pixel;
egl_context_t * const c = get_context( egl_tls_t::getContext() );
@@ -882,19 +1000,7 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
}
}
- EGLBoolean result = s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
-
- if (CC_UNLIKELY(dp->traceGpuCompletion)) {
- EGLSyncKHR sync = EGL_NO_SYNC_KHR;
- {
- sync = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL);
- }
- if (sync != EGL_NO_SYNC_KHR) {
- FrameCompletionThread::queueSync(sync);
- }
- }
-
- return result;
+ return s->cnx->egl.eglSwapBuffers(dp->disp.dpy, s->surface);
}
EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface,
@@ -929,12 +1035,29 @@ const char* eglQueryString(EGLDisplay dpy, EGLint name)
return dp->getExtensionString();
case EGL_CLIENT_APIS:
return dp->getClientApiString();
- case EGL_VERSION_HW_ANDROID:
- return dp->disp.queryString.version;
}
return setError(EGL_BAD_PARAMETER, (const char *)0);
}
+EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name)
+{
+ clearError();
+
+ const egl_display_ptr dp = validate_display(dpy);
+ if (!dp) return (const char *) NULL;
+
+ switch (name) {
+ case EGL_VENDOR:
+ return dp->disp.queryString.vendor;
+ case EGL_VERSION:
+ return dp->disp.queryString.version;
+ case EGL_EXTENSIONS:
+ return dp->disp.queryString.extensions;
+ case EGL_CLIENT_APIS:
+ return dp->disp.queryString.clientApi;
+ }
+ return setError(EGL_BAD_PARAMETER, (const char *)0);
+}
// ----------------------------------------------------------------------------
// EGL 1.1
@@ -1086,7 +1209,7 @@ EGLBoolean eglReleaseThread(void)
egl_tls_t::clearTLS();
#if EGL_TRACE
- if (gEGLDebugLevel > 0)
+ if (getEGLDebugLevel() > 0)
GLTrace_eglReleaseThread();
#endif
return EGL_TRUE;
@@ -1222,6 +1345,21 @@ EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
return result;
}
+EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) {
+ clearError();
+
+ 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.eglSignalSyncKHR) {
+ result = cnx->egl.eglSignalSyncKHR(
+ dp->disp.dpy, sync, mode);
+ }
+ return result;
+}
+
EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync,
EGLint flags, EGLTimeKHR timeout)
{
@@ -1257,6 +1395,22 @@ EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync,
}
// ----------------------------------------------------------------------------
+// EGL_EGLEXT_VERSION 15
+// ----------------------------------------------------------------------------
+
+EGLint eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) {
+ clearError();
+ const egl_display_ptr dp = validate_display(dpy);
+ if (!dp) return EGL_FALSE;
+ EGLint result = EGL_FALSE;
+ egl_connection_t* const cnx = &gEGLImpl;
+ if (cnx->dso && cnx->egl.eglWaitSyncKHR) {
+ result = cnx->egl.eglWaitSyncKHR(dp->disp.dpy, sync, flags);
+ }
+ return result;
+}
+
+// ----------------------------------------------------------------------------
// ANDROID extensions
// ----------------------------------------------------------------------------
@@ -1275,19 +1429,26 @@ EGLint eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR sync)
return result;
}
-EGLint eglWaitSyncANDROID(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags)
+EGLBoolean eglPresentationTimeANDROID(EGLDisplay dpy, EGLSurface surface,
+ EGLnsecsANDROID time)
{
clearError();
const egl_display_ptr dp = validate_display(dpy);
- if (!dp) return EGL_NO_NATIVE_FENCE_FD_ANDROID;
+ if (!dp) {
+ return EGL_FALSE;
+ }
- 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);
+ SurfaceRef _s(dp.get(), surface);
+ if (!_s.get()) {
+ setError(EGL_BAD_SURFACE, EGL_FALSE);
+ return EGL_FALSE;
}
- return result;
+
+ egl_surface_t const * const s = get_surface(surface);
+ native_window_set_buffers_timestamp(s->win.get(), time);
+
+ return EGL_TRUE;
}
// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index 72655df..03397a9 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -14,9 +14,10 @@
** limitations under the License.
*/
+#include "../egl_impl.h"
+
#include "egl_cache.h"
#include "egl_display.h"
-#include "egl_impl.h"
#include "egldefs.h"
#include <fcntl.h>
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 7ca9e40..1955904 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -18,11 +18,12 @@
#include <string.h>
+#include "../egl_impl.h"
+
#include "egl_cache.h"
#include "egl_display.h"
#include "egl_object.h"
#include "egl_tls.h"
-#include "egl_impl.h"
#include "Loader.h"
#include <cutils/properties.h>
@@ -34,35 +35,7 @@ static char const * const sVendorString = "Android";
static char const * const sVersionString = "1.4 Android META-EGL";
static char const * const sClientApiString = "OpenGL_ES";
-// this is the list of EGL extensions that are exposed to applications
-// some of them are mandatory because used by the ANDROID system.
-//
-// mandatory extensions are required per the CDD and not explicitly
-// checked during EGL initialization. the system *assumes* these extensions
-// are present. the system may not function properly if some mandatory
-// extensions are missing.
-//
-// NOTE: sExtensionString MUST be have a single space as the last character.
-//
-static char const * const sExtensionString =
- "EGL_KHR_image " // mandatory
- "EGL_KHR_image_base " // mandatory
- "EGL_KHR_image_pixmap "
- "EGL_KHR_gl_texture_2D_image "
- "EGL_KHR_gl_texture_cubemap_image "
- "EGL_KHR_gl_renderbuffer_image "
- "EGL_KHR_fence_sync "
- "EGL_EXT_create_context_robustness "
- "EGL_NV_system_time "
- "EGL_ANDROID_image_native_buffer " // mandatory
- ;
-
-// extensions not exposed to applications but used by the ANDROID system
-// "EGL_ANDROID_recordable " // mandatory
-// "EGL_ANDROID_framebuffer_target " // mandatory for HWC 1.1
-// "EGL_ANDROID_blob_cache " // strongly recommended
-// "EGL_ANDROID_native_fence_sync " // strongly recommended
-// "EGL_IMG_hibernate_process " // optional
+extern char const * const gExtensionString;
extern void initEglTraceLevel();
extern void initEglDebugLevel();
@@ -211,7 +184,7 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
mClientApiString.setTo(sClientApiString);
// we only add extensions that exist in the implementation
- char const* start = sExtensionString;
+ char const* start = gExtensionString;
char const* end;
do {
// find the space separating this extension for the next one
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index 7bb09a3..754085c 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -1,16 +1,16 @@
-/*
+/*
** Copyright 2007, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -24,8 +24,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <cutils/compiler.h>
#include <utils/SortedVector.h>
@@ -33,7 +31,7 @@
#include <utils/String8.h>
#include "egldefs.h"
-#include "hooks.h"
+#include "../hooks.h"
// ----------------------------------------------------------------------------
namespace android {
diff --git a/opengl/libs/EGL/egl_entries.in b/opengl/libs/EGL/egl_entries.in
index 2ffd417..70d0e52 100644
--- a/opengl/libs/EGL/egl_entries.in
+++ b/opengl/libs/EGL/egl_entries.in
@@ -56,14 +56,30 @@ EGL_ENTRY(EGLBoolean, eglDestroyImageKHR, EGLDisplay, EGLImageKHR)
EGL_ENTRY(EGLSyncKHR, eglCreateSyncKHR, EGLDisplay, EGLenum, const EGLint *)
EGL_ENTRY(EGLBoolean, eglDestroySyncKHR, EGLDisplay, EGLSyncKHR)
EGL_ENTRY(EGLint, eglClientWaitSyncKHR, EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR)
+EGL_ENTRY(EGLBoolean, eglSignalSyncKHR, EGLDisplay, EGLSyncKHR, EGLenum)
EGL_ENTRY(EGLBoolean, eglGetSyncAttribKHR, EGLDisplay, EGLSyncKHR, EGLint, EGLint *)
+/* EGL_EGLEXT_VERSION 15 */
+
+// EGL_ENTRY(EGLStreamKHR, eglCreateStreamKHR, EGLDisplay, const EGLint *)
+// EGL_ENTRY(EGLBoolean, eglDestroyStreamKHR, EGLDisplay, EGLStreamKHR)
+// EGL_ENTRY(EGLBoolean, eglStreamAttribKHR, EGLDisplay, EGLStreamKHR, EGLenum, EGLint)
+// EGL_ENTRY(EGLBoolean, eglQueryStreamKHR, EGLDisplay, EGLStreamKHR, EGLenum, EGLint *)
+// EGL_ENTRY(EGLBoolean, eglQueryStreamu64KHR, EGLDisplay, EGLStreamKHR, EGLenum, EGLuint64KHR *)
+// EGL_ENTRY(EGLBoolean, eglStreamConsumerGLTextureExternalKHR, EGLDisplay, EGLStreamKHR)
+// EGL_ENTRY(EGLBoolean, eglStreamConsumerAcquireKHR, EGLDisplay, EGLStreamKHR)
+// EGL_ENTRY(EGLBoolean, eglStreamConsumerReleaseKHR, EGLDisplay, EGLStreamKHR)
+// EGL_ENTRY(EGLSurface, eglCreateStreamProducerSurfaceKHR, EGLDisplay, EGLConfig, EGLStreamKHR, const EGLint *)
+// EGL_ENTRY(EGLBoolean, eglQueryStreamTimeKHR, EGLDisplay, EGLStreamKHR, EGLenum, EGLTimeKHR*)
+// EGL_ENTRY(EGLNativeFileDescriptorKHR, eglGetStreamFileDescriptorKHR, EGLDisplay, EGLStreamKHR)
+// EGL_ENTRY(EGLStreamKHR, eglCreateStreamFromFileDescriptorKHR, EGLDisplay, EGLNativeFileDescriptorKHR)
+EGL_ENTRY(EGLint, eglWaitSyncKHR, EGLDisplay, EGLSyncKHR, EGLint)
+
/* ANDROID extensions */
EGL_ENTRY(EGLBoolean, eglSetSwapRectangleANDROID, EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint)
EGL_ENTRY(EGLClientBuffer, eglGetRenderBufferANDROID, EGLDisplay, EGLSurface)
EGL_ENTRY(EGLint, eglDupNativeFenceFDANDROID, EGLDisplay, EGLSyncKHR)
-EGL_ENTRY(EGLint, eglWaitSyncANDROID, EGLDisplay, EGLSyncKHR, EGLint)
/* NVIDIA extensions */
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index aaa5e72..d3ee76d 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -1,16 +1,16 @@
-/*
+/*
** Copyright 2007, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -20,8 +20,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <utils/threads.h>
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index 2a08424..518fdec 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -1,16 +1,16 @@
-/*
+/*
** Copyright 2007, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -24,8 +24,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <utils/threads.h>
#include <utils/String8.h>
diff --git a/opengl/libs/EGL/egl_tls.cpp b/opengl/libs/EGL/egl_tls.cpp
index 41cfae1..52312a2 100644
--- a/opengl/libs/EGL/egl_tls.cpp
+++ b/opengl/libs/EGL/egl_tls.cpp
@@ -78,9 +78,7 @@ void egl_tls_t::setErrorEtcImpl(
char value[PROPERTY_VALUE_MAX];
property_get("debug.egl.callstack", value, "0");
if (atoi(value)) {
- CallStack stack;
- stack.update();
- stack.dump();
+ CallStack stack(LOG_TAG);
}
}
tls->error = error;
diff --git a/opengl/libs/EGL/egl_tls.h b/opengl/libs/EGL/egl_tls.h
index 2442ca0..56c5dba 100644
--- a/opengl/libs/EGL/egl_tls.h
+++ b/opengl/libs/EGL/egl_tls.h
@@ -22,7 +22,6 @@
#include <EGL/egl.h>
#include "egldefs.h"
-#include "hooks.h"
// ----------------------------------------------------------------------------
namespace android {
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index c900c1c..b905ea0 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_EGLDEFS_H
#define ANDROID_EGLDEFS_H
-#include "hooks.h"
+#include "../hooks.h"
#define VERSION_MAJOR 1
#define VERSION_MINOR 4
@@ -43,6 +43,9 @@ struct egl_connection_t {
EGLint major;
EGLint minor;
egl_t egl;
+
+ void* libGles1;
+ void* libGles2;
};
// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp
index d23da7a..c160aa0 100644
--- a/opengl/libs/EGL/getProcAddress.cpp
+++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -21,7 +21,6 @@
#include <cutils/log.h>
#include "egldefs.h"
-#include "hooks.h"
// ----------------------------------------------------------------------------
namespace android {
@@ -64,9 +63,9 @@ namespace android {
#define API_ENTRY(_api) __attribute__((noinline)) _api
#define CALL_GL_EXTENSION_API(_api, ...) \
- register unsigned int t0 asm("t0"); \
- register unsigned int fn asm("t1"); \
- register unsigned int tls asm("v1"); \
+ register unsigned int _t0 asm("t0"); \
+ register unsigned int _fn asm("t1"); \
+ register unsigned int _tls asm("v1"); \
asm volatile( \
".set push\n\t" \
".set noreorder\n\t" \
@@ -81,9 +80,9 @@ namespace android {
"j %[fn]\n\t" \
" nop\n\t" \
".set pop\n\t" \
- : [fn] "=c"(fn), \
- [tls] "=&r"(tls), \
- [t0] "=&r"(t0) \
+ : [fn] "=c"(_fn), \
+ [tls] "=&r"(_tls), \
+ [t0] "=&r"(_t0) \
: [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \
[API] "I"(__builtin_offsetof(gl_hooks_t, \
ext.extensions[_api])) \
diff --git a/opengl/libs/EGL/trace.cpp b/opengl/libs/EGL/trace.cpp
index a51b086..bac6ba8 100644
--- a/opengl/libs/EGL/trace.cpp
+++ b/opengl/libs/EGL/trace.cpp
@@ -21,8 +21,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
#include <cutils/log.h>
@@ -39,7 +37,8 @@ namespace android {
// ----------------------------------------------------------------------------
struct GLenumString {
- GLenum e;
+ // The GL_TIMEOUT_IGNORED "enum" doesn't fit in a GLenum, so use GLuint64
+ GLuint64 e;
const char* s;
};