PDA

View Full Version : Lock/UnlockArraysEXT



dare
02-02-2003, 10:15 PM
What is the right use of this extension, and what are the benefits?

JustHanging
02-03-2003, 01:08 AM
It's used by locking your vertex arrays after specifying vertex, normal etc. pointers. Then you call glDrawElements, and after that unlock the arrays.

The arrays can be precompiled at the locking time by the driver. A common advantage is, that shared vertice get transformed only once. The advantage gets bigger if you multipass over the same object, since you can compile (lock) the object once and draw it several times.

-Ilkka

dare
02-03-2003, 07:47 AM
Thanks. So if one vertex is common for n triangles it's tranformed just once, and you spare n-1 transformations, right?
And one more question : is it compatible with glInterleavedArrays?

jwatte
02-03-2003, 11:32 AM
Yes, it is compatible.

The real benefit comes for multi-pass algorithms:




VertexPointer()
LockArrays()
foreach texture layer:
TexCoordPointer()
BindTexture()
DrawElements()
UnlockArrays()

JustHanging
02-04-2003, 01:14 AM
Hey, are you really allowed to change texCoordPointer after lockArrays? That would be great, but I thought you can't do that.

-Ilkka

harsman
02-04-2003, 02:00 AM
The CVA spec is about as vague as you can get on this point. So you can probably change it, but it might trigger a re transform of geometry. On the other hand, that's what happens on hw T&L cards anyway, since they can't "save" transformed vertices.

Jan
02-04-2003, 05:49 AM
It might trigger a re transform of geometry. On the other hand, that's what happens on hw T&L cards anyway, since they can't "save" transformed vertices.


Wouldn´t this mean, that CVA´s are good with shared vertices, but not with mutlipass rendering, because the computations of the first pass are not available in the second?

Jan.

jwatte
02-04-2003, 03:58 PM
With CVA, the computations ARE available for second passes, if you change nothing except bind new textures and change texenv.

However, an optimized driver may realize that it doesn't need to re-transform vertex position and normal values just because you re-specify the texture coordinate array, unless you have texgen enabled.

Even when it has to re-transform, it can do it in a much more efficient way, because you tell it what the minimum and maximum vertex index you'll use is; it can use a highly efficient streaming transform path to just transform the entire chunk between start and end.