Jump to content
  • Advertisement
Sign in to follow this  
Opwiz

Quick question about redundant state-changes

This topic is 4554 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

Hello I just wonder if the direct3d checks for redundant state-change calls such as setting the same effect parameter twice or setting the same vertex buffer. The reason I'm asking is that I want to sort my renderable objects by effect parameters and want to know if I also must keep track of the state-changes made by the previous renderables. Thanks Opwiz

Share this post


Link to post
Share on other sites
Advertisement
My understanding of this is that if you created a pure device, it will not check for redundant state changes which should be faster if you don't have many. If you do, it could be slower.

BennyW

Share this post


Link to post
Share on other sites
State changes are for things where you use the SetRenderState command. Setting global variables in the shader is different. The DirectX debug will list the redundant state changes in the debug window. It will not notice if you are setting shader globals more than once.

It is a good idea to batch drawing calls for geometry that share textures, materials, and other data. But render states, like turning lighting on/off and setting the cull mode are not expensive. The one exception is when you want to enable alpha blending. You should first draw objects that do not use blending and then draw the ones that do.

Share this post


Link to post
Share on other sites
My understand is:

If you are not using a pure device then the DX run-time does some redundant state change checking - the debug spew shows this.

Changing renderstates can cause the driver to require a recompilation of microcode - alpha blending especially so. As you can imagine this is expensive.

However, having said all this modern hw and drivers are pretty fast and it could be that your app isn't going to have much of a problem if you ignore the above.

If you can though - batch.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!