Class XrPerformanceSettingsFeature
Allows interaction with the Performance settings API, which allows the application to provide hints to the runtime about the performance characteristics of the application, and to receive notifications from the runtime about changes in performance state.
Inherited Members
Namespace: UnityEngine.XR.OpenXR.Features.Extensions.PerformanceSettings
Assembly: Unity.XR.OpenXR.dll
Syntax
public class XrPerformanceSettingsFeature : OpenXRFeature
Remarks
Refer to XR performance settings for additional information.
Fields
extensionString
Name of the OpenXR extension for performance settings.
Declaration
public const string extensionString = "XR_EXT_performance_settings"
Field Value
Type | Description |
---|---|
string |
featureId
The feature id string.
Declaration
public const string featureId = "com.unity.openxr.feature.extension.performance_settings"
Field Value
Type | Description |
---|---|
string |
Methods
OnInstanceCreate(ulong)
Called after xrCreateInstance.
Declaration
protected override bool OnInstanceCreate(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrInstance | Handle of the xrInstance |
Returns
Type | Description |
---|---|
bool |
Overrides
SetPerformanceLevelHint(PerformanceDomain, PerformanceLevelHint)
Provides the OpenXR runtime with the desired performance level to be used for the specified domain.
Declaration
public static bool SetPerformanceLevelHint(PerformanceDomain domain, PerformanceLevelHint level)
Parameters
Type | Name | Description |
---|---|---|
PerformanceDomain | domain | Domain for which the performance hit will be sent. |
PerformanceLevelHint | level | Desired performance asked by the application. |
Returns
Type | Description |
---|---|
bool | True if the performance level hint was successfully set, false otherwise. |
Remarks
Refer to [Performance level hints](xref: openxr-performance-settings#performance-settings-level-hints) for additional information.
Events
OnXrPerformanceChangeNotification
Subscribe to this event to receive performance change notifications from the OpenXR runtime.
Declaration
public static event UnityAction<PerformanceChangeNotification> OnXrPerformanceChangeNotification
Event Type
Type | Description |
---|---|
UnityAction<PerformanceChangeNotification> |
Remarks
Refer to Performance notifications for additional information.
XrPerformanceSettingsFeature.OnXrPerformanceChangeNotification += OnGPUPerformanceChange;
Example of handling the performance change notification:
void OnGPUPerformanceChange(PerformanceChangeNotification notification)
{
if (notification.domain != Domain.GPU)
{
return;
}
if (notification.toLevel == PerformanceNotificationLevel.Normal)
{
// Performance has improved
UseDefaultQuality();
}
else
{
// Performance has degraded
UseReducedQuality();
}
}