View Full Version : Which statechanges are omptimized by driver?

10-21-2003, 01:33 AM

Thats my first post on this board, so
dont take it too serios http://www.opengl.org/discussion_boards/ubb/wink.gif

Im writing my Renderer and
I dont know which statechanges i should manage my self.
void renderer::BindTexture(uint id)
if(id != bound_texture)
bound_texture = id;

Is this really neccessary, or does the driver
this kind of optimization for me?
Managing all the important states (textures,
vertexprograms, vbos) my self is ... well, a bit work intesive
especially when you use textureunits and cubemaps which
require even more state changes.

I sort everything in my scene by texture, but every object calls
renderer->SetTexture(mytexture); in their Render() function.

So the state managing would only cut down the
amount of glDoSomeThing calls. Is this really worth the effort?

Sorry for my bad english

10-21-2003, 01:34 AM
Args, damn typo.

10-21-2003, 02:48 AM
There were a few interesting posts on this subject a while ago in the advanced forum. You better do a search for the long answer. The short one though is:
the driver doesn't in general do checks to avoid state changes as this would be unnecessary overhead for apps which try to avoid state changes by sorting etc. . Anyway you can either make sure that the state you're trying to set isn't allready set or you can try to minimize state changes by sorting/grouping geometry according to the state they need. The latter should of course be better but also more complex.