Test your card's PBuffer readback speed

Hello everyone,I found the PBuffer readback speed is very difference between ATi and NVIDIA card.I write a short program to test it,the result shows the ATi card has higher performance than NVIDIA.Because I only do my test in a ATi Radeon 9800SE and a NVIDIA GF5200,so I’m not sure whethere the result is correct.So I post my test program’s code(based Glut),and the result I had get,I hope you can do the test on your machine,and also post the result you get,and your opinion about the problem.

#define WIDTH 512
#define HEIGHT 512
BYTE buf[WIDTHHEIGHT4];
#define REPEAT 30
CPBuffer pbuf; // a “PBuffer” object class,you can create a pbuffer by raw OGL command
void testAGPSpeed()
{
LARGE_INTEGER frequence,start,end;
QueryPerformanceFrequency(&frequence);
QueryPerformanceCounter(&start);
for (int i = 0; i<REPEAT; i++)
glReadPixels(0,0,WIDTH,HEIGHT,GL_BGRA_EXT,GL_UNSIGNED_BYTE,buf);
QueryPerformanceCounter(&end);

double perf=(double)(end.QuadPart -start.QuadPart)/(double)frequence.QuadPart;
perf /=REPEAT;
perf = 1.0/perf;
printf("%f copies/sec

“, perf);
perf = WIDTHHEIGHT*4;
perf /= 1.0e6;
printf(”%f Mbytes/sec
", perf);
}

int main(int argc, char* argv[])
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(WIDTH,HEIGHT);
glutCreateWindow(“AGP Speed Test”);
pbuf.Initialize();
pbuf.CreateBuffer(1024,1024);
testAGPSpeed();
return 0;
}

Below is my test result:
ATi Radeon 9800SE: 86.507644 copys/sec,90.709838 Mbytes/sec;
NVIDIA GF5200: 3.766799 copys/sec,3.949775 Mbytes/sec(too slow,let me surprise);

My results confirm your bad NV perf :
readpixels from pbuffer :
3.661250 copies/sec
3.839099 Mbytes/sec

From normal framebuffer it seems to be ok:
99.716922 copies/sec
104.560771 Mbytes/sec

EDIT: GeForce 3 Ti200 , Detonator 45.23

[This message has been edited by ZbuffeR (edited 12-08-2003).]

I have also had problems with the pbuffer.
I hope I am not off topic, but a glClear
in the pbuffer would make the framerate drop
substantially. However, if I replaced the clear with drawing a polygon that covers
the whole pbuffer and setting glDepthFunc to GL_ALWAYS, the framerate was normal.

Thus, given that the functionality of both functions is the same and they yeld such big differences in the framerate, I’ll consider this a driver bug.

I know that this is different than reading from the pbuffer, but it is a “fillrate like” problem too.

Originally posted by fuxiulian:
However, if I replaced the clear with drawing a polygon that covers the whole pbuffer and setting glDepthFunc to GL_ALWAYS, the framerate was normal.

That is true that glClear is slow on pbuffers. However, I tried your ‘fix’, but got no improvement, it is a little bit slower than the glclear.
e.g. in Geforce3 :
glClear(color and depth):37 fps
nothing:57fps
blackquad,GL_ALWAYS:36fps

Which video card did you used ?

I recently had a similar issue on a GeForce 5600. Surprisingly, an easy workarround was to define WIDTH and HEIGHT as 511 (or as another non-power-of-two value).

Disregarding this driver anomaly (?), graphics hardware from NVidia is generally faster than ATI’s for reading back pixel data from the frame buffer or the pbuffer.

Here it works, same as my last test, Geforce3 :
101.629256 copies/sec
106.565999 Mbytes/sec

In fact, I had to set NO PARAMETERS for the pbuffer, and particularly avoid those two :
WGL_TEXTURE_FORMAT_ARB,WGL_TEXTURE_RGB_ARB,
WGL_TEXTURE_TARGET_ARB,WGL_TEXTURE_2D_ARB,

Thanks to MattS for the solution, see this thread : http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/010964.html

(by the way, the 511x511 changed nothing)