This topic is now archived and is closed to further replies.


D3DX Library

Recommended Posts

In most cases, the D3DX library will be more highly optimized than you could/would do yourself. Unless you have very specific reasons, use the D3DX functions. For instance, the D3DXIntersect... methods use an algorithm for finding the intersection of a ray and an object. That algorithm is probably highly optimized on multiple processors. I would only write my own if I was using a different algorithm, and even then it may not make sense unless my new algorithm was highly superior.

(I''m not sure of the specifics of the D3DXIntersect... functions, but the point holds true in general...)

Share this post

Link to post
Share on other sites
The Mesh functions render through D3D, they do nothing more in most cases then provide a method of bookkeeping, and provide some complex functionality that is difficult and time-consuming for the average user (i.e. optimization). In short, although you could write your own class AS FAST as D3DXMESH, I doubt you could beat it.

If you want meshes to be fast, then be sure to do the following (8.1):

-Be sure to create meshes as managed and write_only if possible. Sometimes you cannot create a mesh like this, so make a system memory one and then call CloneMesh. The mesh will automatically putitself in hardwarememory.

-Call SortAttributeBuffer. A mesh contains an attribute id table. Each face has an ID which indicates what ''subset'' it belongs to. The idea is that each subset has a set of material attributes etc. Unfortunatly, if you don''t call SortAttributeBuffer, then the different faces can be scattered all over the place and this results in numerous draw calls internally.

-Call OptimizeInPlace. Can give you a 200% perf increase on most hardware. This is based on Hughes-Hoppes research on vertex cache optimization, D3DX will autodetect the correct cache size settings for the current HW you are running on.

A note about rendering: Typically, you call DrawSubset(ID). Each time you call this function, all the faces with that ID in the attribute buffer are rendered. This allows for a mesh to have different textures and material properties.

Note also that the memory overhead for doing mesh optimizations can be high, so you might want to do all your optimizations and reformating offline and save the mesh in a good format.


Share this post

Link to post
Share on other sites