Search Unity

Question GPU Instancing not working properly with HDRP

Discussion in 'High Definition Render Pipeline' started by carcasanchez, Jan 14, 2020.

  1. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    Hello, fellow Unity users.
    I am working on a VR simulation using the HDRP (I know is not the appropiate pipeline, but our target hardware is very high-end, and URP limitations are a problem), and, of course, I have numerous performance issues.
    After doing some works of optimization, I have arrived to a curious situation.

    My scene consist in a concert stage. Right now, I have this not-too-fancy low-res seat model populating all the scene.
    upload_2020-1-14_12-11-41.png


    This makes the draw calls increase to: upload_2020-1-14_12-14-30.png

    Of course, being the same model with the same material, I enable GPU instancing to reduce draw calls.
    My surprise? To see that the number doesn't change at all:
    upload_2020-1-14_12-16-19.png

    If I go to the Frame Debugger, I see the same draw calls: upload_2020-1-14_12-19-56.png

    Static Batching doesn't help too much, too (yes, it is deactivated to not override GPU instancing).

    The draw call incresing is not too much in this case, but when I start adding models and detail to the scenery, instancing not working makes the performance drop exponentially.
    I have seen numerous users complaining about GPU instancing being a little erratic. Sadly, documentation and info about the HDRP is scarce and messy.
    For (duh) instance, I read about the SRP batcher interfering with GPU instancing in one forum, but I found (through code, because the checkbox isn't anymore :() that the Batcher is disabled by default.

    So: any clue of what is happening? Is GPU instancing even compatible with VR? Is really an engine issue, or is that I am losing something important?

    I will be grateful about some doc/advanced tutorial on how to interpret the Frame Debugger, as it seems a very powerful tool, but right now is very cryptic and difficult to read.
     

    Attached Files:

  2. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    Edit: Well, NOW, for a reason I still don't comprehend, instancing works when SRP Batcher is disabled.
    This HDRP mess is driving me crazy
     
    Last edited: Jan 14, 2020
    vignesh211 and wanucha1 like this.
  3. arnaud-carre

    arnaud-carre

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    97
    Hi!
    By design, enabling SRP Batcher automatically bypass our generic GPU instancing. (because it's faster for common case). If you want to check performance for various configurations ( SRP batcher ON/OFF, GPU Instancing ON/OFF, Static Batching ON/OFF), please use https://github.com/Unity-Technologi...b/master/Assets/Scripts/SRPBatcherProfiler.cs
    This script display CPU rendering time metrics, and you can compare these numbers in your dedicated scene.
    If your scene use exactly the same material for all the chairs, and have no lightmaps and no light probes, then maybe GPU instancing could still be a win. Just switch off SRP batcher to test ( and look at CPU metrics numbers with SRPBatcherProfiler.cs )
    If you see anything suspicious, you can post screenshot with SRPBatcherProfiler.cs numbers displayed with or without SRP Batcher, and with or without static batching.
     
    oneted_7, glolutphoenix and oleg_v like this.
  4. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    Thank you for your response.
    Optimizing the scene has been a pain for me, since HDRP is still very young. Probably I will start a thread about this.
     
  5. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Hi,

    I use the HDRP Lit shader and enabled GPU instancing for objects copied and scaled - rotated around, but the batches are still enormous (like 3000) and "saved by batching' metric reports a minus -2000, is this meaning the batching is working ?
     
  6. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    In a new chapter of "thing Unity do but don't tell you":
    GPU instancing is disabled by default in HDRP. Yes, even if you have that checkbox marked. If you have negative numbers like yours, batching is not working.
    Why? Because they are implementing a new batcher, the SRP batcher, that works even with different materials, and disables GPU instancing automatically.
    If you want to disable SRP batcher and compare its benefits with GPU instancing, I suggest you to download:
    https://github.com/Unity-Technologi...b/master/Assets/Scripts/SRPBatcherProfiler.cs
    For me, SRP worked very fine, since I am using a lot of different materials.
     
    oleg_v and nasos_333 like this.