How good is Coco2d-x v3 Auto-batching?

I’m starting to look at moving from v2.2.6 to the v3 series, basically for the auto-batching features.

I’ve read the code, but I’d like to really have complete confirmation from someone who is using it on a few points:

Does it really batch everything?
Does it batch CCMenu?
Does it batch CCSCrollView?
Does it batch CC9Patch?
Does it batch BMFont?

@corytrese this is a fantastic question. I think @mannewalis can help us answer this.

I’m very excited to hear an answer. Either way, it will bring me peace and a decision.

So the short answer is that very few nodes will batch together.

Sprites will batch with other sprites if the same texture is used.
Particle quads will batch.
Font letters batch inside of Label, but Label’s will not batch with each other, even if they use the same font.
Sprite3D has some batching capability inside of Sprite3D, so sub meshes can batch.

Beyond that, things do no not batch well. There has been some work to move everything to use a single geometry class, which would make batching easier, but you still have to deal with manually putting as much stuff into single textures as possible, organize your scene so that you are not changing material parameters, shaders, draw modes etc. It’s a complicated issue. Hopefully v4.0 will address this better, but with 3.x you are stuck with Sprites, Sprite3D, Particles, BatchNode, Labels batching, but not with each other.

1 Like

@mannewalis, is there any limitation to sprites of the same texture always batching?
i.e. Load a sprite sheet from a file into sprite frame cache so the sprites are in the same texture. Add sprites from sprite frame cache to various nodes, layers and sprites. Position sprites, nodes and layers with various zOrder and z vertex values.

Yes there is a vertex buffer limit of 64k I think, and also only contiguous sprites will batch. If while traversing the scene graph, the renderer encounters a label or some other node type, it will flush and render what you have so far.