Quick question about redundant state-changes

Started by
2 comments, last by XiotexStudios 17 years, 10 months ago
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

www.marklightforunity.com | MarkLight: Markup Extension Framework for Unity

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
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.
--------------------------Most of what I know came from Frank D. Luna's DirectX books
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.
Byron Atkinson-JonesXiotex Studioswww.xiotex.com

This topic is closed to new replies.

Advertisement