Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f8d4e01 authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

Revert "Revert "Remove GLTrace support""

This reverts commit e6288e26.

Change-Id: Id50a7d471536150bb9e0393e159d66475aa4f473
parent e6288e26
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -27,12 +27,11 @@ LOCAL_SRC_FILES:= \
	EGL/egl_object.cpp     \
	EGL/egl.cpp 	       \
	EGL/eglApi.cpp 	       \
	EGL/trace.cpp              \
	EGL/getProcAddress.cpp.arm \
	EGL/Loader.cpp 	       \
#

LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libGLES_trace
LOCAL_SHARED_LIBRARIES += libcutils libutils liblog
LOCAL_MODULE:= libEGL
LOCAL_LDFLAGS += -Wl,--exclude-libs=ALL
LOCAL_SHARED_LIBRARIES += libdl
@@ -42,7 +41,6 @@ LOCAL_C_INCLUDES += bionic/libc/private
LOCAL_CFLAGS += -DLOG_TAG=\"libEGL\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += -DEGL_TRACE=1

ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true)
  LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION
+0 −3
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@

#include <EGL/egl.h>

#include "../glestrace.h"

#include "egldefs.h"
#include "Loader.h"

@@ -158,7 +156,6 @@ Loader::Loader()
}

Loader::~Loader() {
    GLTrace_stop();
}

static void* load_wrapper(const char* path) {
+0 −156
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include <utils/String8.h>

#include "../egl_impl.h"
#include "../glestrace.h"

#include "egl_tls.h"
#include "egldefs.h"
@@ -54,161 +53,10 @@ pthread_key_t gGLWrapperKey = -1;

// ----------------------------------------------------------------------------

#if EGL_TRACE

EGLAPI pthread_key_t gGLTraceKey = -1;

// ----------------------------------------------------------------------------

/**
 * There are three different tracing methods:
 * 1. libs/EGL/trace.cpp: Traces all functions to systrace.
 *    To enable:
 *      - set system property "debug.egl.trace" to "systrace" to trace all apps.
 * 2. libs/EGL/trace.cpp: Logs a stack trace for GL errors after each function call.
 *    To enable:
 *      - set system property "debug.egl.trace" to "error" to trace all apps.
 * 3. libs/EGL/trace.cpp: Traces all functions to logcat.
 *    To enable:
 *      - set system property "debug.egl.trace" to 1 to trace all apps.
 *      - or call setGLTraceLevel(1) from an app to enable tracing for that app.
 * 4. libs/GLES_trace: Traces all functions via protobuf to host.
 *    To enable:
 *        - set system property "debug.egl.debug_proc" to the application name.
 *      - or call setGLDebugLevel(1) from the app.
 */
static int sEGLTraceLevel;
static int sEGLApplicationTraceLevel;

static bool sEGLSystraceEnabled;
static bool sEGLGetErrorEnabled;

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);
}

gl_hooks_t const* getGLTraceThreadSpecific() {
    return static_cast<gl_hooks_t*>(pthread_getspecific(gGLTraceKey));
}

void initEglTraceLevel() {
    char value[PROPERTY_VALUE_MAX];
    property_get("debug.egl.trace", value, "0");

    sEGLGetErrorEnabled = !strcasecmp(value, "error");
    if (sEGLGetErrorEnabled) {
        sEGLSystraceEnabled = false;
        sEGLTraceLevel = 0;
        return;
    }

    sEGLSystraceEnabled = !strcasecmp(value, "systrace");
    if (sEGLSystraceEnabled) {
        sEGLTraceLevel = 0;
        return;
    }

    int propertyLevel = atoi(value);
    int applicationLevel = sEGLApplicationTraceLevel;
    sEGLTraceLevel = propertyLevel > applicationLevel ? propertyLevel : applicationLevel;
}

void initEglDebugLevel() {
    if (getEGLDebugLevel() == 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;

        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);
            }
        }
    }

    if (getEGLDebugLevel() > 0) {
        if (GLTrace_start() < 0) {
            ALOGE("Error starting Tracer for OpenGL ES. Disabling..");
            setEGLDebugLevel(0);
        }
    }
}

