summaryrefslogtreecommitdiffstats
path: root/opengl/libs
diff options
context:
space:
mode:
authorBen Clayton <bclayton@google.com>2014-08-20 16:32:37 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-20 16:32:37 +0000
commit6c011731d0802dc87d71643303c24d6fc0a2358c (patch)
tree21522b4612b8356710bbf97e76e32701cdb0d06e /opengl/libs
parentd0c20394d26cb6d1662db6b8f489500c62f8c002 (diff)
parent4c5b9acf655531f1be45bf7fffc5ee145a80cca7 (diff)
downloadframeworks_native-6c011731d0802dc87d71643303c24d6fc0a2358c.zip
frameworks_native-6c011731d0802dc87d71643303c24d6fc0a2358c.tar.gz
frameworks_native-6c011731d0802dc87d71643303c24d6fc0a2358c.tar.bz2
am 4c5b9acf: Merge "Don\'t try to capture the pointer when using PBOs for texture APIs" into lmp-dev
* commit '4c5b9acf655531f1be45bf7fffc5ee145a80cca7': Don't try to capture the pointer when using PBOs for texture APIs
Diffstat (limited to 'opengl/libs')
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.cpp33
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.h8
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_fixup.cpp78
3 files changed, 85 insertions, 34 deletions
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.cpp b/opengl/libs/GLES_trace/src/gltrace_context.cpp
index 0323e8f..d1b3586 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_context.cpp
@@ -133,6 +133,9 @@ GLTraceContext::GLTraceContext(int id, int version, GLTraceState *state,
BufferedOutputStream *stream) :
mId(id),
mVersion(version),
+ mVersionMajor(0),
+ mVersionMinor(0),
+ mVersionParsed(false),
mState(state),
mBufferedOutputStream(stream),
mElementArrayBuffers(DefaultKeyedVector<GLuint, ElementArrayBuffer*>(NULL))
@@ -149,10 +152,40 @@ int GLTraceContext::getVersion() {
return mVersion;
}
+int GLTraceContext::getVersionMajor() {
+ if (!mVersionParsed) {
+ parseGlesVersion();
+ mVersionParsed = true;
+ }
+ return mVersionMajor;
+}
+
+int GLTraceContext::getVersionMinor() {
+ if (!mVersionParsed) {
+ parseGlesVersion();
+ mVersionParsed = true;
+ }
+ return mVersionMinor;
+}
+
GLTraceState *GLTraceContext::getGlobalTraceState() {
return mState;
}
+void GLTraceContext::parseGlesVersion() {
+ const char* str = (const char*)hooks->gl.glGetString(GL_VERSION);
+ int major, minor;
+ if (sscanf(str, "OpenGL ES-CM %d.%d", &major, &minor) != 2) {
+ if (sscanf(str, "OpenGL ES %d.%d", &major, &minor) != 2) {
+ ALOGW("Unable to parse GL_VERSION string: \"%s\"", str);
+ major = 1;
+ minor = 0;
+ }
+ }
+ mVersionMajor = major;
+ mVersionMinor = minor;
+}
+
void GLTraceContext::resizeFBMemory(unsigned minSize) {
if (fbcontentsSize >= minSize) {
return;
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.h b/opengl/libs/GLES_trace/src/gltrace_context.h
index 4c38bba..38c7315 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.h
+++ b/opengl/libs/GLES_trace/src/gltrace_context.h
@@ -51,6 +51,9 @@ public:
class GLTraceContext {
int mId; /* unique context id */
int mVersion; /* GL version, e.g: egl_connection_t::GLESv2_INDEX */
+ int mVersionMajor; /* GL major version. Lazily parsed in getVersionX(). */
+ int mVersionMinor; /* GL minor version. Lazily parsed in getVersionX(). */
+ bool mVersionParsed; /* True if major and minor versions have been parsed. */
GLTraceState *mState; /* parent GL Trace state (for per process GL Trace State Info) */
void *fbcontents; /* memory area to read framebuffer contents */
@@ -62,6 +65,9 @@ class GLTraceContext {
/* list of element array buffers in use. */
DefaultKeyedVector<GLuint, ElementArrayBuffer*> mElementArrayBuffers;
+ /* Parses the GL version string returned from glGetString(GL_VERSION) to get find the major and
+ minor versions of the GLES API. The context must be current before calling. */
+ void parseGlesVersion();
void resizeFBMemory(unsigned minSize);
public:
gl_hooks_t *hooks;
@@ -69,6 +75,8 @@ public:
GLTraceContext(int id, int version, GLTraceState *state, BufferedOutputStream *stream);
int getId();
int getVersion();
+ int getVersionMajor();
+ int getVersionMinor();
GLTraceState *getGlobalTraceState();
void getCompressedFB(void **fb, unsigned *fbsize,
unsigned *fbwidth, unsigned *fbheight,
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index e6d0062..be729c7 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -29,6 +29,33 @@
namespace android {
namespace gltrace {
+GLint glGetInteger(GLTraceContext *context, GLenum param) {
+ GLint x;
+ context->hooks->gl.glGetIntegerv(param, &x);
+ return x;
+}
+
+GLint glGetVertexAttrib(GLTraceContext *context, GLuint index, GLenum pname) {
+ GLint x;
+ context->hooks->gl.glGetVertexAttribiv(index, pname, &x);
+ return x;
+}
+
+bool isUsingPixelBuffers(GLTraceContext *context) {
+ if (context->getVersionMajor() < 3) {
+ return false; // PBOs not supported prior to GLES 3.0
+ }
+ return glGetInteger(context, GL_PIXEL_UNPACK_BUFFER_BINDING) != 0;
+}
+
+bool isUsingArrayBuffers(GLTraceContext *context) {
+ return glGetInteger(context, GL_ARRAY_BUFFER_BINDING) != 0;
+}
+
+bool isUsingElementArrayBuffers(GLTraceContext *context) {
+ return glGetInteger(context, GL_ELEMENT_ARRAY_BUFFER_BINDING) != 0;
+}
+
unsigned getBytesPerTexel(const GLenum format, const GLenum type) {
/*
Description from glTexImage2D spec:
@@ -156,7 +183,8 @@ void fixup_addFBContents(GLTraceContext *context, GLMessage *glmsg, FBBinding fb
}
/** Common fixup routing for glTexImage2D & glTexSubImage2D. */
-void fixup_glTexImage(int widthIndex, int heightIndex, GLMessage *glmsg, void *dataSrc) {
+void fixup_glTexImage(GLTraceContext *context, int widthIndex, int heightIndex, GLMessage *glmsg,
+ void *dataSrc) {
GLMessage_DataType arg_width = glmsg->args(widthIndex);
GLMessage_DataType arg_height = glmsg->args(heightIndex);
@@ -175,7 +203,7 @@ void fixup_glTexImage(int widthIndex, int heightIndex, GLMessage *glmsg, void *d
arg_data->set_type(GLMessage::DataType::BYTE);
arg_data->clear_rawbytes();
- if (data != NULL) {
+ if (data != NULL && !isUsingPixelBuffers(context)) {
arg_data->set_isarray(true);
arg_data->add_rawbytes(data, bytesPerTexel * width * height);
} else {
@@ -185,7 +213,7 @@ void fixup_glTexImage(int widthIndex, int heightIndex, GLMessage *glmsg, void *d
}
-void fixup_glTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glTexImage2D(GLTraceContext *context, GLMessage *glmsg, void *pointersToFixup[]) {
/* void glTexImage2D(GLenum target,
GLint level,
GLint internalformat,
@@ -198,10 +226,10 @@ void fixup_glTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
*/
int widthIndex = 3;
int heightIndex = 4;
- fixup_glTexImage(widthIndex, heightIndex, glmsg, pointersToFixup[0]);
+ fixup_glTexImage(context, widthIndex, heightIndex, glmsg, pointersToFixup[0]);
}
-void fixup_glTexSubImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glTexSubImage2D(GLTraceContext *context, GLMessage *glmsg, void *pointersToFixup[]) {
/*
void glTexSubImage2D(GLenum target,
GLint level,
@@ -215,10 +243,11 @@ void fixup_glTexSubImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
*/
int widthIndex = 4;
int heightIndex = 5;
- fixup_glTexImage(widthIndex, heightIndex, glmsg, pointersToFixup[0]);
+ fixup_glTexImage(context, widthIndex, heightIndex, glmsg, pointersToFixup[0]);
}
-void fixup_glCompressedTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glCompressedTexImage2D(GLTraceContext *context, GLMessage *glmsg,
+ void *pointersToFixup[]) {
/* void glCompressedTexImage2D(GLenum target,
GLint level,
GLenum internalformat,
@@ -235,7 +264,7 @@ void fixup_glCompressedTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
arg_data->set_type(GLMessage::DataType::BYTE);
arg_data->clear_rawbytes();
- if (data != NULL) {
+ if (data != NULL && !isUsingPixelBuffers(context)) {
arg_data->set_isarray(true);
arg_data->add_rawbytes(data, size);
} else {
@@ -244,7 +273,8 @@ void fixup_glCompressedTexImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
}
}
-void fixup_glCompressedTexSubImage2D(GLMessage *glmsg, void *pointersToFixup[]) {
+void fixup_glCompressedTexSubImage2D(GLTraceContext *context, GLMessage *glmsg,
+ void *pointersToFixup[]) {
/* void glCompressedTexSubImage2D(GLenum target,
GLint level,
GLint xoffset,
@@ -262,7 +292,7 @@ void fixup_glCompressedTexSubImage2D(GLMessage *glmsg, void *pointersToFixup[])
arg_data->set_type(GLMessage::DataType::BYTE);
arg_data->clear_rawbytes();
- if (data != NULL) {
+ if (data != NULL && !isUsingPixelBuffers(context)) {
arg_data->set_isarray(true);
arg_data->add_rawbytes(data, size);
} else {
@@ -436,26 +466,6 @@ void fixup_glGetActiveAttribOrUniform(GLTraceContext *context, GLMessage *glmsg,
arg_location->add_intvalue(location);
}
-GLint glGetInteger(GLTraceContext *context, GLenum param) {
- GLint x;
- context->hooks->gl.glGetIntegerv(param, &x);
- return x;
-}
-
-GLint glGetVertexAttrib(GLTraceContext *context, GLuint index, GLenum pname) {
- GLint x;
- context->hooks->gl.glGetVertexAttribiv(index, pname, &x);
- return x;
-}
-
-bool isUsingArrayBuffers(GLTraceContext *context) {
- return glGetInteger(context, GL_ARRAY_BUFFER_BINDING) != 0;
-}
-
-bool isUsingElementArrayBuffers(GLTraceContext *context) {
- return glGetInteger(context, GL_ELEMENT_ARRAY_BUFFER_BINDING) != 0;
-}
-
/** Copy @len bytes of data from @src into the @dataIndex'th argument of the message. */
void addGlBufferData(GLMessage *glmsg, int dataIndex, GLvoid *src, GLsizeiptr len) {
GLMessage_DataType *arg_datap = glmsg->mutable_args(dataIndex);
@@ -809,22 +819,22 @@ void fixupGLMessage(GLTraceContext *context, nsecs_t wallStart, nsecs_t wallEnd,
break;
case GLMessage::glTexImage2D:
if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
- fixup_glTexImage2D(glmsg, pointersToFixup);
+ fixup_glTexImage2D(context, glmsg, pointersToFixup);
}
break;
case GLMessage::glTexSubImage2D:
if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
- fixup_glTexSubImage2D(glmsg, pointersToFixup);
+ fixup_glTexSubImage2D(context, glmsg, pointersToFixup);
}
break;
case GLMessage::glCompressedTexImage2D:
if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
- fixup_glCompressedTexImage2D(glmsg, pointersToFixup);
+ fixup_glCompressedTexImage2D(context, glmsg, pointersToFixup);
}
break;
case GLMessage::glCompressedTexSubImage2D:
if (context->getGlobalTraceState()->shouldCollectTextureDataOnGlTexImage()) {
- fixup_glCompressedTexSubImage2D(glmsg, pointersToFixup);
+ fixup_glCompressedTexSubImage2D(context, glmsg, pointersToFixup);
}
break;
case GLMessage::glShaderSource: