Sign in to follow this  
mihu

[D3D10] Sorting calls in renderer while using ID3D10Effects

Recommended Posts

Hi,

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this