Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

While answers will vary depending on the case, I'd love to hear about what people have seen in their past experiences. The question mainly relates to DirectX though if you have some numbers for any other API (OpenGL, consoles etc) I'd be glad to hear them too.

Thanks in advance.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

It depends what states you're changing; different things cost different amounts. Simple state like blend equations and most other SetRenderState stuff is cheap, and gets batched up till the next draw call so doesn't incur a large penalty for hitting the driver. Shaders and render targets are more expensive and will generally cause issues if you swap them excessively.

Usually though render states are not something you have to worry about overly - draw call overhead will almost always dwarf render state costs.

In terms of numbers I'd suggest aiming for no more than a couple of hundred shader swaps per frame, as few render targets as you can get away with and not worry about the rest. Typical numbers for simple state might be 5-10 state changes per draw call, but it's very variable.

share|improve this answer
1  
Most of the "draw call overhead" is actually resolving the batched up state changes, not strictly emitting the draw commands to the hardware. Games with fewer-than average state changes between draw calls can get many more draw calls per frame. –  Jesse Hall Jul 24 '10 at 1:04
add comment

It doesn't matter how much renderstate changes really is, you should always minimize that number, using sorting, etc, as renderstate changes are expensive on most APIs.

share|improve this answer
add comment

Two. Enabling and disabling depth-testing for the UI.

Everything else is handled by shaders.

share|improve this answer
    
What are you talking about? Binding another texture or another shader is also a state change. –  Axel Gneiting Jul 22 '10 at 18:46
    
One shaded, one texture. I assumed only per frame changes count. He explicitly asked about examples. –  Andreas Jul 27 '10 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.