Jump to content
  • Advertisement

Archived

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

yanuart

DrawPrimitive vs DrawIndexedPrimitive

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 don`t go for indexed tri strips, it`s not that much of a difference in fps but it`s just much of a hassle.

Share this post


Link to post
Share on other sites
VladR, I have a little question about terrain rendering...

Look at this:

These are your points in your map

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


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 ?"

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

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

Thanks in advance for clarifications



/* 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 wouldn`t 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)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!