Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Will pay for explanation of Draw Calls.

Discussion in 'iOS and tvOS' started by lakehaze, Feb 23, 2012.

  1. lakehaze

    lakehaze

    Joined:
    Mar 7, 2011
    Posts:
    24
    We do not experience predictable Draw Call dynamic batching. The guidelines in the documentation do not explain what we are seeing.

    Materials are shared.
    Vertex limitations are accounted for.
    Objects' Scaling is frozen at 1,1,1.

    If anybody can clarify how recombinations of geometry, hierarchy, and shader types (transparency and cutout) effect dynamic batching, then I will pay for a video chat session in Skype.

    Current perplexing example:
    Prefab A (21 verts) = 1 dc
    Prefab B (38 verts) = 1 dc
    Both on screen together = 7 dc (why not 1 dc?)
    Combined A and B into single prefab = 4 dc (why not 1 dc?)
     
    Last edited: Feb 23, 2012
  2. lakehaze

    lakehaze

    Joined:
    Mar 7, 2011
    Posts:
    24
    Will pay good money!

    Is there nobody in the community who can explain the above behavior?
     
  3. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I fear it`s not the money that nobody can answer your question here. It`s the lack of a provided example maybe. There`s too much that can influence the drawcalls.

    This is a question that cannot be answered without an example. There must be something funky going on here. A projector shadow is raising the drawcalls for example. Because every object that gets touched by this projector shadow needs to be redrawn. So you have one drawcall for the object without shadow, and one drawcall with shadow, and that makes already two.

    This one is probably partially answerable. Draw calls are not per mesh, but per material. Two materials means two drawcalls. Even when it`s one mesh. Why you get 4 drawcalls instead of two as expected is again a thing of a provided example where we could have a look at.
     
    Last edited by a moderator: Feb 27, 2012
  4. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    The GPU begins it's run by setting up a material and drawing a pile o polygons that use it. If your meshes have multiple materials they will need multiple drawcalls. Careful texture atlasing can help mitigate this.

    When it comes to batching, only mesh pars that share the same material can be batched into a single drawcall. If your scene has 7 materials going on, and everything is on screen, the best possible batching would be 7 drawcalls. Of course the actual number can vary quite a bit based on shadows and other effects.

    David
     
  5. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi,
    You could give Batching Tools a try. It provides an easy way to create skinned meshes, bypassing the dynamic batching and having fewer draw calls.
    There is a short manual and explanations in the first post.
    If you have questions, I will be glad to help.
    -Ippokratis
     
  6. lakehaze

    lakehaze

    Joined:
    Mar 7, 2011
    Posts:
    24
    Thanks for the replies. We found a consultant and were able to pin down our issues.

    Batching Tools looks interesting, but I think we are too deep into development to employ it now. Besides we are already using texture atlases that push the limits of our target devices. But I saved the link for future projects.

    Turns out we were missing two rules:
    1 - Meshes are batched by scale type, not scale value. Types: non-scaled, uniform scaled, non-uniform scaled. 1,1,1 - 2,2,2 - 1,2,1 = 3 calls
    2 - Batches cannot sandwich other batches in zDepth. 3 meshes from front to back, 1,2,1 - 1,1,1 - 1,3,1 = 3 calls, because the uniform-scaled mesh splits the non-uniform-scale group. Overlapping seems to be irrelevant. This applies to all batch-able groups, like material sandwiches. Complex objects can create multi-layered, alternating sandwiches which caused one of our 1-drawcall items to split into 68 calls.

    Hope it's useful to somebody. Feel free to correct any errors.