Imagination PowerVR SDK Blog

Is there a faster alternative to glReadPixels for transferring texture data from GPU to CPU?


#1

As part of our application, we use the GPU to speed up the rendering of stroked brushes on iOS devices. In order to facilitate undoing of the stroked brushes, we need to transfer any modified textures back from the GPU to the CPU. In benchmarks with an iPad2, to transfer a 256x256 RGBA texture to the CPU, it took 20ms using glReadPixels (vs ~0.8ms to upload to GPU). I realise getting the data back is always going to be slower than sending it up, but I want to know if there are special features of the SGX chip, which would allow us to transfer data in a faster (and preferably asynchronous) method?


#2

Hi Mark,



Sorry for the delayed response. There is no core OpenGL ES feature that allows a more efficient read back of buffers that have been written to by the GPU. However, there tend to be platform specific mechanisms that avoid CPU & GPU serialization when data is read back. For example, on Android it’s possible to use a circular buffer of EGLImages so the CPU can read data back from one surface while the GPU writes data into another.



I’m not sure what mechanisms there may be to do this on iOS. You would have to refer to their documentation or discuss it with their support team.



Thanks,

Joe


#3

Hi, thanks Joe. For anyone else reading this question, I did stumble upon an answer here:

http://stackoverflow.com/questions/9550297/faster-alternative-to-glreadpixels-in-iphone-opengl-es-2-0



I implemented the answer, and now I don’t have any delay in reading back texture data.


#4

Hi Mark,



Glad to hear you found a more efficient solution. Thanks for posting the link :slight_smile:



Joe