Reputation: 73683
As Pixel Buffer Objects aren't available in OpenGL ES 2.0, what is the fastest way of transferring textures to the GPU (and back again)? Are there any extensions available for iPad 2 or later that we can use?
Unfortunately I can't use compressed textures as the textures (RGBA8) are generated dynamically in another part of the application.
Upvotes: 3
Views: 2789
Reputation: 170317
For iOS (which, given the reference to iPad here, I'm assuming is your platform), the fastest way to go to and from an uncompressed texture is via the texture caches. These were introduced in iOS 5.0, and basically do a direct memory map between a texture's backing bytes and a local memory byte buffer.
For uploads using a CVOpenGLESTextureCacheRef, I describe the process in this answer. The video camera is a bit of a special case, though, because it provides pixel buffers for you to work with. For other uses, you'll create the pixel buffer yourself and associate the memory to your local byte buffer to upload into the texture. In my benchmarks, the initial upload is no faster than glTexImage2D()
, but I believe subsequent modifications of these bytes are faster.
I talk about the process of using texture caches to capture from FBO texture targets in this answer. That answer is also targeted at a specific use case, encoding video, but the same basic principles can be used with your own custom pixel buffer to pull the raw bytes. In almost every case I've benchmarked, this is faster than glReadPixels()
.
The fastest path, of course, is to not have to go back and forth between CPU and GPU. If you can, take advantage of FBO texture targets and share groups to keep all of your rendering on the GPU.
Upvotes: 3
Reputation: 2832
The EGL Image extensions can be used to allocate textures with pointers that can be used to directly access the texture image data. Typically, this is much faster than using glTexImage2D(). I don't have example code for iOS, but there is example code in this article for Linux and Android:
http://software.intel.com/en-us/articles/using-opengl-es-to-accelerate-apps-with-legacy-2d-guis
Upvotes: 1