Merge "fix EGL debugger"

This commit is contained in:
Mathias Agopian 2011-09-19 14:46:40 -07:00 committed by Android (Google) Code Review
commit 2e176f34ca
8 changed files with 29 additions and 33 deletions

View File

@ -31,6 +31,9 @@ ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
endif
LOCAL_CFLAGS += -DLOG_TAG=\"libGLES2_dbg\"
# we need to access the private Bionic header <bionic_tls.h>
# on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER
# behavior from the bionic Android.mk file

View File

@ -30,13 +30,11 @@ DbgContext * getDbgContextThreadSpecific() {
}
DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
const unsigned MAX_VERTEX_ATTRIBS, const GLenum readFormat,
const GLenum readType)
const unsigned MAX_VERTEX_ATTRIBS)
: lzf_buf(NULL), lzf_readIndex(0), lzf_refSize(0), lzf_refBufSize(0)
, version(version), hooks(hooks)
, MAX_VERTEX_ATTRIBS(MAX_VERTEX_ATTRIBS)
, readFormat(readFormat), readType(readType)
, readBytesPerPixel(GetBytesPerPixel(readFormat, readType))
, readBytesPerPixel(4)
, captureSwap(0), captureDraw(0)
, vertexAttribs(new VertexAttrib[MAX_VERTEX_ATTRIBS])
, hasNonVBOAttribs(false), indexBuffers(NULL), indexBuffer(NULL)
@ -67,11 +65,7 @@ DbgContext* CreateDbgContext(const unsigned version, const gl_hooks_t * const ho
assert(GL_NO_ERROR == hooks->gl.glGetError());
GLint MAX_VERTEX_ATTRIBS = 0;
hooks->gl.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &MAX_VERTEX_ATTRIBS);
GLint readFormat, readType;
hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
hooks->gl.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
DbgContext* dbg = new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS, readFormat, readType);
DbgContext* dbg = new DbgContext(version, hooks, MAX_VERTEX_ATTRIBS);
glesv2debugger::Message msg, cmd;
msg.set_context_id(reinterpret_cast<int>(dbg));
msg.set_expect_response(false);
@ -100,33 +94,31 @@ unsigned GetBytesPerPixel(const GLenum format, const GLenum type)
{
switch (type) {
case GL_UNSIGNED_SHORT_5_6_5:
return 2;
case GL_UNSIGNED_SHORT_4_4_4_4:
return 2;
case GL_UNSIGNED_SHORT_5_5_5_1:
return 2;
case GL_UNSIGNED_BYTE:
break;
default:
assert(0);
LOGE("GetBytesPerPixel: unknown type %x", type);
}
switch (format) {
case GL_ALPHA:
return 1;
case GL_LUMINANCE:
return 1;
break;
case GL_LUMINANCE_ALPHA:
return 2;
case GL_RGB:
return 3;
case GL_RGBA:
case 0x80E1: // GL_BGRA_EXT
return 4;
default:
assert(0);
return 0;
LOGE("GetBytesPerPixel: unknown format %x", format);
}
return 1; // in doubt...
}
void DbgContext::Fetch(const unsigned index, std::string * const data) const

View File

@ -41,11 +41,11 @@ EGLBoolean Debug_eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
void * pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
dbg->hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2],
viewport[3], dbg->readFormat, dbg->readType, pixels);
viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, pixels);
dbg->CompressReadPixelBuffer(msg.mutable_data());
msg.set_data_type(msg.ReferencedImage);
msg.set_pixel_format(dbg->readFormat);
msg.set_pixel_type(dbg->readType);
msg.set_pixel_format(GL_RGBA);
msg.set_pixel_type(GL_UNSIGNED_BYTE);
msg.set_image_width(viewport[2]);
msg.set_image_height(viewport[3]);
}

View File

@ -87,7 +87,6 @@ public:
const unsigned int version; // 0 is GLES1, 1 is GLES2
const gl_hooks_t * const hooks;
const unsigned int MAX_VERTEX_ATTRIBS;
const GLenum readFormat, readType; // implementation supported glReadPixels
const unsigned int readBytesPerPixel;
unsigned int captureSwap; // number of eglSwapBuffers to glReadPixels
@ -124,8 +123,7 @@ public:
unsigned maxAttrib; // number of slots used by program
DbgContext(const unsigned version, const gl_hooks_t * const hooks,
const unsigned MAX_VERTEX_ATTRIBS, const GLenum readFormat,
const GLenum readType);
const unsigned MAX_VERTEX_ATTRIBS);
~DbgContext();
void Fetch(const unsigned index, std::string * const data) const;

View File

@ -77,7 +77,7 @@ void Debug_glDrawArrays(GLenum mode, GLint first, GLsizei count)
pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
Debug_glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
dbg->readFormat, dbg->readType, pixels);
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
break;
case glesv2debugger::Message_Function_SKIP:
@ -134,19 +134,22 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
msg.set_arg7(dbg->maxAttrib); // indicate capturing vertex data
std::string * const data = msg.mutable_data();
if (GL_UNSIGNED_BYTE == type) {
if (dbg->indexBuffer)
if (dbg->indexBuffer) {
FetchIndexed(count, (unsigned char *)dbg->indexBuffer->data +
(unsigned long)indices, data, dbg);
else
} else {
FetchIndexed(count, (unsigned char *)indices, data, dbg);
}
} else if (GL_UNSIGNED_SHORT == type) {
if (dbg->indexBuffer)
if (dbg->indexBuffer) {
FetchIndexed(count, (unsigned short *)((char *)dbg->indexBuffer->data +
(unsigned long)indices), data, dbg);
else
} else {
FetchIndexed(count, (unsigned short *)indices, data, dbg);
} else
}
} else {
assert(0);
}
void * pixels = NULL;
int viewport[4] = {};
@ -174,7 +177,7 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
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
// relying on separate call for transport, this would allow
// auto generated message loop using EXTEND_Debug macro
if (dbg->captureDraw > 0) {
dbg->captureDraw--;
@ -182,7 +185,7 @@ void Debug_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid*
pixels = dbg->GetReadPixelsBuffer(viewport[2] * viewport[3] *
dbg->readBytesPerPixel);
Debug_glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
dbg->readFormat, dbg->readType, pixels);
GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
break;
case glesv2debugger::Message_Function_SKIP:

View File

@ -29,7 +29,7 @@ protected:
gl_hooks_t hooks;
DbgContextTest()
: dbg(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE) {
: dbg(1, &hooks, 32) {
// You can do set-up work for each test here.
hooks.gl.glGetError = GetError;
}

View File

@ -151,7 +151,7 @@ protected:
virtual void SetUp() {
ServerFileTest::SetUp();
dbg = new DbgContext(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE);
dbg = new DbgContext(1, &hooks, 32);
ASSERT_NE((void *)NULL, dbg);
for (unsigned int i = 0; i < sizeof(hooks) / sizeof(void *); i++)
((void **)&hooks)[i] = reinterpret_cast<void *>(glNoop);

View File

@ -44,7 +44,7 @@ protected:
}
virtual void SetUp() {
dbg = new DbgContext(1, &hooks, 32, GL_RGBA, GL_UNSIGNED_BYTE);
dbg = new DbgContext(1, &hooks, 32);
ASSERT_TRUE(dbg != NULL);
for (unsigned int i = 0; i < sizeof(hooks) / sizeof(void *); i++)
((void **)&hooks)[i] = (void *)glNoop;