Imagination PowerVR SDK Blog

glReadPixels quite slow




I'm trying to read data from framebuffer with following line on Zoom OMAP 3430:


glReadPixels( 0, 0, 1920, 1920, GL_RGBA, GL_UNSIGNED_BYTE, pData );


The download speed I get at best is about 8 MB/s. Is that normal? I understood that embedded devices have shared memory, so this should be much faster. Does the tiling effect on the speed? What are the most optimal format and type for reading?





What surface are you reading from, is it a renderbuffer or a texture? What format does it have? How are you measuring the transfer rate? Note that glReadPixels implicitly flushes rendering to the surface you’re reading from, so the time required for glReadPixels may include the whole render pipeline latency.




I'm reading from framebuffer. I have attached texture with GL_RGB format to it. I also learned this latency issue later and discovered that the actual readback speed is about 25 MB/s. After I'm sure that the execution on GPU is really over, I start the timer before I call the glReadPixels and after I get back from reading, I stop the time.


Do you specify format and type as (GL_RGB, GL_UNSIGNED_BYTE), or (GL_RGB, GL_UNSIGNED_SHORT_5_6_5)? Are the texture dimensions powers of two? Do you actually use it as a texture, or could you use a renderbuffer instead? What are you using the pixel data for?


I have tryid both, SHORT_5_6_5 and BYTE. I have noticed that reading back as SHORT_5_6_5 is little bit faster. The dimensions haven’t been always powers of two. What I’m doing is sort of general programming (GPGPU) and the resulting pixel data is not for display.


Yes, 565 should be faster as it needs less bandwidth. If you don’t need to use the data as a texture you should try using a renderbuffer. Textures typically use a different memory layout thus reading from them may be slower.