glReadPixels performance

Started by
4 comments, last by GameDev.net 17 years, 10 months ago
Hello folks I'm currently doing some general purpose programming on the GPU and thererfore I need to download the data back to the main memory for more calculations. The only method I have found so far are framebuffer objects in combination with a glReadPixels call on the FBO that receives the final output image. However, I found the result to be quite slow. On a FBO with a texture size of 352x288 pixels reading back the whole image takes about 60-70 milliseconds which is about six times slower than the computations themselves. Therefore I have some questions to you: 1) Can I speed up the process by doing a shrink operation that reduces the size of the final output texture to 176x144 pixels? Or is the amount of data neglectible for glReadPixels? 2) Is there a faster way than glReadPixels? Thanks for your admittance.
Advertisement
I don't know of any other way to copy from GPU RAM to CPU RAM than glReadPixels.

The amount of RAM copied over the bus is definitely a major factor, though glReadPixels does have its own function call overhead. At these tiny sizes though, the tiny size difference would not be beneficial enough to provide any major increase in reponse time.

The only way to speed this up would be to completely avoid transferring data from GPU RAM to CPU RAM by implementing everything on the GPU.

Is there any way to do this for your objective (if even applicable)? If you can do this, you will be usually rewarded well with high performance.

In cases where the textures are small like that, I've even found that a pure CPU implementation can be faster than a CPU/GPU combination implementation, simply due to the bus latency/tx speed exhibited by glReadPixels.

With a faster PCI Express bus though, this is less of an issue. Plus GPUs are becoming more flexible programmatically as time goes by, so there will be less and less need for the GPU RAM to CPU RAM copy process regardless.
These are my system specs:

Athlon 64 3000
ATI Radeon 9800 Pro
Abit KV8 3rd eye mainboard
1 GB Ram

Is 60 Ms for one glReadPixels call a little bit slow even for that system?
its does sound slow
try different data types, see performance pdf's for hints.
also the PBO (or something similar named) extension i believe helps with readpixels performance
Quote:Original post by zedzeek
...see performance pdf's for hints...
Especially this one.
Quote:Original post by Desperado
ATI Radeon 9800 Pro
[...]
Is 60 Ms for one glReadPixels call a little bit slow even for that system?


This is a known weakness with previous-generation cards. I am not sure exactly why but either the card, software, or AGP bus was only designed for transferring data TO the card, and reading it back was an afterthought.

Apparently modern PCI express cards alleviate this, but I haven't tested that.

This topic is closed to new replies.

Advertisement