View Full Version : ReadPixels Performance

01-24-2003, 04:09 AM
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.

01-24-2003, 04:38 AM
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.

01-24-2003, 08:20 AM
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

01-24-2003, 04:32 PM
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.


01-24-2003, 08:38 PM
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:

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

then you can use the function.

01-27-2003, 07:24 AM
... if the extension was supported and the function pointer is not NULL.

01-29-2003, 05:59 AM
Here's a link to that benchmark

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.

01-30-2003, 04:31 AM
Source code as well, fantastic! Thanks, Tim.

01-30-2003, 01:41 PM
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. :-)

01-30-2003, 02:26 PM
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.

02-04-2003, 12:00 PM
Tim, did you run the benchmark on a AGP 8x card + AGP8x motherboard, what were the results? Thanks.

02-05-2003, 02:49 AM
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.