4
\$\begingroup\$

When we send data for drawing we can mark it as TRIANGLE_STRIP or TRIANGLE_FAN to reduce the number of vertices we have to specify. Now, does this actually improve the rendering speed on the graphics card, or does it merely reduce the amount of data that has to be sent to the card?

I'm using a very simple model. To construct it correctly I need multiple calls to glDrawArrays using TRIANGLE_STRIP. If I switch to using just GL_TRIANGLES I could have just one call to glDrawArrays. Is this type of apporach useful, or is the overhead of an the call to glDrawArrays low enouhg that it won't make a difference.

I will profile, but since I have only one card I don't know if my result will be indicative of the general case. (NOTE: I need to be ES2 compliant, so some of my options are limited).

\$\endgroup\$
1
  • \$\begingroup\$ Use vertex indices. That allows the GPU to only run the vertex shader once for each shared vertex, even when using GL_TRIANGLES. Separate issue from your question, but related to your desire for performance. \$\endgroup\$ Aug 13, 2012 at 16:33

3 Answers 3

3
\$\begingroup\$

A single call to glDrawElements with GL_TRIANGLES should be the most optimal in the general case - have a read of https://web.archive.org/web/20130328101248/http://home.comcast.net/~tom_forsyth/blog.wiki.html#Strippers - strips are basically obsolete and have been for over a decade.

\$\endgroup\$
6
  • \$\begingroup\$ This is a good point. \$\endgroup\$ Aug 13, 2012 at 11:10
  • 3
    \$\begingroup\$ It's interesting that people link to that despite the faulty reasoning for his main point. Namely, he forgets that every triangle from a strip automatically reuses the last two vertices. So his reuse calculations for the strips are entirely wrong. His main thrust is right in that it's easier to build an optimized list than an optimized strip. But the idea that an optimized strip is not as efficient as an optimized list is simply incorrect. \$\endgroup\$ Aug 13, 2012 at 11:42
  • 1
    \$\begingroup\$ A secondary point that's often ignored is that an indexed list can be used to concatenate multiple strips for hardware where primitive restart is unavailable. \$\endgroup\$ Aug 13, 2012 at 13:31
  • 1
    \$\begingroup\$ The link is dead. \$\endgroup\$
    – Tara
    Apr 19, 2016 at 16:54
  • 1
    \$\begingroup\$ @Tara you can use the "Wayback machine", here: web.archive.org/web/20130328101248/http://home.comcast.net/… \$\endgroup\$
    – Gediminas
    Mar 10, 2020 at 18:47
4
\$\begingroup\$

In general, you should not be using glDrawArrays at all. If your model has repeated vertices, you'll get a lot more bang for your buck performance-wise from an index list. There, optimized strips or even triangles will be able to use the pre and post-T&L vertex caches. This means less memory fetching and less vertex shader execution.

\$\endgroup\$
2
  • \$\begingroup\$ In this case I have a lot of repeated models. It does however appear the sentiment is for using indexes (this is my next avenue for exploration). \$\endgroup\$ Aug 13, 2012 at 11:12
  • \$\begingroup\$ I don't see what repeated models have to do with anything. glDrawArrays doesn't make that any easier or harder than glDrawElements. \$\endgroup\$ Aug 13, 2012 at 11:43
2
\$\begingroup\$

A) If your model is simple then you most probably won't need to optimize at all (what's your specs in polycount, target machine etc. ?)

B) If the vertices in your model isn't changing (for example: a lamp post, a landscape, a human character in its bind-pose that the vertex shader will animate), use a VBO

VBO:s are very very fast as you just send your vertex data once at "level-startup".

\$\endgroup\$
2
  • \$\begingroup\$ Experiments on my machine suggest that having one call to dlDrawArrays with a larger set of vertices is significantly faster than multiple calls. (NOTE: I'm just trying to push my system to the limit in my tests at the moment) \$\endgroup\$ Aug 13, 2012 at 9:54
  • \$\begingroup\$ If bundling together polygons is faster, VBO:s might be the way to go. I had a terrain (32k triangles) with a fairly complicated shader (splatshader with 8 textures and a fairly complex lightning model), going from 'sending all vertices & triangles every frame' to VBO changed the framerate from ~200fps to 4500fps on a 8800GT... \$\endgroup\$
    – Valmond
    Aug 13, 2012 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .