Hello Guest

Author Topic: 3.5, and the drawcall inflation effect.  (Read 22305 times)

KyleStaves

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #15 on: April 06, 2012, 03:46:43 pm »
Quote
The unity draw call batching doc goes into detail of how many polys get batched. A quick test shows a textmesh will batch up to about 75 characters.

This was massively helpful, thank you. I was running into a draw call nightmare (not really causing performance issues since I was only hovering about 14 - but it should have been closer to 3 so it was bothering me). My strings were all set with a max length well over the batchable limit - didn't realize the polycount was important there.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #16 on: August 02, 2012, 02:22:28 pm »
Was this problem ever resolved? I too am having nightmare draw call inflations and I have no idea why. I'm abiding by all of the batching rules, so I can't understand why i have 2 materials and 30 draw calls (not even using any textmesh). All I have are several layers in the tilemap editor and that is it. Any reason why my draw call count would be so high? The only shaders I'm using are the built in 2D Toolkit ones SolidVertexColor and BlendVertexColor.

Tochas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #17 on: January 13, 2013, 11:23:34 pm »
Hi,

I am not sure if the effect I am experiencing has something to do with this but here it goes

I have a prefab consisting on an Empty Game Object that has one AnimatedSprite and one Sprite as child
The animated sprite is my character with the set of animations and the "static" sprite is just a circular shadow therefore there is a overlap of the two.

The character has its own spriteCollection while the shadow is on another spriteCollection

the funny thing:
If I drag the prefab into the editor as many times as I want the drawcalls will remain steady about 8
If I create instances of the prefab by an ObjectPool object/script as soon as a character appears on the screen it adds 2 drawcalls giving an ever increasing number of drawcalls as long as the spawner stay active
If I remove the shadow sprite from my prefab and retry both previous test the drawcalls remain steady about 8

as far as this goes I can get to the conclusion to ask to my graphic artist to include the shadow with the character animations but I really want to understand why is this happening so I can design my prefabs in a more drawcall safe manner.

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #18 on: January 14, 2013, 09:05:21 am »
Was this problem ever resolved? I too am having nightmare draw call inflations and I have no idea why. I'm abiding by all of the batching rules, so I can't understand why i have 2 materials and 30 draw calls (not even using any textmesh). All I have are several layers in the tilemap editor and that is it. Any reason why my draw call count would be so high? The only shaders I'm using are the built in 2D Toolkit ones SolidVertexColor and BlendVertexColor.

Dunno how I missed this, but now that its been bumped I might as well answer.

Each layer in your tilemap is likely to end up as a drawcall, depending on the number of tiles used. Batching stops applying after a certain number of polygons, so if your tilemap partition mesh is over a certain size it isn't going to be batched, and there isn't any way around it apart from increasing partition size.

And talking about partition sizes - each partition is a set of draw calls, and when you're at a boundary, you are likely to see 4 of them at the same time. Say you have 5 layers which cant be batched - at a partition boundary, you could in theory go up to 20 draw calls if they don't batch.

This is quite inevitable, and the only way around it is to dynamically generate geometry every frame, but then that is likely to end up slower than the batch overhead. Also, draw call overhead isn't as bad as it used to be a couple generations ago on iOS devices...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #19 on: January 14, 2013, 09:07:41 am »
Hi,

I am not sure if the effect I am experiencing has something to do with this but here it goes

I have a prefab consisting on an Empty Game Object that has one AnimatedSprite and one Sprite as child
The animated sprite is my character with the set of animations and the "static" sprite is just a circular shadow therefore there is a overlap of the two.

The character has its own spriteCollection while the shadow is on another spriteCollection

the funny thing:
If I drag the prefab into the editor as many times as I want the drawcalls will remain steady about 8
If I create instances of the prefab by an ObjectPool object/script as soon as a character appears on the screen it adds 2 drawcalls giving an ever increasing number of drawcalls as long as the spawner stay active
If I remove the shadow sprite from my prefab and retry both previous test the drawcalls remain steady about 8

as far as this goes I can get to the conclusion to ask to my graphic artist to include the shadow with the character animations but I really want to understand why is this happening so I can design my prefabs in a more drawcall safe manner.

Thanks

It likely isn't the same issue at all. What happens in your ObjectPool script? I'd step through / look into the instances to make sure the material instances aren't being duplicated for whatever reason.

Tochas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #20 on: January 15, 2013, 03:36:51 am »
Hi Unikron,

I am using the GameObject.Instantiate() method, passing a stored prefab instance as argument. similar to http://forum.unity3d.com/threads/76851-Simple-Reusable-Object-Pool-Help-limit-your-instantiations!

I will debug to check the reference value between the prefab and instantiated object materials.

On a previous post you mentioned that now draw calls are not a big concern on iOs development, do you have an estimate of how many drawcalls can be considered "ok"?

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3.5, and the drawcall inflation effect.
« Reply #21 on: January 15, 2013, 11:14:38 am »
Its not that they aren't a big concern any more, but with increasing CPU speeds, they are not as bad as they used to be. There isn't a magic number you should be aiming for - you're balancing CPU utilization with the rest of your game, sound, etc. The acceptable draw call count depends very much on what else you're doing. I suggest profiling your app to see what the current utilization is like.