Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [3.3.0] - 2023-03-13
### Changed
- Modified how foveated rendering (ETFR and FFR) is enabled and configured from script to make it more consistent
- Updated the `SystemHeadset` enum to include `Meta_Quest_Pro` and `Meta_Link_Quest_Pro` entries

### Fixed
- Reverted deferred eye texture deletion as we only needed to defer layer deletion
- Fixed a GLES2 script deprecation warning in Unity 2023.1+

### Known Issues
- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime, which is the default in the 2.x and 3.x versions of the Oculus XR Plugin package
- `Unity.XR.Oculus.Stats.AppMetrics` entries currently return `0` on all Oculus runtimes
- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/
- Enabling mobile Depth Submission may cause crashes on application startup if MSAA is disabled. Enabling MSAA will resolve the issue. This will be resolved in future versions of Unity
  • Loading branch information
Unity Technologies committed Mar 13, 2023
1 parent 7b40efe commit 93b5b8d
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 55 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.2.3] - 2023-02-16
## [3.3.0] - 2023-03-13
### Changed
- No changes from 3.2.3-pre.1 other than removing the Pre-release version tag
- Modified how foveated rendering (ETFR and FFR) is enabled and configured from script to make it more consistent
- Updated the `SystemHeadset` enum to include `Meta_Quest_Pro` and `Meta_Link_Quest_Pro` entries

### Fixed
- Reverted deferred eye texture deletion as we only needed to defer layer deletion
- Fixed a GLES2 script deprecation warning in Unity 2023.1+

### Known Issues
- `Unity.XR.Oculus.Stats.PerfMetrics` entries currently return `0` when using the OpenXR runtime, which is the default in the 2.x and 3.x versions of the Oculus XR Plugin package
- `Unity.XR.Oculus.Stats.AppMetrics` entries currently return `0` on all Oculus runtimes
- For both of the above, the suggested replacement is to use the profiling tools available via the Oculus Developer Hub: https://developer.oculus.com/documentation/unity/ts-odh-logs-metrics/
- Enabling mobile Depth Submission may cause crashes on application startup if MSAA is disabled. Enabling MSAA will resolve the issue. This will be resolved in future versions of Unity

## [3.2.3] - 2023-02-16
### Changed
- No changes from 3.2.3-pre.1 other than removing the Pre-release version tag

## [3.2.3-pre.1] - 2023-02-08
### Fixed
- Fixed a potential memory corruption issue on Rift when calculating mirror view rects
Expand All @@ -30,6 +39,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Resolved an issue where Eye Tracked Foveated Rendering settings may conflict with settings provided by the Oculus Integration asset
- `Shared Depth Buffer` on PC should now work correctly when using `Single Pass Instanced` rendering
- Fixed potential jittering and one frame delay when using dynamic render viewports
- Fixed incorrect vertical placement of viewports when using Vulkan

## [3.2.2-pre.1] - 2022-10-24
### Fixed
Expand Down
25 changes: 20 additions & 5 deletions Editor/OculusBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,34 @@ public void OnPreprocessBuild(BuildReport report)
if (report.summary.platformGroup == BuildTargetGroup.Android)
{
GraphicsDeviceType firstGfxType = PlayerSettings.GetGraphicsAPIs(report.summary.platform)[0];
if (firstGfxType != GraphicsDeviceType.OpenGLES3 && firstGfxType != GraphicsDeviceType.Vulkan && firstGfxType != GraphicsDeviceType.OpenGLES2)

#if UNITY_2023_1_OR_NEWER
if (firstGfxType != GraphicsDeviceType.OpenGLES3 && firstGfxType != GraphicsDeviceType.Vulkan)
{
throw new BuildFailedException("OpenGLES2, OpenGLES3, and Vulkan are currently the only graphics APIs compatible with the Oculus XR Plugin on mobile platforms.");
throw new BuildFailedException("OpenGLES3 and Vulkan are currently the only graphics APIs compatible with the Oculus XR Plugin on mobile platforms.");
}
if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel23)

