Jump to content
  • Advertisement
Sign in to follow this  
Juliean

Cost of redundant state changes

This topic is 2448 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

while I tried fixing some memory leaks with my directx-application, I noticed a whole lot of warnings about redundant state changes. Not that I perform (m)any state changes in the code myself, instead I am using the directx effect framework, thus getting many things set automatically like:

CullMode = none;
Zenable = false;
StencilEnable = false;
AlphaBlendEnable = true;
Srcblend = One;
Destblend = One;
AlphaTestEnable = false;
ColorWriteEnable = red | green | blue;


Many times repeatetly. Now, before I start trying out to eliminate these state changes, I just wanted to ask: Is there potential for performance improvements? Like if I render 100 objects with a shader like above, should I try to eliminate the redundand sets of the same states in the effect-file or is it neglegible? (would be quite a lot of work so I only want to try&profile if there is a chance to improve things)..

Share this post


Link to post
Share on other sites
Advertisement
Extra state change calls can definitely add up and introduce additional CPU overhead. Obviously it depends on how many redundant calls there are, but if you start getting into several hundred per frame then it can definitely be worth it to reduce them. For effects, you can implement an ID3DXEffectStateManager in order to filter out redundant state calls. There's a sample in the SDK that shows you how to do it.

Share this post


Link to post
Share on other sites
Thanks for the info, I think I will definitely give it a try. I'll also look into the EffectStateManager, although it sounds kind of complicated. Hopefully I'll save a bit CPU overhead..
''

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!