Archived

This topic is now archived and is closed to further replies.

edotorpedo

VA slower than calling glVertex ???

Recommended Posts

edotorpedo    198
Hi, I''ve built this quadtree GeoMM terrain engine. For rendering leaves at my 4-deep quadtree I first used the following code glBegin(GL_TRIANGLE_STRIP) glVertex(...) glEnd() and got about 100 FPS at 171 patches drawn. But once I heard about vertex arrays, I recoded my drawing-routine, so it now looks like this: glVertexPointer(..) glDrawElements(GL_TRIANGLE_STRIP,....) but I get only about 95 FPS at the same 171 patches drawn. How can Vertex Arrays be slower than just *normal* glVertex rendering ?? Is it because I switch vertex array at every leaf? I already asked wether that would make a difference, but folks at this forum said it to be very fast (because no actual data is transferred). I can understand that my GPU doens''t cache any vertex data, because I switch vertex array 171 times each frame. Is this normal? And if yes, what do I have to do different, so that it really speeds up my rendering. Do I have to use one large vertex array (and lots of IB'') in stead of one vertex array at each leaf and only 4 IB''s? Thanks, Edo

Share this post


Link to post
Share on other sites
kronq    122
How to draw fast:

- minimize rendering state changes -- draw everything you can with the same textures, etc before switching

- yes, use one large vertex array if possible. Prepare it before rendering then use ''glLockArraysEXT'' to lock it (''compiled vertex array'' extension)

- or, for the next step up from compiled vertex arrays check out NVidia''s ''Vertex Array Range'' extension: http://developer.nvidia.com/view.asp?IO=var_fence

- read "Batch, Batch, Batch:" What Does It Really Mean? NVidia GDC presentation: http://developer.nvidia.com/view.asp?IO=presentations
its written with D3D examples, but it mostly applies to GL

Share this post


Link to post
Share on other sites
Prefect    373
Using vertex arrays should never be slower than the exactly corresponding sequence of glVertex() etc. calls (at least it never was for me).
I''d look at how you''re building the vertex array (e.g. using the heap and heap fragmentation might slow things down), or if you''re doing unnecessary state changes.

cu,
Prefect

Share this post


Link to post
Share on other sites
edotorpedo    198

Well, as I said I use about 256 different VA''s (one for each leaf of my quadtree). My VA is just an array of

class CVertex {
public:
float x,y,z;
float normalx, normaly, normalz;
};

At each leaf I switch VA, and render it using glDrawElements (I have 4 static index buffers to draw VA at different LOD).

However, it is slower. And if I create one large VA I''d also have to create 3 IB''s at each leaf! This will eat a lot of memory (about 2.5 MB''s more I calculated).

I will look into this VAR-extension though. BTW: what does this glLockArrays do? I reckon it writes all data from VA to GPU, so that you can''t change the VA anymore. To apply this, can you have multiple vertex arrays?

Thanks,

Edo

Share this post


Link to post
Share on other sites