Sign in to follow this  
littlekid

Directx Internal Optimization

Recommended Posts

From what I have read so far, directx does a fair amount of optimization. E.g: D3D10Device->IASetInputLayout(A); D3D10Device->IASetInputLayout(B); would result in this as directx optimize by setting a dirty region. D3D10Device->IASetInputLayout(B); What about this scenario: D3D10Device->IASetInputLayout(A); DrawMeshOne(); D3D10Device->IASetInputLayout(A); DrawMeshTwo(); Will directx removes the 2nd similar IASetInputLayout() instruction? Or do I have to optimize them by myself? Reason being that each of my CObject class handles the draw code itselfs meaning CObject::Draw() does this:
CObject::Draw()
{
    IASetInputLayout(CObject::Layout);
    IASetPrimitiveTopology(CObject::Topology);
    
    for each effect pass
        DrawIndexedPrimitive();
}
Hence when many CObject::Draw() are executed, it would lead to the above scenario.

Share this post


Link to post
Share on other sites
The D3D10 runtime generally (and in this case, definitely) turns redundant calls like this into a no-op before it gets to the driver. There is still some overhead in any API call, but it's probably as fast or faster than you checking yourself to see if the handles match.

Share this post


Link to post
Share on other sites
State management and optimization in D3D10 is a lot better than with D3D9. Previously it was a serious concern to all AppDev's to ensure an optimal and efficient interaction with the API, but with D3D10 it can (at least initially) take more of a back seat. As in more conventional optimization - wait until it shows up in your "worst offenders" list before you expend substantial effort on improving it.

Tools like NVPerfHUD are good for trying to identify where the bottlenecks really are. You can start to trace this sort of thing back to the characteristics of your application and hence identify where the code needs attention.


hth
Jack

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