Performance Art 2: When is a draw call not a draw call?

So we know that draw calls are a major killer for us.  So you would basically assume that the more draw calls there are, the worse the performance.  Well, this is not always true.  There's a funny scenario happening in the Adrenaline Expansion Pack right now.  Without the material batching, there's one area that is causing over 12,000 draw calls.  This is about 12x the USRDA recommended daily dosage of draw calls for any individual.  So it's a slide show right?  Actually, it's running at about 15-20 frames per second on most people's machines.  Which brings me to part 2 of the Performance Art thread:  When is a draw call not a draw call?

 Okay, a draw call is always a draw call.  Every new draw call involves the CPU sending information to the GPU to be rendered.  And believe me, we have our own overhead for each draw call (things like pull on ground and other procedures to make sure everything is rendering in the correct place).  However, if you have several thousand objects in a scene that all have the exact same material and textures, and are using a simple material with only diffuse and night textures, they can all be ripped out in a row without a single material switch.  Which means there is virtually no processing between each draw call except the new vertex information (in this case, incredibly simple apartment complexes of 100 vertices or less).  And on top of that, the pixel shader requires about 3 instructions.  So for 8500 of the 12000 draw calls, there is not a single material switch, very simple vertex data being sent to the card and almost no GPU calculations in the pixel shader.

So what's the lesson here?  Well the first is that we still need to do material batching, and when we do, those 8500 draw calls are going to become a handful.  The second lesson is that a draw call is not always super expensive.  If you author your content smartly (reusing textures and material settings exactly, using fewer vertices in the model and creating simple materials) you can rip through draw calls incredibly quickly.  And the benefit to authoring content that way is that when material batching comes in, all of those objects suddenly batch up into a few draw calls.  The last lesson is that we are really kicking it up a notch for the expansion pack.  Seattle, with all of the autogen cranked and traffic turned all the way up is still only about 5000 to 6000 draw calls.  I know, I say "only" like that's a low number.  It's still extremely excessive and hopefully the material batching work will really knock those numbers down and knock the framerates up.