Vertex arrays - behind the scenes

Hi,

I have some questions about what happens behind the scenes (i.e. at driver and GPU level) when you use vertex arrays.

I’m working on yet another terrain engine, and to save as much space as possible, I use the following vertex format:
• UV1: 2 GLshorts (first pair of texcoords)
• UV2: 2 GLbytes (second pair of texcoords, used for detail texture)
• Normal: 3 GLbytes (quantized vertex normal)
• Padding: 1 GLbyte
• XYZ: 3 GLshorts

This gives me a nice and small 16-byte structure, which can be aligned to DWORD boundaries in memory. Is it worth bothering with this if all you’re doing is throwing this array at the 3D card?

Also, I don’t actually use the normals for rendering. They’re only there for things like collision detection. Would it be noticably faster if I took them out of the vertex array and stored them separately?

On a related topic, just how does all this data get transferred to the card? If I specify each array separately (as opposed to using glInterLeavedArrays()), can the whole array still be transferred in one go?

And finally, notice that I used integer types for everything. Is there a speed difference between this and floats?

Thanks

  • Tom

For NVIDIA cards, that format will not get you very good results.

If you look at the VAR spec, it essentially tells you what vertex formats we support natively in HW. The short answer is that we generally support FLOAT, UNSIGNED_BYTE (for colors), and SHORT (in some cases).

Anything other than these types will clearly slow you down, because we’ll convert it on the fly – this applies even if it saves space in memory.

Now, on existing driver releases, this won’t be good enough. Generally, you’ll have to select one of a number of fast paths. I don’t have the list handy; I believe a (possibly incomplete) list is in the OpenGL performance FAQ.

On future driver releases (think 10.xx), we’ve gone ahead and written a much more general way of dealing with the problem. On those drivers, CVAs with a format that matches the HW format are the way to go.

  • Matt

i believe a lot of ppl would love to see this list of the ‘fast paths’ i know it’ll save me a lot of time testing.