displays lists vs arrays

Well,

What’s the best option when you are trying to speed up your game-engine: display lists or arrays. (Note: using skeletal deformation systems)

Thanks,

vertex arrays

Its not a “option #1 for all cases”. it depends. i find display lists to be almost unbeatable in speed if you include in the list all state changes and geometry of an object in your engine. The are really fast in good implementations.
BUT, in the case of skeletal deformation, maybe you dont have the option of using display lists at all, since display lists are static (you compile then once, then call them each frame).

I recently wrote a program solely for the purposes of testing the speed changes using all the different rendering modes (glBegin/End, glDrawElements with Tris and Strips, glDrawArrays, Display Lists, etc). Display Lists smoked everything else. Especially Display Lists of Tri Strips! However unless your geometry is completely static Display Lists aren’t an option. I got some good results using glDrawElements with triangle strips.

But can’t you stick a glDrawElements or DrawArrays call inside a display list? If so, it isn’t an either or question but rather the answer is to use both together. And what about compiled vertex arrays?
soupnazi, what hardware did you test this on? Thanks!

The best ways to send vertices to opengl, according to my tests and what I’ve read, are from best to worst:
-display lists of triangle strips inmediate (haven’t tryed with gldrawelements inside lists, but since displaylists are optimized in the driver they should reach similar if not identical performance in good drivers).
-glDrawElements of gl_triangle_strips
-display lists of discreet triangles
-inmediate triangle strips
-glDrawElements of discreet triangles
-inmediate discreet triangles

of course, depending on the model, order changes. If geometry is not strip-friendly, you can easily beat strips with discreet triangles, or if you have lots of display lists, each with 3 or 4 triangles, you probably can beat display lists with inmediate triangles or strips, etc.

also, using extensions such as EXT_compiled_vertex_arrays and vendor-specific extensions can increase performance, and close the gap between display lists and glDrawElements for example.

but in 95% of the cases, display lists win, specially if you include material and texture state changes inside them. For dynamic geometry, glDrawElements Strips is the way to go.

What about the guy who said that dispaly lists don’t make use of T&L or at least cost CPU due to the fact they’re not stored onboard?

This has been cleared by THE MAN himself, Matt (the guy from nvidia):
-display lists accelerate everything a geforce can.

Check it our at http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/001791.html

[This message has been edited by coco (edited 01-23-2001).]

coco is right on here: I test all of these rendering modes in my program and they basically run in the order of speed he shows here. Triangle Strips in Display List is hugely fast. My machine is a P2-300 (don’t laugh!) with a GeForce DDR. Trying to organize your geometry to use Triangle Strips is the best idea, and if they can’t be static then DrawElements with Triangle Strips.

Originally posted by coco:
[b]The best ways to send vertices to opengl, according to my tests and what I’ve read, are from best to worst:
-display lists of triangle strips inmediate (haven’t tryed with gldrawelements inside lists, but since displaylists are optimized in the driver they should reach similar if not identical performance in good drivers).
-glDrawElements of gl_triangle_strips
-display lists of discreet triangles
-inmediate triangle strips
-glDrawElements of discreet triangles
-inmediate discreet triangles

of course, depending on the model, order changes. If geometry is not strip-friendly, you can easily beat strips with discreet triangles, or if you have lots of display lists, each with 3 or 4 triangles, you probably can beat display lists with inmediate triangles or strips, etc.

also, using extensions such as EXT_compiled_vertex_arrays and vendor-specific extensions can increase performance, and close the gap between display lists and glDrawElements for example.

but in 95% of the cases, display lists win, specially if you include material and texture state changes inside them. For dynamic geometry, glDrawElements Strips is the way to go.[/b]

Yes you can stick DrawElements in a Display List. I haven’t tested CVA’s yet, that’s my next task I’m testing on a P2-300 with GeForce DDR.

Originally posted by Punchey:
But can’t you stick a glDrawElements or DrawArrays call inside a display list? If so, it isn’t an either or question but rather the answer is to use both together. And what about compiled vertex arrays?
soupnazi, what hardware did you test this on? Thanks!

I’ve always heard that you should minimize the number of calls to glDrawElements… but how is that possible when you’re using strips ?

If i have a scene of 1000 triangles that can be arranged in 100 strips, should i have a single glDrawElements for the 1000 triangles, or 100 calls for the 100 strips ?

Y.

The condition I use to find out if a stripped model is faster that the raw triangles is
numvertices_with_strips < numvertices_without_strips
numstrips2+numvertices < numfaces3
As you may have guessed, the formula says that “if I send less vertices using strips (numstrips2+numvertices) than the vertices I send using triangles (numfaces3), then use strips, else use triangles”

So the answer to your question is yes, use strips in that case, because it will send only 1200 vertices, compared to 3000 vertices without strips. When the numbers get really close, probably triangles will be a little faster than strips because of glDrawElements overhead (strips need 100 calls to glDrawElements, while triangles nedd 1 call).

I completely agree if you are using immediate mode, but…

When you are using glDrawElements with triangles lists, are you sure Nb_tri * 3 vertices are sent to the card ?

Say i have a VA with vertices V0,V1,V2 and V3.
I send two triangles with indices 0 1 2 and 2 1 3.

I was under the impression that 4 vertices and 6 indices were sent, not 6 vertices and 6 indices.

If i’m right, what’s the advantage of using triangle strips ? With triangle strip mode, i’ll simply use indices 0 1 2 3. Less indices, but the same number of vertices, and do not forget the overhead induced by many calls to glDrawElements.

So my question stands: which way is better? :slight_smile:

Y.

You’re theoretically right. My formula would be correct for the number of indices sent, but not for the number of vertices sent.
But I see that in real word drivers, using strips vs triangles even with vertex arrays is still way faster. I dont know if drivers internally send all the vertices or what, maybe sending indices is expensive, etc.
I guess in the end you have to benchmark both and choose which ever is faster. In the case of a game, you could have an “Autoadjusting of parameters” option or something, where you run your engine with various aproaches (gl_triangles, strips, display lists, etc) so you can choose the fastest.

[This message has been edited by coco (edited 01-24-2001).]

Ok, display lists with static data and vertex arrays with dynamic data…

Thanks to all,