如何抓取OpenGLES log?

在分析画面异常问题时,有时需要抓取OpenGL ES Log,以便分析送给GPU的指令流是怎么样的?
进入Settings->developer options->Enable OpenGL trace,勾选Logcat
然后手机连接usb至电脑,执行如下命令:

adb shell stop
adb shell start

然后再开启main log,抓取复现过程的log, 打印信息如下:

12-16 21:04:19.748 12627 12648 D libEGL  : glGenTextures(1, (GLuint *) 0x78faec88);
12-16 21:04:19.748 12627 12648 D libEGL  : glBindTexture(0xde1, 5);
12-16 21:04:19.748 12627 12648 D libEGL  : glPixelStorei(0xcf5, 4);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexImage2D(0xde1, 0, 6408, 3, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void *) 0x7555278c);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2801, 9728);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2800, 9728);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2802, 33071);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2803, 33071);
12-16 21:04:19.749 12627 12648 D libEGL  : glGenTextures(1, (GLuint *) 0x78fafac8);
12-16 21:04:19.749 12627 12648 D libEGL  : glBindTexture(0xde1, 6);
12-16 21:04:19.749 12627 12648 D libEGL  : glPixelStorei(0xcf5, 4);
12-16 21:04:19.749 12627 12648 D libEGL  : glTexImage2D(0xde1, 0, 6408, 144, 72, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void *) 0x794e900c);
12-16 21:04:19.750 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2801, 9728);
12-16 21:04:19.750 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2800, 9728);
12-16 21:04:19.750 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2802, 33071);
12-16 21:04:19.750 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2803, 33071);
12-16 21:04:19.750 12627 12648 D libEGL  : glGenTextures(1, (GLuint *) 0x78faf948);
12-16 21:04:19.750 12627 12648 D libEGL  : glBindTexture(0xde1, 7);
12-16 21:04:19.751 12627 12648 D libEGL  : glPixelStorei(0xcf5, 4);
12-16 21:04:19.751 12627 12648 D libEGL  : glTexImage2D(0xde1, 0, 6408, 72, 72, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void *) 0x794c700c);
12-16 21:04:19.752 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2801, 9728);
12-16 21:04:19.752 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2800, 9728);
12-16 21:04:19.752 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2802, 33071);
12-16 21:04:19.753 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2803, 33071);
12-16 21:04:19.753 12627 12648 D libEGL  : glGenTextures(1, (GLuint *) 0x7590eec8);
12-16 21:04:19.753 12627 12648 D libEGL  : glBindTexture(0xde1, 8);
12-16 21:04:19.753 12627 12648 D libEGL  : glPixelStorei(0xcf5, 4);
12-16 21:04:19.753 12627 12648 D libEGL  : glTexImage2D(0xde1, 0, 6408, 168, 168, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void *) 0x7949f00c);
12-16 21:04:19.755 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2801, 9728);
12-16 21:04:19.755 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2800, 9728);
12-16 21:04:19.755 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2802, 33071);
12-16 21:04:19.755 12627 12648 D libEGL  : glTexParameteri(0xde1, 0x2803, 33071);
12-16 21:04:19.755 12627 12648 D libEGL  : glEnable(0xbe2);
12-16 21:04:19.756 12627 12648 D libEGL  : glDiscardFramebufferEXT(0x8d40, 1, (const GLenum *) 0x790c6ee8);
12-16 21:04:19.756 12627 12648 D libEGL  : glViewport(0, 0, 1080, 1920);
12-16 21:04:19.756 12627 12648 D libEGL  : glInsertEventMarkerEXT(0, (const GLchar *) 0x9280f8c0);
12-16 21:04:19.756 12627 12648 D libEGL  : glUseProgram(1);
12-16 21:04:19.756 12627 12648 D libEGL  : glUniform4f(2, 0.980392, 0.980392, 0.980392, 1);
12-16 21:04:19.756 12627 12648 D libEGL  : const GLfloat value[] = {
12-16 21:04:19.756 12627 12648 D libEGL  :     1080, 0, 0, 0,
12-16 21:04:19.756 12627 12648 D libEGL  :     0, 1920, 0, 0,
12-16 21:04:19.756 12627 12648 D libEGL  :     0, 0, 1, 0,
12-16 21:04:19.756 12627 12648 D libEGL  :     0, 0, 0, 1
12-16 21:04:19.756 12627 12648 D libEGL  : };
12-16 21:04:19.756 12627 12648 D libEGL  : glUniformMatrix4fv(0, 1, GL_FALSE, value);
12-16 21:04:19.756 12627 12648 D libEGL  : glDisableVertexAttribArray(1);
12-16 21:04:19.756 12627 12648 D libEGL  : glDisable(0xbe2);
12-16 21:04:19.756 12627 12648 D libEGL  : glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
12-16 21:04:19.757 12627 12648 D libEGL  : glCreateProgram();
12-16 21:04:19.757 12627 12648 D libEGL  : glProgramBinaryOES(3, 0x8f61, (const void *) 0x7762eeac, 4192);
12-16 21:04:19.757 12627 12648 D libEGL  : glGetProgramiv(3, 0x8b82, (GLint *) 0x790c681c);
12-16 21:04:19.757 12627 12648 D libEGL  : glBindAttribLocation(3, 0, (const GLchar *) 0x92811358);
12-16 21:04:19.757 12627 12648 D libEGL  : glGetUniformLocation(3, (const GLchar *) 0x928113a8);
12-16 21:04:19.757 12627 12648 D libEGL  : glGetUniformLocation(3, (const GLchar *) 0x928113b8);
12-16 21:04:19.757 12627 12648 D libEGL  : glUseProgram(3);
12-16 21:04:19.757 12627 12648 D libEGL  : glGetUniformLocation(3, (const GLchar *) 0x928113c8);
12-16 21:04:19.757 12627 12648 D libEGL  : glUniform4f(2, 0.988235, 0.356863, 0.137255, 1);
12-16 21:04:19.757 12627 12648 D libEGL  : const GLfloat value[] = {
12-16 21:04:19.757 12627 12648 D libEGL  :     0.00185185, 0, 0, 0,
12-16 21:04:19.757 12627 12648 D libEGL  :     0, -0.00104167, 0, 0,
12-16 21:04:19.757 12627 12648 D libEGL  :     0, 0, -1, 0,
12-16 21:04:19.757 12627 12648 D libEGL  :     -0.999879, 0.999932, 0, 1
12-16 21:04:19.757 12627 12648 D libEGL  : };

也可以在Systrace上看到

如何抓取OpenGLES log?_第1张图片
2016-12-16 21:18:28屏幕截图.png
如何抓取OpenGLES log?_第2张图片
2016-12-16 21:18:12屏幕截图.png

你可能感兴趣的:(如何抓取OpenGLES log?)