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. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi all, once again for any issues you think you have found or weird situations:

    Please log a bug with the repro project linked in this thread. We are actively monitoring this thread for bug ID's to jump on. Not having a project or tracking point makes it really difficult. Most of the time it's not possible for us to say if something is an issue or not / explain what is being seen without a repro project. Some of the issues above might be real issues. Send me those bug ID's!!
     
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    laurentlavigne likes this.
  4. acohade_unity

    acohade_unity

    Unity Technologies

    Joined:
    May 27, 2022
    Posts:
    3
    qjlmeyes - thanks for all the testing and feedback :) Here's a few answers !
    Yes - this is something we have in our backlog to investigate in future versions!

    I'm a bit confused by this one :) It does seem like you get from ~2.5 to ~1.8ms for the culling job, isn't it ?

    Unfortunately, with any draw indirects, as the drawCounts are updated on the GPU, we are not able to update Stats (neither those screenshot, and the GPU Resident Drawer Stats in the rendering debugger).
    In the meantime, you should be able to visualize visible and/or culled instances using the Rendering Debugger :
    Show Visible Instances:
    upload_2024-3-20_10-48-41.png

    Show Culled Instances:
    upload_2024-3-20_10-49-27.png
     
    AntonioModer likes this.
  5. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    Although the single elimination task has been reduced from 2.5ms to 1.8ms, the elimination with LOD has increased the number of tasks, and a single job thread has an additional elimination task of 1.1ms.
    The cumulative elimination time has not decreased, and both sides are 3ms. So the improvement in LOD is not significant
     
  6. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    So Unity advertised speedtree assets to benefit from gpu resident drawer starting from Unity 6 beta (or 2023.3) here's my test results. I used a single tree prefab that is exported from the latest speedtree version and the project is using hdrp with all graphical features enabled: volumetric fog and clouds, water, screen space reflection, contact shadows, ocean, ssgi, stp at 70% forced render scaling. Screenshots are taken from DX12 Ilccp builds with no vsync.
    I am comparing results with and without Gpu resident drawer (ignoring gpu occlusion culling).

    For the first test i spawned the trees as gameobjects:
    Screenshot 2024-03-23 145543.png
    Screenshot 2024-03-23 145532.png

    For the second test i spawned the trees using the terrain system, which is the correct workflow by the way as it doesn't clogs the scene with too many gameobjects. Here's the result:
    Screenshot 2024-03-23 145634.png
    Screenshot 2024-03-23 145614.png

    The only oimprovement i can see is when lots of tree game objects are present in the scene, but this kind of workflow creates various problems in large scenes.
     
    soleron and laurentlavigne like this.
  7. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Here i remade the test in the editor. You can see the batch count decrease when gameobjects and gpu resident drawer are used. Overall not much of a performance improvement (as you can see in build tests).

    I am a bit disappointed as i was hoping for and official instancing support solution for terrain trees even if paywalled behind speedtree, but that doesn't seem to be the case as i think there would not be any difference with other types of tree assets.

    Screenshot 2024-03-23 151347.png Screenshot 2024-03-23 151410.png Screenshot 2024-03-23 152045.png Screenshot 2024-03-23 152058.png

    Note: This test has overall worse performance as i enabled real time global illiumination.
     
    Last edited: Mar 24, 2024
  8. Kabinet13

    Kabinet13

    Joined:
    Jun 13, 2019
    Posts:
    151
    I'd be very interested to see a profiler capture with and without. It might be that your framerate is gpu bound (speedtree is slow gpu side) and that you just aren't seeing an fps difference even if the cpu has a lot of pressure relieved.
     
  9. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Sure, here's a couple of snapshots with the terrain trees. (Enabling or disabling gpu drawer doesn't have any effect on performance)
    Screenshot 2024-03-24 085002.png
    Screenshot 2024-03-24 085041.png
     
  10. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Here are some snapshots with gameobject trees without gpu resident drawer:
    Screenshot 2024-03-24 085528.png
    Screenshot 2024-03-24 085540.png

    And here's with gpu resident drawer enabled:
    Screenshot 2024-03-24 085711.png
    Screenshot 2024-03-24 085723.png

    Seems that using trees with terrain already comes with the same performance improvements that gameobject trees have when coupled with gpu resident drawer instancing. Also having many trees as gameobject really isn't optimal for use.
     
    Last edited: Mar 24, 2024
    TerraUnity likes this.
  11. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Sidenote here's the tree i used which is very light and optimized. (Includes billboard which is used at distance)
    upload_2024-3-24_9-3-12.png
     
  12. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    75
    Unfortunately, in a normal gaming environment, there is not much performance gain. For our current project, after the Unity 6.b12 update, gpu driven was expected to provide at least 20% gain, but we noticed that it reduced the current FPS. There was not even any cpu ms gain.
     
  13. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Terrain tree's drawn by the terrain system are already instanced batched, so the new pathway doesn't really help much here. To get increased gains you'd need to move to a system that does indirect rendering so the batches aren't limited to 1023 or 512 objects per batch.

    Further, looking at final FPS is often not really a good way to benchmark these things. For instance, if your GPU bound already, and you move drawing to the GPU (via instanced indirect), you save CPU time but end up at the exact same frame rate because the GPU is still bound by drawing the same things. And since most people like to test these kinds of things on large scenes of trees, which don't run AI or Path planning, etc, the CPU is mostly free to spend time submitting batches because there's no game play running.
     
    icauroboros likes this.
  14. icauroboros

    icauroboros

    Joined:
    Apr 30, 2021
    Posts:
    174
    I'm curious, what's your preferred tools and setup for GPU profiling?
     
  15. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Depends heavily on platform- When I can get Instruments to work (it breaks a lot) it's really nice because it can show you how much time is taken in various parts of shader code. But render doc, pix, etc, all have their places. I really wish the landscape of GPU profiling wasn't so scattered and vendor specific. I'd use the Unity one a lot more but it's never worked on macs..
     
    Ruslank100 likes this.
  16. icauroboros

    icauroboros

    Joined:
    Apr 30, 2021
    Posts:
    174
    Correct me if I'm wrong but there is no way to see usage (SOL for nvida terms) of the individual elements on Unity profiler (and renderdoc?) as I understand.

    So in theory you can optimize all the ALU, L1 hit rate, L2 Hit rate, SM occupancy of your compute shader that already Vram bound, but you will not see any improvements on fps count, gpu millisecond, or profilers that not show occupancy rates, right?
     
  17. Crazy34

    Crazy34

    Joined:
    Jul 14, 2019
    Posts:
    75
    In our recent tests, we have seen that it provides a significant advantage in situations such as billboard trees with tens or even hundreds of thousands of billboards. It's not very noticeable in general game performance at first, but given the lightweighting on the CPU, it allows us to get extra power for our custom CPU-based systems (such as Path finder, AI, etc.). Any advanced developer already understands that this is the case, as mentioned in the first message of this thread.

    Still, it seems to need a bit more performance boost.

    However, the feature we are looking for the most is to render without creating a gameobject in the scene. Because as I just said, if there are hundreds of thousands of gameobjects in the scene, even fps drops can be annoying just by turning these objects off and on collectively. There is also an unnecessary CPU usage that we cannot understand. In this case we had to switch to the drawmeshinstancedindirect method again.

    However, I can say that there is a real performance advantage in huge cities of 5000-6000 prefabs. This was a good reason for us to activate GPU Driven.

    We hope this system will develop further. Because for many years there has been a need for a system like this, with simple control.
     
    andreiagmu and Neonage like this.
  18. Armageddon104

    Armageddon104

    Joined:
    Sep 14, 2014
    Posts:
    24
    Hello, I'm making a zero-GC game and I need this to be removed:

    upload_2024-3-27_0-43-50.png

    It's in build and editor on Windows 10 with D3D12.
     
    Pitou22 likes this.
  19. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    344
    they say the last 10% of finishing a game takes 90% of the time.. you're asking Unity to fix a 0.001ms Size 32 GC Alloc?
     
    TerraUnity likes this.
  20. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    288
    It's possible with gameobjects? o_O
     
    Shikoq likes this.
  21. cloverme

    cloverme

    Joined:
    Apr 6, 2018
    Posts:
    199
    So frustrating there's no tutorials on GRP Resident Drawer or GPU Occlusion Culling. Why on earth is Unity so adverse to putting relevant dev related videos out on Youtube, but throws up dozens of monetization and IP videos... so frustrating.

    The only info I can find on GPU Occlusion is a Chinese video... which, by the way, confirms hi-z occlusion.

     
    andreiagmu likes this.
  22. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    Notice that these are still preview features in a beta release. I wouldn’t count on any information in any tutorials to stay fresh after the features are officially released.
     
    andreiagmu likes this.
  23. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    288
    Wanna ask again, will there be Material Overrides from Entities? It would be a selling feature for GPU Resident Drawer, since many people dreamed of proper replacement for MaterialPropertyBlock, instead of having to duplicate material for each unique instance, which is very troublesome and poor for performance.
    Since GRD is BRG - it can easily allow that, and the workflow would become better than ever :p
     
    Ruslank100 likes this.
  24. Armageddon104

    Armageddon104

    Joined:
    Sep 14, 2014
    Posts:
    24
    Anything that triggers a GC flush will cause stutter. The ms of the allocation function clearly isn't the issue, it's the fact that there's an allocation every single frame, that quickly builds up.
     
  25. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    290
    Don't quote me on this, but I think I saw someone mention that during the GDC stream. Can't remember if it was something they said was being worked on or something they already have plans to do. Let me look through notes and the recorded live stream to double check though.
     
  26. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We are in the process of figuring out how to properly do overrides that unifies MaterialPropertyBlocks, Entities Overrides, and GRD support. It will not be for Unity 6.0 unfortunately because it will need some bigger changes across unity and we don't want to just bolt on 3rd new way of doing overrides and instead refactor and have one clean correct way.
     
  27. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    91
    Love hearing that we would ideally get 1 good way to do things soon!

    I just started a new project on URP, 6000.0.0b13 with the hope of trying out the GPU resident drawer. With an empty scene, found that the GPU resident drawer is generating garbage every frame. Only 48 bytes... but its the only garbage generated every frame. Nothing else in the player loop generates garbage. Disabling the GPU resident drawer, even while in play mode, removes the garbage generation. Is 0GC something that is targeted for GPU resident drawer on Unity 6's release? (please be so q-q)
     
  28. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We'll look into this, I can see where it's coming from it might not be a trivial fix.
     
    Peter77 and Yoraiz0r like this.
  29. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    626
    Bad performance in my case.

    This is the same frame in 2023.2.15
    upload_2024-4-8_23-52-6.png

    upload_2024-4-8_23-59-46.png

    And here it is following the setup instructions in 6 Beta 12
    All materials were instanced already.

    upload_2024-4-8_23-51-55.png

    upload_2024-4-9_0-5-33.png
     
    Last edited: Apr 8, 2024
  30. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    803
    Are you sure it's the same? The Unity 6 version has twice the amount of tris and 50% more shadow casters.
     
  31. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We have fixed this btw, it will be in a future beta, not sure of the exact one but it will be there for release.
     
    laurentlavigne, Yoraiz0r and Pitou22 like this.
  32. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Please log a bug and post the number, we can't do anything unless we know what is happening.
     
    laurentlavigne likes this.
  33. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    626
    The projejct in question is 11GB (without libraries etc.) and I do not have a fast enough upload. Took 5 hours to upload on UVC.Using the bug menu the upload breaks in the process. Is there any way I could privately link the project from Version Control? or add you to my project? That would be much faster.
     
  34. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    Yes, the current method of copying shaders has very poor performance and consumes a lot of memory
     
  35. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    Generate 10,000,000 cubes and selecting one of them will cause the Drawer to frequently perform high energy consuming operations
    upload_2024-4-12_17-50-0.png
     
  36. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    Moving 1,000,000 cubes at once will cause the system to become increasingly sluggish until it crashes or becomes unresponsive
    upload_2024-4-12_17-52-54.png
    upload_2024-4-12_17-52-28.png
    upload_2024-4-12_17-53-46.png
     
  37. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    1,000,000
     
  38. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
    Does it seem that the custom batch render group cannot use hiz occlusion culling? Because there is no occlusion display in the debug. Can you provide an API to create a rendering instance for Gpu Resident Drawer without creating a GameObject, and support updating rendering instance data in the job
     
  39. qjlmeyes

    qjlmeyes

    Joined:
    Apr 19, 2023
    Posts:
    23
  40. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,434
    it's incredibly buggy in b16
    i sent the project, you can see by yourself

    i'm bagging this with APV, as don't know which break.
    https://forum.unity.com/threads/switching-to-gpu-resident-drawer-apv-breaks-in-74268.1581666/
    https://forum.unity.com/threads/render-graph-apv-urp-8-lights-failure.1581723/

    After getting rid of all red and yellow in the console, it works in editor but not in build, desktop or quest 2: all geometry is missing despite shaders being fine. the particles show up. Some shaders are ASE but others are URP/lit.

    upload_2024-4-20_21-3-23.png upload_2024-4-20_21-3-45.png upload_2024-4-20_21-4-7.png upload_2024-4-20_21-5-14.png upload_2024-4-20_21-5-0.png
     
    Last edited: Apr 21, 2024
    Peter77 likes this.
  41. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,627
    Are these shaders located in an assetbundle? Can you compare the shader assetbundle size of a build where the geometry shows up and where it's missing?

    I'm asking because I have the same issue of missing geometry and found that it seems that Unity strips all shader variants, see https://forum.unity.com/threads/uum...ed-as-by-design-_-tsu-_.1550459/#post-9770076
     
  42. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,434
    I'll try turning off stripping but this seems weird that URP/lit would be stripped out.
     
  43. lolium

    lolium

    Joined:
    Oct 14, 2014
    Posts:
    34
    soleron likes this.
  44. Minos321

    Minos321

    Joined:
    Jul 7, 2018
    Posts:
    44
    Hey everyone! Excited to dig deeper into this feature. However, when I enable it, my editor crashes. Sometimes when hitting play mode, sometimes when working in the editor. I just worked for hours without a crash with GPU drawer turned off, and as soon as I enabled it, I got two crashes. Bug #IN-75529
     
  45. Minos321

    Minos321

    Joined:
    Jul 7, 2018
    Posts:
    44
    By the way, is it normal that the batches more than double with Resident GPU Drawer turned on?

    With GPU Resident Drawer turned off + Static batching turned on:
    upload_2024-5-6_17-49-5.png

    With GPU Resident Drawer turned on + Static batching turned off + GPU Occlusion culling On:
    upload_2024-5-6_17-50-12.png

    With GPU resident Drawer On + Static Batching On + GPU Occlusion Culling ON:
    upload_2024-5-6_17-51-2.png
     
    Enzi and Lex4art like this.
  46. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    626
    This has become a constant crash which persists even in Unity 6 Preview.

    Reported Bug IN-75893
     
  47. unity_OwsoyU3laIykcQ

    unity_OwsoyU3laIykcQ

    Joined:
    Dec 9, 2019
    Posts:
    4
    This is very annoying 23.3 once worked fine for me but now the editor crashes over and over again when it is turned on. Is there some quick fix that we don't think about but it works?
     
    Gasimo likes this.
  48. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    626
    I have not tried it yet, but maybe use a new set of project settings that does not include the changes for GPU Driven Rendering?

    I have noticed that the crash happens when some shader is recompiling. Or immediately after it recompiles.

    Sometimes it happens right after launching a scene. (I assume again because some shader compiles.)

    Opening the project again in a non Unity 6 version, (i.e. 2023.2) fixes the issue, however you have to jump through a few hoops because some packages are not unloading properly.

    i.e.in some cases HDRP 17 persists along with version 16 in some weird way. They are both installed simultaneously and can't be removed but only manualy.
     
  49. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    626
    I reported a bug too along with some others. Was quite weird.
    Like the objects disappeared. Only the terrain was showing and that under conditions. Eventually that disappeared too.
     
  50. morfevs

    morfevs

    Joined:
    Dec 21, 2016
    Posts:
    20
    Hi all! Have you tried the Unity6 GPU Resident Drawer? I did! and I found WORSE performance than before! I wonder what im doing wrong or if my case is not supported.
     

    Attached Files: