#### Archived

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

# DrawPrimitive vs DrawIndexedPrimitive

This topic is 6127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there any significant perfomance setback between those two ??

##### Share on other sites
You can use an index to render fewer vertices. For example, a quad of two triangles can either use 6 vertices (triangle list), or 4 vertices (indexed triangle list). The savings become more significant with more complex objects.

##### Share on other sites
In my MD2 model class, I initially started with indexed vertex buffers but found that for my simple app a triangle list rendered quicker!
I don''t know why but it did. I got much better frame rates when I stopped using the indexed list.
You should try both to see but don''t worry about non-indexed lists being really really slow because they aren''t. They just may be faster for you like they are for me.

##### Share on other sites
This sounds very strange. I''m tempted to say that you were doing something wrong...

Triangle for triangle, indexed lists should always be faster because you are talking about processing less vertices.

##### Share on other sites
CrazedGenius - yeah I know, it doesn''t make much sense.
Rendering MD2s with LERPing between frames is not as straightforward as simply rendering a single vertex buffer with an indexed list though.
You have to recreate each vertex if you are not using vertex shaders anyway.
I want to do some more testing on it later but for now, the non indexed vertex buffer is working great.

##### Share on other sites
It depends on how much vertices are being sent in one call to DrawIndexedPrimitive and how many times you call it in your Render Loop.
When I changed my terrain renderer from unindexed triangle list to indexed triangle list i noticed 100% difference. However I had my data sorted well - i had heightmap terrain. And dont go for indexed tri strips, its not that much of a difference in fps but its just much of a hassle.

##### Share on other sites

Look at this:

*---*---*---*---*---*
|    |    |    |    |    |
*---*---*---*---*---*
|    |    |    |    |    |
*---*---*---*---*---*
|    |    |    |    |    |
*---*---*---*---*---*
|    |    |    |    |    |
*---*---*---*---*---*
|    |    |    |    |    |
*---*---*---*---*---*

Each point has a TU and TV for texturing, right ?

Let's zoom for a single "tile", the higher left one:

*---------*----
|        /  |
|      /    |
|    /      |    /
|  /        |  /
*---------*----
|        /  |
|      /    |

If the upperleft vertice have (0.0f, 0.0f) and (1.0f, 1.0f) in the lowerright vertice in (TU, TV) coordinates.

The question is :

"Take the last considerations I've showed you, does the tile at the right side of the upperleft tile of the terrain will have a lowerleft vertex with texture coordinates (1.0f, 1.0f) (I mean while using a index buffer that the purpose is for reusing vertices). Imagine if this tile must not have (1.0f, 1.0f) coordinates, but (0.0f, 1.0f) because it uses another texture or another region of the texture. Do you have to use special texture coordinates or draw quads like this ?"

*---------* *---------*
|        /  |   |        /  |
|      /    |   |      /    |
|    /      |   |    /      |
|  /        |   |  /        |
*---------* *---------*

*---------* *---------*
|        /  |   |        /  |
|      /    |   |      /    |
|    /      |   |    /      |
|  /        |   |  /        |
*---------* *---------*

/* Bullmax */
-------------
Reality has many forms : good and evil, black and white, ying and yang.

Edited by - Bullmax on February 2, 2002 8:51:44 PM

##### Share on other sites
Now I remember why I switched from an indexed list to a simple list of tris.
I had strange texture coordinate problems because the model that I was importing had shared vertices with different u, v coordinates.
Its been so long since I wrote that code, I couldn''t remember why I switched.

##### Share on other sites
ryoder: a couple of reasons why the index list would be slower are; because it involves an additional lookup and also the memory pattern wouldn''t be so good (causing cache misses).

##### Share on other sites
Bullmax, do you want to use two different textures on one quad (two triangles) ?
If i understand u well, then two texture coordinates should be enough. If you break the indexed triangle list by adding degenerate triangles, you might loose the performance advantage of indexed list, therefore it would be easier to use just ordinary triangle list(nonindexed).
However, if we are talking about characters - models, it is easier to just use nonindexed tri list since if you have just low poly character, there wouldnt be such a big difference in performance.
But as for heightmap terrain, indexing definitely is big difference in performance (at least if you draw large chunks of terrain at once)

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633284
• Total Posts
3011211
• ### Who's Online (See full list)

There are no registered users currently online

×