PDA

View Full Version : glDrawElements vs. glDrawArrays



Nikki_k
06-29-2014, 02:20 PM
What's the general advice concerning these two functions in cases where an index buffer is not really necessary.

I have a relatively large buffer with a few 1000 triangles but the vertices are all different, i.e. the index buffer would just contain the values from 0 - maxVertex in linear order, it's all drawn with a single GL_TRIANGLES draw call.
So obviously it can be easily drawn with glDrawArrays without ever creating an index buffer. But I'm wondering if some hardware may not really like this ending up being slower than creating the redundant index buffer anyway.
Any info?

Dark Photon
06-29-2014, 02:32 PM
Pipelines have been long optimized for indexed triangles, but unless there's some odd driver bug, I wouldn't expect to see DrawArrays in your circumstance being less efficient. Since it's easy, I would try it both ways just to be sure though.

Nikki_k
06-30-2014, 12:12 AM
On my hardware (NVidia Geforce 550Ti) I cannot detect any difference, even when repeatedly calling it in a loop. But we all know that drivers of different manufacturers act differently but without anything quickly available to test I was hoping that someone knew.

Agent D
06-30-2014, 02:32 AM
If you don't specifically target that one weired driver/card combination that only five people in the world use, why do you want to optimize for it?

mhagain
06-30-2014, 04:21 AM
If you don't specifically target that one weired driver/card combination that only five people in the world use, why do you want to optimize for it?

This, basically.

Wanting to run on "all hardware" is, IMO, a completely unrealistic objective.