PDA

View Full Version : is glBindTexture expensive ?



vbovio
08-22-2007, 02:50 PM
what is better ?

1)
glBindTexture(texture);

2)
if (texture != activeTexture) {
glBindTexture(texture);
activeTexture = texture;
}

I have heard somewhere that glBindTexture is somewhat expensive, so probably option 2 is better, but I also have heard that the extra if is yet more expensive.. so which one is true ?

Thanks.

zed
08-22-2007, 05:23 PM
2 is faster

Cyranose
08-24-2007, 08:19 PM
or 3) sort objects by the most expensive state changes (may be the texture bind, but could be program bind, lighting on/off, etc..) and don't change that state until you have to.

#2 improves on #1 on average. But if your scene ping-pongs between two or more textures (e.g., ABABAB...), you're no better off.

Lindley
08-27-2007, 11:25 AM
Does the same apply to glActiveTexture?

km,
09-09-2007, 08:46 PM
Also keep in mind that option 2 might affect depending on the size of texture.

If you are loading very small textures (1MB or so) throughout your program then OpenGL driver already will have copy in memory and overall cost would be far less than loading first time.

Ketan