PDA

View Full Version : Why is VAR so slow?



WhatEver
03-01-2002, 04: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?

Korval
03-01-2002, 05: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.

WhatEver
03-01-2002, 05: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?

Korval
03-01-2002, 07: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.

WhatEver
03-01-2002, 08: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.

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

- Matt

wimmer
03-02-2002, 02: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.

Michael

WhatEver
03-02-2002, 06: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)?

What's the hex value for GL_VERTEX_ARRAY_RANGE_NV_WITHOUT_FLUSH?

richardve
03-02-2002, 07:18 AM
Originally posted by WhatEver:
What's the hex value for GL_VERTEX_ARRAY_RANGE_NV_WITHOUT_FLUSH?

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

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

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

- Matt

WhatEver
03-02-2002, 12:42 PM
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...

knackered
03-03-2002, 08: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?

harsman
03-03-2002, 12:16 PM
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".

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