Which is the FASTEST way to read A pixel from Texture/Framebuffer

Hi everyone !

I am write a program, need to read back only several pixels from a render target texture attached on a FBO.

So which is the best way to do this ? Because I only need very few pixels, so I think if I use PBO or ReadBack mode will caused more delay than directly calling glReadPixels. Am I right ?

Thanks very much.

There is no “fastest” way. There are only varying degrees of slow ways. What you’re doing is inherently slow and will force a full pipeline flush.

Using PBO with glReadPixels will (or should) always provide the theoretical maximum readback speed, since it does not stall the pipeline.

Also note that the fixed cost of an individual glReadPixels is very high, so it depending on how many pixels you need exactly and how these pixels are located, it might be a lot faster to just read a bounding rectangle or even the full framebuffer than multiple single-pixel-reads…

You need to define “fastest”. Do you mean “lowest latency” or “least effect on FPS” or “lowest CPU consumption”. Korval answered for “least effect on FPS” and “lowest CPU consumption” but you reference to “more delay” implied you may have desired “lowest latency”.

If you need a gather operation as implied by “few pixels” then consider a second pass that packs the pixels into another FBO so that they can be read with a single glReadPixels call. This will avoid the problem addressed by Overmind.

Multiple threads reading specific areas of an image at sametime??