consequent call overhead

Started by
1 comment, last by rewolfer 14 years, 9 months ago
State changes in graphics APIs can be expensive, but if I were to make the same state change call twice in a row, would it take twice as long or does opengl know the current state. ie. Should I record which shader is enabled before calling glUseProgram again, in case its already setup?
Advertisement
As to whether the gl knows that the shader is already bound and just basically "skips" that call would really depend on the manufactures implementation of opengl, perhaps someone with better knowledge of nvidia's or amd/ati's driver's could comment?

If you are really keen on checking yourself you could do something like this:
if(nowShader != currentBoundShader){glUseProgam(nowShader);currentBoundShader = nowShader;}


of course this means you have an if statement every time you want to bind a shader. I think it is easier to just make sure you use glUsePrgram(0) whenever you are finished with a shader that way you can avoid any checking. If you have to use that same shader multiple times per frame than try and group that geometry together so you don't have to enable so many times.
Thank you. I do use grouping, but was just pondering to myself about that - i guess you're right about the implementation dependance.

This topic is closed to new replies.

Advertisement