if (PlayerSettings.colorSpace != ColorSpace.Linear && (firstGfxType == GraphicsDeviceType.OpenGLES3))
{
throw new BuildFailedException("Android Minimum API Level must be set to 23 or higher for the Oculus XR Plugin.");
throw new BuildFailedException("Only Linear Color Space is supported when using OpenGLES. Please set Color Space to Linear in Player Settings, or switch to Vulkan.");
}
#else
if (firstGfxType != GraphicsDeviceType.OpenGLES3 && firstGfxType != GraphicsDeviceType.Vulkan && firstGfxType != GraphicsDeviceType.OpenGLES2)
{
throw new BuildFailedException("OpenGLES2, OpenGLES3, and Vulkan are currently the only graphics APIs compatible with the Oculus XR Plugin on mobile platforms.");
}

if (PlayerSettings.colorSpace != ColorSpace.Linear && (firstGfxType == GraphicsDeviceType.OpenGLES3 || firstGfxType == GraphicsDeviceType.OpenGLES2))
{
throw new BuildFailedException("Only Linear Color Space is supported when using OpenGLES. Please set Color Space to Linear in Player Settings, or switch to Vulkan.");
}

#endif

if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel23)
{
throw new BuildFailedException("Android Minimum API Level must be set to 23 or higher for the Oculus XR Plugin.");
}

