Jump to content

[SOLVED] Instancing stress test


photo

Recommended Posts

So I compiled a stress test of Unigine's instancing/rendering capabilities, and my results are pretty strange. I'm hoping someone can explain why I'm getting these numbers.

 

All tests are performed in a new scene, with only the profiler and toolbar visible.
The object I'm using has 452 triangles and the default mesh-base material with one diffuse texture. All post-processing effects are off.

 

Machine specs:

 

Intel i7 CPU, 2.8 GHz

Nvidia GeForce GTS 250

8 GB RAM

1920x1080 resolution

 

 

1. Everything disabled, blank screen
    FPS: 700
    Draw Calls: 2

    Shaders: 3
    Triangles: 2
    Materials: 2

2. A single object, no light
    FPS: 535
    Draw Calls: 4

    Shaders: 5
    Triangles: 906        over 2x original triangle count
    Materials: 4

3. Two identical objects, same materials, no light
    FPS: 500
    Draw Calls: 4

    Shaders: 5
    Triangles: 1810        about 4x original triangle count
    Materials: 4

4. 2 identical objects, world light enabled
    FPS: 480
    Draw Calls: 7

    Shaders: 8
    Triangles: 4070        4.5x original triangle count
    Materials: 5

5. 10 identical objects, world light enabled
    FPS: 452
    Draw Calls: 8         +1

    Shaders: 8
    Triangles: 19438    4.3x original triangle count
    Materials: 5

6. 50 identical objects, world light enabled
    FPS: 407
    Draw Calls: 10        +2

    Shaders: 7             -1? wtf?
    Triangles: 90402    4x original triangle count
    Materials: 5

7. 200 identical objects, world light enabled
    FPS: 145
    Draw Calls: 56         +46!

    Shaders: 8
    Triangles: 738570    over 8x original triangle count
    Materials: 5

8. 800 identical objects, world light enabled
    FPS: 57
    Draw Calls: 204         +148!

    Shaders: 8
    Triangles: 2912238    still 8x original triangle count
    Materials: 5

9. 3200 identical objects, world light enabled
    FPS: 19
    Draw Calls: 602         +398!

    Shaders: 6                 -2? Wtf?
    Triangles: 8678402    6x original triangle count
    Materials: 5

10. 3200 identical objects, world light DISABLED
    FPS: 27
    Draw Calls: 402

    Shaders: 5
    Triangles: 5785602    4x original triangle count
    Materials: 4

 

 

The triangle and draw call counts are all over the place. I have some questions about this. Why do the profiler's triangle counts never match the object's tri count? Is it counting the triangles rendered in each pass? And if that's the case, why do the numbers still never match up evenly? There are tests where the triangle count is over 8 times what it should be!

I performed this test with static meshes, because I've read that the batching in Unigine is done automatically, and the first couple cloning tests support that theory. So why do the draw calls increase? If these objects were truly instanced, shouldn't the engine draw them all in one call? And the draw call/poly increase never matches up with the rate at which I'm duplicating objects.

Why does the directional light dramatically increase the triangle count?

Why are there changes in shader count?

I was also seeing some very strange behavior when copying objects. When getting up to the higher numbers where the
numbers start to stray, I noticed a huge spike in the tri count when I copied objects, and watched it lower based on how near in world space the clone was to the original.

I also saw the triangle count change based on where the objects were on the screen, and how far away the camera was. These objects didn't have any lod assigned, why would this change?

Link to comment

Hi Ted!

Our engine is using multi-pass rendering technique so there might be some things that may confuse you.

First of all, take a look at our rendering sequence here: https://developer.unigine.com/en/docs/1.0/principles/render/sequence/
Second, I'll able to answer more precisely if you show me your testbed.

Profiler's triangle counter matches number of triangles that will be rendered bu gpu including all passes and editor/profiler gui so that might be the case.

Number of draw calls can be changed due to batching. Also, make sure you have instancing enabled ('d3d11_render_use_instancing' should be set to 1 for dx11, 'd3d9_render_use_instancing' for dx9 and 'gl_render_use_arb_draw_instanced' for opengl)

Link to comment

post-1189-0-32290800-1384215682_thumb.jpg

 

Both d3d9_render_use_instancing and d3d11_render_use_instancing are set to 1.

I did a bit more digging into this subject, and found that Unity's batching has a comparable result. They put a limit on the number of tris the engine will batch, likely to reduce processing; their limit is about 21.9k. I expect most engines probably employ a similar tactic. So that answers that question.

I replicated my test world to get a screenshot to show you, and though the same number of objects are being rendered in the scene with the same settings, the draw calls and tri count differ wildly based on where the camera is, and how close together the objects are. Why would these values change?

Link to comment

So spatial tree optimization is what's increasing draw calls and tri count depending on where an object is on the screen, and how close it is to other objects? What exactly is it doing there?

Also, why does the shader count change throughout the test?

Link to comment

Ted, I did my investigation, here's the results. Hope it'll clear some things for you. :)

 

I've run your scene and got your results. That's a good start.

 

First of all, I enabled all debug render textures by using 'render_show_textures 1' concole command so I was able to see what's going on. Each texture means at least one draw call and one shader with exception for deferred pass if your hardware has MRT support.

 

Then I started to switch off passes such as motion blur, post-process, scattering, hdr via system menu and via 'render_skip_*' console commands (there's a lot of them and you can control each rendering step). Actually, I left only 'render_skip_opacity_ambient' with zero value. The shader count still behave strangely.

 

After that, I switched off shadows by using 'render_force_no_shadows 1' console command and the magic has gone. Shader count showed proper values to me.

 

So the answer is world light shadows may differ shader & dip count as there're rendered in splits (actually, four splits, you can see shadow texture via 'render_show_textures 1' console command), each split can be skipped if there are no objects in it. That means less dip and shader count.

Link to comment
×
×
  • Create New...