Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. 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

Official GPU Driven Rendering In Unity

Discussion in 'Unity 6 Beta' started by Tim-C, Oct 6, 2023.

  1. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    Does it work if the Speed Tree is placed as a GameObject with mesh renderer and the 'Tree' component (the one that's responsible for the wind)? Or does it need the 'Tree' component to be removed?
     
  2. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    307
    I couldn't migrate my project to the alpha version because that's too much work. So, I use the asset from asset store to test it. This scene is pretty good test case I think. sane number of unique meshes and material with good amount of reuse.

    GPU Residency Off


    GPU Residency On


    Testing in Build result in around +4 fps
    Unity Alpha 2023.3.0a11 HDRP DX11

    Can anyone help explained to me why the stat on GPUResidency_On is so much better but the fps gain is not that much?
    Edit: okay, I'm probably main thread bound on both test. Though, the checkbox literally half the gpu time lol That's crazy.
    Am I correct in assuming that this feature might be even better in the future where you implement indirect instancing?

    Asset from
    https://assetstore.unity.com/packag...ese-modular-house-hdrp-free-erbeilo-3d-215357
     
  3. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    75
    Because you are making a very wrong observation by looking at the FPS. If you examine the MS values, you will notice that there is a serious relaxation on the CPU when GPU Driven is active. Increasing CPU performance in a scene that already has a GPU bottleneck will not increase FPS.
     
  4. Kabinet13

    Kabinet13

    Joined:
    Jun 13, 2019
    Posts:
    152
    I did some preliminary testing with the lumberyard Bistro Demo, but noticed an overall performance regression when updating to 2023.3 (seemingly unrelated to and unaffected by the GPU Resident drawer) The regression seems to have to do with the main thread, since GPU time remains at ~10ms (Consistent with the GPU bound 100fps this scene had before updating), while the CPU frame time is now closer to 18ms. The editor overall does feel a lot faster and snappier to use, but I'm kind of at a loss as to where this regression is coming from. (Note: I did test both with and without static batching, and it didn't seem to make a big impact)

    Unfortunately this means I have been unable to test properly or notice any real benefits with this feature. (Unrelatedly, the batches count in the profiler and statistics panel both seem to report upwards of 5k batches, while the frame debugger only shows only 20 Hybrid Batch Groups)

    upload_2023-10-28_11-48-24.png
     
  5. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    288
    This system is a godsend! Improvements are drastic, especially with many point-light shadows (26k objects, 33 lights, from 53 to 133 fps!).

    Can we now have per-instance material property overrides like in Entities, or is it planned?
    And also, how could this system be used with custom SRPs?
     
    antoinecharton likes this.
  6. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    211
    Any hopes of this making it to 2022.3 LTS for long-term projects locked in, without many options to upgrade the engine at this point? :D
     
    FernandoMK likes this.
  7. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    440
    I assume that it won't be backported, as LTS only receives bug fixes.
     
    antoinecharton likes this.
  8. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    196
    Unfortunately the feature is too big to be back-ported.
     
  9. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    196
    Here is an example on MacBook on which your scene is CPU bound.

    GPU instancing off
    Screenshot 2023-11-01 at 4.36.22 PM.png

    GPU instancing on
    Screenshot 2023-11-01 at 4.36.48 PM.png
     
  10. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    307
    Why is the render thread so much faster, lord. I thought this feature is specifically CPU optimization? Does this mean there are more room to use GPU for other thing right?

    This feature is wonderful. Thank you everyone on the team for this.
     
  11. slime73

    slime73

    Joined:
    May 14, 2017
    Posts:
    107
    The render thread is a CPU thread dedicated to doing work related to the render commands lower level graphics APIs like Direct3D provide, like draw calls. If you want to see GPU performance, the Unity profiler window has a section for that (as well as a section for CPU performance that shows exactly what each CPU thread is doing in a timeline view) - or you can use an external GPU profiler.

    The pop-up statistics view in the game window doesn't really show GPU performance directly.
     
  12. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    75
    Unfortunately, there are still developers who lack knowledge about GPU and CPU bottlenecks. GPU Driven is a feature I have really appreciated in recent years.

    Anyway, there is a detail I am curious about. Unfortunately, I could not catch a suitable working environment on this subject, so I would like to learn from authorised friends. While GPU Driven is active, does SRP Batcher continue to show its effect at the same time? So if we consider 30k Batches to 3k, do these 3k batches also have a feature such as falling between 500-1000 with SRP Batcher in the background?
     
  13. Zarbuz

    Zarbuz

    Joined:
    Oct 13, 2015
    Posts:
    45
    I really hope this feature can be implemented with WebGPU ! I have tested this feature in my project and the number of drawcalls have decreased significantly! You’ve have made a really good job! Congratulations to all the team!
     
    DannyWebbie, adamgolden and KamilCSPS like this.
  14. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    449
    Really wanted to +1 this. The Web platform would massively benefit from this tech compared to other platforms. Much bigger impact.
     
  15. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    Bugs:
    In GPUDriven\Lightmaps.cs, struct MaterialLookupKey uses textureIndex as HashCode. It will cause separate Instance Draw Calls in a multi lightmapped scene which could be optimized to only one draw call.
     
  16. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    This isn't the index you think it is. We have an array of texture arrays. Each item has different format / resolution / setting. This index is the index into this that - not into the texture2d array itself. Looking at it locally this seems to be working as expected for us, are you seeing something different?
     
  17. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    upload_2023-11-10_13-50-46.png upload_2023-11-10_13-51-50.png
    2000 cubes with 20 different baked point light generate 21 lightmaps. It generates 21 instance draw calls in Frame Debugger. I think these draw calls could be batched into 1 draw call.
    upload_2023-11-10_13-52-48.png
     
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Can you raise a bug with this project so I can take a look? That should be one draw call imo :)
     
  19. Amplify_David

    Amplify_David

    Joined:
    Mar 29, 2023
    Posts:
    207
    @Tim-C
    Hello sir, you're doing wonderful work keep it coming.
     
    Last edited: Nov 13, 2023
  20. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    IN-60524 - 2023 GPU Resident Drawer doesn't batch different lightmaps.
    You could check GPUDriven\Lightmaps.cs, struct MaterialLookupKey, wrong index?
     
  21. MikkelSim

    MikkelSim

    Unity Technologies

    Joined:
    Nov 14, 2023
    Posts:
    2
    There's indeed a problem with the index, it's supposed to be an index into the list of texture arrays, but it isn't. Good catch! Going to submit a fix for this.
     
    LooperVFX, Rewaken, LYHyper and 3 others like this.
  22. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    174
    Any ETA for deferred compatibility and URP?
     
  23. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    383
    Firstly, congratulations to the devs on landing this feature into alpha - this is the kind of work that unity deeply needs and will be the basis for serious performance in the future. Awesome stuff!

    I am tempted see how it large game goes with it, though I think it is too close to release to use sadly.

    Our game makes little use of GPU instancing as we have a lot of unique meshes and they may only be duplicated in frustum maybe 10-20 times depending on what the player does.
    Would that mean at this stage this project may do little for us?

    Another question about your roadmap - one area of massive CPU improvement I've witnessed has been in GPU temporal culling. Ie letting the GPU render the whole scene as bounding boxes and using those results to only render a subset.
    It's this something you're considering in the future?
     
    antoinecharton and joshcamas like this.
  24. mariandev

    mariandev

    Joined:
    Mar 30, 2013
    Posts:
    24
    Regarding your second question, they've just announced the GPU occlusion culling at Unite. You can watch it in the keynote at 17m54s https://www.youtube.com/live/8ZIdejTiXAE?t=17m54s . Hope this helps
     
    LooperVFX likes this.
  25. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    152
    Hello, could you please clarify if it means that your scene is GPU bound? So with mid range GPUs and CPUs we will see little to no effect fps wise?
     
  26. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    383
    Oh nice! Haven't had a chance to watch it in full yet. Is this also available in the alpha?
     
  27. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    448
    GPU bound in most cases means that you are pixel-bound. So your game is basically doing too many computations per pixel per frame like for example by having very complex shaders and/or post processing effects running each frame.
     
  28. TMThomsen

    TMThomsen

    Joined:
    Oct 27, 2018
    Posts:
    2
    I don't get the same options as on the screenshots in the first post when I select "Instanced Drawing" on our URP asset.

    Am I missing something? Or has it been changed in a newer version?
     
  29. OdemGeek

    OdemGeek

    Joined:
    May 23, 2020
    Posts:
    2
    With this feature disabled I have better performance, because of LOD cross fading. I don't know if this is how it should be.
    Cross fading Disabled:
    ab04fc48-f35f-4fde-b219-e2d7673d5813.jpg
    Cross fading Enabled:
    6c5724fe-9713-4e0c-9256-ebd1682780c4.jpg
    9f10c7b8-fb64-4ef6-87ef-216f7ba056f2.jpg
    There are more batches because of "Nodes have different LOD cross-fade mode". This doesn't happen when GPU Driven rendering is off. (Happens but only adds one batch in pass for objects using cross fade).
    I use Unity 2023.3.а14, HDRP 17.0.1 with DX12.
     
    MikkelSim likes this.
  30. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    196
    You have the correct version :) .
     
  31. lolium

    lolium

    Joined:
    Oct 14, 2014
    Posts:
    34
    first of all let me just express how exciting i was seeing that unity is finally getting GPU drawer & occulusion support at Unite! I wanted to try but seems like only resident drawer was available for 2023.3.0a14. i converted my project and tried it out, and it is significantly worse performance wise. i know it is still WIP but just to provide my datapoint. hope to get an idea how to debug further

    static batching + no gpu instance
    staticbatching_slum.png

    turn off static batching + gpu instanced drawer
    gpu-instanceddrawer.png

    the batches are much better, but fps lower.
    the profiler/frame debugger wasnt too useful, could be that i wasnt looking at the right place.
     
    lacas8282 likes this.
  32. APSchmidt

    APSchmidt

    Joined:
    Oct 31, 2023
    Posts:
    262
    I found the setting in the "Ultra_ pipeline Asset" in Assets/Settings but it doesn't say "enable". Is this different for Linux?

    Capture d’écran_2023-11-19_19-35-23.jpg
     
  33. acohade_unity

    acohade_unity

    Unity Technologies

    Joined:
    May 27, 2022
    Posts:
    3
    This does look like a bug ! We'll take a look :)

    ------------------------------------------------------------------------------------------

    This is indeed a problem. Could you share profiler frames / screenshots, it's hard to say without more information ! As an informed guess, can you make sure that Burst compilation is enabled ? upload_2023-11-20_14-26-30.png

    ----------------------------------------------------------------------------------------------


    Instanced Drawing is indeed what you are looking for :)
     
    antoinecharton likes this.
  34. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Can you please log a bug and report the number here so we can investigate?
     
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Can you please log a bug so that we can investigate?
     
  36. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    It will be in a few weeks but we are still doing some polish before pushing it into an alpha release.
     
  37. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    <3
     
  38. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    I found the Texture2DArray which are used to cache lightmaps in scene are isReadable by default. I think this could be optimized to be marked no longer readable.
     
  39. APSchmidt

    APSchmidt

    Joined:
    Oct 31, 2023
    Posts:
    262
    Sorry that I ask but what for?
     
  40. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    https://docs.unity3d.com/ScriptReference/Texture-isReadable.html

    Note: Readable textures use more memory than non-readable textures. You should only make a texture readable when you need to, and you should make textures non-readable when you are done working with the data on the CPU.
     
  41. lolium

    lolium

    Joined:
    Oct 14, 2014
    Posts:
    34
    thwackstudio likes this.
  42. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
  43. lolium

    lolium

    Joined:
    Oct 14, 2014
    Posts:
    34
    You folks are working on some of the most impactful changes to rendering in Unity. wish you the best of luck!
     
  44. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Personally, I just want to bring changes to the engine that bring great improvements to existing projects and make it easer for people to push content. Specifically for me this means just getting as much rendering stuff off the main thread as possible so that you have more time available to do simulation and similar for your games instead of Unity eating that time for rendering. We've got a lot of ideas on how to do it but nothing in this space is quick or easy - all I can say is that what you are seeing with this work here is just the start and we are going to keep pushing in this direction moving forward.
     
  45. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    BUGS: Lightmaps Texture2DArray will not work with mipmap limit.:)
    Hope you guys could have time to fix it.
     
  46. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Yep we are working on an improved system to fix this. Won't be ready or a little bit but we hope to land it before full release. As a workaround we are adding an option to 'use legacy lightmaps' which will use the same lightmapping binding as with gameobjects but it means batches will break more often but will work with systems like mip streaming and similar.
     
    joshcamas and LYHyper like this.
  47. acohade_unity

    acohade_unity

    Unity Technologies

    Joined:
    May 27, 2022
    Posts:
    3
    As an alternative option, you can set the following settings in Lighting settings :

    Would this work for your use case ?
     
  48. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    I don't think so. I just want to use some mipmap limit settings to reduce lightmap VRAM size on some low end platform.
     
  49. LYHyper

    LYHyper

    Joined:
    Oct 11, 2023
    Posts:
    11
    Thanks for your apply. Currently there are 2 kinds of lightmaps in VRAM the origin texture2d lightmaps and the new texture2darray lightmap, hoping to have a way to reduce VRAM in the future.
     
  50. bnmguy

    bnmguy

    Joined:
    Oct 31, 2020
    Posts:
    137
    Unless you want white or fuchsia color lightmaps (Hint: You don't) this a required for Texture2DArray.