Nexus 5 上的 GLSurfaceView 帧率问题 [英] GLSurfaceView framerate issues on Nexus 5

查看:30
本文介绍了Nexus 5 上的 GLSurfaceView 帧率问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个示例应用程序(、YouTube) 显示明显的帧率要低得多.

简而言之,我的编码 &显示循环执行以下操作:

  • 使 MediaCodec Surface 输入 EGL 上下文成为当前
  • 将相机帧绘制到 MediaCodec EGL 表面
  • 使 GLSurfaceView EGL 上下文成为当前的
  • 为 GLSurfaceView 绘制相同的相机框架

在 Galaxy Nexus LTE 和 Nexus 7(均采用 AOSP 4.4)上,应用程序按预期运行.到目前为止,只有 Nexus 5 出现了绘制到屏幕上的帧数和明显的帧数之间的这种差异......

我祈祷我没有疯.

解决方案

我能够复制这种行为,我的 GL 向导同事发现了问题.

基本上,其中一个 EGL 上下文没有注意到纹理内容发生了变化,因此它继续渲染旧数据.我们认为它会偶尔更新,因为它有一组循环通过的缓冲区,因此最终它会重新使用您正在查看的缓冲区.

我能够通过更新纹理渲染器类来解决我的代码中的问题,更改此:

GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

为此:

GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

解除绑定和重新绑定会导致驱动程序选择正确的缓冲区.

I have an example application (full source) that encodes camera frames with MediaCodec while displaying them on a GLSurfaceView.

Systrace confirms 30 drawing calls are made each second:

However, a screenrecord recording (.mp4, YouTube) shows the apparent framerate to be considerably lower.

In a nutshell, my encoding & display loop does the following:

  • Makes a MediaCodec Surface input EGL Context current
  • Draws a camera frame to the MediaCodec EGL surface
  • Makes the GLSurfaceView EGL Context current
  • Draws the same camera frame to the GLSurfaceView

On a Galaxy Nexus LTE and Nexus 7 (both with AOSP 4.4), the application performs as expected. So far only the Nexus 5 experiences this discrepancy between the number of frames drawn to the screen and the number of frames apparent...

I pray I'm not insane.

解决方案

I was able to replicate the behavior, and my GL wizard office-mate figured out the problem.

Basically, one of the EGL contexts isn't noticing that the texture contents have changed, so it keeps rendering older data. We think it's getting occasional updates because it has a set of buffers that it cycles through, so eventually it re-uses the buffer you're looking at.

I was able to fix the problem in my code by updating the texture renderer class, changing this:

GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

to this:

GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

The un-bind and re-bind causes the driver to pick up the right buffer.

这篇关于Nexus 5 上的 GLSurfaceView 帧率问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