Sorting Vertex Array


I read one month ago, a paper from nvidia, which shows with graphically that vertex buffer (sorry in DX :frowning: ) are drawn faster when there are sorted. So, I sorted my vertex array (in openGL so, I’m not treacherous person), but I loose 1,15 millions of polygone, what an ugly performance, isn’t it? Anybody know why I get a such slowdown? Is it only working with DX?

Here an example of my vertices indexes before and after sorting :

before : 0;17;18;18;1;0;1;18;19;19
after : 0;1;2;2;3;0;3;2;4;4

and so on … of course I change my vertex, normals, texture coordinate array to suit with the new index array, do I use a wrong


PS : I have a GeForce 2 MX.

You probably got such a slowdown because you spent time you would have been rendering in a sort operation.

I would imagine that sorting only helps through its use of cache memory. If your arrays are separate (as opposed to interleved), they may be stomping on each other’s cache memory.

Anyway, I wouldn’t be too concerned about this in any event. Since you are using OpenGL, not D3D, you should look into other vertex array optimizations first (CVAs, VARs, etc). And sorting will offer no help to VARs, since the memory is uncached anyway.

No, when you quickly reuse indices, you can get more vertex caching benefits. But that’s all.

  • Matt

Hum, I discovered the problem, now I’ve got the same performance with sorted array than “random” array.I am disappointed, I’ll try to implement VAR.

Thanks for your piece of information,