Hi,
I have some strange performance results when I use PBO. I’m on a nVidia 9800 gtx. I’ve found a way to get faster result with the PBO, but I don’t understand why it is faster.
Here is the fastest way :
glTexImage2D( GL_TEXTURE_2D, a_nLevel, nInternalFormat, a_nUDim, a_nVDim, bordersize, nExternalFormat, nType, NULL );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, unBuf );
glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, nSize, NULL, GL_STREAM_DRAW );
void* ioMem = glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
memcpy( ioMem, a_pData, nSize );
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glTexSubImage2D( GL_TEXTURE_2D, a_nLevel, 0, 0, a_nUDim, a_nVDim, nExternalFormat, nType, NULL );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
But if I use that code, it is like 2 time slower:
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, unBuf );
glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, nSize, NULL, GL_STREAM_DRAW );
void* ioMem = glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
memcpy( ioMem, a_pData, nSize );
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glTexImage2D( GL_TEXTURE_2D, a_nLevel, nInternalFormat, a_nUDim, a_nVDim, bordersize, nExternalFormat, nType, NULL );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
I do not see why it is slower. It look if the surface allocation is slower when a pbo is binded…
That cause a problem with the compressed texture since I cannot call glCompressedTeximage2D with a NULL pointer for data.
So if I use:
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, unBuf );
glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, nSize, NULL, GL_STREAM_DRAW );
void* ioMem = glMapBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
memcpy( ioMem, a_pData, nSize );
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glCompressedTexImage2DARB( GL_TEXTURE_2D, a_nLevel, internalformat, a_nUDim, a_nVDim, bordersize, nSize, NULL );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
it is way slower then using:
glCompressedTexImage2D( GL_TEXTURE_2D, a_nLevel,internalformal, a_nUDim,a_nVDim,bodersize, nSize, a_pData );
It is really strange to have such result. It’s look like if I will not be able to use pbo with compressed texture, since the performance are really slower…
Thanks in advance,
J-P