Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: vertex_array_range problems, again :)

  1. #1
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    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,
    -Lev

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: vertex_array_range problems, again :)

    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.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: vertex_array_range problems, again :)

    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 :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    Re: vertex_array_range problems, again :)

    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);
    glVertexPointer(a);
    glDrawElements(a);
    glVertexArrayRangeNV(size_2, ptr_2);
    glVertexPointer(b);
    glDrawElements(b);

    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?

    -Lev

  5. #5
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    Re: vertex_array_range problems, again :)

    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

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    FRANCE
    Posts
    157

    Re: vertex_array_range problems, again :)

    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

  7. #7
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    Re: vertex_array_range problems, again :)

    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??

    -Lev

  8. #8
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: vertex_array_range problems, again :)

    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 -
    Cass
    Cass Everitt -- cass@xyzw.us

  9. #9
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Karlsruhe, Germany
    Posts
    486

    Re: vertex_array_range problems, again :)

    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.

    -Lev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •