Batching and Optimization – ShiVa Engine

Batching and Optimization

1 – Draw calls
2 – Auto-batcher
3 – Object combiner
4 – Numbers

Draw calls

The major problem on IPhone is the draw call number. If you have more than 25 draw calls, your IPhone game won’t be at 60 fps (1000 draw calls for a computer).


The engine has a feature to optimize the draw call number. All the models having less than 32 vertices will be merged by the engine and will be sent to the video card at the same time (1 draw call). However, there is a limitation, this merge is computed at each frame and if you have a many objects, the CPU will be overloaded.
Note you can gain performances if your models have no scale and no rotation.
Learn more about the auto-batching optimisation

Object combiner

There is a new feature with ShiVa 1.8.1, allowing you to merge all your models into a single mesh. Here, the merge is computed only one time, so during the game, the CPU will be free of this operation. The draw call number will be also very little (1 draw call for all of the objects you have merged).
How to combine your objects? The combiner take a group of objects so you have to create the root of the group, a dummy for example:

hGroup = scene.createRuntimeObject ( hScene, "" )

Then, for each object you want to combine, parent it to the group:

object.setParent ( hObject, hGroup, true )

The group is ready, it’s merge time, call the function bellow to combine your objects into a single mesh.

hCombined = scene.combineRuntimeObjectsGroup ( hScene, hGroup )

You now have a clone of your models, you can remove the group of models and set visible the result of the merge.

scene.destroyRuntimeObject ( hScene, hGroup )
object.setVisible (hCombined, true )

This method is very effective but has limitations: the object merge has to be a simple object (a group of objects having no children, not a group of groups), and objects can’t have have controllers (no AI, etc).


Here is an example of the performance gain. 2000 objects in the scene.

3GS (framerate):
– Not combined with transformations: 11 fps
– Not combined without transformations: 15 fps
– Combined: 50 fps
Computer (CPU usage):
– Not combined with transformations: 55%
– Not combined without transformations: 40%
– Combined: 2%
As you can see, the difference of performances is very impressive, it’s really important to use this feature in your mobile games.

  • slackBanner