PDA

View Full Version : PBO + glReadPixels stalling (asking for GL_FLOATs)



MalcolmB
07-07-2009, 10:15 AM
Hey, are there any known rules for getting non-stalling calls to glReadPixels with PBOs (on nvidia hardward, 186.18 drivers).
My code is:

bind a read FBO.
attach the texture to the FBO.
set the read buffer to the FBO attachment.
bind the PBO
call glReadPixels, requesting GL_BGRA channel order.

If I ask for GL_FLOAT as the data type, the call stalls, even if the texture is 32- bit float format. If I ask for unsigned bytes, then it doesn't stall.

Even if I call glFinish() before the ReadPixels call, it still stalls.

Either way, I'd hope the data conversion could be done asynchronously...

Any thoughts?

yooyo
07-07-2009, 02:34 PM
Try GL_RGBA when you working with float or integer and GL_BGRA when you working with 8bit/channel.
Im not sure in this, but I remember some old test which was faster in GL_RGBA mode when fbo texture was integer.

If you want to copy 32bitRGBA to rgba32f using glReadPixel, dont count on on the fly conversion. Better render in rgba32f texture and read as GL_FLOAT.

MalcolmB
07-07-2009, 02:55 PM
When you say 32bitRGBA you mean 8bit/channel right?

Ok I'll try out RGBA

MalcolmB
07-07-2009, 03:19 PM
To update this, yes, if I use RGBA for 32-bits it works asynchronously.

I guess this means there is no way to download 16-bit float textures asynchronously?

yooyo
07-07-2009, 04:39 PM
OK.. to clarify:
- if your backbuffer (or texture) is 8bit/component (32bit total) then use GL_BGRA in glReadPixels

- if your fbo texture is 16 or 32bit/component(64 or 128bit total) integer, float or short, use GL_RGBA in glReadPixels call

- do not download 32bit rgba as GL_FLOAT
- do not download rgba32f as unsigned byte

16bit float is als known as half.

MalcolmB
07-08-2009, 09:48 AM
Ok got it, thanks

billconan
02-02-2010, 08:06 PM
hello,

thank you very much.

but i don't understand, what data type i should use.

my fbo texture is 32bit each channel GL_RGBA32F

so i did this

glReadPixels( 0,0,50,50, GL_RGBA, GL_FLOAT, data);

or this

glReadPixels( 0,0,50,50, GL_RGBA32F, GL_FLOAT, data);

the value of the data is negative. i guess i did something wrong.

how do you read back a GL_RGBA32F texture?