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

Commit e9f619f0 authored by David Li's avatar David Li
Browse files

GLES2Dbg: initial tests

Change-Id: Ibf07eff68d39267fd5c9bec2870f59a5ae2f51e3
parent 8f048419
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -45,3 +45,5 @@ LOCAL_MODULE:= libGLESv2_dbg
LOCAL_MODULE_TAGS := optional

include $(BUILD_SHARED_LIBRARY)

include $(LOCAL_PATH)/test/Android.mk
+34 −3
Original line number Diff line number Diff line
@@ -25,11 +25,11 @@ extern "C"
namespace android
{

static pthread_key_t sEGLThreadLocalStorageKey = -1;
pthread_key_t dbgEGLThreadLocalStorageKey = -1;

DbgContext * getDbgContextThreadSpecific()
{
    tls_t* tls = (tls_t*)pthread_getspecific(sEGLThreadLocalStorageKey);
    tls_t* tls = (tls_t*)pthread_getspecific(dbgEGLThreadLocalStorageKey);
    return tls->dbg;
}

@@ -63,7 +63,7 @@ DbgContext::~DbgContext()
DbgContext * CreateDbgContext(const pthread_key_t EGLThreadLocalStorageKey,
                              const unsigned version, const gl_hooks_t * const hooks)
{
    sEGLThreadLocalStorageKey = EGLThreadLocalStorageKey;
    dbgEGLThreadLocalStorageKey = EGLThreadLocalStorageKey;
    assert(version < 2);
    assert(GL_NO_ERROR == hooks->gl.glGetError());
    GLint MAX_VERTEX_ATTRIBS = 0;
@@ -149,6 +149,37 @@ void DbgContext::Compress(const void * in_data, unsigned int in_len,
    }
}

unsigned char * DbgContext::Decompress(const void * in, const unsigned int inLen,
                                       unsigned int * const outLen)
{
    assert(inLen > 4 * 3);
    if (inLen < 4 * 3)
        return NULL;
    *outLen = *(uint32_t *)in;
    unsigned char * const out = (unsigned char *)malloc(*outLen);
    unsigned int outPos = 0;
    const unsigned char * const end = (const unsigned char *)in + inLen;
    for (const unsigned char * inData = (const unsigned char *)in + 4; inData < end; ) {
        const uint32_t chunkOut = *(uint32_t *)inData;
        inData += 4;
        const uint32_t chunkIn = *(uint32_t *)inData;
        inData += 4;
        if (chunkIn > 0) {
            assert(inData + chunkIn <= end);
            assert(outPos + chunkOut <= *outLen);
            outPos += lzf_decompress(inData, chunkIn, out + outPos, chunkOut);
            inData += chunkIn;
        } else {
            assert(inData + chunkOut <= end);
            assert(outPos + chunkOut <= *outLen);
            memcpy(out + outPos, inData, chunkOut);
            inData += chunkOut;
            outPos += chunkOut;
        }
    }
    return out;
}

void * DbgContext::GetReadPixelsBuffer(const unsigned size)
{
    if (lzf_refBufSize < size + 8) {
+4 −1
Original line number Diff line number Diff line
@@ -73,8 +73,9 @@ struct GLFunctionBitfield {
};

struct DbgContext {
private:
    static const unsigned int LZF_CHUNK_SIZE = 256 * 1024;

private:
    char * lzf_buf; // malloc / free; for lzf chunk compression and other uses

    // used as buffer and reference frame for ReadPixels; malloc/free
@@ -129,6 +130,8 @@ public:

    void Fetch(const unsigned index, std::string * const data) const;
    void Compress(const void * in_data, unsigned in_len, std::string * const outStr);
    static unsigned char * Decompress(const void * in, const unsigned int inLen,
                                      unsigned int * const outLen); // malloc/free
    void * GetReadPixelsBuffer(const unsigned size);
    bool IsReadPixelBuffer(const void * const ptr)  {
        return ptr == lzf_ref[lzf_readIndex];
+3 −2
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
        Die("Failed to send message length");
    }
    nsecs_t c0 = systemTime(timeMode);
    sent = send(clientSock, str.c_str(), str.length(), 0);
    sent = send(clientSock, str.data(), str.length(), 0);
    float t = (float)ns2ms(systemTime(timeMode) - c0);
    if (sent != str.length()) {
        LOGD("actual sent=%d expected=%d clientSock=%d", sent, str.length(), clientSock);
@@ -246,8 +246,9 @@ int * MessageLoop(FunctionCall & functionCall, glesv2debugger::Message & msg,
    msg.set_function(function);

    // when not exectResponse, set cmd to CONTINUE then SKIP
    // cmd will be overwritten by received command
    cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
    cmd.set_expect_response(false);
    cmd.set_expect_response(expectResponse);
    glesv2debugger::Message_Function oldCmd = cmd.function();
    Send(msg, cmd);
    expectResponse = cmd.expect_response();
+4 −12
Original line number Diff line number Diff line
@@ -43,10 +43,8 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)

    void * pixels = NULL;
    int viewport[4] = {};
    if (!expectResponse) {
    cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
        cmd.set_expect_response(false);
    }
    cmd.set_expect_response(expectResponse);
    glesv2debugger::Message_Function oldCmd = cmd.function();
    Send(msg, cmd);
    expectResponse = cmd.expect_response();
@@ -61,8 +59,6 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
            msg.set_function(glesv2debugger::Message_Function_glDrawArrays);
            msg.set_type(glesv2debugger::Message_Type_AfterCall);
            msg.set_expect_response(expectResponse);
            if (!expectResponse)
                cmd.set_function(glesv2debugger::Message_Function_SKIP);
            if (!expectResponse) {
                cmd.set_function(glesv2debugger::Message_Function_SKIP);
                cmd.set_expect_response(false);
@@ -154,10 +150,8 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*

    void * pixels = NULL;
    int viewport[4] = {};
    if (!expectResponse) {
    cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
        cmd.set_expect_response(false);
    }
    cmd.set_expect_response(expectResponse);
    glesv2debugger::Message_Function oldCmd = cmd.function();
    Send(msg, cmd);
    expectResponse = cmd.expect_response();
@@ -172,8 +166,6 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
            msg.set_function(glesv2debugger::Message_Function_glDrawElements);
            msg.set_type(glesv2debugger::Message_Type_AfterCall);
            msg.set_expect_response(expectResponse);
            if (!expectResponse)
                cmd.set_function(glesv2debugger::Message_Function_SKIP);
            if (!expectResponse) {
                cmd.set_function(glesv2debugger::Message_Function_SKIP);
                cmd.set_expect_response(false);
Loading