Texture fast upload

I am working on a multi screen application (after effect like on synchronised multi screen but with very basic effects). My apps works fine except that it takes a while to create the texture and so slow down my apps … I use glteximage2D to create my texture like that :

glGenTextures(1, &texture1);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, texture1);
if(depth==32)
{
glTexImage2D( GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA8, 2048,h, 0,GL_RGBA, GL_UNSIGNED_BYTE,imagecache1.bits() );
else
{
// qWarning(“taille nulle”);
}
}
else
{
glTexImage2D( GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA8, 2048,h, 0,GL_RGB, GL_UNSIGNED_BYTE,imagecache1.bits() );
else
{
// qWarning(“taille nulle”);
}
}
glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); //GL_REPEAT GL_CLAMP
glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_NEAREST GL_LINEAR
glTexParameterf(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

But it can take 5ms to do that … How can I improve the loading … IT works with nvidia card fx5600 Agp8x .
Is it better to use GL_RGBA or GL_BGRA_EXT ?
Do you know where I can find a tutorial to test the NV_PIXEL_DATA_RANGE … Do you know if it really improve the performance …

BGRA_EXT is the fastest.

Are you calling the above code for each frame?

Use glTexSubImage2D to reload texture data once you have created your texture using glTexImage2D. Dont create and delete your texture each time.

PDR should help you but someone else tried it and couldnt get any speed up. I havent tried PDR with subimage2d myself. I am not aware of any PDR tutorials. The important thing about PDR isnt the direct speed up you might get, its the fact that it allows you to do the operation asynchronously, freeing up your cpu to work on other things.

There is some example code using PDR here http://www.adrian.lark.btinternet.co.uk/PixPerf.zip

It is a readpixels benchmark so its not quite what you want but it should help you.

[This message has been edited by Adrian (edited 11-24-2003).]

I use gltexsubimage2d to upload any change… But it takes some times. …

If your data arrives in BGRA byte order, or could easily be made to arrive in BGRA byte order, then you need to make sure you provide that byte order to OpenGL and specify the external format as GL_BGRA (which is core OpenGL since 1.2, not an _EXT anymore).

Uploading GL_BGRA is faster than GL_RGBA for many cards. It also matters to get good alignment of data in memory.

Also, run a profiler on your program to see where you’re spending the time. It may be in a surprising place, and give you new insights at for how to improve things.

It’s an nvidia card (geforce fx5600 or TI4600). I can’t use GL_BGRA (compilation error). I have to use GL_BGRA_EXT. Does it makes any change? I have profiling my apps and the bottelneck is glteximage2D …