Directx Internal Optimization

Started by
1 comment, last by jollyjeffers 15 years, 9 months ago
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.
Advertisement
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.
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement