View Full Version : Why is VAR so slow?

03-01-2002, 03:47 PM
When I use VAR for models that have under n(I don't know exactly, somewhere around 3,000 maybe) triangles it slows down instead of speeds up. To get any noticeable speed increase I have to have really high triangle counts, so high that it wouldn't be practical for any game.

What is VAR good for in games? When would you use it?

03-01-2002, 04:11 PM
What are you doing between successive model renders?

What is VAR good for in games? When would you use it?

You answered your own question: "really high triangle counts." This gives you an incentive to use lots and lots of triangles. After all, you only use VAR when you need fast vertex transfer. And the only time you need fast vertex transfer is when you are doing lots of vertex transfer.

03-01-2002, 04:24 PM
I set the VAR pointers for every model. When all the models are drawn then I call: glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);

The data is only copied to the VAR memory once at init time. I do however copy vertex data and then normal data into the VAR mem, no interlieving in other words. Is that a bad thing? I did it like that so I could allocate one HUGE chunk of VAR mem and then share the VAR mem among all my models. Doing this alowed me to avoid copying data to VAR memory between differant models.

Does that make sense to you?

03-01-2002, 06:58 PM
I think that diabling VAR between models is a bad idea, especially if the next model you're going to render is just going to reenable it. Since you are turning off VAR, I'll bet the driver has to do a glFlush (or finish, or which ever one stalls the CPU until the graphics chip is finished). So, you're basically losing half of the gain in using VAR by disabling it after every model. Don't do that.

03-01-2002, 07:14 PM
I turn it off after all the models are drawn. I learned my lesson long ago for disabling it after every model http://www.opengl.org/discussion_boards/ubb/smile.gif.

03-01-2002, 08:51 PM
Don't disable it at all for best results.

- Matt

03-02-2002, 01:55 AM
And if you need to turn it off for some reason, then use glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV_WITH OUT_FLUSH);

Whether you get a speedup by using VAR depends on your memory system and whether you are transfer-bound at all. I have found that interleaving data does give a performance boost in many cases. If you have enough vidmem and only AGP 2x, be sure to store the models in video memory, not in agp (that's faster in my experience), especially if you write them only once.


03-02-2002, 05:35 AM
If I didn't turn it off then all the stuff I draw in imediate mode(menus and text) are all screwed up...unless it wasn't suppose to do that and it was a driver problem(I haven't updated my drivers for a while http://www.opengl.org/discussion_boards/ubb/smile.gif)?


03-02-2002, 06:18 AM
Originally posted by WhatEver:

I have to RTFM you.. sorry http://www.opengl.org/discussion_boards/ubb/smile.gif

It's GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV and you can find it here: http://www.nvidia.com/dev_content/nvopenglspecs/GL_NV_vertex_array_range2.txt

03-02-2002, 08:27 AM
I got it! Thx guys.

03-02-2002, 09:25 AM
VAR being enabled should have zero effect on immediate mode.

- Matt

03-02-2002, 11:42 AM
You're right. Now that a think back it wasn't the imediate mode screwing up, I was drawing models with VAR and without VAR. If I didn't disable the VAR the non-VAR models would look all screwy.

Forgive me for this was about 8 months ago...

03-03-2002, 07:57 AM
Just want to clarify something, while we're on the general topic of VAR...
Does using DrawRangeElements rather than just DrawElements speed things up when using VAR?
In other words, does forewarning the driver that the vertices referenced will be in a certain range help at all?

03-03-2002, 11:16 AM
If you look at this thread (http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/005647.html) Matt said "DRE doesn't help when using VAR".

03-03-2002, 10:44 PM
It was a rhetorical question http://www.opengl.org/discussion_boards/ubb/wink.gif