PDA

View Full Version : Performance issue in GLES20.glreadpixels in android?



umresh
09-04-2014, 06:08 AM
Is there any way to improve the performance of glreadpixels in android? Is there any other way to read the display data to convert to image in openGL?

Thank you.

mhagain
09-05-2014, 09:52 AM
If you want to convert the screen image to a texture, then glCopyTexImage (https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml) and glCopyTexSubImage (https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexSubImage2D.xml) are the preferred ways. The copy will be carried out by the GPU and shouldn't involve any round-tripping, read-backs or synchronization.

If you just want to read back the screen pixels in order to do some software operation on them, then there is no fast way. The best you can get is glReadPixels with parameters carefully chosen to match the display mode (being careul to not fall into the trap of using e.g GL_RGB because you think it will save memory - all that it will do is cause an even slower format conversion in the driver), but either way you're going to get a huge pipeline stall.

The exception to this is if you don't need the data immediately following the read-back. In desktop GL you can do an asynchronous readback to a pixel buffer object (PBO) but this facility doesn't seem to be available in ES.