Upgrading from v3.12 to 3.15.1 doubles draw calls

Upgrading from v3.12 to 3.15.1 doubles draw calls
0

#1

Hi guys,

I just migrated my project from cocos v3.12 to v3.15.1 (yeah, I know there is v3.17 :P). Everything compiles and runs well (60FPS), but I noticed that number of draw calls in one of my screen increased drastically (at least x2). I haven’t changed anything in my code. In that screen I am using ScrollView, 6 DrawNodes (with a lot of drawn lines on every draw node, I draw all lines only once), one particle system and lots of sprites. All sprites use the same spritesheet and every node has the same Z (0).

So, where should I look for? Maybe I should change something in my code?

Thanks,
kds


Is Cocos2dx going to shut down
#2

Not sure what the problem may be, but if you are using cc.ScrollView, you should move to ccui.ScrollView (yes, there are two). It’s better and faster, and the code change should be minor.

For C++, it means changing CCScrollView to UIScrollView.


#3

Hi @fleon, thanks for reply. I am using cocos2d::ui::ScrollView, I guess this is what you meant.

I looked inside the cocos and in 3.15 there were some changes with globalZorder. Maybe this is a root cause? I will try to rearrange my scene a little bit and see if it helps.

This is strange because this is the only scene in my game I noticed huge increase in draw calls, and this is the only scene I am using “fullscreen” scroll view :slight_smile:


#4

Definitely try using a Layout parent node (or just plain Node*) instead of ScrollView just to see if draw calls are still doubled?

If you can remove things for testing, definitely try to not create/add any Sprites, see if that’s the culprit (or the rest). If not then try the others (scroll, drawnode, particles).

Possibly sprites are getting ordered between the DrawNodes causing it to render multiple draw calls instead of a single batch draw call? Also, how many is “lots of” sprites? If it’s massive then there may have been changes to limits on how many quads per call?

Just some thoughts.


#5

Thanks @stevetranby . I will check your suggestions and share the results.


#6

Me again. Finally, I have made some tests. In general I found 3 issues with ScrollView (?) which cause additional draw calls.

  1. TTF fonts - font is not batched :confused: Let’s say it can be solved by using BMFont (at least I hope so :P).

  2. I found out that ScrollView is drawing everything all the time, even not visible nodes. Solution is to hide invisible elements. So it is also solved in some way, but should be fixed internally by cocos :confused:

This is similar to the issue described here: https://github.com/cocos2d/cocos2d-x/issues/19087 - but… it was closed with no solution…

  1. For displaying items in the scroll view I was using ui::Button (items must be clickable). Changing items to “pure” ui::Widget and implementing custom touching/highlighting solved draw calls.

Maybe it will help someone :slight_smile: