# Cost of redundant state changes

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

## 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 on other sites
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 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..
''

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632654
• Total Posts
3007669
• ### Who's Online (See full list)

There are no registered users currently online

×