Author Topic: Optimizing Draw Calls and Draw Order - Need Info  (Read 5298 times)

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Optimizing Draw Calls and Draw Order - Need Info
« on: September 23, 2014, 10:13:58 PM »
Today I defined my most complex UI, and when I clicked on Stats I saw 14 draw calls.  I've opened up the Draw Call Tool window, and I can see the draw calls are just alternating between the NGUI Atlas material and the NGUI Font material.  Is this because I have Sprites and Label's intertwined in my UI?

Just for more understanding:
- I remember in a video tutorial something being said about draw order. Is it really bad to have 2 widgets using the same draw order?  My "Panel" is full screen, and  have a bunch of sprites that represent sub-panels, I call them windows. For each window I just define their draw order from back to front, starting at 0. So each window will have sprites and label's that share draw orders with other windows.  Will this add draw calls?
- If instead I just uniquely set each draw order from 0 to 57, for example, would this be a better for ngui to draw?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Optimizing Draw Calls and Draw Order - Need Info
« Reply #1 on: September 24, 2014, 01:41:39 PM »
Yes, interrupting a continuous flow of widgets breaks up draw calls. So something like this:

Widget (depth 0)
- Dynamic font label (depth 1)
-- Widget (depth 2)

...will result in 3 draw calls, while something like this:

Widget (depth 0)
- Dynamic font label (depth 2)
-- Widget (depth 1)

... will have only 2.

P.S. I strongly discourage using dynamic fonts. They have too many issues on Unity's side that no one can fix. Not even Unity themselves.

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Optimizing Draw Calls and Draw Order - Need Info
« Reply #2 on: September 24, 2014, 02:45:55 PM »
What's a dynamic font, and what are my options?

I just use a .ttf or .otf, use your font maker tool, create a prefab and get it added to my atlas, and specify the font in the UILabel font field in the inspector.  Maybe I've been doing it wrong? It does seem like I shouldn't be incurring more draw calls if I'm using a single atlas to draw the entire UI. But I thought maybe a special material was used for rendering the glyphs from the atlas.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Optimizing Draw Calls and Draw Order - Need Info
« Reply #3 on: September 24, 2014, 03:10:06 PM »
Font Maker makes bitmap fonts. Dynamic fonts is when you reference a TTF on the label directly, without using the Font Maker.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Optimizing Draw Calls and Draw Order - Need Info
« Reply #4 on: September 25, 2014, 04:03:03 AM »
It might be useful for you to take a look at this tool I made, which shows you individual draw calls so you can see how it's split up

http://www.tasharen.com/forum/index.php?topic=6166.0