PDA

View Full Version : Vertex array not much faster?



haigu
12-09-2000, 03:37 AM
I am outputing some triangle fans in my program.
but in immediate mode, calling glTexCoord2fv and glVertex3fv, I have a FPS of 82.
When calling glDrawElements(), FPS was 84, only a little faster.
Is this a resonable result?
my card is TNT2 Pro

Ysaneya
12-09-2000, 04:28 AM
Looks like your application is not CPU-limited, so you can't expect it to be faster with VAs.

Y.

IronPeter
12-09-2000, 06:43 AM
Store vertex atribs. in video-memory.

12-09-2000, 07:16 AM
On a TNT2, using DrawElement or friends
instead of immediate mode will not save as
much, because the CPU still needs to fetch
all the data and do the transform, so your
two bottlenecks are typically CPU transform
and texture fill.

Immediate mode adds some function call
overhead, which accounts for the 2 fps speed-
up you saw. Putting your vertex attributes
on the card (or in AGP memory) only helps on
cards with hardware transform, because there
the bottlenecks are different.

Thus, profile your code to see if you're fill
rate limited or vertex transform limited;
then take the appropriate algorithmic action
to reduce that part of your work (typically
by doing smarter culling or clipping in these
cases).

IronPeter
12-09-2000, 11:29 AM
Excuse me please, you wrote TNT2 PRO,
I read GF2 PRO ;-).

zedus
12-10-2000, 03:15 AM
How do you store vertex atribs in video memory?

Sylvain
12-10-2000, 09:12 AM
Yeah?? what do you mean by that?? is this the locking system??

IronPeter
12-10-2000, 11:09 AM
To Zedus:Storing vertex information in video memory is useful for GeForce 1-2 cards. There is NV_vertex_array_range extension. It's very easy to use this extension:

buffer=wglAllocateMemoryNV(sizeof(...)0,0,0);
glVertexArrayRangeNV(sizeof(...),buffer);


You can find demo at www.nvidia.com (http://www.nvidia.com)

Bob
12-10-2000, 12:44 PM
You shouldn't just draw 'some triangles' and then say something like, 'it's not that much faster'. You say your application was running at 82-84 fps, which can easily be the refreshrate of your monitor, and the driver is waiting for a new refresh before swapping the buffers (more commonly known as vertical retrace). What you need to do to be able to come with a more correct conclusion is to draw more that just a few triangles. I would say you need to draw several thousands of them. Begin with 10k or 100k or so.

And by the way, try turn off the 'wait for vertical retrace' if it is on,and if it was you will probably see a giant leap in performance.

Tom Nuydens
12-11-2000, 01:09 AM
I did some experiments with this: http://www.gamedeveloper.org/delphi3d/download/transfer.zip

I also have a TNT2, and I found vertex arrays or display lists to be MUCH faster than the equivalent glVertex*() calls.

- Tom

haigu
12-11-2000, 01:18 AM
I was rendering about 2K triangle fans,
each fan has 8 triangles at most. And I am sure that I have turned off V-sync, that's why I come across this problem.
Now I think the problem is because that each fan doesn't share any vertices with other fans.

IronPeter
12-11-2000, 02:48 AM
Maybe fillrate is bottleneck?

Bob
12-11-2000, 03:36 AM
I think the problem is that you draw loads of small fans. This means you have to call another glDrawArrays (or whatever function you use) for each fan, and when drawing this many small fans, the speed you gain when using vertex arrays instead of immediate calls is so small you won't notice it. Vertex arrays is used to draw many primitives at once, not many primitives in small chunks. What you are doing is telling OpenGL to draw each fan, and the fan consists of just a few vertices, 8 triangles is 9 vertices to be precise, which in turn means you only reduce the number of calls by 1/9th - not that great.

Try drawing thousands of triangles with immediate calls, and then the same triangles in ONE SIGNLE vertex array.

haigu
12-11-2000, 06:23 PM
Bob, does that mean outputing triangle fans with vertex array is not a good idea?

zed
12-11-2000, 10:05 PM
maybe you're noyt geometery limited try reducing the size of your window does the app speed up

Bob
12-11-2000, 10:32 PM
Well, both yes and no, depending on how you draw your fans in the end.

Simply drawing a fan like that doesn't give you any notable performace leaps, only some extra job of building the arrays. It because of, as I said above, you need to send so many small vertex arrays instead of one big.

What you can do to draw your fans, is split them up in standard GL_TRIANGLES and use indexed vertex arrays. This way you won't send any more vertices, since you are using some of them more than once (the startvertex in each fan for example), but you will only call the array once, not 2.000 times http://www.opengl.org/discussion_boards/ubb/smile.gif I can't guaratee any major improvements, because it's also driver-dependent. Better drivers most certainly got better support for this. So this can also be the problem, bad support for vertex arrays (most unlikely in your case though, since you got a NVidia-board, which got great drivers, unless you got old drivers).

[This message has been edited by Bob (edited 12-11-2000).]

12-12-2000, 11:59 AM
Triangle fans aren't that great an idea,
especially for hardware, because you don't
usually get a whole lot of geometry through
to the card per call. Thus, function call
overhead still might matter.

For a non-HW T&L card, it might not matter
as much, but it will still matter somewhat.

Try this: separate all your fans into one
big array of GL_TRIANGLE index elements per
texture (or material, or whatever).
While this means transferring more indexes
to the driver/card, it also means many fewer
function calls, and thus might be a win.