Search Unity

Resolved Heavy performance drop with Hybrid Renderer in Unity 2020.3

Discussion in 'Graphics for ECS' started by Extrys, May 2, 2021.

  1. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    Currently happening on unity 2020.3.6
    with Hybrid renderer 0.11.0 preview 42
    and Universal render pipeline 10.4.0

    Tested Cases:

    I have been testing on PC
    having 12k entities

    Built-in render pipeline with GameObjects
    ~60fps ~16ms average

    Built-in render pipeline with Entities and hybrid renderer v1
    ~200fps ~5ms average

    Built-in render pipeline with Entities and ENABLE_HYBRID_RENDERER_V2
    ~52fps ~19ms average (Even worst than not using ecs at all)
    EDIT: This specific case was tested wrong

    URP with Entities and hybrid renderer v1
    ~200fps ~5ms average (Entities not visible and seems there is not compatibility with V1 anymore)

    URP with Entities and ENABLE_HYBRID_RENDERER_V2
    ~55fps ~18ms average (Even worst than not using ecs at all Again)


    I have reported the issue, I hope it gets solved soon, or someone tell me what I'm doing wrong
     
    Last edited: May 3, 2021
    Thygrrr likes this.
  2. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    238
    In case it helps as a reference point, 2020.3.1f1, HR 0.11.0 & URP 10.3.2, HR V2 enabled I can comfortably render more than 100k dynamic animated simple lit cube entities with a directional light & shadows @ > 60fps (980ti, 3900x), in editor. It could be your meshes or materials are much more complex than this toy example but just to check the obvious - Enable GPU Instancing is enabled on your URP material?

    upload_2021-5-2_22-0-28.png
     
    Extrys likes this.
  3. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    upload_2021-5-3_11-11-18.png
    I'm in the newer 2020 version currently
    And something is definitely wrong with V2
    it seem like is batching Each cube separatedly

    GPU Instanced is enabled
     
  4. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Could you paste a screenshot of a problematic frame from the Unity Profiler? That should provide some insight into why your rendering is slower than expected. If Hybrid Renderer is taking a lot of CPU time, please verify that Burst is enabled (Jobs > Burst > Enable compilation).

    EDIT: Another possible cause of slowdown is if your entities are using a transparent material. Hybrid Renderer V2 renders such entities separately by default, so they can be depth sorted to produce the correct result. If you do not care about depth sorting, you can disable this behavior using the DISABLE_HYBRID_TRANSPARENCY_BATCH_PARTITIONING scripting define, after which HRV2 should batch them similarly to HRV1.

    Also, some things worth mentioning here:
    • The built-in render pipeline is not compatible Hybrid Renderer V2.
    • "GPU Instanced" does not affect HRV2. It only affects HRV1, which requires it to be enabled.
    • The "batching" statistics are not accurate for any version of Hybrid Renderer. Those statistics are for Unity's built-in GameObject batching. For Hybrid Renderer, the only important statistics are the CPU main thread and render thread time.
     
    Last edited: May 3, 2021
  5. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345

    This is Built in render pipeline with gameobjects, even no logic at all, just rendering
    upload_2021-5-3_15-57-42.png




    This is Built in render pipeline with V1 HR
    upload_2021-5-3_15-56-33.png




    URP HR V2 (jobsDebuger: OFF LeakDetection: OFF safetyChecks: OFF EnableCompilation: Enabled )
    upload_2021-5-3_16-9-11.png
     
  6. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    A better screenshot for
    URP HR V2 (jobsDebuger: OFF LeakDetection: OFF safetyChecks: OFF EnableCompilation: Enabled )
    upload_2021-5-3_16-17-0.png
     
  7. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    ok i was using transparent shaders, i will try it without being transparent so it should work too right?
     
  8. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    Ok this is what i have seen

    If you convert the entities using non transparent shader it works correctly as expected

    BUT
    if i change the material to transparent in runtime the entities change to transparent and the framerate stays good

    Also viceversa
    If i have Transparent entities running slowly if i change the material in runtime it continues slow

    This is weird, i would like to know why is that



    Also
    DISABLE_HYBRID_TRANSPARENCY_BATCH_PARTITIONING
    Works like a charm
     
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    I highly recommend u to submit bug report and post your case number at here.
     
  10. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    well that last bug has noting to do with this post, it should be in a different thread i think
    Also I suppose its happens because when the entity is already converted they stay in the same batch groups, acting like enabling that last DISABLE_HYBRID_TRANSPARENCY_BATCH_PARTITIONING, but without it, is weird.
     
  11. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    The reason is that transparent entities are split into different batches using the HybridBatchPartition shared component, which is added automatically at GameObject conversion time if the Material on the MeshRenderer is determined to be transparent, unless DISABLE_HYBRID_TRANSPARENCY_BATCH_PARTITIONING is defined in which case it is not added. If you change the Material at runtime, the HybridBatchPartition will still remain.

    You can remove the HybridBatchPartition shared component when you change the Material to make HRV2 batch efficiently again. You can do this regardless of whether the Material is transparent or not, but if you do it with a transparent Material, then incorrect looking rendering can result if objects are on top of each other in the view.
     
    andreiagmu likes this.
  12. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    well I guess this awsome, is there any component to stop rendering an object? like disabling rendering?
    Maybe a "Disable" tag component?
     
  13. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Yes, there is a tag component called "DisableRendering" which does exactly that. Any entities with that component should be efficiently skipped by the Hybrid Renderer.
     
    andreiagmu likes this.
  14. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    Cool thanks a lot for your help!
     
    JussiKnuuttila likes this.