[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering triangle meshes with OpenGL



On Fri, Sep 20, 2002 at 08:03:39AM +0200, Jorrit Tyberghein wrote:
> Mark Collins wrote:
> 
> >On Thursday 19 September 2002 7:11 am, you wrote:
> >
> >>I think you should have a look at glDrawElements() instead. This is a
> >>lot faster
> >>compared to using display lists.
> >>
> >
> >Um, no. Display lists are pre-computed, where as vertex arrays aren't. 
> >When done properly, compiled lists are the fastest way to go.
> >
> I have done some benchmarks on nvidia hardware. In theory you may be right
> but in practice most drivers are optimized for glDrawElements and not 
> display
> lists. This is at least the case on nvidia. glDrawElements was a LOT faster
> compared to display lists last time I benchmarked it (which was some 
> time ago
> so current drivers may have different results).

The reason for this is simple: in most geometry many triangles meet at
each vertex. Using an array means one can transform each vertex as
needed only once and the re-use the result for each of those
triangles. Presenting the verticies as individual tuples makes it much
harder for the driver to spot that it's done a transform on this tuple
recently - compared with the array version of this check which is
(probably) a lookup in an array of flags.

I'd be surprised if display lists turned out enourmously faster than
arrays in very many cases, simply because of this issue, unless the
list compiler can spot that you've already used this tuple before and
insert a "reuse the information". The speedups may be showing a
difference in which memory the list is residing - the arrays are in
main RAM, whereas the display lists could be in specialised memory on
the card.

It's important to test with a number of kinds of geometry - a sphere
will help show up the effect of the vertex re-use whereas a collection
of unconnected triangles will not.