Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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).

share|improve this question
    
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. –  Sean Middleditch Aug 13 '12 at 16:33

3 Answers 3

up vote 2 down vote accepted

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

share|improve this answer
    
This is a good point. –  edA-qa mort-ora-y Aug 13 '12 at 11:10
1  
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. –  Nicol Bolas Aug 13 '12 at 11:42
    
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. –  Darth Satan Aug 13 '12 at 13:31

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.

share|improve this answer
    
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). –  edA-qa mort-ora-y Aug 13 '12 at 11:12
    
I don't see what repeated models have to do with anything. glDrawArrays doesn't make that any easier or harder than glDrawElements. –  Nicol Bolas Aug 13 '12 at 11:43

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".

share|improve this answer
    
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) –  edA-qa mort-ora-y Aug 13 '12 at 9:54
    
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... –  Valmond Aug 13 '12 at 12:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.