Now I have a OpenGL rendering project that need to download about 16 or more textures to disk. So I want to use PBO + glGetTexImage to improve the performance, not only using glGetTexImage.
So I made an experiment to test the performance of using PBO + glGetTexImage. In my experiment I found that using PBO + glGetTexImage would not improve any performance.
I want to know that if I use them not correctly or using PBO+ glGetTexImage would not improve performance in today’s graphic card.
The following is my snippet code
//////initialize code
#define COUNT 16
GLuint _downloadPBO[COUNT];
GLubyte *savedbyte[COUNT];
#define _width 1024
#define _height 1024
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
for(int i=0;i<COUNT;i++)
{
glGenBuffers(1 , & _downloadPBO[i]);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, _downloadPBO[i]);
glBufferData(GL_PIXEL_PACK_BUFFER_ARB, _width * _height * 4, NULL, GL_STREAM_READ);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
////performance test code/////////////
t1.start();
glBindTexture(GL_TEXTURE_2D, texid[GROUND_TEXTURE]);
for(int i=0;i<COUNT;i++)
{
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, _downloadPBO[i]);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));//
savedbyte[i] = (GLubyte *)glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
}
t1.stop();
copyTime = t1.getElapsedTimeInMilliSec();
///////////////////////////////////////////////////////////////
When COUNT=1,the copyTime is about 2.8 ms! When COUNT=16,the copyTime is about 46ms!
I use Microsoft OS and OpenGL 3.0 programming language and CPU Intel Pentium Dual-Core 2.5GHz,2GB RAM ,Geforce 9500 Card.
Any suggestion would be appreciated!!!