Order of Texture Binding

Hi,

Hopefully a quick question!

I am writing a large-ish number of quads to the screen (say 10000) from a pool of about 15 different textures. As the code loops across the screen it binds and then displays the appropriate texture, each in turn. My question is -> Would there be any performance benefit to writing all of one type of texture first before writing a second? The cost would be in the numerous (*15) passes of the display loop and if statements, but the benefit (?) would be in binding a maximum of 15 times instead of 10,000?

Regardless of the textures displayed, they are varied with glColor3f().

Many thanks for reading.

Dan

It depends on what your bottleneck(s) is on your specific hardware and OpenGL driver.

Assuming the distribution of textures across your quads is fairly uniform, then binding 15 times is likely to be faster than binding 10,000 times. It’s the same number of quads and approximately the same amount of fill and CPU work given the same quad submission approach.

However, you’re talking about efficiency, but yet you say you’re using immediate mode (e.g. glColor3f). Immediate mode alone is in competition with performance. You can put in a display list to help, or better you can put a bunch of quads in a vertex array or VBO and launch them all at once in a single batch (that cuts down on a lot of CPU work submitting quads). If you’re fill bound and your quads are opaque, consider rendering them front-to-back and/or do a depth-only pass first.

Many thanks Dark Photon! Lots there to think about.

I am using glColor3f to alter the shade of a texture. I’ll see if rendering the different shades of textures upfront makes a difference.
As for display lists, I didn’t use them because I thought they were deprecated?

Not deprecated, removed from the core profile. Immediate mode is in the same boat though.

The key question you have to answer is are you going to target the core profile or the compatibility profile. In the latest core profile, these are both gone. In the compatibility profile, you can still use them both.