Jump to content
  • Advertisement
Sign in to follow this  

[D3D10] Sorting calls in renderer while using ID3D10Effects

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


I'd like to sort my draw calls in renderer by shader, in order to minimize state changes. Currently for simplicity I assume, that all my techniques consist of one pass, so for each object I'm calling pass->Apply only once.

Now, as far as I understand, calling pass->Apply sets all neccessary states, as well as shaders, that are used by that pass. Examining frame history in PIX confirms that.

The problem lays in the fact, that calls VSSetShader, GSSetShader, PSSetShader are being issued no matter if they are needed. Currently all objects in my scene use the same technique and pass, to setting shaders each time is unneccessary.

I could get rid of call to Apply, but this way also shader constants won't be commited to device (and these ones I am changing between subsequent objects).

I thought that maybe calls to XXSetShader are not costly for the driver if they don't actually change anything, but I did a test comparing performance for two scenes, one with the same shader used to draw all objects, and another with two shaders (comparable in terms of complexity) used to draw every second object. So in the latter case, there are many meaning shader changes, and in the former all calls to XXSetShader don't do anything. Both versions run at the same speed. Seems like it doesn't matter for performance whether XXSetShader calls are meaning or not.
(I know that tests could actually be bottlenecked by something else, so I'm not absolutely sure about conclusions from these.)

I was wondering if state blocks would be of any help, but docs about them are rather vague, so I'm not even sure what purpose they serve.

So, the question is, what can I do to avoid calls that change shaders while still being able to commit shader constant changes?

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!