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 16

Thread: Which way to cover with TRIANGLE_STRIPs is faster?

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Which way to cover with TRIANGLE_STRIPs is faster?

    I have an surface that a single non-overlapping triangle strip can't cover. Which approach is more efficient?

    (a) Creating two triangle strips, the first with 10 vertices, and the second with 4 verticles (10 triangles total)

    (b) Creating one triangle strip with 14 vertices (12 triangles total: one tri overlaps, and one tri degenerate into a line since all points have the same y- and z-values).

    If you know why, that would also be nice to know.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    595

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    Strange question. The answer is:

    b)

    Why? Because calls into GL cost CPU time. If you consume too much of it, your app becomes CPU limited.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    Thanks for explaining!

    Why a strange question? I started learning OpenGL yesterday and it wasn't obvious whether to strive to optimize the # of triangles or the # of calls.

    (Although I'm using immediate mode now and I realize that in itself's not ideal for performance.)


  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    b) - "one tri overlaps" this is likely to cause depth fighting and be visually problematic.

    Try doing sensible things first, like avoid immediate mode, before doing more dangerous things that would bring limited improvements.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    965

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    The first thing you should do is read this:

    http://hacksoflife.blogspot.com/2010...-to-strip.html

    Triangle strips are seriously old hat; they were great in 1998 but much much faster and more flexible ways of handling geometry are now available, ways which involve considerably less setup on your part, and ways which you should be using instead.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    941

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    If you want to work with triangle strips, you should rather use primitive restart insttead of degenerate or overlapping triangles.
    However, I agree with mhagain that strips don't provide that much of performance nowadays. You should rather go with indexed triangles and try to depart from immediate mode as it will always result in CPU bottleneck due to the enormous number of API calls needed.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    > Try doing sensible things first, like avoid immediate mode,

    The context is I'm studying a computer graphics textbook and it is asking me to using triangle strips (and fans, and quads, and quad strips, and lines, and points, etc.) in immediate mode.

    Textbooks usually do not cover the cutting edge of technology, but (hopefully) lay a strong foundation.

    > Triangle strips are seriously old hat;

    > You should rather go with indexed triangles and try to depart from immediate mode

    Thanks, good to know. I read your article on indexed triangles, and will read it again once I get further along in my studies.

  8. #8
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    Quote Originally Posted by GLRon
    > Try doing sensible things first, like avoid immediate mode,

    The context is I'm studying a computer graphics textbook and it is asking me to using triangle strips (and fans, and quads, and quad strips, and lines, and points, etc.) in immediate mode.
    That's great for getting started, but definitely not after a few weeks down the road when you have your "graphics legs" and want good performance. Look in the index for "vertex cache" (or "post T&L cache", though that naming is a bit antiquated) and if you don't find it, you might consider getting a newer graphics book to read along side it.

    A few more excellent blog posts to read regarding triangle strips and why they're a has-been when it comes to GPU performance, and have been for many years:

    * http://home.comcast.net/~tom_forsyth...html#Strippers
    * http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Vertex%20Cache%20Optimisation]]
    * http://developer.nvidia.com/object/devnews005.html (search for cache)

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    595

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    ZBuffer, I got my recommendation from this document:

    Rendering Huge Triangle Meshes with OpenGL: Louis Bavoil

    To connect 2 strips, use degenerate triangles, or the
    GL_NV_primitive_restart extension.
    For example, to connect 2 strips of array of indices A and B, you can use:
    ... A_n-2 A_n-1 A_n-1 B_0 B_0 B_1 B_2...
    But I see the use of strips is mostly pointless, nowadays.

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    965

    Re: Which way to cover with TRIANGLE_STRIPs is faster?

    Anyway, if one uses tristrips, can one be reasonably certain they aren't going to render slower than indexed triangles?
    Strips will render slower than indexed triangles because strips are completely unable to make use of the GPUs vertex cache, meaning that duplicate vertexes will need to be retransformed and/or vertex shaders will need to be run again for them.

    The only way to make use of your vertex cache is to use indexes - because the cache stores indexes. You can, of course, order your indexes to replicate a strip layout if you want, but the point is that you need to use indexes.

    Note that this only applies in cases where this is actually your application bottleneck. If your bottleneck is elsewhere then you won't notice a difference. But at the same time that doesn't mean that you should feel that it's OK to use strips, because doing so could make this become your bottleneck!

Posting Permissions

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