In my current scenegraph I’m naievely binding my textures, shaders, vbos and whatnot for every object I draw. Frequently I am rebiniding the same information for subsequent objects. The way I understand it, binding takes up a good chunk of rendering time. Is OpenGL smart enough to catch this, or should I be tracking these repeated bindings and skipping them?
Also, does glEnable()/glDisable() have a lot of overhead?
There are 2 solutions to this.
- Track state changes in your renderer and avoid redundent calls.
- Sort objects to avoid redundent calls. Sorting can be complex since you might want to sort for multiple reasons (blending, texture, shader, texture 1, texture 2)
All right. So you’re saying doing this is definitely worth while.
So you’re saying doing this is definitely worth while.
No, he said what it would take to have fewer changes. Whether it is worthwhile is something that can only be determined by profiling.