DrawRangeElements and MultiDrawRangeElements


Two quick questions :
1 - Is the function drawRangeElements faster than drawElements ?(I read that it could be in some cases : http://www.spec.org/gwpg/gpc.static/vbo_whitepaper.html ), and so is it worth the effort to store pointers in the array and range information ?
(Here’s what I do for a mesh : Got an Index Buffer Object of unsigned shorts, with range information and a vertex buffer object with offset information. So for the drawing I first bind the VBO at the good offset and then call drawRange with the corresponding range information + a good offset as well… I can give more details if I’m not making myself clear enough ;))

2 - Why is glMultiDrawRangeElments not implemented ? I could really use it to simplify my draw-calls from question 1 !


Yes it is faster because the driver does not have to scan the index array to place bounds on the size of the required memory transfer.

Ok, That’s what I thought… But I don’t understand why glMultiDrawRangeElements isn’t available then.
Is MultiDrawElements faster than a DrawElements in a for loop (or is it the same : in the gl3.2 specs, it is said to have the “same effect”) ?

OpenGL does not specify performance. It simply provides opportunities for drivers to optimize; whether an implementation takes it is another question. glDrawRangeElements is one such opportunity. glMultiDrawElements is another. glDrawElementsBaseVertex and glDrawElementsInstanced are others.

Some combinations of these features are provided, and some are not. BaseVertex can be combined with any one of the others, but none of the others can be used together. This is probably to keep down the sheer number of possible drawing functions you could use.

As to specifically why MultiDraw cannot be combined with Range, I guess they didn’t feel it was a worthwhile optimization possibility. And personally, I’m not convinced that Range is a significant optimization on modern hardware either, so long as buffer objects aren’t being thrashed.

Certainly if you happen to be using bindless for your vertex data, you’re effectively guaranteed that the data will be there.

Also ATI cards don’t seem to care. Or at least, not my HD 3300. It reports MAX_INT for the maximum range vertex count, and 2^24 for max range index count. So either it has very high hardware limits, or it works just like a glDrawElements call.

Yes you’re right, performance means “implemented” in OpenGL for me. If it is implemented, it should mean that drivers know how to react to such calls. As for the drawRangeElements vs drawElements matter, I’m going to make a bench application to see if it’s really worth storing additional range informationn and how large is the performance gap (if any).
Anyway, thanks for your time !