How to Combine Multiple AIS_ConnectedInteractive Elements for Single Draw Call?

I am working on drawing a large number of identical elements (with the same geometric content but different Transforms). By using AIS_ConnectedInteractive, I can reuse the Presentation data without recalculating it repeatedly. However, even with this technique, each element still requires an individual draw call.

How can I merge these elements and draw them in a single draw call?

My primary concern is how to handle the differences in Transforms.

gkv311 n's picture

The current implementation of AIS_ConnectedInteractive implies that the same geometry could be rendered multiple times having different locations. This routine allows sharing graphical data (e.g. spare GPU memory), but rendering itself requires multiple draw calls.

What you may do is using a larger AIS_InteractiveObject that would group multiple sub-objects. Even though graphical geometry will be duplicated here (more GPU memory will be required), the rendering will show much better time - which could be especially noticed on a large number of small objects grouped together. You don't need to group EVERYTHING in one object - just group in batched of reasonable size.

OpenGL theoretically allows rendering the same geometry multiple times with different transformation in a single draw call via glDrawElementsInstanced and similar methods, but this is not that trivial to apply here, and OCCT doesn't do that for now (you may implement it on own, however, if you are familiar with OpenGL by subclassing OpenGl_Group/OpenGl_PrimitiveArray).