gltrace: attach contents of the appropriate framebuffer
Currently, gltrace always attaches the contents of the currently bound framebuffer. This patch changes it to attach the contents of FB0 on eglSwap, and the currently bound framebuffer for the glDraw* calls. Change-Id: Ice0520d45d75638fe61cd91149df773074216510
This commit is contained in:
parent
3005c4f778
commit
f132ac35d8
@ -82,19 +82,33 @@ void GLTraceContext::resizeFBMemory(unsigned minSize) {
|
|||||||
|
|
||||||
/** obtain a pointer to the compressed framebuffer image */
|
/** obtain a pointer to the compressed framebuffer image */
|
||||||
void GLTraceContext::getCompressedFB(void **fb, unsigned *fbsize, unsigned *fbwidth,
|
void GLTraceContext::getCompressedFB(void **fb, unsigned *fbsize, unsigned *fbwidth,
|
||||||
unsigned *fbheight) {
|
unsigned *fbheight, FBBinding fbToRead) {
|
||||||
int viewport[4] = {};
|
int viewport[4] = {};
|
||||||
hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport);
|
hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
unsigned fbContentsSize = viewport[2] * viewport[3] * 4;
|
unsigned fbContentsSize = viewport[2] * viewport[3] * 4;
|
||||||
|
|
||||||
resizeFBMemory(fbContentsSize);
|
resizeFBMemory(fbContentsSize);
|
||||||
|
|
||||||
//TODO: On eglSwapBuffer, read FB0. For glDraw calls, read currently
|
// switch current framebuffer binding if necessary
|
||||||
// bound FB.
|
GLint currentFb = -1;
|
||||||
//hooks->gl.glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bound_fb);
|
bool fbSwitched = false;
|
||||||
//hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
if (fbToRead != CURRENTLY_BOUND_FB) {
|
||||||
|
hooks->gl.glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFb);
|
||||||
|
|
||||||
|
if (currentFb != 0) {
|
||||||
|
hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
fbSwitched = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
|
hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, fbcontents);
|
GL_RGBA, GL_UNSIGNED_BYTE, fbcontents);
|
||||||
|
|
||||||
|
// switch back to previously bound buffer if necessary
|
||||||
|
if (fbSwitched) {
|
||||||
|
hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, currentFb);
|
||||||
|
}
|
||||||
|
|
||||||
*fbsize = lzf_compress(fbcontents, fbContentsSize, fbcompressed, fbContentsSize);
|
*fbsize = lzf_compress(fbcontents, fbContentsSize, fbcompressed, fbContentsSize);
|
||||||
*fb = fbcompressed;
|
*fb = fbcompressed;
|
||||||
*fbwidth = viewport[2];
|
*fbwidth = viewport[2];
|
||||||
|
@ -24,6 +24,8 @@ namespace gltrace {
|
|||||||
|
|
||||||
using ::android::gl_hooks_t;
|
using ::android::gl_hooks_t;
|
||||||
|
|
||||||
|
enum FBBinding {CURRENTLY_BOUND_FB, FB0};
|
||||||
|
|
||||||
class GLTraceContext {
|
class GLTraceContext {
|
||||||
void *fbcontents; /* memory area to read framebuffer contents */
|
void *fbcontents; /* memory area to read framebuffer contents */
|
||||||
void *fbcompressed; /* destination for lzf compressed framebuffer */
|
void *fbcompressed; /* destination for lzf compressed framebuffer */
|
||||||
@ -34,7 +36,9 @@ public:
|
|||||||
gl_hooks_t *hooks;
|
gl_hooks_t *hooks;
|
||||||
|
|
||||||
GLTraceContext();
|
GLTraceContext();
|
||||||
void getCompressedFB(void **fb, unsigned *fbsize, unsigned *fbwidth, unsigned *fbheight);
|
void getCompressedFB(void **fb, unsigned *fbsize,
|
||||||
|
unsigned *fbwidth, unsigned *fbheight,
|
||||||
|
FBBinding fbToRead);
|
||||||
};
|
};
|
||||||
|
|
||||||
GLTraceContext *getGLTraceContext();
|
GLTraceContext *getGLTraceContext();
|
||||||
|
@ -31,7 +31,8 @@ void GLTrace_eglSwapBuffers(void *dpy, void *draw) {
|
|||||||
glmessage.set_context_id(1);
|
glmessage.set_context_id(1);
|
||||||
glmessage.set_function(GLMessage::eglSwapBuffers);
|
glmessage.set_function(GLMessage::eglSwapBuffers);
|
||||||
|
|
||||||
fixup_addFBContents(&glmessage);
|
// read FB0 since that is what is displayed on the screen
|
||||||
|
fixup_addFBContents(&glmessage, FB0);
|
||||||
traceGLMessage(&glmessage);
|
traceGLMessage(&glmessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +96,10 @@ void fixup_glGetString(GLMessage *glmsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add the contents of the framebuffer to the protobuf message */
|
/* Add the contents of the framebuffer to the protobuf message */
|
||||||
void fixup_addFBContents(GLMessage *glmsg) {
|
void fixup_addFBContents(GLMessage *glmsg, FBBinding fbToRead) {
|
||||||
void *fbcontents;
|
void *fbcontents;
|
||||||
unsigned fbsize, fbwidth, fbheight;
|
unsigned fbsize, fbwidth, fbheight;
|
||||||
getGLTraceContext()->getCompressedFB(&fbcontents, &fbsize, &fbwidth, &fbheight);
|
getGLTraceContext()->getCompressedFB(&fbcontents, &fbsize, &fbwidth, &fbheight, fbToRead);
|
||||||
|
|
||||||
GLMessage_FrameBuffer *fb = glmsg->mutable_fb();
|
GLMessage_FrameBuffer *fb = glmsg->mutable_fb();
|
||||||
fb->set_width(fbwidth);
|
fb->set_width(fbwidth);
|
||||||
@ -299,7 +299,7 @@ void fixupGLMessage(GLMessage *glmsg) {
|
|||||||
case GLMessage::glDrawElements:
|
case GLMessage::glDrawElements:
|
||||||
/* void glDrawArrays(GLenum mode, GLint first, GLsizei count) */
|
/* void glDrawArrays(GLenum mode, GLint first, GLsizei count) */
|
||||||
/* void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) */
|
/* void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) */
|
||||||
fixup_addFBContents(glmsg);
|
fixup_addFBContents(glmsg, CURRENTLY_BOUND_FB);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -14,16 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gltrace.pb.h"
|
|
||||||
|
|
||||||
#ifndef __GLTRACE_FIXUP_H_
|
#ifndef __GLTRACE_FIXUP_H_
|
||||||
#define __GLTRACE_FIXUP_H_
|
#define __GLTRACE_FIXUP_H_
|
||||||
|
|
||||||
|
#include "gltrace.pb.h"
|
||||||
|
#include "gltrace_context.h"
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace gltrace {
|
namespace gltrace {
|
||||||
|
|
||||||
void fixupGLMessage(GLMessage *message);
|
void fixupGLMessage(GLMessage *message);
|
||||||
void fixup_addFBContents(GLMessage *message);
|
void fixup_addFBContents(GLMessage *message, FBBinding fbToRead);
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user