glDrawElements or glDrawArrays in case of maximum duplication?

Started by
3 comments, last by JohnnyCode 10 years, 5 months ago

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!

Advertisement

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

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?

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

profile and compare

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

This topic is closed to new replies.

Advertisement