PDA

View Full Version : Compiled Vertex Arrays



HFAFiend
04-22-2001, 02:36 PM
What can't you do, once you lock an array? I know you can't change the contence of the array, but are there any openGL commands you can't use?

jwatte
04-22-2001, 03:05 PM
The extension is actually somewhat murky WRT this subject. I've heard Matt complain about that before :-)

I believe almost anything is allowed, but that certain commands (especially those that change the modelview or projection matrices) will negate any benefit of the lock, because it'll force the driver to flush its post-transform state.

The way most people use it, and the thing that drivers seem to optimize for, is multi-pass rendering over the same geometry to compensate for a lack of texture units (i e you may need 4 texture passes, but there's only 2 units). Thus, I believe changing the texture pointer and/or the texture matrix would still keep you on the optimized path (although of course the driver will have to re-transform the texture coordinates if you change the matrix).

For HT&L cards, the benefits of locking are less, but better than nothing. VAR/AGP/fence is much better, though.

HFAFiend
04-22-2001, 03:37 PM
So, in other words, I should lock only what I will render right away (because I have to do transformations between groups of vertex data)?

HFAFiend
04-22-2001, 03:57 PM
Also, should one use glDrawElements and/or glDrawArrays, when using compiled vertex arrays?

mcraighead
04-22-2001, 04:12 PM
Yes, the extension is extremely vague. I don't like the CVA extension at all.

- Matt

jwatte
04-23-2001, 08:23 AM
If DrawArrays works on your data, you should use that, as dealing with indexes involves extra overhead. However, if using indexes means you send fewer vertices to the driver (i e there is vertex re-use) then you should use DrawElements -- the overhead of processing the indexes is less than the overhead of tranforming vertexes more than once for "typical" meshes.

Locking a vertex array does only seem useful for the local case (i e around a grouped set of redering calls for the same geometry). If you need to change the modelview or projection matrices, you shouldn't keep the arrays locked.

An interesting experiment is to run GLTrace on something using the Quake3 engine (like Quake3, or Alice) -- looking at that output, it's pretty clear how LockArrays should be used :-)

HFAFiend
04-23-2001, 11:22 AM
GLTrace? How do I do that?

andreiga
04-23-2001, 12:25 PM
Originally posted by mcraighead:
Yes, the extension is extremely vague. I don't like the CVA extension at all.

- Matt

If CVA is not a good extension, what kind of drawing method should be used if I have a GeForce2 and I want to use vertex programs?
If I'm remembering well in a doc you said that VAR extension should not be used with GF2 and vertex programs (because of the software vertex transforming).

Andrei

mcraighead
04-24-2001, 08:35 AM
If you're using vertex programs, CVA won't help. You'll have to live with whatever performance you get. It's not in HW, so don't expect anything special.

- Matt