void setGLHooksThreadSpecific(gl_hooks_t const *value) {
    if (sEGLGetErrorEnabled) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksErrorTrace);
    } else if (sEGLSystraceEnabled) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksSystrace);
    } else if (sEGLTraceLevel > 0) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksTrace);
    } else if (getEGLDebugLevel() > 0 && value != &gHooksNoContext) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(GLTrace_getGLHooks());
    } else {
        setGlTraceThreadSpecific(NULL);
        setGlThreadSpecific(value);
    }
}

/*
 * Global entry point to allow applications to modify their own trace level.
 * The effective trace level is the max of this level and the value of debug.egl.trace.
 */
extern "C"
void setGLTraceLevel(int level) {
    sEGLApplicationTraceLevel = 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) {
    setEGLDebugLevel(level);
}

#else

void setGLHooksThreadSpecific(gl_hooks_t const *value) {
    setGlThreadSpecific(value);
}

#endif

/*****************************************************************************/

static int gl_no_context() {
@@ -231,10 +79,6 @@ static int gl_no_context() {

static void early_egl_init(void)
{
#if EGL_TRACE
    pthread_key_create(&gGLTraceKey, NULL);
    initEglTraceLevel();
#endif
    int numHooks = sizeof(gHooksNoContext) / sizeof(EGLFuncPointer);
    EGLFuncPointer *iter = reinterpret_cast<EGLFuncPointer*>(&gHooksNoContext);
    for (int hook = 0; hook < numHooks; ++hook) {
+0 −52
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@
#include <utils/Trace.h>

#include "../egl_impl.h"
#include "../glestrace.h"
#include "../hooks.h"

#include "egl_display.h"
@@ -231,8 +230,6 @@ static void(*findProcAddress(const char* name,
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);
extern EGLBoolean egl_init_drivers();
extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS];
extern int getEGLDebugLevel();
extern void setEGLDebugLevel(int level);
extern gl_hooks_t gHooksTrace;

} // namespace android;
@@ -683,10 +680,6 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
            }
            egl_context_t* c = new egl_context_t(dpy, context, config, cnx,
                    version);
#if EGL_TRACE
            if (getEGLDebugLevel() > 0)
                GLTrace_eglCreateContext(version, c);
#endif
            return c;
        }
    }
@@ -792,10 +785,6 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
        if (c) {
            setGLHooksThreadSpecific(c->cnx->hooks[c->version]);
            egl_tls_t::setContext(ctx);
#if EGL_TRACE
            if (getEGLDebugLevel() > 0)
                GLTrace_eglMakeCurrent(c->version, c->cnx->hooks[c->version], ctx);
#endif
            _c.acquire();
            _r.acquire();
            _d.acquire();
@@ -980,10 +969,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
                "no more slots for eglGetProcAddress(\"%s\")",
                procname);

#if EGL_TRACE
        gl_hooks_t *debugHooks = GLTrace_getGLHooks();
#endif

        if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) {
            bool found = false;

@@ -993,10 +978,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
                addr =
                cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] =
                cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
                debugHooks->ext.extensions[slot] =
                gHooksTrace.ext.extensions[slot] =
#endif
                        cnx->egl.eglGetProcAddress(procname);
                if (addr) found = true;
            }
@@ -1088,34 +1069,6 @@ EGLBoolean eglSwapBuffersWithDamageKHR(EGLDisplay dpy, EGLSurface draw,
    if (!_s.get())
        return setError(EGL_BAD_SURFACE, EGL_FALSE);

#if EGL_TRACE
    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)) {
@@ -1365,11 +1318,6 @@ EGLBoolean eglReleaseThread(void)
{
    clearError();

#if EGL_TRACE
    if (getEGLDebugLevel() > 0)
        GLTrace_eglReleaseThread();
#endif

    // If there is context bound to the thread, release it
    egl_display_t::loseCurrent(get_context(getContext()));

+0 −11
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ static char const * const sClientApiString = "OpenGL_ES";
extern char const * const gBuiltinExtensionString;
extern char const * const gExtensionString;

extern void initEglTraceLevel();
extern void initEglDebugLevel();
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);

// ----------------------------------------------------------------------------
@@ -139,15 +137,6 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
    {
        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();

#endif

        setGLHooksThreadSpecific(&gHooksNoContext);

        // initialize each EGL and
Loading