Jump to content

  • Log In with Google      Sign In   
  • Create Account

glDrawElements or glDrawArrays in case of maximum duplication?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 JohnnyCode   Members   -  Reputation: 292

Like
0Likes
Like

Posted 04 November 2013 - 07:36 PM

Hi,

 

I wonder what call would perform faster in case I have maximaly duplicated verticies in the geometry- meaning I have numoftris*3 verticies in my mesh. In this case indexing the triangles makes no sense, so the question is wheather I should use drawarray call , or, stil use indexed aproach by drawelements.

 

Thanks!



Sponsor:

#2 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 05 November 2013 - 10:38 AM

Why would "indexing make no sense" ? - Also, indexing is generally faster.



#3 samoth   Crossbones+   -  Reputation: 5033

Like
1Likes
Like

Posted 05 November 2013 - 11:06 AM

In the particular case that you describe, using glDrawArrays will likely indeed be faster (or at least equally fast), since you cannot expect any benefit from the vertex cache, and you save a bit of bandwidth and cache memory (and 2-3 API calls) by not having to upload the indices in addition.

Also, possibly, it might be slightly faster to directly access vertex data in a strictly linear fashion than to go through an index only to result in the exact same access pattern afterwards. Though I'm sure GPUs have highly optimized specialized hardware paths to do just this exact thing at very little extra cost (no extra cost other than having more cache pressure).

 

However, even if it is not faster or even very slightly slower, it may still "make sense" to use indices, not for performance but because it may be more flexible. It depends on what you want to do.

 

Is there a reason why you do not share any vertices? That is very unusual. Are these a cloud of isolated triangles?


Edited by samoth, 05 November 2013 - 11:08 AM.


#4 mhagain   Crossbones+   -  Reputation: 8277

Like
2Likes
Like

Posted 05 November 2013 - 12:15 PM

I'd guess it's different per-vertex normals.

 

Even so I'd still index since it would mean that you can have a single "draw me a mesh" routine that handles setting states, buffers and issuing the draw call; it may not be more optimal from a performance perspective but it would seem a reasonable tradeoff from the code organisation/design perspective.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 05 November 2013 - 01:31 PM

profile and compare



#6 JohnnyCode   Members   -  Reputation: 292

Like
0Likes
Like

Posted 06 November 2013 - 09:11 AM

Thanks, my problem is I need face normals per vertex, thus it will duplicate verticies up to tri*3, unless triangles are in plane, which is just rare.

 

About profiling, no, GPUs differ so much from model to model, from driver to driver that I rather wanted to know technical facts of both methods than actual peprformance.

 

Thanks






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS