Peformance for using Frame buffers and glReadPixels

Hi,

I am using Open GLES 1.1 and I have to use glReadPixels to generate output data at 1024x1024. As glReadPixels is slow, I am looking into using the GL_OES_framebuffer_object extension and render textures into frame buffer objects first before glReadPixels. Can this help improve the performance for glReadPixels ?

Thanks.:slight_smile:

I don’t see how.

Thus, is there any other way that i can obtain the output data besides glReadPixels and not using pixmap?

You can’t make copying pixels itself faster that way, but if you are rendering multiple frames then you can avoid stalling the CPU and GPU when using glReadPixels. As GPUs operate in parallel to the CPU, if you do a few draw calls and then call glReadPixels immediately afterwards, chances are that the GPU hasn’t finished processing those draw calls. So glReadPixels will have to wait, letting the CPU idle. Then once the GPU has finished rendering and the driver can start copying pixels, the GPU will be idle since no further draw calls have been queued.

If you render to a texture/renderbuffer and then delay calling glReadPixels for a “safe” amount of time during which you submit draw calls for further frames, you can avoid these stalls.

Thanks!
Can I clarify further on this please.
Say I need 15 frames per second, but I only have 1 texture as I just need to display the same texture 15 times but making different gl operations on it. Thus I will render my first texture for the first frame to a frame buffer, make a few gl operations and call gldraw, then do the same for the next few frames. Subsequently I only start to render my first frame from the buffer and call glreadpixels for the first frame, so as to delay the time?

If I do glflush everytime after gldraw, does this cause the glreadpixels to slow down too?

Thanks again.

The glReadPixels function has an implicit finish/fence since it needs to ensure rendering is completed before coping things back to the user pointer. So avoiding unnecessary flushes/finishes is always good.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.