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_BYTE,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(),iAttributes,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(),nPixelFmt,width,height,iFlag);
m_hdcPBuffer=wglGetPbufferDCARB(m_hPBuffer);
m_hrcPBuffer=wglCreateContext(m_hdcPBuffer);
BOOL bRet=wglMakeCurrent(m_hdcPBuffer,m_hrcPBuffer);