Drawing objects in texture-use-order=better performance

Started by
1 comment, last by Toji 18 years, 11 months ago
Hi everbody, Would my application benefit from drawing all objects in the order, so that objects using the same texture are drawn directly after each other? Would OpenGL bother, if I do a unnsessary texture bind like: glBindTexture(Text1); Draw(Object1); glBindTexture(Text1); Draw(Object2); Thanks! Nathan
Advertisement
yes yes yes (picture scene from when harry met sally here)... :)

[edit] though the entire point to this is that you dont have to do the extra texture setting [/edit]
-Scoot
Wether or not glBindTexture() would actually bother going through the redundant Texture Setting is entirely up to the driver. Most current drivers probably do include some sort of redundancy check. I did some simple tests a while back (nothing fancy) comparing a single glBindTexture() to multiple redundant calls for each object and really didn't see much of a difference in frame rate. (Using a Fx5500)

HOWEVER

Just because this one test turned out okay does NOT mean that you should just let it slide. Drivers can be an unpredictable bunch, and it's ALWAYS better to handel things like this on your own, so that you know it will act the same no matter what system someone is using. Usually simply tracking the last used texture is sufficent:

GLuint lastTexID = -1;void MyTextureBind( GLuint texID ){    if(lastTexID != texID)    {       glBindTexture(texID);       lastTexID = texID;     }}


Calling a function like this in place of glBindTexture() ensures that you don't get any redundant texture sets. This is especially effective if your render queue is already sorted by texture.
// The user formerly known as Tojiro67445, formerly known as Toji [smile]

This topic is closed to new replies.

Advertisement