PDA

View Full Version : the speed of readback from PBuffer



pango
10-13-2003, 11:59 PM
Hello everyone,if you accuse me post same question again,you mistake me.I had found the reason of my program's poor performance of reading data back:my program read data from PBuffer(Pixel Buffer) directly.I rewrite my program to read data from the front buffer(the buffer that store the image will be displayed in a window),the bandwidth is about 180Mbytes/sc,but I change to read data from PBuffer,the bandwidth dropped down to about 2.5Mbytes/sc.The difference make me surprise,why the read back speed of PBuffer is so slow?Is my test result right?
I post my code of reading data from PBuffer and the creating of PBuffer,if there had some mistake,please let me know,thanks!

//the code of reading data from Pbuffe
pbuf.MakeCurrent();//my PBuffer class's instance
for (int i=0;i<100; i++)
glReadPixels(0,0,512,512,GL_BGR_EXT,GL_UNSIGNED_BY TE,buf);

//my pbuffer creating code:
int iAttributes[]={
WGL_DRAW_TO_PBUFFER_ARB,TRUE,
WGL_DEPTH_BITS_ARB,24,
WGL_RED_BITS_ARB,8,
WGL_GREEN_BITS_ARB,8,
WGL_BLUE_BITS_ARB,8,
WGL_ALPHA_BITS_ARB,8,
WGL_BIND_TO_TEXTURE_RGBA_ARB,TRUE,
0,0};
float fAttributes[]={0,0};
GLint nPixelFmt;
unsigned int nNumFmt;
if(!wglChoosePixelFormatARB(wglGetCurrentDC(),iAtt ributes,fAttributes,1,&nPixelFmt,&nNumFmt))
return FALSE;

int iFlag[]={
WGL_PBUFFER_LARGEST_ARB,TRUE,
WGL_TEXTURE_FORMAT_ARB,WGL_TEXTURE_RGBA_ARB,
WGL_TEXTURE_TARGET_ARB,WGL_TEXTURE_2D_ARB,
0,0
};
m_hPBuffer=wglCreatePbufferARB(wglGetCurrentDC(),n PixelFmt,width,height,iFlag);
m_hdcPBuffer=wglGetPbufferDCARB(m_hPBuffer);
m_hrcPBuffer=wglCreateContext(m_hdcPBuffer);
BOOL bRet=wglMakeCurrent(m_hdcPBuffer,m_hrcPBuffer);

flo
10-14-2003, 04:28 AM
Try reading from a PBuffer that has no power-of-two width and height (i.E., not 512x512, but 511x511 or so.) I had exactly same same issue with the PBuffer on GeForceFX boards recently, and changing the size fixed that problem.

I assume that this is a driver bug.

heath
10-14-2003, 06:34 AM
You stated that the buffer that stores the image(pbuffer) from which you read will be displayed in a window. If this is the case, don't use readpixel, use glCopyTexSubImage2D() to a texture, and then apply that texture to a polygon.

You could use the render to texture stuff also, but that will get a little messy if non power of two destinations are required.

Hope This helps,
Heath.

[This message has been edited by heath (edited 10-14-2003).]

Christian Schüler
10-21-2003, 04:24 AM
Hi, I am new to this board.

I have experienced the same on an MX, that is, PBuffers have generally a worse fillrate than windows.

- when drawing polygons
- when clearing
- when reading back

Maybe this has to do with internal memory layout for pow-2 textures, since texture memory is swizzled?

SirKnight
10-21-2003, 07:09 AM
What do you mean by "than windows?"

-SirKnight

Christian Schüler
10-21-2003, 10:39 PM
I think this thread is related:
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/010600.html

With "windows" I mean rendering into the back buffer. Sorry for the sloppy terminus.