Indices VS Vertices

Started by
5 comments, last by kauna 11 years, 8 months ago
Hello fellows,
I came up with some questions other beginners in 3D stuff are may interested in also.
What are the pros/cons of using pure vertices for a mesh (Trianglestrip), or using indexed vertices (Trianglelist)?
I run a few tests with DrawInstanced and DrawIndexedInstanced. It appeared to be much more performant when I was using only vertices.
Are there some tips what to use when? What provides which advantages?
When I load models/animations what should I use?
You may know a good article on this?

EDIT: What is a maximum number of vertices send to GPU per frame to remain fine performace on a medium pc?

Thank you
Advertisement
Indexed meshes don't have duplicate vertices. With proper management it'll make your models smaller in size and faster to render due to vertex cache.
Always use triangle-order optimized indexbuffers. (e.g. D3DXOptimizeFaces()).

Strips vs. Lists: from my experience both perform equally well on modern hardware, but strips are smaller (lists 3 indices per triangle, strips +/- 2 indices per triangle).

EDIT: What is a maximum number of vertices send to GPU per frame to remain fine performace on a medium pc?


Depends greatly how you implement it. You can send several megabytes of data through dynamic vertex buffers, textures, buffer objects (etc) to the GPU per frame and maintain good fps. Of course the most efficient way to draw is not to send data to GPU and use static buffers which already reside in the GPU memory. Since that isn't realistic case, you'll need to take care about the amount data that travels through the bus to the GPU.

Top GPU's can handle some hundred of millions of polygon's per second in test scenarios. The question of maximum vertices per frame is highly relativistic depending on the overall complexity of the used vertex/pixel/geometry/domain shaders + size of polygons + amount of used shader resources + number of used render targets and surface formats + blending operations + etc ... you get the point.

Cheers!
Thanks for your concern.
Currently I am sending 256*256*6 indices for 256*256 vertices (with pos and texcoord). Drawing 50 of those with DrawIndexedInstanced. Instancedata is just setting X and Z offset , and the vertex and pixelshader are pretty basic. Just one rendertarget, everthing else basic also. It's the only thing I'm doing per frame. The FPS fall down to 10. I dont really get why this is happening. Is this really already to much data to send?
When I throw the DrawIndexedInstanced line out, FPS go up to 350.

[media]
[/media]
How can people do something like that maintain a decent performance???

Strips vs. Lists: from my experience both perform equally well on modern hardware, but strips are smaller (lists 3 indices per triangle, strips +/- 2 indices per triangle).

There's a tradeoff in this. Strips have a lower index count for sure, but lists can have a lower vertex count. With strips you're never going to get better than 1 vertex per triangle, whereas with a list the theoretical best case is 0.5 vertexes per triangle. As vertexes tend to be larger than indexes (is there ever any case in which they're smaller?) this can amount to a huge saving in vertexes as the cost of a smaller overhead in indexes.

That's not the full story though. The precise saving you'll get will be heavily dependent on the model you're rendering; if you have a lot of duplicated data then obviously there is more saving to be made with lists. You can also consider strips with primitive restart if you can target more modern hardware (which I assume is the case since you mentioned D3D10/11 draw calls), although my own experience is that it tends to be something of a wash between that and lists.

It's rarely mentioned but lists are also good for concatenating multiple strips (which you can also do with primitive restart) and for concatenating strips with fans and/or quads (which you can't do with primitive restart). Given the huge bandwidth of modern hardware that one point, IMO, tends to lead to me generally favouring lists, as it can result in less (and faster) preprocessing of model data in order to get it into a format where it can be used for drawing with, even in cases where a single large strip may benchmark as more performant. It also can lead to cleaner simpler code if everything can go through a common draw point.

One final point worth noting is that lists were used for everything in Quake 3 Arena; see: http://www.gamers.org/dEngine/quake3/johnc_glopt.html. Yes, it's an old old old game, and yes, it's OpenGL, not D3D, but it was used as a common graphics benchmark for such a long time that it should be considered as a reasonable indicator of the direction much graphics hardware and drivers have been optimized in.


Always use triangle-order optimized indexbuffers. (e.g. D3DXOptimizeFaces()).

It's worth noting that these calls, despite being D3D9 and not present in 10 or 11, can be used in D3D10 or 11 by just including the relevant headers and libs.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


When I throw the DrawIndexedInstanced line out, FPS go up to 350.


Using debug or retail build? using debug or retail d3d libraries? Your hardware? Any errors in debug windows?


How can people do something like that maintain a decent performance???
[/quote]

The video shows and explains it pretty well ... instead of drawing lots of trees, they use clever impostor tricks.

Cheers!

This topic is closed to new replies.

Advertisement