Optimising using vertex arrays

I think this only applies when not locking the vertex array, or not using nvidias VAR. Because whith these all the vertices in the desired area of memory is processed, double used Vertices are (should) only be processed once.
At least i gained a large increase in Framerate only by locking my VertexArrays (i use one per Object aprox 1000 Vertices per Array)

Lars

Moz: i’ll explain “sequential” versus “non-sequential” VA access:
Imagine you have a simple VA with 12 elements, and you are using GL_TRIANGLES primitive ( 3 elements per triangle ).
Sequential access, for example: 0 1 2 , 3 4 5, 6 7 8, 9 10 11
Non-sequential access: 0 1 2, 9 10 11, 6 7 8, 3 4 5

Y.

Is there substantial overhead in calling gl*Pointer that makes it prohibitive to use? It seems to me that these calls can’t possibly take as long as copying (AGP memory or just regular) potentially thousands of vertices each frame. After all, the data is already in memory each frame (in the case of static data); its just a matter of getting the hardware to look in the right place of rit.

hm… when you do something like this:

unsigned char* buffer0 = new unsigned char[ sizeofbuffer0 ];
fill it…
unsigned char* buffer1 = new unsigned char[ sizeofbuffer1 ];
fill it…

and then use glDrawElements, its NOT important if you do it like this:

glDrawElements( buffer0 );
glDrawElements( buffer1 );
glDrawElements( buffer0 );
glDrawElements( buffer1 );
glDrawElements( buffer0 );
glDrawElements( buffer1 );

or like this:

glDrawElements( buffer0 );
glDrawElements( buffer0 );
glDrawElements( buffer0 );
glDrawElements( buffer1 );
glDrawElements( buffer1 );
glDrawElements( buffer1 );

and why?! because opengl processes EVERY VERTEX AFTER THE OTHER… and like that it done store anything ( not in your cpumemory! )… and it does not remember the last pointer… ( vertex_program shows it best… one vertex after the other… )

means… if you dont lock your array ( then it will be copied onto gpu ram or something like this… ) or use wglAllocate ( and best of all: lock it there ) etc but just simple new or malloc, and then glDrawElements… it does not do anything else then everytime it is called beginning reading out first vertex, send it to your program/ffp and then do it with the next…

AND EVEN IF IT COPIES IT ONTO ITS RAM FIRST AND PROCESSES IT THEN THERE, THERE IS NO DIFFERENCE…

why? cause even when you let the pointer be, you possibly have changed the data, and it has to reread it again…

learn how opengl/gpu’s works, and you learn much but its simple… its a pipeline, every thing after the other one… first the vertices, then it rasterices the triangle ( it stores up to 3 vertices to do that ) and the rastericer calls for every pixel on the triangle the “pixel program”, wich is not fully accessable by us today, but you can change much of it with registercombiners (2) and textureshaders…

every one after the other one, and this incredible fast

Originally posted by Ysaneya:
[b]
Sequential access, for example: 0 1 2 , 3 4 5, 6 7 8, 9 10 11
B]

Uh!

It’s never the case when you use glDrawElements, that’s why you need an index array.
Otherwise you would simply use glDrawArrays … which you don’t because glDrawElements is more convenient.
And in nvidia’s performance FAQ, it is said that glDrawElements is often faster than glDrawArrays. So there is no gain in having the sequential VA access you describe.

I’m pretty sure that the sequential stuff only matters for writing data into AGP memory. I don’t quite see how people keep forgetting that the way the graphics card reads AGP is very different from how the CPU does. They are in two very different places accessing it in very different ways. So feel free to use your glDrawElements() call on vertex_array_range_NV memory.