8

There has been quite a buzz about rendering performance between indexed triangles or triangle strips. But I believe there is a case that has not been considered enough.

Indexed triangles are rendered like this in OpenGl:

glDrawElements(GL_TRIANGLES, ...);

But for some reason a lot of people consider rendering strips only in this way:

glDrawArrays(GL_TRIANGLE_STRIP, ...);

Out there there are some very good indexers (Forsyth, Tipsify to name a few) that optimize your mesh to be convenient for the GPU transform cache to be rendered in GL_TRIANGLES mode. Ideally they can achieve like 0.5 rendered vertices per triangle or something like that.

But why not doing this?

glDrawElements(GL_TRIANGLE_STRIP, ...);

I mean, you combine the low index bandwidth of strip rendering with the efficient GPU transform cache usage that the above indexers provide. With few modifications, am I right in saying that a strip indexer that optimizes the strip to be also Tcache-friendly can be a good idea?

Probably it won't reach the 0.5 goal, but at least a 0.6 perhaps? Also, don't forget the massive index bandwidth gain (potentially one third against GL_TRIANGLES).

3
  • 1
    Index bandwidth is hardly an issue these days. You can store indices in a static VBO on the GPU for most use cases.You benefit from the post-T&L cache whether it is using primitive modes that share elements (e.g. Fans, Strips) or indices that allow explicit reuse of transformed vertices during primitive assembly. Triangle lists in strip-order are said to be just as efficient as strips on modern GPUs and do not require special primitive restart indices. Vertex transform has not been a bottleneck in most rendering situations for years, though with tessellation you may see renewed interest. Nov 5, 2013 at 23:22
  • @AndonM.Coleman I agree with you on the fact that if the index data is already in the GPU the two drawing modes are equally efficient. But it is definitely NOT the same if the vertex data is in a VBO but the index data is not. If for some reason the user is uploading a bunch of indices to the GPU very often (every frame perhaps) sending 2.5-3 times less indices does have an impact. Nov 6, 2013 at 19:12
  • 2
    @user2464424 Keeping vertex or index data not in VBO is just not wise. You depend on driver to calculate the amount of data to be paged in and forcing it to upload the whole data in most ineffective moment - in drawcall. Driver may also allocate new buffers for each draw which is really, really slow. Also not using VBOs kills indirect drawcalls, etc.
    – sacygan
    Nov 17, 2013 at 16:54

1 Answer 1

-1

glDrawElements needs to pass data from CPU to GPU at the time of the call. Specifically, the last parameter is a pointer to that data.

glDrawArrays does not require passing data to the GPU at the time of the call. This is probably why glDrawElements is not usually considered when you are storing vertex/index data on the card.

5
  • 5
    There are buffer objects for both cases, so that answer does not make sense.
    – derhass
    Jul 22, 2014 at 21:34
  • 1
    The index data can (and typically is) also in a buffer. Anyway, this whole question is based on invalid assumptions, IMHO. Using glDrawElements() with indexed triangle strips is completely standard. Jul 22, 2014 at 21:35
  • 1
    Yeah, and primitive restart is also very useful in such a scenario.
    – derhass
    Jul 22, 2014 at 21:41
  • If the index data is in a buffer, what is the last argument to glDrawElements for?
    – Thomas
    Jul 22, 2014 at 22:23
  • 2
    @Thomas. If an index buffer (GL_ELEMENT_ARRAY_BUFFER) is bound, the last argument to glDrawElements() is a relative offset (in bytes) into the buffer. Jul 23, 2014 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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