Advertisement

Vertex arrays and performance anyone ?

Started by February 17, 2003 02:56 AM
3 comments, last by rodzilla 22 years ago
Does anybody have clues about how vertex arrays affect performance ? Is it better to put vertices, normals, tecture coords in separate arrays or to interleave them ? Of course, I can do the test on my PC, but I''m not sure the results would be relevant for all gfx cards, and all apps. Thanx a lot !
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)

Interleaving is cache friendly, therefore usually faster.

But the only real way to know is to test it.

Maybe you could write an engine that tests it run-time
and has the ability to change vertex array settings
run-time ( that''s what I''m currently doing ).

If you wan''t to learn more about cache etc. check out

http://www.agner.org/assem/
-> pentopt.zip

worth a read if you''re interested in low-level performance issues ( such as cache ).

Advertisement
most model files use separate lists and indexing...

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
Thanx for your answers !

Seriema : I don''t really care for model file formats, because I will convert them if needed.

Separate lists is not really a problem, but separate indexing is pretty annoying, because I don''t know how to render a mesh defined with, for example, vertices and normals with different indices (I want to keep the glDrawArray/glDrawElements approach).

Anyway I''ll make a few tests and come back with the results.
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)

If you have different indices for, say vertices and normals,
you can render them like this:

// assuming that the vertices start at 0 and normals start
// at 248

glVertexPointer ( 3, GL_FLOAT, 0, &vertices [ 0 ] );
glNormalPointer ( GL_FLOAT, 0, &normals [ 248 ] );

glDrawElements ( ... );


if you however have your vertices and normals in different
order, then it is not possible to render them before you
re-order them. ( of course )


btw. you might want to use glDrawElements instead of glDrawArray
because glDrawArray is not Vertex Cache friendly .. ^_^ Vertex
Cache is a feature of the 3d hardware, as opposed to CPU cache
discussed earlier. You can find more info on Vertex Cache at

http://developer.nvidia.com

anyways, the key idea with Vertex Cache is that when you render
vertices with glDrawElements, you occasionally use the same
vertex index more than once, and the 3d hardware caches the
last 16 or 24 or so calculated vertices, so it does not have
to do them again. With glDrawArray you have multiple entries
on different indices for the same vertices, and since the Vertex
Cache works by comparing the indices, it never knows if the
vertex has already been done.

This topic is closed to new replies.

Advertisement