Sign in to follow this  

glDrawElements or glDrawArrays in case of maximum duplication?

This topic is 1533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this