// some features don't work in non-ARM64 builds
if ((PlayerSettings.Android.targetArchitectures & AndroidArchitecture.ARM64) != AndroidArchitecture.ARM64)
{
Expand Down
Binary file modified Runtime/Android/arm32/libOculusXRPlugin.so
Binary file not shown.
Binary file modified Runtime/Android/arm64/libOculusXRPlugin.so
Binary file not shown.
152 changes: 138 additions & 14 deletions Runtime/FFR.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,143 @@
using System;
using UnityEngine;
using UnityEngine.Android;

namespace Unity.XR.Oculus
{
public static partial class Utils
{
static void PermissionGrantedCallback(string permissionName)
{
if (permissionName == "com.oculus.permission.EYE_TRACKING")
{
NativeMethods.SetEyeTrackedFoveatedRenderingEnabled(true);
}
}

/// <summary>
/// Returns true if the user has allowed the Eye Tracking permission.
/// </summary>
public static bool IsEyeTrackingPermissionGranted()
{
return Permission.HasUserAuthorizedPermission("com.oculus.permission.EYE_TRACKING");
}

/// <summary>
/// Gets or sets dynamic foveated rendering which will change the foveated rendering level automatically based on the current performance.
/// Works for both FFR and ETFR.
/// </summary>
public static bool useDynamicFoveatedRendering
{
get
{
return NativeMethods.GetTiledMultiResSupported();
}
set
{
if (!NativeMethods.GetTiledMultiResSupported())
{
Debug.LogWarning("Can't enable dynamic FFR on current platform");
}

NativeMethods.SetTiledMultiResDynamic(value);
}
}

/// <summary>
/// Gets or sets the foveated rendering level. This works for both FFR and ETFR
/// level can be 0, 1, 2, 3, or 4:
///
/// * -1 (get) not supported on current platform
/// * 0 foveated rendering disabled
/// * 1 low foveated rendering level
/// * 2 medium foveated rendering level
/// * 3 high foveated rendering level
/// * 4 high top foveated rendering level
/// </summary>
public static int foveatedRenderingLevel
{
get
{
if (!NativeMethods.GetTiledMultiResSupported())
{
Debug.LogWarning("Can't get foveation level on current platform");
return -1;
}

return NativeMethods.GetTiledMultiResLevel();
}
set
{
if (!NativeMethods.GetTiledMultiResSupported())
{
Debug.LogWarning("Can't set foveation level on current platform");
}

NativeMethods.SetTiledMultiResLevel(value);
}
}

/// <summary>
/// Returns whether or not eye tracked foveated rendering (ETFR) is supported.
/// You cannot enable ETFR using eyeTrackedFoveatedRenderingEnabled if the feature isn't supported.
/// </summary>
public static bool eyeTrackedFoveatedRenderingSupported
{
get
{
return NativeMethods.GetEyeTrackedFoveatedRenderingSupported();
}
}

/// <summary>
/// Gets or sets whether eye tracked foveated rendering is enabled or not.
/// </summary>
public static bool eyeTrackedFoveatedRenderingEnabled
{
get
{
if (eyeTrackedFoveatedRenderingSupported)
return NativeMethods.GetEyeTrackedFoveatedRenderingEnabled();
return false;
}
set
{
if (eyeTrackedFoveatedRenderingSupported)
{
if (value)
{
if (IsEyeTrackingPermissionGranted())
{
NativeMethods.SetEyeTrackedFoveatedRenderingEnabled(value);
}
else
{
var permissionCallbacks = new PermissionCallbacks();
permissionCallbacks.PermissionGranted += PermissionGrantedCallback;
Permission.RequestUserPermission("com.oculus.permission.EYE_TRACKING", permissionCallbacks);
}
}
else
{
NativeMethods.SetEyeTrackedFoveatedRenderingEnabled(value);
}
}
}
}

/// <summary>
/// Set the degree of foveation. Only supported on mobile. See [Oculus Documention](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/).
/// </summary>
/// <param name="level">
/// level can be 0, 1, 2, 3, or 4:
///
/// * 0 disables multi-resolution
/// * 1 low FFR setting
/// * 2 medium FFR setting
/// * 3 high FFR setting
/// * 4 high top FFR setting
/// * 0 disables foveated rendering
/// * 1 low foveated rendering level
/// * 2 medium foveated rendering level
/// * 3 high foveated rendering level
/// * 4 high top foveated rendering level
/// </param>
[Obsolete("Please use foveatedRenderingLevel instead.", false)]
public static bool SetFoveationLevel(int level)
{
if (!NativeMethods.GetTiledMultiResSupported())
Expand All @@ -29,12 +150,14 @@ public static bool SetFoveationLevel(int level)
return true;
}


/// <summary>
/// Enable or disable dynamic FFR. Only supported on mobile. See [Oculus Documention](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/).
/// Enable or disable dynamic foveated rendering. Only supported on mobile. See [Oculus Documention](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/).
/// </summary>
/// <param name="enable">
/// Set to true to enable dynamic FFR or false to disable it.
/// Set to true to enable dynamic foveated rendering or false to disable it.
/// </param>
[Obsolete("Please use useDynamicFoveatedRendering instead", false)]
public static bool EnableDynamicFFR(bool enable)
{
if (!NativeMethods.GetTiledMultiResSupported())
Expand All @@ -48,16 +171,17 @@ public static bool EnableDynamicFFR(bool enable)
}

/// <summary>
/// Returns the degree of foveation. Only supported on mobile. See [Oculus Documentation](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/).
/// Returns the level of foveated rendering. Only supported on mobile. See [Oculus Documentation](https://developer.oculus.com/documentation/quest/latest/concepts/mobile-ffr/).
/// </summary>
/// <returns>
/// * -1 error retrieving foveation level
/// * 0 disables multi-resolution
/// * 1 low FFR setting
/// * 2 medium FFR setting
/// * 3 high FFR setting
/// * 4 high top FFR setting
/// * -1 error
/// * 0 disables foveated rendering
/// * 1 low foveated rendering level
/// * 2 medium foveated rendering level
/// * 3 high foveated rendering level
/// * 4 high top foveated rendering level
/// </returns>
[Obsolete("Please use foveatedRenderingLevel instead.", false)]
public static int GetFoveationLevel()
{
if (!NativeMethods.GetTiledMultiResSupported())
Expand Down
14 changes: 0 additions & 14 deletions Runtime/OculusLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,12 @@ public override bool Initialize()
RegisterUpdateCallback.Initialize();
}


if (settings != null && (settings.FoveatedRenderingMethod == OculusSettings.FoveationMethod.EyeTrackedFoveatedRendering) && NativeMethods.GetEyeTrackedFoveatedRenderingSupported())
{
var permissionCallbacks = new PermissionCallbacks();
permissionCallbacks.PermissionGranted += PermissionGrantedCallback;
Permission.RequestUserPermission("com.oculus.permission.EYE_TRACKING", permissionCallbacks);
}

return displaySubsystem != null && inputSubsystem != null;
#else
return false;
#endif
}

internal void PermissionGrantedCallback(string permissionName)
{
if (permissionName == "com.oculus.permission.EYE_TRACKING")
NativeMethods.SetHasUserAuthorizedEyeTrackingPermission(true);
}

public override bool Start()
{
#if ENABLE_VR
Expand Down
38 changes: 26 additions & 12 deletions Runtime/OculusPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum SystemHeadset
// Standalone headsets
Oculus_Quest = 8,
Oculus_Quest_2 = 9,
Meta_Quest_Pro = 10,
Placeholder_10 = 10,
Placeholder_11,
Placeholder_12,
Expand All @@ -34,7 +35,8 @@ public enum SystemHeadset
Rift_S,
Oculus_Link_Quest,
Oculus_Link_Quest_2,
PC_Placeholder_4103,
Meta_Link_Quest_Pro,
PC_Placeholder_4103 = Meta_Link_Quest_Pro,
PC_Placeholder_4104,
PC_Placeholder_4105,
PC_Placeholder_4106,
Expand Down Expand Up @@ -109,13 +111,6 @@ internal static void SetUserDefinedSettings(UserDefinedSettings settings)
#endif
}

internal static void SetHasUserAuthorizedEyeTrackingPermission(bool authorized)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Internal.SetHasUserAuthorizedEyeTrackingPermission(authorized);
#endif
}

internal static int SetCPULevel(int cpuLevel)
{
#if OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Expand Down Expand Up @@ -295,6 +290,22 @@ internal static bool GetEyeTrackedFoveatedRenderingSupported()
#endif
}

internal static bool GetEyeTrackedFoveatedRenderingEnabled()
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
return Internal.GetEyeTrackedFoveatedRenderingEnabled();
#else
return false;
#endif
}

