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

Commit 1305ac5a authored by David Li's avatar David Li Committed by Android (Google) Code Review
Browse files

Merge "GLES2Debugger: Added DbgContext and vertex data capturing."

parents 6686201d 65948aa0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "egl_impl.h"

#include "Loader.h"
#include "glesv2dbg.h"

// ----------------------------------------------------------------------------
namespace android {
@@ -114,7 +115,6 @@ Loader::Loader()

Loader::~Loader()
{
    extern void StopDebugServer();
    StopDebugServer();
}

+17 −4
Original line number Diff line number Diff line
@@ -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
@@ -325,14 +333,12 @@ static void initEglTraceLevel() {
        char cmdline[256] = {};
        if (fgets(cmdline, sizeof(cmdline) - 1, file))
        {
            LOGD("\n*\n*\n* initEglTraceLevel cmdline='%s' \n*\n*", cmdline);
            if (!strcmp(value, cmdline))
                gEGLDebugLevel = 1;
        }    
        fclose(file);
    }
    
    extern void StartDebugServer();
    if (gEGLDebugLevel > 0)
        StartDebugServer();
}
@@ -341,7 +347,7 @@ static void setGLHooksThreadSpecific(gl_hooks_t const *value) {
    if (gEGLTraceLevel > 0) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksTrace);
    } else if (gEGLDebugLevel > 0) {
    } else if (gEGLDebugLevel > 0 && value != &gHooksNoContext) {
        setGlTraceThreadSpecific(value);
        setGlThreadSpecific(&gHooksDebug);
        LOGD("\n* setGLHooksThreadSpecific gHooksDebug");
@@ -586,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);
@@ -1393,6 +1404,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();
+1 −1
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ extern "C" {

// declare all Debug_gl* functions
#define GL_ENTRY(_r, _api, ...) _r Debug_##_api ( __VA_ARGS__ );
#include "../GLES2_dbg/include/glesv2_dbg.h"
#include "glesv2dbg_functions.h"
#undef GL_ENTRY

#define GL_ENTRY(_r, _api, ...) Debug_ ## _api,
+1 −1
Original line number Diff line number Diff line
@@ -4,10 +4,10 @@ include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
    src/api.cpp \
    src/dbgcontext.cpp \
    src/debugger_message.pb.cpp \
    src/egl.cpp \
    src/server.cpp \
    src/shader.cpp \
    src/texture.cpp \
    src/vertex.cpp

+24 −9
Original line number Diff line number Diff line
@@ -31,7 +31,16 @@ def generate_api(lines):
    externs = []
    i = 0
    # these have been hand written
    skipFunctions = ["glTexImage2D", "glTexSubImage2D", "glShaderSource", "glReadPixels", "glDrawArrays", "glDrawElements"]
    skipFunctions = ["glTexImage2D", "glTexSubImage2D", "glReadPixels",
"glDrawArrays", "glDrawElements"]
    
    # these have an EXTEND_Debug_* macro for getting data
    extendFunctions = ["glCopyTexImage2D", "glCopyTexSubImage2D", "glShaderSource"]
    
    # these also needs to be forwarded to DbgContext
    contextFunctions = ["glUseProgram", "glEnableVertexAttribArray", "glDisableVertexAttribArray", 
"glVertexAttribPointer", "glBindBuffer", "glBufferData", "glBufferSubData", "glDeleteBuffers",]
    
    for line in lines:
        if line.find("API_ENTRY(") >= 0: # a function prototype
            returnType = line[0: line.find(" API_ENTRY(")]
@@ -49,7 +58,8 @@ def generate_api(lines):
                
            parameters = parameterList.split(',')
            paramIndex = 0
            if line.find("*") >= 0 and (line.find("*") < line.find(":") or line.find("*") > line.rfind(":")):
            if line.find("*") >= 0 and (line.find("*") < line.find(":") or line.find("*") > line.rfind(":")): # unannotated pointer
                if not functionName in extendFunctions:
                    # add function to list of functions that should be hand written, but generate code anyways
                    extern = "%s Debug_%s(%s);" % (returnType, functionName, RemoveAnnotation(parameterList))
                    sys.stderr.write("%s should be hand written\n" % (extern))
@@ -132,6 +142,8 @@ def generate_api(lines):
            if inout in ["out", "inout"]:
                print "            msg.set_time((systemTime(timeMode) - c0) * 1e-6f);"
                print "        " + getData
            if functionName in contextFunctions:
                print "            getDbgContextThreadSpecific()->%s(%s);" % (functionName, arguments)
            if returnType == "void":
                print "            return 0;"
            else:
@@ -145,6 +157,8 @@ def generate_api(lines):
                print "    // FIXME: check for pointer usage"
            if inout in ["in", "inout"]:
                print getData
            if functionName in extendFunctions:
                print "    EXTEND_Debug_%s;" % (functionName) 
            print "    int * ret = MessageLoop(caller, msg, expectResponse,"
            print "                            glesv2debugger::Message_Function_%s);" % (functionName)
            if returnType != "void":
@@ -160,7 +174,7 @@ def generate_api(lines):
        print extern

if __name__ == "__main__":
    print """
    print """\
/*
 ** Copyright 2011, The Android Open Source Project
 **
@@ -180,6 +194,7 @@ if __name__ == "__main__":
// auto generated by generate_api_cpp.py

#include "src/header.h"
#include "src/api.h"

template<typename T> static int ToInt(const T & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (int &)t; }
template<typename T> static T FromInt(const int & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (T &)t; }
Loading