Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question URP on Quest 2 Depth Texture enable Destroys the framerate

Discussion in 'Universal Render Pipeline' started by HRDev, Aug 5, 2022.

  1. HRDev

    HRDev

    Joined:
    Jun 4, 2018
    Posts:
    35
    Hello everybody. I am developing a VR game with quest 2 using Vulkan as Graphics api. I need to activate the Depth Txture in the URP settings to do some fog effects. But when I activate this Depth Texture the framerate goes from 90 to 45/50... without doing anything else, without adding anything to the scene, just activating DepthTexture... it's normal? is there a way to optimize it?

    I noticed that with OpenGLES3 it is better, should I make the switch to OpenGLES3? I prefer to avoid...
     
    D3m0n likes this.
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,929
    There indeed is an issue with vulkan and depth which is really annoying. I assume you are using Unity 2021? (2020 doesn't have this issue afaik)
    If so, have you updated to the latest release already?
    OpenGLES can definitely have better performance, so if your game does run with all your requirements on it definitely use it. Oculus is pushing vulkan with new features like phase sync, but it's not required
     
  3. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    The issue is known and already being worked on, the Vulkan's performance drop is caused by URP's depth copy pass if MSAA is enabled.
     
    D3m0n and DevDunk like this.
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,929
    I think in the past someone already found the PR causing the issue. Is there any ETA for it? Will it be fixed in the 2021 LTS or will ot just be 2022?
     
  5. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    The issue was caused by optimization change preferring depth copy instead of depth prepass, fix already passed testing and waiting for code merge. I can't give you ETA or backport promises, I'm not working on this case.
     
    Koboct-Denis and DevDunk like this.
  6. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    647
    So the testing shows that just regenerating the depth buffer is faster than copying it in the general cases the team tested?
     
  7. Koboct-Denis

    Koboct-Denis

    Joined:
    Jul 20, 2022
    Posts:
    3
    Hello, any news on the fix?
     
    D3m0n likes this.
  8. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    631
    On quest 2, the gpu is using a tiled deferred rendering architecture. To copy the depth buffer you need to resolve this texture. Depending on your resolution and MSAA level this can take several ms per copy. If generating a new one costs less than that, it's worth it. Really though, you should avoid needing the depth buffer at all on quest.
     
    Last edited: Oct 2, 2022
  9. D3m0n

    D3m0n

    Joined:
    Nov 11, 2014
    Posts:
    143
    Same problem.
     
  10. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    77
    @rjonaitis
    Hi,
    Has this 2021 URP MSAA problem been solved? Is there a link? Where is the progress now? Thanks
     
  11. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,929
    I think it has been fixed yes
     
  12. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    77
  13. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    77
  14. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    77
    I tested 2021.3.16 and didn't feel any performance improvement,With 2021 URP and MSAA 4X problem.
     
  15. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,929
    Yes, it was a noticeable improvement for me.

    If you have a project which performs more than 5% faster on the latest 2020lts vs 2021lts with the same settings etc make a bug report including both projects so they can fix it.
     
  16. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Same here. Let's stay in touch. I want to have a nice fog in the game. But I can't. Maybe 2022 version solved the problem?
     
  17. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    631
    You can have fog on quest 2 hardware, you just need to do it in your fragment shader.

    upload_2023-1-20_10-11-47.png

    Here's a screenshot of our recent game (minus the shadows and bloom, it looks the same on quest). Fog and a few other "post process"-like effects are possible, but you'll need to be writing HLSL.
     
  18. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    64
    if you are having performance issues on Quest 2 due to the extra Copy Depth pass which was introduced in 21, replacing the old default depth prepass, the suggested setup to still force the prepass (which is cheaper on that specific platform most of the time, depending on your scene complexity) is to select "force prepass" as "Depth Texture Mode":

    upload_2023-1-23_10-7-13.png
     
    Rustamovich and DevDunk like this.
  19. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    I've tried this one, but it didn't help me. But thanks anyway.

    My setup is as follows:
    Unity 2021.3.16f1
    URP 12.1.8
    XR Plugin 4.2.1

    I would love to hear your thoughts about my setup
     
  20. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    64
    Unfortunately without knowing the details of your application it's not possible to figure out what the problem is.

    My previous post is specifically for users that upgraded to 21 and found an extra copy depth pass in the frame.

    The reason for that is that, before 21.2, URP always did a depth prepass when a depth texture was required. This caused performance issues in vertex bound applications and was reported by users, so we decided to remove the costly depth prepass and copy the depth instead.
    But while removing the depth prepass improved perf in vertex bound situations (lot of geometry to draw), it caused regressions in fragment bound ones.
    Quest 2 games are more often fragment bound than vertex bound, so this is the most likely cause of regressions when upgrading to 21.

    Because of the wide range of platforms and possible application types URP supports, we decided to now give the option to force the prepass vs the copy depth, because only users will know after profiling what is best for their specific use case. So that is the suggested best practice for (most) Quest 2 and VR games, unless they are vertex bound because of unoptimized content.

    So to go back to your issue: without profiling and frame captures it is impossible to know what is your bottleneck. It could be a depth prepass vs depth copy issue, too many post processing passes, wrong quality settings, etc

    If you know what the specific issue is and if URP doesn't provide ways to optimize your frame then we would be happy to know what the issue is and consider a fix if possible