PDA

View Full Version : Optimizing performance through glDrawArrays



sansan
12-09-2003, 12:02 AM
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?

Overmind
12-09-2003, 01:02 AM
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...

sansan
12-09-2003, 01:10 AM
Thanks for hint about CAPS and one big array, I'll try to follow them both! http://www.opengl.org/discussion_boards/ubb/smile.gif

ido77
12-09-2003, 01:22 PM
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)

ZbuffeR
12-10-2003, 11:37 AM
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.