Search Unity

Resolved HOW TO: Improve Performance with Vulkan and Oculus Quest (2)

Discussion in 'VR' started by DevDunk, Nov 9, 2021.

  1. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    I noticed that performance on Vulkan sucked on the Quest 2, even on Unity 2021.2. In the end I did fix the issue and it gave me a 30-60% performance boost and a lot better RAM usage!

    The issue:
    - Oculus XR plugin defaults to 1.10.0

    The fix:
    - Push to the latest 2.0 (2020.3) or 3.0 (2021.2) version

    How to:
    - Go to your project's root folder (where you stored your project)
    - Open the Packages folder
    - Open the Manifest.json file (notepad will do)
    - Change:
    "com.unity.xr.management": "4.0.7",
    "com.unity.xr.oculus": "1.10.0",

    To:
    "com.unity.xr.management": "4.2.0",
    "com.unity.xr.oculus": "3.0.0-pre.1", (or 2.0.0-preview.1)


    This way you use the latest version and also gain the ability to use Late Latching for better latency
    ( and in the future SpaceWarp, which you currently need a modded URP for in Unity 2020.3: https://github.com/Oculus-VR/Unity-Graphics/tree/2020.3/oculus-app-spacewarp )
     
    fuzzy3d likes this.
  2. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Future is here already. You need 2020.3.21 or newer 2020.3 version, those SRP packages from oculus branch, 2.0 preview for OculusXR and Oculus v34 integration package from asset store. After you have these in the project, install Oculus version of OpenXR from oculus tools menu and use OVRManager.SetSpaceWarp(true); on your scripts to turn it on in the build.

    For debugging this, latest OVR Metrics Tool for Quests already supports AppSW.

    As a side note, on my brief testing with 2020.3, 2021.2 and 2022.1 for Quest 2 builds, 2020.3 alone even before App SpaceWarp feels tad faster than what we have on the newer engine versions URPs.

    also: Application SpaceWarp Developer Guide: Unity | Oculus Developers
     
    Last edited: Nov 12, 2021
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    App SpaceWarp is coming to URP when? I understand it's still in preview and I'd rather not use a preview. Any info?
     
    DevDunk and fuzzy3d like this.
  4. OstrichBoy

    OstrichBoy

    Joined:
    Dec 28, 2014
    Posts:
    15
    I have done everything you said and added ovrmanager.setspacewarp(true) on the Start function. There seems to be no fps change with it set to true or false?
     
  5. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    Spacewarp needs a modified URP version currently afaik, check the Oculus Dev blog
     
  6. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    glenneroo and DevDunk like this.
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm happy to wait for it to go in mainstream URP rather than some funky version that's stuck in the mists of time.

    Hopefully there is some kind of ETA for that.
     
    fuzzy3d and DevDunk like this.
  8. qstrinati-imaging

    qstrinati-imaging

    Joined:
    Sep 16, 2020
    Posts:
    7
    I followed your instructions, installed, modded what needed to be and put
    OVRManager.SetSpaceWarp(true);
    at every scene's awakening. It seems to be working well in a build on the Quest 2, although it is about 10/15fps slower than before. But in the editor, in play mode, the headset stays at its original position and does not follow the movements of the real one.
    There is also a Debug.Log from the OVRManager that I never got:
    Code (CSharp):
    1. [OVRManager] mainCamera found for MRC:
    2. UnityEngine.Debug:LogFormat (string,object[])
    3. OVRManager:FindMainCamera () (at Assets/Oculus/VR/Scripts/OVRManager.cs:2040)
    4. OVRManager:SetSpaceWarp (bool) (at Assets/Oculus/VR/Scripts/OVRManager.cs:1159)
    5. LaunchSpaceWarp:Awake () (at Assets/Scripts/LaunchSpaceWarp.cs:8)
    6.  
    It worked well prior to the changes to integrate SpaceWarp.
    I used:
    Unity 2020.3.22f1
    Modded SRP 10.7.0: com.unity.render-pipelines.core; com.unity.render-pipelines.universal; com.unity.shadergraph
    Oculus Integration 34
    Oculus XR Plugin 2.0.0-preview.1
    XR Plugin Management 4.2.0

    Would this be an issue with Vulkan ? Or is it way more likely that the preview packages messed things ?
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It has to use Vulkan, it doesn't support OpenGL ES3+
     
    fuzzy3d and glenneroo like this.
  10. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Application SpaceWarp doesn't work on PC, only natively on Quests meaning AppSW wont work when you play in editor.
     
    glenneroo likes this.
  11. qstrinati-imaging

    qstrinati-imaging

    Joined:
    Sep 16, 2020
    Posts:
    7
    I am using Vulkan. So it is normal that when playing in editor with AppSW, I cannot use Oculus Link to see it in my Quest then ?
     
  12. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    You can use oculus link, but it just wont use AppSW. It's just like you were using a rift s with link
     
  13. qstrinati-imaging

    qstrinati-imaging

    Joined:
    Sep 16, 2020
    Posts:
    7
    But that is my issue, Unity detects the headset but does not play in it, game view looks as if there is not headset connected and the camera stays on the ground. And when using an ASW build on Quest 1, after about 20s the camera gets stuck, showing always the same view and giving a wonderful motion sickness moment.
    I will try to change the experimental features that come with Vulkan to see if it stops messing on the Quest 1.
     
  14. qstrinati-imaging

    qstrinati-imaging

    Joined:
    Sep 16, 2020
    Posts:
    7
    I just found out that one cannot use the Subsampled Layout option with Quest 1 (as it is written in the options duh). But still, after a few seconds the camera gets stuck between 2 frames and alternates quickly between them. The only options checked under "XR Plug-in Management > Oculus" are "Target Devices: Quest" and "Experimental: Application SpaceWarp (Vulkan)". This behaviour does not appear on the Quest 2.
     
  15. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    Check if you're using the quest or quest 2 before setting spacewarp or just not use it until it is properly implemented
     
    hippocoder likes this.
  16. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    For me the new Oculus XR 2.0.0 break playing in editor. It only work on Quest.
    I have to go back to 1.11.0 to make the editor work again.

    Also the Custom URP package break shader and vfx graph view. Really don't move to this version except if you really want to add AppSW, it's not ready yet.
     
    laurentlavigne likes this.
  17. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    You sure you cloned the custom SRP packages with Git LFS? and you got ALL three packages, core, universal and shadergraph from it? You need all three for this.
     
  18. gshape

    gshape

    Joined:
    Aug 8, 2012
    Posts:
    104
    The shader graph previews are all errors, but the generated shader seems usable upload_2021-12-2_15-56-22.png
    Steps to reproduce:
    1. create new project using Unity 2020.3.22f1 and URP pipeline template
    2. close unity, go to manifest.json, remove the com.render-pipelines.universal
    3. clone from https://github.com/Oculus-VR/Unity-Graphics.git and made sure i'm on the branch 2020.3/oculus-app-spacewarp
    4. made sure the lfs was working by inspecting some dll such as com.unity.render-pipelines.core\Editor\ShaderGenerator\ICSharpCode.NRefactory.dll (it should be >500kb and not just 1kb)
    5. copy the core, universal, and shadergraph folders into the new project's Packages folder
    6. open the project with unity
    7. create > Shader > URP > Lit Shader Graph
    8. create some nodes

    console produces errors, e.g.
    Shader error in 'hidden/preview/UV_4a2305d9640541b386be037a015d0e3d': 'GetPrevObjectToWorldMatrix': function must return a value at Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl(18) (on d3d11)
    Shader error in 'hidden/preview/UV_4a2305d9640541b386be037a015d0e3d': undeclared identifier 'UNITY_MATRIX_PREV_M' at Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl(18) (on d3d11)

    some additional warnings I do not understand
    upload_2021-12-2_15-53-18.png

    some asmdef has missing references (just showing two, there are more that missing). not sure if this is relevant or important.
    upload_2021-12-2_15-58-54.png
    upload_2021-12-2_15-59-46.png
     
  19. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    Yes. AppSW work fine on Quest. It's just PC version that don't work anymore
     
  20. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    228
    This is the first time in 10+ years that I have not been able to put any technology into operation in unity. I'm not a programmer, but so far I've managed to download, set up and try everything from github - but I'm completely clueless here. I hope that SpaceWarp will get to the official URP as soon as possible - which I will download in some way that I can handle ...
     
    hippocoder likes this.
  21. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Same here. I am experienced but using this version of URP will ruin my project, so I can't use it even if I want to, due to it being tied to editor versions and stability. I want Unity to push a proper version on main.
     
  22. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    Probably will happen in Unity 2022.2 or 2023.1 I'm guessing.
    AppSW needs motion vector support, which 2022.1 already has, but they do need to make proper support for AppSW as well.
    2020 or 2021 probably won't support it officially due to the motion vector support and them both being pretty feature locked already
     
  23. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Just to be clear. Oculus only officially gives out URP fork for 2020.3 / URP 10.8 (which is wip version of 10.8, not ideal to one from Unity).

    If you know how to use git, you CAN just cherry-pick Unity's AppSW commits to any URP 10 version and it would probably work fine so you are not really forever stuck with the 10.8'ish version.

    I also have some 2022.1 compatible branches on my git repo if people are feeling really adventurous but there's zero support from anyone for them. For example: https://github.com/0lento/Graphics/tree/app-spacewarp-2022.1

    These branches may or may not work on latest 2022.1 betas (I wouldn't know) but again if one knows how to use git, you should be able to pick URP version for your specific URP version and cherry-pick the commits to it.
     
  24. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's something Unity's paid for though. I mean, if I wanted to keep cherry picking I 100% would move to unreal in a heartbeat.

    Unity's job is to deal with this. It's the whole business model. When they don't, it means they're at at fault, because of their partnership program.
     
    laurentlavigne likes this.
  25. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I feel AppSW is still quite experimental tech so it requiring extra effort to work with is kinda expected. But I'm sure they are still working together on getting this merged some day.
     
  26. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    228
    Yes, exactly. And it's also more of an Oculus thing, not Unity - what I wanted to say was frustration with my own incompetence in the github - and I have experience with LFS, for example. I thought so...
    Anyway, SpaceWarp is extremely important tech.
     
    Last edited: Jan 7, 2022