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

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

Merge "GLES2Dbg: send some GL implementation constants to client"

parents 96dfedc5 620676ee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ message Message
        TimeMode = 1; // arg0 = SYSTEM_TIME_* in utils/Timers.h
        ExpectResponse = 2; // arg0 = enum Function, arg1 = true/false
        CaptureSwap = 3; // arg0 = number of eglSwapBuffers to glReadPixels
        GLConstant = 4; // arg0 = GLenum, arg1 = constant; send GL impl. constants
    };
    optional Prop prop = 21; // used with SETPROP, value in arg0
    optional float clock = 22; // wall clock in seconds
+18 −1
Original line number Diff line number Diff line
@@ -71,7 +71,24 @@ DbgContext * CreateDbgContext(const pthread_key_t EGLThreadLocalStorageKey,
    GLint readFormat, readType;
    hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
    hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
    return new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS, readFormat, readType);
    DbgContext * const dbg = new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS, readFormat, readType);

    glesv2debugger::Message msg, cmd;
    msg.set_context_id(reinterpret_cast<int>(dbg));
    msg.set_expect_response(false);
    msg.set_type(msg.Response);
    msg.set_function(msg.SETPROP);
    msg.set_prop(msg.GLConstant);
    msg.set_arg0(GL_MAX_VERTEX_ATTRIBS);
    msg.set_arg1(MAX_VERTEX_ATTRIBS);
    Send(msg, cmd);

    GLint MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0;
    hooks->gl.glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &MAX_COMBINED_TEXTURE_IMAGE_UNITS);
    msg.set_arg0(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
    msg.set_arg1(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
    Send(msg, cmd);
    return dbg;
}

void DestroyDbgContext(DbgContext * const dbg)
+8 −6
Original line number Diff line number Diff line
@@ -477,6 +477,7 @@ bool Message_Prop_IsValid(int value) {
    case 1:
    case 2:
    case 3:
    case 4:
      return true;
    default:
      return false;
@@ -488,6 +489,7 @@ const Message_Prop Message::CaptureDraw;
const Message_Prop Message::TimeMode;
const Message_Prop Message::ExpectResponse;
const Message_Prop Message::CaptureSwap;
const Message_Prop Message::GLConstant;
const Message_Prop Message::Prop_MIN;
const Message_Prop Message::Prop_MAX;
const int Message::Prop_ARRAYSIZE;
+6 −4
Original line number Diff line number Diff line
@@ -258,11 +258,12 @@ enum Message_Prop {
  Message_Prop_CaptureDraw = 0,
  Message_Prop_TimeMode = 1,
  Message_Prop_ExpectResponse = 2,
  Message_Prop_CaptureSwap = 3
  Message_Prop_CaptureSwap = 3,
  Message_Prop_GLConstant = 4
};
bool Message_Prop_IsValid(int value);
const Message_Prop Message_Prop_Prop_MIN = Message_Prop_CaptureDraw;
const Message_Prop Message_Prop_Prop_MAX = Message_Prop_CaptureSwap;
const Message_Prop Message_Prop_Prop_MAX = Message_Prop_GLConstant;
const int Message_Prop_Prop_ARRAYSIZE = Message_Prop_Prop_MAX + 1;

// ===================================================================
@@ -544,6 +545,7 @@ class Message : public ::google::protobuf::MessageLite {
  static const Prop TimeMode = Message_Prop_TimeMode;
  static const Prop ExpectResponse = Message_Prop_ExpectResponse;
  static const Prop CaptureSwap = Message_Prop_CaptureSwap;
  static const Prop GLConstant = Message_Prop_GLConstant;
  static inline bool Prop_IsValid(int value) {
    return Message_Prop_IsValid(value);
  }
+15 −5
Original line number Diff line number Diff line
@@ -159,8 +159,17 @@ bool TryReceive(glesv2debugger::Message & cmd)

float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
{
    // TODO: use per DbgContext send/receive buffer and async socket
    //  instead of mutex and blocking io; watch out for large messages
    static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
    pthread_mutex_lock(&mutex); // TODO: this is just temporary
    struct Autolock {
        Autolock() {
            pthread_mutex_lock(&mutex);
        }
        ~Autolock() {
            pthread_mutex_unlock(&mutex);
        }
    } autolock;

    if (msg.function() != glesv2debugger::Message_Function_ACK)
        assert(msg.has_context_id() && msg.context_id() != 0);
@@ -176,7 +185,6 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
                Die("MAX_FILE_SIZE reached");
            }
        }
        pthread_mutex_unlock(&mutex);
        return 0;
    }
    int sent = -1;
@@ -192,7 +200,11 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
        LOGD("actual sent=%d expected=%d clientSock=%d", sent, str.length(), clientSock);
        Die("Failed to send message");
    }

    // TODO: factor Receive & TryReceive out and into MessageLoop, or add control argument.
    // mean while, if server is sending a SETPROP then don't try to receive,
    //  because server will not be processing received command
    if (msg.function() == msg.SETPROP)
        return t;
    // try to receive commands even though not expecting response,
    //  since client can send SETPROP and other commands anytime
    if (!msg.expect_response()) {
@@ -204,8 +216,6 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
        }
    } else
        Receive(cmd);

    pthread_mutex_unlock(&mutex);
    return t;
}

Loading