Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Ecs with hybrid renderer slower than gameobjects

Discussion in 'Graphics for ECS' started by crener, Dec 30, 2019.

  1. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    I decided to give ecs another go since trying it when first available. It took a few days but I rewrote a simplified spline system that a project is using.

    So I created a benchmark which creates 10000 gameobject/entities from a prefab and moves them along the same spline.

    The ecs side works amazingly with the entity updating and spline position computation but falls short on the rendering front which ends up making it slower than using game objects.

    Ecs spline time: ~1ms (from entity debugger)
    Ecs render time: 160ms
    Ecs FPS: 6.1 FPS

    Go spline time: ~19ms
    Go render time: 1.7ms
    Go FPS: 22.7 FPS

    This is running on a very old laptop atm (due to what is available over the holiday period)

    The issue is that the ecs system doesn't have seem todo any batching so there are 10k draw calls. Is there a way to fix this? Is the dots hybrid package the recommended way to render or should I be using one of the rendering pipelines?

    Is this just the current state of things? If so I'll look back in a year or so to see if this has changed at all...

    Thanks for any advice
     
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Yes, you should be using the DOTS Hybrid Package + one of the SRPs. ECS render batching doesn't exist with the old pipeline. I'd recommend upgrading to the latest 2019.3 release candidate (in the beta section of the hub) and try messing with the latest packages.

    Also take into account if profiling in the editor there are various safety checks enabled, the only true measurement of ECS performance at this time is in a built player (although if your ECS code doesn't deal with rendering, you'll generally see an improvement with burst).
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    I'm getting the opposite result with legacy renderer and hybrid, that's in 2019.3f3
    60fps gameobject and 120fps when they're converted to entities
     
  4. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    I'm using burst (got around 6ms down to 1ms).

    On 19.3f03 which is latest as far as I know. I'll grab one of the SRPs and see if that makes a difference.
     
  5. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    Hmm strange, maybe it's the shader? I'm using the unlit color shader if that makes a difference
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    with 2019.3? weird indeed... tell us how the SRP changes that.
    upload_2019-12-30_17-32-36.png
     
  7. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Bear in mind, I think only HDRP will have the full instancing support as of current. The plan is to have full URP instancing support mid-next year. There were some issues with the way URP supports instancing that need to be addressed first (on top of all the other higher-priority URP features people are still waiting on. Like Camera Stacking and custom PP V3)

    I'd expect both to be fully usable around Unite Copenhagen 2020.
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    I forgot to turn on GPU instancing in material. Legacy renderer now runs at 20 fps with 100K objects@ 111M polys. 473 batches on a 2060rtx
    I'd say f3 fixed legacy + DOTS performances and I remember that HDRP was slightly faster than legacy... ah let's try HDRP
    upload_2019-12-30_19-0-15.png
    HDRP loses a couple fps losing the lit shader
    upload_2019-12-30_19-15-57.png
     
  9. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    So I've gone and tried todo this with HDRP but sadly the computer I'm stuck with only has integrated graphics so HDRP refuses to run. I'm going to have to see if this works when I'm back at my desktop in a week for two.

    I tried the universal pipeline and that didn't have any difference to fps, it might have ended up making the gameobject version render a little slower in the end. Oh well.

    I'll update when I can get some testing done.
     
  10. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    when I turn off rendermeshsystemv2 cpu usage drops a lot and fps ups from 50fps to 130 fps
    You can't move objects but camera responds to lod, even when i turn off the lod system o_O
     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,822
    Yep, this issue has been already highlighted in few threads already. It is a bit frustrating.
    I am sure Unity DOTS team can tackle the issue eventually.
     
  12. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    I seems that you have read up a lot on that. Do you have a *GOOD* thread that explains how rendering works ?
     
  13. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,822
    Yes I read few threads.
    But best you get lurking around too, if you want to get familiar with that case.
    https://forum.unity.com/search/127843893/?q=rendermeshsystemv2&t=post&o=date&c[node]=147+422+425
    These are threads, which are probably most relevant.
    Few lines down, you should see
    Turning off culling of RenderMeshSystemV2

    Also using Graphics API

    https://docs.unity3d.com/2019.3/Documentation/ScriptReference/Graphics.html
    like DrawMesh ... allows avoid this issue.

    These are some references, which will hopefully help you catch on the topic.
     
  14. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,455
    ah ok, so it's a hybrid thing, I'm sure they'll fix it, I won't worry about it.
     
  15. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    Ok, Got back to my Desktop and ECS is F***ing awesome! Got HDRP downloaded and hit play on my gameobject benchmark... ~30 fps (~28ms) then went over to the entity benchmark scene BOOM 230 fps (~4.5ms)!

    This is going to be great, now I just have to wait till they support the sprite renderer with the vector graphics package :)
     
  16. crener

    crener

    Joined:
    Aug 29, 2015
    Posts:
    27
    Ok, might have spoken too soon. I forgot that you need to setup hdrp with the render pipeline and all that stuff. So i did that and the fps with entities got lowered to 130 fps. Interestingly by default the batching was still 0.

    After I swapped over the single shader in the scene to a hdrp version the scene summary said it was doing 42 batches with 19982 saved by batching.

    What I don't understand with that is where did the extra 10k draw calls come from (since there are only 10k meshes but basically 20k calls with everything added together)? and why is the performance still 130 fps even though there is batching? the CPU time has increased a lot and the render time is next to nothing so could it just be that my scene is too simple to see any performance increase from hdrp vs hybrid?