Optimizing performance through glDrawArrays

Dear all,

I have the following problem:

My function draws several textured quads (about 10), vertex co-ordinates being computed on-the-fly using certain logic. Quite a simple thing, indeed.

But this function is called ~50000 times when the scene is drawn, and things are quite slow. After some analysis, it became obvious that the most part of the time is consumed by glVertex and glTexCoord calls (~40%).

So my idea is to improve my function: first compute all the vertices and texels putting them into arrays, and then use glDrawArrays.

My main concern is that the size of arrays will be small - about 40-50 vertices and texels.

So, my question is:

SHOULD I EXPECT ANY PERFORMANCE BENEFIT FROM USING glDrawArrays WITH RELATIVELY SMALL ARRAYS (less then one hundred vertices) AS COMPARED TO USING glVertex DIRECTLY?

With arrays of size 40-50 you won’t get much of a speed improvement. A better method would be to compute all vertices (meaning 50000*50) and store them in one array, and the draw this array in one single call.

This works only if you use the same texture for everything. If not, sort your geometry so that you have one array per texture, so you have just one glDrawArrays call per texture.

I hope that helps
Overmind

A friendly side notice: Typing in CAPS is commonly considered shouting and is not very polite…

Thanks for hint about CAPS and one big array, I’ll try to follow them both!

If you want to go even faster use the vertex array range extension (VAR) or the vertex binary object extension (VBO)(availables on NVIDIA’s cards)

Originally posted by ido77:
If you want to go even faster use the vertex array range extension (VAR) or the vertex binary object extension (VBO)(availables on NVIDIA’s cards)

Not totally correct :
see http://oss.sgi.com/projects/ogl-sample/registry/

VAR:GL_NV_vertex_array_range
Nvidia specific.
VBO:GL_ARB_vertex_buffer_object
supported by any card with quite recent drivers I think.