ReadPixels Performance

Regrading glReadPixel Performance:

I am using Opengl for model projection in a Machine Vision application. I need to read back the projection to perform a comparison with an image.

Is there anyway to speed up the glReadPixels op or avoid it? Can I expect a Speed increase with different Video Cards, AGP 8X? I am using an Nvidia MX440 under Linux.

Many Thanks, Tim Roberts.

For NVIDIA cards you can use the pixel data range extension: http://www.nvidia.com/dev_content/nvopenglspecs/GL_NV_pixel_data_range.txt
It will allow you to use readpixels asynchronously and will give you a small speed boost as well.

In theory AGP8x should allow for faster readpixels but I haven’t seen any benchmarks and I couldn’t say for sure.

I did post a link to a readpixels benchmark in this thread. http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008155.html

but the link is now down and I am away from my computer with the software so I can’t send it to you for a few days, maybe someone else could provide you with a link? I would be very interested to see how much better an AGP8x card performs in that test.

try all the various methods + data types
eg dont just try RGB with GLubyte but try it also with packed pixels or with BGR etc
it can vary 1-10x speedwise

Thanks a lot for the help.

I am get a time of ~8ms to transfer a single 640*480 frame (averaged over a thousand frames).

I am having trouble with the nvidia extensions, I can’t figure out how to get them to work! wglAllocateMemory doesn’t work I think its a linking issue, call gives null reference error. but I can’t find obvious documentation on how to link this in windows. Any help appreciated.

Tim.

You need to retrieve function pointers for extension functions using wglGetProcAddress. For example, this is what you would do to use wglAllocateMemory:

declare the function:
PFNWGLALLOCATEMEMORYNVPROC wglAllocateMemoryNV;

retrieve a function pointer for the function:
wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)wglGetProcAddress(“wglAllocateMemoryNV”);

then you can use the function.

… if the extension was supported and the function pointer is not NULL.

Here’s a link to that benchmark
http://ds.dial.pipex.com/town/plaza/yr20/PixPerf.zip

Run it with the following command line options:

pixperf -read -type ubyte -format bgra -size 128
pixperf -read -type ubyte -format bgra -size 128 -readpdr

On my GF4600 XP2000 AGP4x, latest detonators:
42.5 MPixels/sec without
50.7 MPixels/sec with the extension.

Source code as well, fantastic! Thanks, Tim.

hey Troberts, what are you working on? I’m a postgrad in computer vision, too, and intend to use OpenGL to accelerate colour consistency checks and mesh optimisation. Maybe. :slight_smile:

Ph.D. in Human Tracking. I use Opengl for model projection. Basically I use a 3D model with a textured surface, capture the framebuffer and compare a statistical model of the appearance with the image. My papers are published in ICCV and BMVC (2002). Opengl has worked really well for me although I would love to know how to speed up the glReadPixel transfer, hence the post. Tim.

Tim, did you run the benchmark on a AGP 8x card + AGP8x motherboard, what were the results? Thanks.

I don’t have the equipment at the moment but within the next few months I am building a new workstation and will investigate fully the effect of different memroy settings, AGP and the nvidia extensions. Thanks again for your help, Tim.