Search Unity

Question How to set refresh rate with OpenXR

Discussion in 'VR' started by Occuros, Aug 20, 2021.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    When using the oculus framework (with OVRManager etc.) it is well documented how to set the framerate of the quest from the default 72Hz to the higher levels (like 90Hz or even 120Hz).


    How can the same be set when using OpenXR (with the oculus plugin for OpenXR)?

    We only found a way to get the refresh rate, but not to set it.
     
    Aldeminor and Hobodi like this.
  2. Rory_B

    Rory_B

    Joined:
    May 6, 2017
    Posts:
    4
    I am using the Oculus XR Plugin for this script, not the OpenXR Plugin. However, it sounds like it might help you?

    (Lifted and modified from this previous post)
    https://forum.unity.com/threads/90hz-for-quest-2.1006934/

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5. using UnityEngine;
    6. using Unity.XR.Oculus;
    7.  
    8. public class RefRate : MonoBehaviour {
    9.     void Start() {
    10.         if (Performance.TryGetDisplayRefreshRate(out float rate)) {
    11.             Debug.Log("Current refresh rate " + rate);
    12.             float newRate = 72f;
    13.             string debugout = "";
    14.             if (Performance.TryGetAvailableDisplayRefreshRates(out float[] rates)) {
    15.                 for (int i = 0; i < rates.Length; i++) {
    16.                     if (i != 0) {
    17.                         debugout = debugout + ", ";
    18.                     }
    19.                     debugout = debugout + rates[i];
    20.                 }
    21.                 Debug.Log("Available rates " + debugout);
    22.                 newRate = rates.Max();
    23.             }
    24.             if (rate < newRate) {
    25.                 if (Performance.TrySetDisplayRefreshRate(newRate)) {
    26.                     Debug.Log("Setting new refresh rate to " + newRate);
    27.                     // Time.fixedDeltaTime = 1f / newRate;
    28.                     // Time.maximumDeltaTime = 1f / newRate;
    29.                 }
    30.             }
    31.         }
    32.     }
    33. }
    34.  
     
  3. the_real_apoxol

    the_real_apoxol

    Unity Technologies

    Joined:
    Dec 18, 2020
    Posts:
    467
    This is not yet possible with OpenXR. There is an oculus extension to the OpenXR specification that does this but Oculus has not implemented this yet for Unity/OpenXR.
     
    sandstedt likes this.
  4. swedishfisk

    swedishfisk

    Joined:
    Oct 14, 2016
    Posts:
    57
    Hey guys, any news on this? We're currently relying on OVRManager from Oculus Integration to set refresh rate of display but would like to move to something more generic
     
  5. the_real_apoxol

    the_real_apoxol

    Unity Technologies

    Joined:
    Dec 18, 2020
    Posts:
    467
    No update as of yet, until oculus officially switches over to OpenXR I am not sure there will be much change.

    If you are blocked you could look into writing your own feature that calls the `XR_FB_display_refresh_rate` extension methods as I believe the Oculus OpenXR runtime does implement it. This would require a custom feature and some native code likely.
     
    swedishfisk likes this.
  6. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    172
    Is this still the case? Or it is possible now?
     
  7. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    105
    There is still no generic way to set displayRefreshRate in OpenXR.
    For Oculus devices, using its Oculus Integration asset, in OVRPlugin.cs there is a variable called systemDisplayFrequency can do the trick.
     
  8. cubaschi

    cubaschi

    Joined:
    Oct 23, 2012
    Posts:
    51
    Is this still the case? This is crazy. Using a current Oculus integration package together with OpenXR breaks controllers for me. We've spent days trying to find a solution for this issue and are now in trouble because we can't update our game that is in the store.
     
  9. efficientTech

    efficientTech

    Joined:
    Jul 23, 2021
    Posts:
    6
    I'm also having this issue. We have a momentary lag spike at the beginning of our game that's causing the OpenXR refresh rate to tank. Is there a way to reset the target refresh rate post throttling?

    found this post but haven't been able to set refresh rate with OpenXR

    Performance.TrySetDisplayRefreshRate((float)refreshRate);

    throws error:
    DllNotFoundException: Unable to load DLL 'OculusXRPlugin'. Tried the load the following dynamic libraries: Unable to load dynamic library 'OculusXRPlugin' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "OculusXRPlugin" not found
    10-25 21:42:30.546 21458 21478 E Unity : at Unity.XR.Oculus.NativeMethods+Internal.SetDisplayFrequency (System.Single refreshRate) [0x00000] in <00000000000000000000000000000000>:0
    10-25 21:42:30.546 21458 21478 E Unity : at Unity.XR.Oculus.NativeMethods.SetDisplayFrequency (System.Single refreshRate) [0x00000] in <00000000000000000000000000000000>:0
    10-25 21:42:30.546 21458 21478 E Unity : at Unity.XR.Oculus.Performance.TrySetDisplayRefreshRate (System.Single refreshRate) [0x00000] in <00000000000000000000000000000000>:0
    10-25 21:42:30.546 21458 21478 E Unity : at QuestGraphicsSettings.SetRefreshRate (RefreshRates refreshRate) [0x00000] in <00000000000000000000000000000000>:0
    10-25 21:42:30.546 21458 21478 E Unity : at QuestGraphicsSettings.Start () [0x00000] in <00000000000000000000000000000000>:0
     
  10. Armegalo

    Armegalo

    Joined:
    May 14, 2018
    Posts:
    30

    Performance.TrySetDisplayRefreshRate only works with the Oculus plugin, not OpenXR :/
     
  11. HAIRGROW

    HAIRGROW

    Joined:
    May 17, 2013
    Posts:
    19
    Hmmm..... Is this still an issue? Not being able to generically set the Meta Quest 2 headset to 90 fps with OpenXR. I've been developing with OpenXR in my project for awhile because I want to deploy to both PC and Android devices. When I create a build, using a very simple scene, for both platforms, I noticed a complete difference in the speed of the players movement mechanic. When I profile the performance directly on the headset, I'm getting a steady 72 fps per second. But on PC the game can run at 90+ so the speed at which the player is moving feels much better. I'm trying to get the game to run at 90 fps per second on the headset, but Meta has changed all they're SDKs. So the Oculus Integration package is deprecated. I tried implementing the Meta XR Core SDK as I'm only interested in setting the headset to 90 fps, but when implemented, it breaks all the controller controls implemented via OpenXR Version 1.9.1. I'm not sure if this is the same problem @cubaschi mentioned, but its definitely similar. Does meta have a compatible SDK that can work with OpenXR? I'm still searching for a way to set the FPS on the headset that won't break my current controls. My hope is that by increasing the FPS on the headset, the speed of the player movement won't feel sluggish. Again, I've already profiled the app and I'm getting a steady 72 fps but it still feels sluggish as compared to the PC. Any help would be greatly appreciated.
     
  12. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    Man I need this ability so bad. Right now I'm stuck. Because if I use the Oculus Plugin, I can set FFR, and Refresh rate, but I can't manage passthrough with the AR Camera Manager.

    So, I'm using OpenXR so I can use the AR Camera Manager, but then I can't set FFR or Refresh Rate.

    EDIT: Just double checked the Meta Quest OpenXR Feature Groups, and there is a feature group called Meta Quest: Display Utilities. Documentation shows there is the ability to set the refresh rate.

    https://docs.unity3d.com/Packages/c...xr@1.0/manual/features/display-utilities.html

    EDIT: I did just test this. And it works. But rather than the 72, 90, and 120 options you'd expect from the Oculus Plugin, the options it gives you with OpenXR is 72, 80, and 90.
     
    Last edited: Feb 12, 2024
  13. Nikolhs123

    Nikolhs123

    Joined:
    Mar 14, 2020
    Posts:
    1
    mrphilipjoel First of all thank you for this discovery! What version of Unity are you using? In Unity 2022.3.0 I tried copying the code from the link you provided but maybe they changed the features from the documentation. For example, the if (displaySubsystem.TryGetSupportedDisplayRefreshRates( Allocator.Temp, out var refreshRates)) changed to if (displaySubsystem.TryGetDisplayRefreshRate(out var refreshRates)) and the displaySubsystem.TryRequestDisplayRefreshRate(refreshRates[0]) does not exist anymore. I also need this ability very bad :(
     
  14. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    I'm using unity 2021.3.34f1. But, I don't think that matters. You would need to make sure you have the com.unity.xr.meta-openxr package installed.
    I'm using version 0.1.2 in my project.
     
  15. OhIcanchangethenamethatsgood

    OhIcanchangethenamethatsgood

    Joined:
    Apr 8, 2021
    Posts:
    24
    Unfortunately this call doesnt work anymore since the last Oculus Update as it seems (pure speculation)...
    It definitely worked a few weeks ago, but now the application won't set refreshrate of the device and stuck at 72 hz.

    Instead calling the method of the XRDisplaySubsystem.TryGetSupportedDisplayRefreshRates(..) will throw an UNKOWN Error.
    upload_2024-3-7_16-15-29.png

    Calling displaySubsystem.running results in false.

    So somehow the Subsystem isn't starting anymore but I have no idea why.
    Nothing changed in the project settings and the package is toggled on:
    upload_2024-3-7_16-28-37.png

    upload_2024-3-7_16-28-58.png

    Calling displaySubsystem.Start(); does not start the subsystem.

    Any idea what might be wrong here?
     
    Last edited: Mar 7, 2024