本文介绍了使用OpenGL ES纹理缓存而不是glReadPixels来获取纹理数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 5中,引入了OpenGL ES Texture缓存,提供了从摄像机视频数据到OpenGL的直接方式,无需复制缓冲区。在。

In iOS 5, OpenGL ES Texture caches were introduced to provide a direct way from the camera video data to OpenGL without the need of copying the buffers. There was a brief introduction to texture caches in session 414 - Advances in OpenGL ES for iOS 5 of WWDC 2011.

我发现了一个有趣的最后进一步滥用这个概念并绕过对 glReadPixels 只需锁定纹理,然后直接访问缓冲区。

I found an interesting article which abuses this concept further in the end and circumvents a call to glReadPixels by simply locking the texture, and then accessing the buffer directly.

glReadPixels 真的很慢到期到iPad 2中使用的基于图块的渲染器(即使只使用1x1纹理)。但是,所描述的方法似乎比 glReadPixels 处理得更快。

glReadPixels is really slow due to the tile-based renderer which is used in iPad 2 (even when you use only 1x1 textures). However, the described method seems to process faster than glReadPixels.

文章中提出的方法是否有效,是否可用于提升依赖于 glReadPixels 的应用程序?

Is the proposed method in the article even valid and can it be used to boost applications which rely on glReadPixels?

由于OpenGL处理​​与CPU并行的图形数据,如何在渲染完成时知道 CVPixelBufferLockBaseAddress 调用没有与OpenGL交谈?

Since OpenGL processes graphics data in parallel to the CPU, how should the CVPixelBufferLockBaseAddress call know when the rendering is done without talking to OpenGL?

推荐答案

我在,基于你上面链接的文章和来自WWDC 2011的Apple的ChromaKey样本。鉴于Apple在他们的一个样本中使用了这个,并且我没有听到任何反击这来自他们的OpenGL ES工程师,我相信这是对纹理缓存的有效使用。它适用于我尝试过的每个兼容iOS 5.x的设备,并且也适用于iOS 5.0和5.1。它比 glReadPixels()快得多。

I describe a means of doing this in this answer, based on your above-linked article and Apple's ChromaKey sample from WWDC 2011. Given that Apple used this in one of their samples, and that I've not heard anything countering this from their OpenGL ES engineers, I believe this to be a valid use of the texture caches. It works on every iOS 5.x-compatible device that I've tried, and works in iOS 5.0 and 5.1 just as well. It's much, much faster than glReadPixels().

至于何时锁定像素缓冲区基地址,你应该可以使用 glFlush()等来阻止,直到所有数据都被渲染到你的FBO纹理。这似乎适用于我从纹理支持的FBO完成的30 FPS 1080p电影编码。

As far as when to lock the pixel buffer base address, you should be able to use glFlush() or the like to block until all data has been rendered to your FBO texture. This seems to work for the 30 FPS 1080p movie encoding I've done from texture-backed FBOs.

这篇关于使用OpenGL ES纹理缓存而不是glReadPixels来获取纹理数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:58