glDrawElements, Performance, vertex reuse

Started by
4 comments, last by CoreMeltdown 19 years, 7 months ago
when using Vertex Arrays and glDrawElements to specify a drawing order for the verts if your ordering hits the same vert many times, does that vertex data get copied to the card for each hit? or is it smart enought to cache them for reuse? my big concern is CPU activity, copying data from system to video memory is getting expensive. No, i dont have VBOs im thinking that assuming its caching them a cheap way to do texture tiling is to have the verts in a heightfiled alternate between 0 and 1 tex coords do one DrawElemetns that draws every other quad bind a mirror image of the texture do a second call that draws all the rest of the quads then youd get the texture tiled across the terrain, without having to do more than one tex coord per vertex, no duplicated data of course this only works if it will let me keep vertex data on card across draw calls..... or if it allows texture binding someplace in the middle hmm now that i think of it im pretty sure the answer to this is no, not without VBOs or mabye CVAs
Advertisement
Quote:Original post by haphazardlynamed
when using Vertex Arrays
and glDrawElements to specify a drawing order for the verts
if your ordering hits the same vert many times, does that vertex data get copied to the card for each hit? or is it smart enought to cache them for reuse?


Yes, there is what is called the "vertex cache" on the graphics card. It isn't very large ( about 17 or something on a GF2/3 ), so don't expect too much. Your drawing order will seriously affect how much use you get out of the vertex cache.
If at first you don't succeed, redefine success.
If you're concerned about CPU load, use VBOs. IF you for some bizarre reason can't use VBOs, at least use glDrawRangeElements to stress the CPU less when doing draw calls.
Unfortunatly VBO doesn't work everywhere..
For instance, my laptop has a geforce2go, and it's drivers don't support VBO.
(don't ask me why, i've installed the latest drivers)

Personally, i use VBO with a VA fallback..
Is VAR supported?
If at first you don't succeed, redefine success.
Quote:Original post by haphazardlynamed
... does that vertex data get copied to the card for each hit? or is it smart enought to cache them for reuse?


Yes, every card since GeForce256 uses a vertex cache, usually fifo with 16-24 slots. I implemented it in my software renderer and the gain wrt non-cached vertices are extremely significative.
However, you should send indices to your gfx card in an order that minimizes cache faults. To do so, nVidia set up a very useful routine.

Give it a try and test again your app.

This topic is closed to new replies.

Advertisement