CCB loaded node hierarchy - draw call optimization


#1

I have a pretty complex UI node structure loaded from a .ccbi file, this includes CCSpites, CCMenuItems, CCLayerColors primarily. The draw call counter sometimes exceeds 300, so I need to do something to increase performance. The obvious approach is batching, but I have no idea how to implement it when having a multilevel hierarchy of CCSprites.
Like this:
root layer
~~CCMenu
—CCMenuItem
—It’s sprite
—CCMenuItem
—Second sprite
~~Another CCMenu
—It’s CCMenuItem
—Third sprite

would give us 3 draw calls (1 for each CCSprite). Provided, they are all from the same texture, they could theoretically be batched. Anyone can help?


#2

I would also like to know if batching with cocos2d-x is possible in such situation. Did you figured it out?


#3

Leszek S wrote:

I would also like to know if batching with cocos2d-x is possible in such situation. Did you figured it out?

No, it’s not. I wrote a metarenderer which “disables” CCSprites from the complicated tree node call and draws them on the metalayers by 1 call per layer/texture. Objects must be tweaked manually if you have multilayered CCB file (I believe, you do) with “set meta level” routine.

The code is still raw, but it gave me drop from 600 draw calls on the most complicated scene to an acceptable value of 14.

It doesn’t support rendering CCLayerColor and similar, only CCSprites (including CCLabelBMFonts, CCMenuItemSprites and everything).

When I finish it, I could share the code.


#4

Thanks for the tip. Code would be also useful.