glReadPixels使用太慢 [英] glReadPixels too slow to use

查看:4849
本文介绍了glReadPixels使用太慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 glReadPixels 采取定期快照在并条机 的方法GLSurfaceView.Renderer 。我需要借这个快照定期保持救了我的数据按我的应用程序的要求。

I am using glReadPixels to take a snapshot at regular intervals in drawFrame method of GLSurfaceView.Renderer. I need to take this snapshot at regular intervals to keep saving my data as per my app requirements.

然而是很慢,显示滞后。以下是我使用的方法:

However glReadPixels performance is really slow and shows a lag. Here's how I use the method:

gl.glReadPixels(0, 0, 1280, 752, GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE, bb);

有没有替代品使用 glReadPixels ?我如何保存图像,而不会造成滞后?

Is there a alternative to use glReadPixels? How can I save the image without causing a lag?

推荐答案

我不知道这是否是在Android,但也许公益组织(像素缓冲区对象)会给出一个性能提升。看到这个<一href="http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=235757&an=">OpenGL.org螺纹。

I don't know if that is available on android, but maybe PBOs (Pixel buffer objects) will give a performance boost. See this OpenGL.org thread.

不过,不要指望奇迹!随着1280 * 752 RGBA图像,你transfering 3.67 MB数据的每一帧。我不知道这个数字对于Android,但我敢打赌,你都面临着内存带宽或硬盘驱动器写入的瓶颈。如果您减少提供ReadPixel的大小并获得更好的性能,你知道这就是问题所在。

However, don't expect miracles! With a 1280*752 RGBA image, you are transfering 3.67 MB of data each frame. I don't know the figures for Android, but I would bet you are facing a memory bandwidth or hard drive write bottleneck. If you reduce the size of your readPixel and get much better performance, you know that's the problem.

此外,你需要在A成分?也许读回RGB更快。尝试读回以不同的格式。有些是办法的比别人快,因为他们更好地映射到OpenGL的内存重新presentation。例如,BGRA可能比RGBA更快。当你要求的格式不匹配的OpenGL了,每个像素必须在操作过程中进行转换。

Also, do you need the "A" component? Maybe reading back RGB is faster. Try reading back in different formats. Some are way faster than others because they map better to the OpenGL memory representation. For example, BGRA might be faster than RGBA. When the you request a format that doesn't match what OpenGL has, each pixel must be converted during the operation.

这篇关于glReadPixels使用太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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