Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: glDrawElements slower than glColor* + glVertex*

  1. #1
    Intern Contributor
    Join Date
    Mar 2000
    Location
    Austin, TX USA
    Posts
    50

    glDrawElements slower than glColor* + glVertex*

    In the attempt to get a speed increase by removing the overhead of hundreds of glcolor* and glvertex* calls, I started using vertex arrays with a single call to glDrawElements to draw a triangle strip. I repeat this 10 times a frame(reload the vertex buffer then call glDrawElements). To my surprise, this actually draws slower!!! I get the same behavior with and without hardware acceleration. Anyone know why?!?!?!

    J

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,463

    Re: glDrawElements slower than glColor* + glVertex*

    All depends on the driver's optimizations.

    Sometimes, if a format hasn't been optimized in a driver, the driver will effectively convert your vertex array call into internal immediate mode calls. (Yuck!)

    - Matt

  3. #3
    Intern Contributor
    Join Date
    Mar 2000
    Location
    Austin, TX USA
    Posts
    50

    Re: glDrawElements slower than glColor* + glVertex*

    Yes, that's what I am guessing is happening(yuck! is right).

    This leads me to believe there exist no options to optimize this code(display lists are out of the question). Someone please tell me I'm wrong

    J

  4. #4
    Intern Contributor
    Join Date
    Mar 2000
    Location
    Austin, TX USA
    Posts
    50

    Re: glDrawElements slower than glColor* + glVertex*

    Matt -

    Just re-read your post. By "format" do you mean float/double/byte/etc? Is it possible there's a better way to specify my vertex data to allow this to be optimal?

    thanks

    J

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: glDrawElements slower than glColor* + glVertex*

    Also the used arrays should play into it, like if you're using the Normal array or all the others. At least that is, if I'm following Matt correctly.
    - Michael Steinberg

  6. #6
    Intern Contributor
    Join Date
    Mar 2000
    Location
    Austin, TX USA
    Posts
    50

    Re: glDrawElements slower than glColor* + glVertex*

    All I'm using is the color array and vertex array. Are you saying the number of arrays I use should make a difference?

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,463

    Re: glDrawElements slower than glColor* + glVertex*

    Everything -- the arrays in use, the data type for each array, and the number of components for each array. Sometimes also the stride.

    - Matt

  8. #8
    Intern Contributor
    Join Date
    Mar 2000
    Location
    Austin, TX USA
    Posts
    50

    Re: glDrawElements slower than glColor* + glVertex*

    Alright...the natural question that follows:

    What can I do to get this optimized???

    J

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,463

    Re: glDrawElements slower than glColor* + glVertex*

    I can help you if it's NVIDIA HW, but if not, not much I can do. I'd need to know the specific format you are using, the HW, the driver version, and the DrawElements parameters.

    - Matt

  10. #10
    Guest

    Re: glDrawElements slower than glColor* + glVertex*

    Also make sure that you fill your vertex
    buffers correctly, because it is uncached
    memory and writes are VERY EXPENSIVE (but
    works out OK if you write serially, dword
    or qword size chunks at a time).

    If you're re-filling the geometry ten times
    a frame, it seems your vertex buffer is too
    small. Ideally, you'll be able to allocate
    enough vertex buffer space to hold your
    entire geometry, load it once at scene
    prepare, and then just issue indexed drawing
    commands, not touching the vertex data at
    all (same goes for color, normals, texcoords
    etc).

Posting Permissions

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