vertex_array_range problems, again :)

Well, i’m having problems setting up vertex array range extension.

The problem is that with VAR my app is slower -> I’ve not setup VAR correct.

This is what I do:

allocate 4 MB with wglAllocateMemory(4mb, 0, 0, 0.5)
all arrays(vertex, normal, texcoord, triangles) are placed in this memory.

each frame for each object:

enable all arrays I draw
enable vertex array range
specify vertex array range
draw my arrays.

The weird thing is that when I allocate the memory with wglAllocateMemory(4Mb, 0, 0, 0) the app runs at the same speed as without VAR. and If I allocate with
wglAllocateMemory(4MB, 0, 0, 1) and do not enable VAR, the speed drops dramatically, with enabled VAR it runs faster but not as fast as with arrays in system memory and VAR disabled.

Where can be my problem?

one question to glVertexArrayRangeNV : do I have to pass size and pointer in a way that all my arrays lie in the range? (vertex array, normal array, texcoord array, triangles array), or how is it suppposed to work?

Thanks in advance,

You should only call glVertexArrayRangeNV once. It shouldn’t be in the rendering loop either.

BTW, if the app doesn’t speed up with VAR, you might consider that you aren’t addressing the bottleneck. If you’re fillrate-bound, sending vertices faster will never help.

Enabling VAR is a slow operation. Luckily, you only need to do it once on startup (right after you call AllocateMemoryNV).

If you do all your drawing using vertex arrays, you don’t need to re-enable them every frame, although you probably want to change the pointer around within the memory block you allocated, to draw different things :slight_smile:

Well, it works now. The problem was that the triangles array must be in system memory. But one problem persists. If I want to draw multiply buffers, the speed drops.

the code looks like this:

(all arrays(gl***Pointer) are in AGP memory)
Enable Vertex array range

for each frame:

glVertexArrayRangeNV(size, ptr);
glVertexArrayRangeNV(size_2, ptr_2);

this is very slow, much slower than drawing “normal” vertex arrays. I haven’t got a decent profiler, so I can’t tell where exactrly the bottleneck is, so whats the problem with it?


one addition:
when drawing 1 object (45100 triangle, with lighting and texturing disabled, I have
~ 8.3 Mtris per second on a GF1 DDR, when drawing 2 objects of the same type the speed drops to 0.8 Mtris per second.


Lev, just one question, why did you call glVertexArrayRange for each object? I call once, just after allocating AGP memory for the whole block of memory … and I haven’t got any performance fall, but may be I’m wrong, I am not claiming that I know perfectly the VAR

it did the trick. The reason why I was calling the func for each object was that specs say NV10 only supports 2^16 as max array index. So to draw more stuff, buffer switching is needed and I thought I would accomplish it with glVertexArrayRangeNV, but no need to do that, i’m referencing 90000 vertices and i’m just fine. the thing is that in glArrayElement you have to keep index < 2^16.

One question from my side: I cannot allocate much memory whats the reason?
I can allocate ~ 7300000 bytes, but not 8000000 bytes, and the priority paramater in wglAllocateMemoryNV doesnt change it, i.e I can allocate <=7MB with priority 1, but also <=7MB with priority 0.5. I thought one can allocate more APG memory than video memory??


Sounds like everything got sorted out here, but let me state this again:

The general formula should be to allocate 1 large chunk of memory and set the vertex array range to the whole thing. You can move your pointers around within this range as necessary to address the 2^16 index range, but only set the range once, and only enable VAR once.

Hope this helps -

Yup, this is what it turned out to be, but this information is not easy to find. This board seems to be the only place.