internal static void SetEyeTrackedFoveatedRenderingEnabled(bool isEnabled)
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Internal.SetEyeTrackedFoveatedRenderingEnabled(isEnabled);
#endif
}

internal static bool GetShouldRestartSession()
{
#if !OCULUSPLUGIN_UNSUPPORTED_PLATFORM
Expand Down Expand Up @@ -324,16 +335,13 @@ private static class Internal
[DllImport("OculusXRPlugin")]
internal static extern void SetUserDefinedSettings(UserDefinedSettings settings);

[DllImport("OculusXRPlugin")]
internal static extern void SetHasUserAuthorizedEyeTrackingPermission(bool authorized);

[DllImport("OculusXRPlugin")]
internal static extern int SetCPULevel(int cpuLevel);

[DllImport("OculusXRPlugin")]
internal static extern int SetGPULevel(int gpuLevel);

[DllImport("OculusXRPlugin", CharSet=CharSet.Auto)]
[DllImport("OculusXRPlugin", CharSet = CharSet.Auto)]
internal static extern void GetOVRPVersion(byte[] version);

[DllImport("OculusXRPlugin")]
Expand Down Expand Up @@ -390,6 +398,12 @@ private static class Internal
[DllImport("OculusXRPlugin")]
internal static extern bool GetEyeTrackedFoveatedRenderingSupported();

[DllImport("OculusXRPlugin")]
internal static extern bool GetEyeTrackedFoveatedRenderingEnabled();

[DllImport("OculusXRPlugin")]
internal static extern void SetEyeTrackedFoveatedRenderingEnabled(bool isEnabled);

[DllImport("OculusXRPlugin")]
internal static extern bool GetShouldRestartSession();
}
Expand Down
4 changes: 2 additions & 2 deletions Runtime/OculusSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public enum FoveationMethod
public bool SharedDepthBuffer = true;

/// <summary>
/// Enable or disable support for submitting the depth buffer on mobile. This enables depth testing between layers on Oculus mobile platforms.
/// Enables support for submitting the depth buffer on mobile. This allows for depth testing between layers on mobile Oculus platforms.
/// </summary>
[SerializeField, Tooltip("Allows Unity to submit it's depth buffer to the Oculus runtime to allow for depth testing between layers.")]
[SerializeField, Tooltip("Enables support for submitting the depth buffer on mobile. This allows for depth testing between layers on mobile Oculus platforms.")]
public bool DepthSubmission = false;

/// <summary>
Expand Down
Binary file modified Runtime/x64/OculusXRPlugin.dll
Binary file not shown.
Binary file modified Runtime/x86/OculusXRPlugin.dll
Binary file not shown.
Loading

0 comments on commit 93b5b8d

Please sign in to comment.