summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES2_dbg/src
diff options
context:
space:
mode:
authorDavid Li <davidxli@google.com>2011-04-08 18:41:00 -0700
committerDavid Li <davidxli@google.com>2011-04-12 15:56:10 -0700
commite2ad4d0e3748c2f0180d24d1b3468aac79adac3a (patch)
treebfa8647edf051ce768ee9c855d7d488924fc1377 /opengl/libs/GLES2_dbg/src
parentce30eb8a90a1ac458e15e773057a8a73b0918ae6 (diff)
downloadframeworks_base-e2ad4d0e3748c2f0180d24d1b3468aac79adac3a.zip
frameworks_base-e2ad4d0e3748c2f0180d24d1b3468aac79adac3a.tar.gz
frameworks_base-e2ad4d0e3748c2f0180d24d1b3468aac79adac3a.tar.bz2
GLES2Dbg: add EXTEND_AFTER_CALL_Debug_* macro and improve protocol
To allow auto generate of Debug_glReadPixels function. Also added AfterGeneratedCall messag type, and client override of expectResponse for improving protocol. Also implemented callers for client to get shader/program iv & infolog Change-Id: I8426de0be4b7ffcb8b2b4f063ad85d19a9d2d72e Signed-off-by: David Li <davidxli@google.com>
Diffstat (limited to 'opengl/libs/GLES2_dbg/src')
-rw-r--r--opengl/libs/GLES2_dbg/src/api.cpp68
-rw-r--r--opengl/libs/GLES2_dbg/src/api.h13
-rw-r--r--opengl/libs/GLES2_dbg/src/caller.cpp2
-rw-r--r--opengl/libs/GLES2_dbg/src/caller.h18
-rw-r--r--opengl/libs/GLES2_dbg/src/dbgcontext.cpp23
-rw-r--r--opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp2
-rw-r--r--opengl/libs/GLES2_dbg/src/debugger_message.pb.h4
-rw-r--r--opengl/libs/GLES2_dbg/src/header.h4
-rw-r--r--opengl/libs/GLES2_dbg/src/server.cpp35
-rw-r--r--opengl/libs/GLES2_dbg/src/vertex.cpp119
10 files changed, 202 insertions, 86 deletions
diff --git a/opengl/libs/GLES2_dbg/src/api.cpp b/opengl/libs/GLES2_dbg/src/api.cpp
index e26e1d7..c483547 100644
--- a/opengl/libs/GLES2_dbg/src/api.cpp
+++ b/opengl/libs/GLES2_dbg/src/api.cpp
@@ -597,6 +597,9 @@ void Debug_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, G
const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
_c->glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+#ifdef EXTEND_AFTER_CALL_Debug_glCopyTexImage2D
+ EXTEND_AFTER_CALL_Debug_glCopyTexImage2D;
+#endif
return 0;
}
} caller;
@@ -618,7 +621,9 @@ void Debug_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, G
msg.set_arg6(height);
msg.set_arg7(border);
+#ifdef EXTEND_Debug_glCopyTexImage2D
EXTEND_Debug_glCopyTexImage2D;
+#endif
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glCopyTexImage2D);
}
@@ -637,6 +642,9 @@ void Debug_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
_c->glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+#ifdef EXTEND_AFTER_CALL_Debug_glCopyTexSubImage2D
+ EXTEND_AFTER_CALL_Debug_glCopyTexSubImage2D;
+#endif
return 0;
}
} caller;
@@ -658,7 +666,9 @@ void Debug_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
msg.set_arg6(width);
msg.set_arg7(height);
+#ifdef EXTEND_Debug_glCopyTexSubImage2D
EXTEND_Debug_glCopyTexSubImage2D;
+#endif
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glCopyTexSubImage2D);
}
@@ -2169,6 +2179,49 @@ void Debug_glPolygonOffset(GLfloat factor, GLfloat units)
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glPolygonOffset);
}
+void Debug_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+{
+ glesv2debugger::Message msg;
+ struct : public FunctionCall {
+ GLint x;
+ GLint y;
+ GLsizei width;
+ GLsizei height;
+ GLenum format;
+ GLenum type;
+ GLvoid* pixels;
+
+ const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
+ _c->glReadPixels(x, y, width, height, format, type, pixels);
+#ifdef EXTEND_AFTER_CALL_Debug_glReadPixels
+ EXTEND_AFTER_CALL_Debug_glReadPixels;
+#endif
+ return 0;
+ }
+ } caller;
+ caller.x = x;
+ caller.y = y;
+ caller.width = width;
+ caller.height = height;
+ caller.format = format;
+ caller.type = type;
+ caller.pixels = pixels;
+
+ msg.set_arg0(x);
+ msg.set_arg1(y);
+ msg.set_arg2(width);
+ msg.set_arg3(height);
+ msg.set_arg4(format);
+ msg.set_arg5(type);
+ msg.set_arg6(ToInt(pixels));
+
+ // FIXME: check for pointer usage
+#ifdef EXTEND_Debug_glReadPixels
+ EXTEND_Debug_glReadPixels;
+#endif
+ int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glReadPixels);
+}
+
void Debug_glReleaseShaderCompiler(void)
{
glesv2debugger::Message msg;
@@ -2302,6 +2355,9 @@ void Debug_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, c
const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
_c->glShaderSource(shader, count, string, length);
+#ifdef EXTEND_AFTER_CALL_Debug_glShaderSource
+ EXTEND_AFTER_CALL_Debug_glShaderSource;
+#endif
return 0;
}
} caller;
@@ -2316,7 +2372,9 @@ void Debug_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, c
msg.set_arg3(ToInt(length));
// FIXME: check for pointer usage
+#ifdef EXTEND_Debug_glShaderSource
EXTEND_Debug_glShaderSource;
+#endif
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glShaderSource);
}
@@ -2477,6 +2535,9 @@ void Debug_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsize
const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
_c->glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+#ifdef EXTEND_AFTER_CALL_Debug_glTexImage2D
+ EXTEND_AFTER_CALL_Debug_glTexImage2D;
+#endif
return 0;
}
} caller;
@@ -2501,7 +2562,9 @@ void Debug_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsize
msg.set_arg8(ToInt(pixels));
// FIXME: check for pointer usage
+#ifdef EXTEND_Debug_glTexImage2D
EXTEND_Debug_glTexImage2D;
+#endif
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glTexImage2D);
}
@@ -2621,6 +2684,9 @@ void Debug_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) {
_c->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+#ifdef EXTEND_AFTER_CALL_Debug_glTexSubImage2D
+ EXTEND_AFTER_CALL_Debug_glTexSubImage2D;
+#endif
return 0;
}
} caller;
@@ -2645,7 +2711,9 @@ void Debug_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
msg.set_arg8(ToInt(pixels));
// FIXME: check for pointer usage
+#ifdef EXTEND_Debug_glTexSubImage2D
EXTEND_Debug_glTexSubImage2D;
+#endif
int * ret = MessageLoop(caller, msg, glesv2debugger::Message_Function_glTexSubImage2D);
}
diff --git a/opengl/libs/GLES2_dbg/src/api.h b/opengl/libs/GLES2_dbg/src/api.h
index b9fc341..2afbe35 100644
--- a/opengl/libs/GLES2_dbg/src/api.h
+++ b/opengl/libs/GLES2_dbg/src/api.h
@@ -29,6 +29,19 @@
#define EXTEND_Debug_glCopyTexSubImage2D EXTEND_Debug_glCopyTexImage2D
+#define EXTEND_AFTER_CALL_Debug_glReadPixels \
+ { \
+ DbgContext * const dbg = getDbgContextThreadSpecific(); \
+ if (dbg->IsReadPixelBuffer(pixels)) { \
+ dbg->CompressReadPixelBuffer(msg.mutable_data()); \
+ msg.set_data_type(msg.ReferencedImage); \
+ } else { \
+ const unsigned int size = width * height * GetBytesPerPixel(format, type); \
+ dbg->Compress(pixels, size, msg.mutable_data()); \
+ msg.set_data_type(msg.NonreferencedImage); \
+ } \
+ }
+
#define EXTEND_Debug_glShaderSource \
std::string * const data = msg.mutable_data(); \
for (unsigned i = 0; i < count; i++) \
diff --git a/opengl/libs/GLES2_dbg/src/caller.cpp b/opengl/libs/GLES2_dbg/src/caller.cpp
index ad9440b..6b72751 100644
--- a/opengl/libs/GLES2_dbg/src/caller.cpp
+++ b/opengl/libs/GLES2_dbg/src/caller.cpp
@@ -771,7 +771,7 @@ const int * GenerateCall(DbgContext * const dbg, const glesv2debugger::Message &
msg.set_time((systemTime(timeMode) - c0) * 1e-6f);
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_function(cmd.function());
- msg.set_type(glesv2debugger::Message_Type_AfterCall);
+ msg.set_type(glesv2debugger::Message_Type_AfterGeneratedCall);
return ret;
}
diff --git a/opengl/libs/GLES2_dbg/src/caller.h b/opengl/libs/GLES2_dbg/src/caller.h
index 5447757..e8111b3 100644
--- a/opengl/libs/GLES2_dbg/src/caller.h
+++ b/opengl/libs/GLES2_dbg/src/caller.h
@@ -138,7 +138,9 @@ static const int * GenerateCall_glGetProgramiv(DbgContext * const dbg,
const glesv2debugger::Message & cmd,
glesv2debugger::Message & msg, const int * const prevRet)
{
- assert(0);
+ GLint params = -1;
+ dbg->hooks->gl.glGetProgramiv(cmd.arg0(), cmd.arg1(), &params);
+ msg.mutable_data()->append(reinterpret_cast<char *>(&params), sizeof(params));
return prevRet;
}
@@ -146,7 +148,10 @@ static const int * GenerateCall_glGetProgramInfoLog(DbgContext * const dbg,
const glesv2debugger::Message & cmd,
glesv2debugger::Message & msg, const int * const prevRet)
{
- assert(0);
+ const GLsizei bufSize = static_cast<GLsizei>(dbg->GetBufferSize());
+ GLsizei length = -1;
+ dbg->hooks->gl.glGetProgramInfoLog(cmd.arg0(), bufSize, &length, dbg->GetBuffer());
+ msg.mutable_data()->append(dbg->GetBuffer(), length);
return prevRet;
}
@@ -162,7 +167,9 @@ static const int * GenerateCall_glGetShaderiv(DbgContext * const dbg,
const glesv2debugger::Message & cmd,
glesv2debugger::Message & msg, const int * const prevRet)
{
- assert(0);
+ GLint params = -1;
+ dbg->hooks->gl.glGetShaderiv(cmd.arg0(), cmd.arg1(), &params);
+ msg.mutable_data()->append(reinterpret_cast<char *>(&params), sizeof(params));
return prevRet;
}
@@ -170,7 +177,10 @@ static const int * GenerateCall_glGetShaderInfoLog(DbgContext * const dbg,
const glesv2debugger::Message & cmd,
glesv2debugger::Message & msg, const int * const prevRet)
{
- assert(0);
+ const GLsizei bufSize = static_cast<GLsizei>(dbg->GetBufferSize());
+ GLsizei length = -1;
+ dbg->hooks->gl.glGetShaderInfoLog(cmd.arg0(), bufSize, &length, dbg->GetBuffer());
+ msg.mutable_data()->append(dbg->GetBuffer(), length);
return prevRet;
}
diff --git a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
index 40a77d7..eb0e1a9 100644
--- a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
+++ b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
@@ -124,6 +124,7 @@ void DbgContext::Compress(const void * in_data, unsigned int in_len,
{
if (!lzf_buf)
lzf_buf = (char *)malloc(LZF_CHUNK_SIZE);
+ assert(lzf_buf);
const uint32_t totalDecompSize = in_len;
outStr->append((const char *)&totalDecompSize, sizeof(totalDecompSize));
for (unsigned int i = 0; i < in_len; i += LZF_CHUNK_SIZE) {
@@ -146,8 +147,10 @@ void * DbgContext::GetReadPixelsBuffer(const unsigned size)
if (lzf_refBufSize < size + 8) {
lzf_refBufSize = size + 8;
lzf_ref[0] = (unsigned *)realloc(lzf_ref[0], lzf_refBufSize);
+ assert(lzf_ref[0]);
memset(lzf_ref[0], 0, lzf_refBufSize);
lzf_ref[1] = (unsigned *)realloc(lzf_ref[1], lzf_refBufSize);
+ assert(lzf_ref[1]);
memset(lzf_ref[1], 0, lzf_refBufSize);
}
if (lzf_refSize != size) // need to clear unused ref to maintain consistency
@@ -162,6 +165,7 @@ void * DbgContext::GetReadPixelsBuffer(const unsigned size)
void DbgContext::CompressReadPixelBuffer(std::string * const outStr)
{
+ assert(lzf_ref[0] && lzf_ref[1]);
unsigned * const ref = lzf_ref[lzf_readIndex ^ 1];
unsigned * const src = lzf_ref[lzf_readIndex];
for (unsigned i = 0; i < lzf_refSize / sizeof(*ref) + 1; i++)
@@ -169,6 +173,25 @@ void DbgContext::CompressReadPixelBuffer(std::string * const outStr)
Compress(ref, lzf_refSize, outStr);
}
+char * DbgContext::GetBuffer()
+{
+ if (!lzf_buf)
+ lzf_buf = (char *)malloc(LZF_CHUNK_SIZE);
+ assert(lzf_buf);
+ return lzf_buf;
+}
+
+unsigned int DbgContext::GetBufferSize()
+{
+ if (!lzf_buf)
+ lzf_buf = (char *)malloc(LZF_CHUNK_SIZE);
+ assert(lzf_buf);
+ if (lzf_buf)
+ return LZF_CHUNK_SIZE;
+ else
+ return 0;
+}
+
void DbgContext::glUseProgram(GLuint program)
{
while (GLenum error = hooks->gl.glGetError())
diff --git a/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp b/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
index 046c954..ee76847 100644
--- a/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
+++ b/opengl/libs/GLES2_dbg/src/debugger_message.pb.cpp
@@ -436,6 +436,7 @@ bool Message_Type_IsValid(int value) {
case 0:
case 1:
case 2:
+ case 3:
return true;
default:
return false;
@@ -445,6 +446,7 @@ bool Message_Type_IsValid(int value) {
#ifndef _MSC_VER
const Message_Type Message::BeforeCall;
const Message_Type Message::AfterCall;
+const Message_Type Message::AfterGeneratedCall;
const Message_Type Message::Response;
const Message_Type Message::Type_MIN;
const Message_Type Message::Type_MAX;
diff --git a/opengl/libs/GLES2_dbg/src/debugger_message.pb.h b/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
index b2ec5a0..63b952c 100644
--- a/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
+++ b/opengl/libs/GLES2_dbg/src/debugger_message.pb.h
@@ -236,7 +236,8 @@ const int Message_Function_Function_ARRAYSIZE = Message_Function_Function_MAX +
enum Message_Type {
Message_Type_BeforeCall = 0,
Message_Type_AfterCall = 1,
- Message_Type_Response = 2
+ Message_Type_AfterGeneratedCall = 2,
+ Message_Type_Response = 3
};
bool Message_Type_IsValid(int value);
const Message_Type Message_Type_Type_MIN = Message_Type_BeforeCall;
@@ -510,6 +511,7 @@ class Message : public ::google::protobuf::MessageLite {
typedef Message_Type Type;
static const Type BeforeCall = Message_Type_BeforeCall;
static const Type AfterCall = Message_Type_AfterCall;
+ static const Type AfterGeneratedCall = Message_Type_AfterGeneratedCall;
static const Type Response = Message_Type_Response;
static inline bool Type_IsValid(int value) {
return Message_Type_IsValid(value);
diff --git a/opengl/libs/GLES2_dbg/src/header.h b/opengl/libs/GLES2_dbg/src/header.h
index 9d51e8e..83ddf70 100644
--- a/opengl/libs/GLES2_dbg/src/header.h
+++ b/opengl/libs/GLES2_dbg/src/header.h
@@ -75,7 +75,7 @@ struct GLFunctionBitfield {
struct DbgContext {
private:
static const unsigned int LZF_CHUNK_SIZE = 256 * 1024;
- char * lzf_buf; // malloc / free; for lzf chunk compression
+ char * lzf_buf; // malloc / free; for lzf chunk compression and other uses
// used as buffer and reference frame for ReadPixels; malloc/free
unsigned * lzf_ref [2];
@@ -128,6 +128,8 @@ public:
return ptr == lzf_ref[lzf_readIndex];
}
void CompressReadPixelBuffer(std::string * const outStr);
+ char * GetBuffer(); // allocates lzf_buf if NULL
+ unsigned int GetBufferSize(); // allocates lzf_buf if NULL
void glUseProgram(GLuint program);
void glEnableVertexAttribArray(GLuint index);
diff --git a/opengl/libs/GLES2_dbg/src/server.cpp b/opengl/libs/GLES2_dbg/src/server.cpp
index 7039c84..e740e92 100644
--- a/opengl/libs/GLES2_dbg/src/server.cpp
+++ b/opengl/libs/GLES2_dbg/src/server.cpp
@@ -169,14 +169,13 @@ float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd)
}
// try to receive commands even though not expecting response,
- // since client can send SETPROP commands anytime
+ // since client can send SETPROP and other commands anytime
if (!msg.expect_response()) {
if (TryReceive(cmd)) {
- LOGD("Send: TryReceived");
if (glesv2debugger::Message_Function_SETPROP == cmd.function())
- LOGD("Send: received SETPROP");
+ LOGD("Send: TryReceived SETPROP");
else
- LOGD("Send: received something else");
+ LOGD("Send: TryReceived %u", cmd.function());
}
} else
Receive(cmd);
@@ -213,12 +212,16 @@ int * MessageLoop(FunctionCall & functionCall, glesv2debugger::Message & msg,
glesv2debugger::Message cmd;
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_type(glesv2debugger::Message_Type_BeforeCall);
- const bool expectResponse = dbg->expectResponse.Bit(function);
+ bool expectResponse = dbg->expectResponse.Bit(function);
msg.set_expect_response(expectResponse);
msg.set_function(function);
- if (!expectResponse)
- cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
+
+ // when not exectResponse, set cmd to CONTINUE then SKIP
+ cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
+ cmd.set_expect_response(false);
+ glesv2debugger::Message_Function oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
while (true) {
msg.Clear();
nsecs_t c0 = systemTime(timeMode);
@@ -233,22 +236,34 @@ int * MessageLoop(FunctionCall & functionCall, glesv2debugger::Message & msg,
msg.set_function(function);
msg.set_type(glesv2debugger::Message_Type_AfterCall);
msg.set_expect_response(expectResponse);
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(glesv2debugger::Message_Function_SKIP);
+ cmd.set_expect_response(false);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
break;
case glesv2debugger::Message_Function_SKIP:
return const_cast<int *>(ret);
case glesv2debugger::Message_Function_SETPROP:
SetProp(dbg, cmd);
- Receive(cmd);
+ expectResponse = cmd.expect_response();
+ if (!expectResponse) // SETPROP is "out of band"
+ cmd.set_function(oldCmd);
+ else
+ Receive(cmd);
break;
default:
ret = GenerateCall(dbg, cmd, msg, ret);
msg.set_expect_response(expectResponse);
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(cmd.SKIP);
+ cmd.set_expect_response(expectResponse);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
break;
}
}
diff --git a/opengl/libs/GLES2_dbg/src/vertex.cpp b/opengl/libs/GLES2_dbg/src/vertex.cpp
index 471e5ad..3abea67 100644
--- a/opengl/libs/GLES2_dbg/src/vertex.cpp
+++ b/opengl/libs/GLES2_dbg/src/vertex.cpp
@@ -21,74 +21,13 @@ namespace android
bool capture; // capture after each glDraw*
}
-void Debug_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
-{
- DbgContext * const dbg = getDbgContextThreadSpecific();
- glesv2debugger::Message msg, cmd;
- msg.set_context_id(reinterpret_cast<int>(dbg));
- msg.set_type(glesv2debugger::Message_Type_BeforeCall);
- const bool expectResponse = dbg->expectResponse.Bit(glesv2debugger::Message_Function_glReadPixels);
- msg.set_expect_response(expectResponse);
- msg.set_function(glesv2debugger::Message_Function_glReadPixels);
- msg.set_arg0(x);
- msg.set_arg1(y);
- msg.set_arg2(width);
- msg.set_arg3(height);
- msg.set_arg4(format);
- msg.set_arg5(type);
- msg.set_arg6(reinterpret_cast<int>(pixels));
-
- const unsigned size = width * height * GetBytesPerPixel(format, type);
- if (!expectResponse)
- cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
- Send(msg, cmd);
- float t = 0;
- while (true) {
- msg.Clear();
- nsecs_t c0 = systemTime(timeMode);
- switch (cmd.function()) {
- case glesv2debugger::Message_Function_CONTINUE:
- dbg->hooks->gl.glReadPixels(x, y, width, height, format, type, pixels);
- msg.set_time((systemTime(timeMode) - c0) * 1e-6f);
- msg.set_context_id(reinterpret_cast<int>(dbg));
- msg.set_function(glesv2debugger::Message_Function_glReadPixels);
- msg.set_type(glesv2debugger::Message_Type_AfterCall);
- msg.set_expect_response(expectResponse);
- if (dbg->IsReadPixelBuffer(pixels)) {
- dbg->CompressReadPixelBuffer(msg.mutable_data());
- msg.set_data_type(msg.ReferencedImage);
- } else {
- dbg->Compress(pixels, size, msg.mutable_data());
- msg.set_data_type(msg.NonreferencedImage);
- }
- if (!expectResponse)
- cmd.set_function(glesv2debugger::Message_Function_SKIP);
- Send(msg, cmd);
- break;
- case glesv2debugger::Message_Function_SKIP:
- return;
- case glesv2debugger::Message_Function_SETPROP:
- SetProp(dbg, cmd);
- Receive(cmd);
- break;
- default:
- GenerateCall(dbg, cmd, msg, NULL);
- msg.set_expect_response(expectResponse);
- if (!expectResponse)
- cmd.set_function(cmd.SKIP);
- Send(msg, cmd);
- break;
- }
- }
-}
-
void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
DbgContext * const dbg = getDbgContextThreadSpecific();
glesv2debugger::Message msg, cmd;
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_type(glesv2debugger::Message_Type_BeforeCall);
- const bool expectResponse = dbg->expectResponse.Bit(glesv2debugger::Message_Function_glDrawArrays);
+ bool expectResponse = dbg->expectResponse.Bit(glesv2debugger::Message_Function_glDrawArrays);
msg.set_expect_response(expectResponse);
msg.set_function(glesv2debugger::Message_Function_glDrawArrays);
msg.set_arg0(mode);
@@ -105,9 +44,13 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
void * pixels = NULL;
GLint readFormat = 0, readType = 0;
int viewport[4] = {};
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
+ cmd.set_expect_response(false);
+ }
+ glesv2debugger::Message_Function oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
while (true) {
msg.Clear();
nsecs_t c0 = systemTime(timeMode);
@@ -121,7 +64,16 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
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);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
+ // TODO: pack glReadPixels data with vertex data instead of
+ // relying on sperate call for transport, this would allow
+ // auto generated message loop using EXTEND_Debug macro
if (capture) {
dbg->hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport);
dbg->hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
@@ -138,14 +90,22 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
return;
case glesv2debugger::Message_Function_SETPROP:
SetProp(dbg, cmd);
- Receive(cmd);
+ expectResponse = cmd.expect_response();
+ if (!expectResponse) // SETPROP is "out of band"
+ cmd.set_function(oldCmd);
+ else
+ Receive(cmd);
break;
default:
GenerateCall(dbg, cmd, msg, NULL);
msg.set_expect_response(expectResponse);
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(cmd.SKIP);
+ cmd.set_expect_response(expectResponse);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
break;
}
}
@@ -169,7 +129,7 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
glesv2debugger::Message msg, cmd;
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_type(glesv2debugger::Message_Type_BeforeCall);
- const bool expectResponse = dbg->expectResponse.Bit(glesv2debugger::Message_Function_glDrawElements);
+ bool expectResponse = dbg->expectResponse.Bit(glesv2debugger::Message_Function_glDrawElements);
msg.set_expect_response(expectResponse);
msg.set_function(glesv2debugger::Message_Function_glDrawElements);
msg.set_arg0(mode);
@@ -197,9 +157,13 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
void * pixels = NULL;
GLint readFormat = 0, readType = 0;
int viewport[4] = {};
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(glesv2debugger::Message_Function_CONTINUE);
+ cmd.set_expect_response(false);
+ }
+ glesv2debugger::Message_Function oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
while (true) {
msg.Clear();
nsecs_t c0 = systemTime(timeMode);
@@ -213,7 +177,16 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
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);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
+ // TODO: pack glReadPixels data with vertex data instead of
+ // relying on sperate call for transport, this would allow
+ // auto generated message loop using EXTEND_Debug macro
if (capture) {
dbg->hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport);
dbg->hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
@@ -230,14 +203,22 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
return;
case glesv2debugger::Message_Function_SETPROP:
SetProp(dbg, cmd);
- Receive(cmd);
+ expectResponse = cmd.expect_response();
+ if (!expectResponse) // SETPROP is "out of band"
+ cmd.set_function(oldCmd);
+ else
+ Receive(cmd);
break;
default:
GenerateCall(dbg, cmd, msg, NULL);
msg.set_expect_response(expectResponse);
- if (!expectResponse)
+ if (!expectResponse) {
cmd.set_function(cmd.SKIP);
+ cmd.set_expect_response(expectResponse);
+ }
+ oldCmd = cmd.function();
Send(msg, cmd);
+ expectResponse = cmd.expect_response();
break;
}
}