summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libs/EGL')
-rw-r--r--opengl/libs/EGL/Loader.cpp2
-rw-r--r--opengl/libs/EGL/egl.cpp50
-rw-r--r--opengl/libs/EGL/trace.cpp46
3 files changed, 92 insertions, 6 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 747c829..2502f15 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -30,6 +30,7 @@
#include "egl_impl.h"
#include "Loader.h"
+#include "glesv2dbg.h"
// ----------------------------------------------------------------------------
namespace android {
@@ -114,6 +115,7 @@ Loader::Loader()
Loader::~Loader()
{
+ StopDebugServer();
}
const char* Loader::getTag(int dpy, int impl)
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index e13af1c..e567c88 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -45,6 +45,7 @@
#include "hooks.h"
#include "egl_impl.h"
#include "Loader.h"
+#include "glesv2dbg.h"
#define setError(_e, _r) setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
@@ -223,9 +224,15 @@ struct egl_context_t : public egl_object_t
egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
int impl, egl_connection_t const* cnx, int version)
: dpy(dpy), context(context), config(config), read(0), draw(0), impl(impl),
- cnx(cnx), version(version)
+ cnx(cnx), version(version), dbg(NULL)
{
}
+ ~egl_context_t()
+ {
+ if (dbg)
+ DestroyDbgContext(dbg);
+ dbg = NULL;
+ }
EGLDisplay dpy;
EGLContext context;
EGLConfig config;
@@ -234,6 +241,7 @@ struct egl_context_t : public egl_object_t
int impl;
egl_connection_t const* cnx;
int version;
+ DbgContext * dbg;
};
struct egl_image_t : public egl_object_t
@@ -296,9 +304,9 @@ EGLAPI pthread_key_t gGLTraceKey = -1;
// ----------------------------------------------------------------------------
-static int gEGLTraceLevel;
+static int gEGLTraceLevel, gEGLDebugLevel;
static int gEGLApplicationTraceLevel;
-extern EGLAPI gl_hooks_t gHooksTrace;
+extern EGLAPI gl_hooks_t gHooksTrace, gHooksDebug;
static inline void setGlTraceThreadSpecific(gl_hooks_t const *value) {
pthread_setspecific(gGLTraceKey, value);
@@ -314,12 +322,35 @@ static void initEglTraceLevel() {
int propertyLevel = atoi(value);
int applicationLevel = gEGLApplicationTraceLevel;
gEGLTraceLevel = propertyLevel > applicationLevel ? propertyLevel : applicationLevel;
+
+ property_get("debug.egl.debug_proc", value, "");
+ 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 (!strcmp(value, cmdline))
+ gEGLDebugLevel = 1;
+ }
+ fclose(file);
+ }
+
+ if (gEGLDebugLevel > 0)
+ StartDebugServer();
}
static void setGLHooksThreadSpecific(gl_hooks_t const *value) {
if (gEGLTraceLevel > 0) {
setGlTraceThreadSpecific(value);
setGlThreadSpecific(&gHooksTrace);
+ } else if (gEGLDebugLevel > 0 && value != &gHooksNoContext) {
+ setGlTraceThreadSpecific(value);
+ setGlThreadSpecific(&gHooksDebug);
+ LOGD("\n* setGLHooksThreadSpecific gHooksDebug");
} else {
setGlThreadSpecific(value);
}
@@ -561,6 +592,11 @@ egl_context_t* get_context(EGLContext context) {
return egl_to_native_cast<egl_context_t>(context);
}
+DbgContext * getDbgContextThreadSpecific()
+{
+ return get_context(getContext())->dbg;
+}
+
static inline
egl_image_t* get_image(EGLImageKHR image) {
return egl_to_native_cast<egl_image_t>(image);
@@ -1378,6 +1414,8 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
loseCurrent(cur_c);
if (ctx != EGL_NO_CONTEXT) {
+ if (!c->dbg && gEGLDebugLevel > 0)
+ c->dbg = CreateDbgContext(c->version, c->cnx->hooks[c->version]);
setGLHooksThreadSpecific(c->cnx->hooks[c->version]);
setContext(ctx);
_c.acquire();
@@ -1607,7 +1645,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] =
cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
- gHooksTrace.ext.extensions[slot] =
+ gHooksDebug.ext.extensions[slot] = gHooksTrace.ext.extensions[slot] =
#endif
cnx->egl.eglGetProcAddress(procname);
}
@@ -1635,6 +1673,10 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
{
+ EGLBoolean Debug_eglSwapBuffers(EGLDisplay dpy, EGLSurface draw);
+ if (gEGLDebugLevel > 0)
+ Debug_eglSwapBuffers(dpy, draw);
+
clearError();
SurfaceRef _s(draw);
diff --git a/opengl/libs/EGL/trace.cpp b/opengl/libs/EGL/trace.cpp
index d3e96ba..f3e101b 100644
--- a/opengl/libs/EGL/trace.cpp
+++ b/opengl/libs/EGL/trace.cpp
@@ -325,7 +325,7 @@ static void Tracing_ ## _api _args { \
#define TRACE_GL(_type, _api, _args, _argList, ...) \
static _type Tracing_ ## _api _args { \
- TraceGL(#_api, __VA_ARGS__); \
+ TraceGL(#_api, __VA_ARGS__); \
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
return _c->_api _argList; \
}
@@ -333,11 +333,11 @@ static _type Tracing_ ## _api _args { \
extern "C" {
#include "../trace.in"
}
+
#undef TRACE_GL_VOID
#undef TRACE_GL
#define GL_ENTRY(_r, _api, ...) Tracing_ ## _api,
-
EGLAPI gl_hooks_t gHooksTrace = {
{
#include "entries.in"
@@ -348,6 +348,48 @@ EGLAPI gl_hooks_t gHooksTrace = {
};
#undef GL_ENTRY
+
+#undef TRACE_GL_VOID
+#undef TRACE_GL
+
+// define the ES 1.0 Debug_gl* functions as Tracing_gl functions
+#define TRACE_GL_VOID(_api, _args, _argList, ...) \
+static void Debug_ ## _api _args { \
+ TraceGL(#_api, __VA_ARGS__); \
+ gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
+ _c->_api _argList; \
+}
+
+#define TRACE_GL(_type, _api, _args, _argList, ...) \
+static _type Debug_ ## _api _args { \
+ TraceGL(#_api, __VA_ARGS__); \
+ gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
+ return _c->_api _argList; \
+}
+
+extern "C" {
+#include "../debug.in"
+}
+
+#undef TRACE_GL_VOID
+#undef TRACE_GL
+
+// declare all Debug_gl* functions
+#define GL_ENTRY(_r, _api, ...) _r Debug_##_api ( __VA_ARGS__ );
+#include "glesv2dbg_functions.h"
+#undef GL_ENTRY
+
+#define GL_ENTRY(_r, _api, ...) Debug_ ## _api,
+EGLAPI gl_hooks_t gHooksDebug = {
+ {
+ #include "entries.in"
+ },
+ {
+ {0}
+ }
+};
+#undef GL_ENTRY
+
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------