Archived

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

Sir_Spritely

Most effecient way to draw a triangle

Recommended Posts

I''ve been drawing triangles via the method show in the SDK Tutorial 1. However I created a DX9 application using the wizard and this shows a different method creating a triangle. So which is the most effecient the SDK Tutorial 1, or the Visual C++ 6 DX9 Application Wizard which is automatically installed when you install the SDK9. I haven''t posted any code because I figured most ppl will be able to view the code easy enough. Thanks, Paul.

Share this post


Link to post
Share on other sites
Having been doing a terrain engine for the past few days, I have found that using index buffers with tri-lists has proved quicker than say just using triangle lists with no index buffers - this is because using index buffers you can share vertices, hence less vertices need to be drawn. This works well where triangles are joined together like in a terrain.

Share this post


Link to post
Share on other sites
1) Drawing "a" triangle is NEVER efficient in D3D - first key thing is drawing lots (say 100s) of related triangles at the same time - i.e. batch them. Drawing too few triangles per Draw*Primitive*() call implies having lots of draw calls per frame to achieve decent polygon counts. Too many draw calls per frame is bad for performance. The various IHVs have published a few papers on this over the years - well worth a read.

2) Indexed Triangle Strips are the "fastest" because they potentially have the lowest number of vertices per triangle. However they''re only good if the length of the strips [you can join strips/turn corners with degenerate triangles] means you don''t have too many batches (see above).

3) Keeping good locality of reference in your index data (i.e. make sure the indices don''t jump around the vertex stream too much) helps for vertex caching, particularly the post-T&L cache (you only get that with indexed primitives). A vertex already in the post-T&L cache is a vertex that doesn''t have to be re-transformed and lit.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites