version 2.0.0
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fd4c5098d66cc74294f6c590e9e24cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,206 @@
|
||||
# 12.54. XR_FB_display_refresh_rate
|
||||
## Name String
|
||||
XR_FB_display_refresh_rate
|
||||
## Revision
|
||||
1
|
||||
## Overview
|
||||
|
||||
On platforms which support dynamically adjusting the display refresh rate, application developers may request a specific display refresh rate in order to improve the overall user experience, examples include:
|
||||
|
||||
A video application may choose a display refresh rate which better matches the video content playback rate in order to achieve smoother video frames.
|
||||
|
||||
An application which can support a higher frame rate may choose to render at the higher rate to improve the overall perceptual quality, for example, lower latency and less flicker.
|
||||
|
||||
This extension allows:
|
||||
|
||||
An application to identify what display refresh rates the session supports and the current display refresh rate.
|
||||
|
||||
An application to request a display refresh rate to indicate its preference to the runtime.
|
||||
|
||||
An application to receive notification of changes to the display refresh rate which are delivered via events.
|
||||
|
||||
In order to enable the functionality of this extension, the application must pass the name of the extension into xrCreateInstance via the XrInstanceCreateInfo::enabledExtensionNames parameter as indicated in the Extensions section.
|
||||
|
||||
New Object Types
|
||||
|
||||
New Flag Types
|
||||
|
||||
New Enum Constants
|
||||
|
||||
XrStructureType enumeration is extended with:
|
||||
|
||||
XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB
|
||||
|
||||
XrResult enumeration is extended with:
|
||||
|
||||
XR_ERROR_DISPLAY_REFRESH_RATE_UNSUPPORTED_FB
|
||||
|
||||
New Enums
|
||||
|
||||
New Structures
|
||||
|
||||
Receiving the XrEventDataDisplayRefreshRateChangedFB event structure indicates that the display refresh rate has changed.
|
||||
|
||||
The XrEventDataDisplayRefreshRateChangedFB structure is defined as:
|
||||
|
||||
// Provided by XR_FB_display_refresh_rate
|
||||
typedef struct XrEventDataDisplayRefreshRateChangedFB {
|
||||
XrStructureType type;
|
||||
const void* next;
|
||||
float fromDisplayRefreshRate;
|
||||
float toDisplayRefreshRate;
|
||||
} XrEventDataDisplayRefreshRateChangedFB;
|
||||
Member Descriptions
|
||||
type is the XrStructureType of this structure.
|
||||
|
||||
next is NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
|
||||
|
||||
fromDisplayRefreshRate is the previous display refresh rate.
|
||||
|
||||
toDisplayRefreshRate is the new display refresh rate.
|
||||
|
||||
Valid Usage (Implicit)
|
||||
The XR_FB_display_refresh_rate extension must be enabled prior to using XrEventDataDisplayRefreshRateChangedFB
|
||||
|
||||
type must be XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB
|
||||
|
||||
next must be NULL or a valid pointer to the next structure in a structure chain
|
||||
|
||||
New Functions
|
||||
|
||||
The xrEnumerateDisplayRefreshRatesFB function is defined as:
|
||||
|
||||
// Provided by XR_FB_display_refresh_rate
|
||||
XrResult xrEnumerateDisplayRefreshRatesFB(
|
||||
XrSession session,
|
||||
uint32_t displayRefreshRateCapacityInput,
|
||||
uint32_t* displayRefreshRateCountOutput,
|
||||
float* displayRefreshRates);
|
||||
Parameter Descriptions
|
||||
session is the session that enumerates the supported display refresh rates.
|
||||
|
||||
displayRefreshRateCapacityInput is the capacity of the displayRefreshRates, or 0 to retrieve the required capacity.
|
||||
|
||||
displayRefreshRateCountOutput is a pointer to the count of float displayRefreshRates written, or a pointer to the required capacity in the case that displayRefreshRateCapacityInput is insufficient.
|
||||
|
||||
displayRefreshRates is a pointer to an array of float display refresh rates, but can be NULL if displayRefreshRateCapacityInput is 0.
|
||||
|
||||
See Buffer Size Parameters chapter for a detailed description of retrieving the required displayRefreshRates size.
|
||||
|
||||
xrEnumerateDisplayRefreshRatesFB enumerates the display refresh rates supported by the current session. Display refresh rates must be in order from lowest to highest supported display refresh rates. Runtimes must always return identical buffer contents from this enumeration for the lifetime of the session.
|
||||
|
||||
Valid Usage (Implicit)
|
||||
The XR_FB_display_refresh_rate extension must be enabled prior to calling xrEnumerateDisplayRefreshRatesFB
|
||||
|
||||
session must be a valid XrSession handle
|
||||
|
||||
displayRefreshRateCountOutput must be a pointer to a uint32_t value
|
||||
|
||||
If displayRefreshRateCapacityInput is not 0, displayRefreshRates must be a pointer to an array of displayRefreshRateCapacityInput float values
|
||||
|
||||
Return Codes
|
||||
Success
|
||||
XR_SUCCESS
|
||||
|
||||
XR_SESSION_LOSS_PENDING
|
||||
|
||||
Failure
|
||||
XR_ERROR_FUNCTION_UNSUPPORTED
|
||||
|
||||
XR_ERROR_VALIDATION_FAILURE
|
||||
|
||||
XR_ERROR_RUNTIME_FAILURE
|
||||
|
||||
XR_ERROR_HANDLE_INVALID
|
||||
|
||||
XR_ERROR_INSTANCE_LOST
|
||||
|
||||
XR_ERROR_SESSION_LOST
|
||||
|
||||
XR_ERROR_SIZE_INSUFFICIENT
|
||||
|
||||
The xrGetDisplayRefreshRateFB function is defined as:
|
||||
|
||||
// Provided by XR_FB_display_refresh_rate
|
||||
XrResult xrGetDisplayRefreshRateFB(
|
||||
XrSession session,
|
||||
float* displayRefreshRate);
|
||||
Parameter Descriptions
|
||||
session is the XrSession to query.
|
||||
|
||||
displayRefreshRate is a pointer to a float into which the current display refresh rate will be placed.
|
||||
|
||||
xrGetDisplayRefreshRateFB retrieves the current display refresh rate.
|
||||
|
||||
Valid Usage (Implicit)
|
||||
The XR_FB_display_refresh_rate extension must be enabled prior to calling xrGetDisplayRefreshRateFB
|
||||
|
||||
session must be a valid XrSession handle
|
||||
|
||||
displayRefreshRate must be a pointer to a float value
|
||||
|
||||
Return Codes
|
||||
Success
|
||||
XR_SUCCESS
|
||||
|
||||
XR_SESSION_LOSS_PENDING
|
||||
|
||||
Failure
|
||||
XR_ERROR_FUNCTION_UNSUPPORTED
|
||||
|
||||
XR_ERROR_VALIDATION_FAILURE
|
||||
|
||||
XR_ERROR_RUNTIME_FAILURE
|
||||
|
||||
XR_ERROR_HANDLE_INVALID
|
||||
|
||||
XR_ERROR_INSTANCE_LOST
|
||||
|
||||
XR_ERROR_SESSION_LOST
|
||||
|
||||
The xrRequestDisplayRefreshRateFB function is defined as:
|
||||
|
||||
// Provided by XR_FB_display_refresh_rate
|
||||
XrResult xrRequestDisplayRefreshRateFB(
|
||||
XrSession session,
|
||||
float displayRefreshRate);
|
||||
Parameter Descriptions
|
||||
session is a valid XrSession handle.
|
||||
|
||||
displayRefreshRate is 0.0f or a supported display refresh rate. Supported display refresh rates are indicated by xrEnumerateDisplayRefreshRatesFB.
|
||||
|
||||
xrRequestDisplayRefreshRateFB provides a mechanism for an application to request the system to dynamically change the display refresh rate to the application preferred value. The runtime must return XR_ERROR_DISPLAY_REFRESH_RATE_UNSUPPORTED_FB if displayRefreshRate is not either 0.0f or one of the values enumerated by xrEnumerateDisplayRefreshRatesFB. A display refresh rate of 0.0f indicates the application has no preference.
|
||||
|
||||
Note that this is only a request and does not guarantee the system will switch to the requested display refresh rate.
|
||||
|
||||
Valid Usage (Implicit)
|
||||
The XR_FB_display_refresh_rate extension must be enabled prior to calling xrRequestDisplayRefreshRateFB
|
||||
|
||||
session must be a valid XrSession handle
|
||||
|
||||
Return Codes
|
||||
Success
|
||||
XR_SUCCESS
|
||||
|
||||
XR_SESSION_LOSS_PENDING
|
||||
|
||||
Failure
|
||||
XR_ERROR_FUNCTION_UNSUPPORTED
|
||||
|
||||
XR_ERROR_VALIDATION_FAILURE
|
||||
|
||||
XR_ERROR_RUNTIME_FAILURE
|
||||
|
||||
XR_ERROR_HANDLE_INVALID
|
||||
|
||||
XR_ERROR_INSTANCE_LOST
|
||||
|
||||
XR_ERROR_SESSION_LOST
|
||||
|
||||
XR_ERROR_FEATURE_UNSUPPORTED
|
||||
|
||||
XR_ERROR_DISPLAY_REFRESH_RATE_UNSUPPORTED_FB
|
||||
|
||||
Issues
|
||||
|
||||
Changing the display refresh rate from its system default does not come without trade-offs. Increasing the display refresh rate puts more load on the entire system and can lead to thermal degradation. Conversely, lowering the display refresh rate can provide better thermal sustainability but at the cost of more perceptual issues, like higher latency and flickering.
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77f492ea9a608234294b51cf030292f6
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e3d6a1242bdfeb429ae342486ba096e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
// "VIVE SDK
|
||||
// © 2020 HTC Corporation. All Rights Reserved.
|
||||
//
|
||||
// Unless otherwise required by copyright law and practice,
|
||||
// upon the execution of HTC SDK license agreement,
|
||||
// HTC grants you access to and use of the VIVE SDK(s).
|
||||
// You shall fully comply with all of HTC’s SDK license agreement terms and
|
||||
// conditions signed by you and all SDK and API requirements,
|
||||
// specifications, and documentation provided by HTC to You."
|
||||
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
namespace VIVE.OpenXR.DisplayRefreshRate
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "XR FB Display Refresh Rate",
|
||||
BuildTargetGroups = new[] { BuildTargetGroup.Android},
|
||||
Company = "HTC",
|
||||
Desc = "Support the display refresh rate.",
|
||||
DocumentationLink = "..\\Documentation",
|
||||
OpenxrExtensionStrings = kOpenxrExtensionString,
|
||||
Version = "1.0.0",
|
||||
FeatureId = featureId)]
|
||||
#endif
|
||||
public class ViveDisplayRefreshRate : OpenXRFeature
|
||||
{
|
||||
const string LOG_TAG = "VIVE.OpenXR.DisplayRefreshRate";
|
||||
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
|
||||
void WARNING(string msg) { Debug.LogWarning(LOG_TAG + " " + msg); }
|
||||
void ERROR(string msg) { Debug.LogError(LOG_TAG + " " + msg); }
|
||||
|
||||
/// <summary>
|
||||
/// OpenXR specification <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_FB_display_refresh_rate">12.54. XR_FB_display_refresh_rate</see>.
|
||||
/// </summary>
|
||||
public const string kOpenxrExtensionString = "XR_FB_display_refresh_rate";
|
||||
|
||||
/// <summary>
|
||||
/// The feature id string. This is used to give the feature a well known id for reference.
|
||||
/// </summary>
|
||||
public const string featureId = "vive.openxr.feature.displayrefreshrate";
|
||||
|
||||
#region OpenXR Life Cycle
|
||||
private XrInstance m_XrInstance = 0;
|
||||
/// <summary>
|
||||
/// Called when <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrCreateInstance">xrCreateInstance</see> is done.
|
||||
/// </summary>
|
||||
/// <param name="xrInstance">The created instance.</param>
|
||||
/// <returns>True for valid <see cref="XrInstance">XrInstance</see></returns>
|
||||
protected override bool OnInstanceCreate(ulong xrInstance)
|
||||
{
|
||||
if (!OpenXRRuntime.IsExtensionEnabled(kOpenxrExtensionString))
|
||||
{
|
||||
WARNING("OnInstanceCreate() " + kOpenxrExtensionString + " is NOT enabled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_XrInstance = xrInstance;
|
||||
DEBUG("OnInstanceCreate() " + m_XrInstance);
|
||||
|
||||
return GetXrFunctionDelegates(m_XrInstance);
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrDestroyInstance">xrDestroyInstance</see> is done.
|
||||
/// </summary>
|
||||
/// <param name="xrInstance">The instance to destroy.</param>
|
||||
protected override void OnInstanceDestroy(ulong xrInstance)
|
||||
{
|
||||
m_XrInstance = 0;
|
||||
DEBUG("OnInstanceDestroy() " + xrInstance);
|
||||
}
|
||||
|
||||
private XrSystemId m_XrSystemId = 0;
|
||||
/// <summary>
|
||||
/// Called when the <see cref="XrSystemId">XrSystemId</see> retrieved by <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrGetSystem">xrGetSystem</see> is changed.
|
||||
/// </summary>
|
||||
/// <param name="xrSystem">The system id.</param>
|
||||
protected override void OnSystemChange(ulong xrSystem)
|
||||
{
|
||||
m_XrSystemId = xrSystem;
|
||||
DEBUG("OnSystemChange() " + m_XrSystemId);
|
||||
}
|
||||
|
||||
private XrSession m_XrSession = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Called when <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrCreateSession">xrCreateSession</see> is done.
|
||||
/// </summary>
|
||||
/// <param name="xrSession">The created session ID.</param>
|
||||
protected override void OnSessionCreate(ulong xrSession)
|
||||
{
|
||||
m_XrSession = xrSession;
|
||||
DEBUG("OnSessionCreate() " + m_XrSession);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrDestroySession">xrDestroySession</see> is done.
|
||||
/// </summary>
|
||||
/// <param name="xrSession">The session ID to destroy.</param>
|
||||
protected override void OnSessionDestroy(ulong xrSession)
|
||||
{
|
||||
DEBUG("OnSessionDestroy() " + xrSession);
|
||||
|
||||
m_XrSession = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region OpenXR function delegates
|
||||
/// xrGetInstanceProcAddr
|
||||
OpenXRHelper.xrGetInstanceProcAddrDelegate XrGetInstanceProcAddr;
|
||||
|
||||
//xrRequestDisplayRefreshRateFB
|
||||
OpenXRHelper.xrRequestDisplayRefreshRateFBDelegate xrRequestDisplayRefreshRateFB;
|
||||
|
||||
//xrGetDisplayRefreshRateFB
|
||||
OpenXRHelper.xrGetDisplayRefreshRateFBDelegate xrGetDisplayRefreshRateFB;
|
||||
|
||||
//xrEnumerateDisplayRefreshRatesFB
|
||||
OpenXRHelper.xrEnumerateDisplayRefreshRatesFBDelegate xrEnumerateDisplayRefreshRatesFB;
|
||||
|
||||
|
||||
private bool GetXrFunctionDelegates(XrInstance xrInstance)
|
||||
{
|
||||
/// xrGetInstanceProcAddr
|
||||
if (xrGetInstanceProcAddr != null && xrGetInstanceProcAddr != IntPtr.Zero)
|
||||
{
|
||||
DEBUG("Get function pointer of xrGetInstanceProcAddr.");
|
||||
XrGetInstanceProcAddr = Marshal.GetDelegateForFunctionPointer(
|
||||
xrGetInstanceProcAddr,
|
||||
typeof(OpenXRHelper.xrGetInstanceProcAddrDelegate)) as OpenXRHelper.xrGetInstanceProcAddrDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("xrGetInstanceProcAddr");
|
||||
return false;
|
||||
}
|
||||
|
||||
IntPtr funcPtr = IntPtr.Zero;
|
||||
DEBUG("Try Get function pointer of xrRequestDisplayRefreshRateFB.");
|
||||
|
||||
/// xrRequestDisplayRefreshRateFB
|
||||
if (XrGetInstanceProcAddr(xrInstance, "xrRequestDisplayRefreshRateFB", out funcPtr) == XrResult.XR_SUCCESS)
|
||||
{
|
||||
if (funcPtr != IntPtr.Zero)
|
||||
{
|
||||
DEBUG("Get function pointer of xrRequestDisplayRefreshRateFB.");
|
||||
xrRequestDisplayRefreshRateFB = Marshal.GetDelegateForFunctionPointer(
|
||||
funcPtr,
|
||||
typeof(OpenXRHelper.xrRequestDisplayRefreshRateFBDelegate)) as OpenXRHelper.xrRequestDisplayRefreshRateFBDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("0. Get function pointer of xrRequestDisplayRefreshRateFB failed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("1. Get function pointer of xrRequestDisplayRefreshRateFB failed.");
|
||||
}
|
||||
|
||||
/// xrGetDisplayRefreshRateFB
|
||||
if (XrGetInstanceProcAddr(xrInstance, "xrGetDisplayRefreshRateFB", out funcPtr) == XrResult.XR_SUCCESS)
|
||||
{
|
||||
if (funcPtr != IntPtr.Zero)
|
||||
{
|
||||
DEBUG("Get function pointer of xrGetDisplayRefreshRateFB.");
|
||||
xrGetDisplayRefreshRateFB = Marshal.GetDelegateForFunctionPointer(
|
||||
funcPtr,
|
||||
typeof(OpenXRHelper.xrGetDisplayRefreshRateFBDelegate)) as OpenXRHelper.xrGetDisplayRefreshRateFBDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("0. Get function pointer of xrGetDisplayRefreshRateFB failed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("1. Get function pointer of xrGetDisplayRefreshRateFB failed.");
|
||||
}
|
||||
|
||||
/// xrEnumerateDisplayRefreshRatesFB
|
||||
if (XrGetInstanceProcAddr(xrInstance, "xrEnumerateDisplayRefreshRatesFB", out funcPtr) == XrResult.XR_SUCCESS)
|
||||
{
|
||||
if (funcPtr != IntPtr.Zero)
|
||||
{
|
||||
DEBUG("Get function pointer of xrEnumerateDisplayRefreshRatesFB.");
|
||||
xrEnumerateDisplayRefreshRatesFB = Marshal.GetDelegateForFunctionPointer(
|
||||
funcPtr,
|
||||
typeof(OpenXRHelper.xrEnumerateDisplayRefreshRatesFBDelegate)) as OpenXRHelper.xrEnumerateDisplayRefreshRatesFBDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("0. Get function pointer of xrEnumerateDisplayRefreshRatesFB failed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR("1. Get function pointer of xrEnumerateDisplayRefreshRatesFB failed.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrRequestDisplayRefreshRateFB">xrRequestDisplayRefreshRateFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRate"></param>
|
||||
/// <returns></returns>
|
||||
public XrResult RequestDisplayRefreshRate(float displayRefreshRate)
|
||||
{
|
||||
if (!OpenXRRuntime.IsExtensionEnabled("XR_FB_display_refresh_rate"))
|
||||
{
|
||||
WARNING("RequestDisplayRefreshRate: XR_FB_display_refresh_rate is NOT enabled.");
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
return xrRequestDisplayRefreshRateFB(m_XrSession, displayRefreshRate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrGetDisplayRefreshRateFB">xrGetDisplayRefreshRateFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRate"></param>
|
||||
/// <returns></returns>
|
||||
public XrResult GetDisplayRefreshRate(out float displayRefreshRate)
|
||||
{
|
||||
if (!OpenXRRuntime.IsExtensionEnabled("XR_FB_display_refresh_rate"))
|
||||
{
|
||||
WARNING("GetDisplayRefreshRate: XR_FB_display_refresh_rate is NOT enabled.");
|
||||
displayRefreshRate = 90.0f;
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
return xrGetDisplayRefreshRateFB(m_XrSession, out displayRefreshRate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrEnumerateDisplayRefreshRatesFB">xrEnumerateDisplayRefreshRatesFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRateCapacityInput"></param>
|
||||
/// <param name="displayRefreshRateCountOutput"></param>
|
||||
/// <param name="displayRefreshRates"></param>
|
||||
/// <returns></returns>
|
||||
public XrResult EnumerateDisplayRefreshRates(UInt32 displayRefreshRateCapacityInput, out UInt32 displayRefreshRateCountOutput, out float displayRefreshRates)
|
||||
{
|
||||
if (!OpenXRRuntime.IsExtensionEnabled("XR_FB_display_refresh_rate"))
|
||||
{
|
||||
WARNING("EnumerateDisplayRefreshRates: XR_FB_display_refresh_rate is NOT enabled.");
|
||||
displayRefreshRateCountOutput = 0;
|
||||
displayRefreshRates = 90.0f;
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
return xrEnumerateDisplayRefreshRatesFB(m_XrSession, displayRefreshRateCapacityInput, out displayRefreshRateCountOutput, out displayRefreshRates);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c6529da49ed6c34e9fc93a1ccfd9d4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using VIVE.OpenXR.DisplayRefreshRate;
|
||||
|
||||
namespace VIVE.OpenXR
|
||||
{
|
||||
public class XR_FB_display_refresh_rate_defs
|
||||
{
|
||||
public virtual XrResult RequestDisplayRefreshRate(float displayRefreshRate)
|
||||
{
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
|
||||
public virtual XrResult GetDisplayRefreshRate(out float displayRefreshRate)
|
||||
{
|
||||
displayRefreshRate = 90.0f;
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
|
||||
public virtual XrResult EnumerateDisplayRefreshRates(UInt32 displayRefreshRateCapacityInput, out UInt32 displayRefreshRateCountOutput, out float displayRefreshRates)
|
||||
{
|
||||
displayRefreshRateCountOutput = 0;
|
||||
displayRefreshRates = 90.0f;
|
||||
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
public class XR_FB_display_refresh_rate
|
||||
{
|
||||
static XR_FB_display_refresh_rate_defs m_Instance = null;
|
||||
public static XR_FB_display_refresh_rate_defs Interop
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Instance == null)
|
||||
{
|
||||
m_Instance = new XR_FB_display_refresh_rate_impls();
|
||||
}
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrRequestDisplayRefreshRateFB">xrRequestDisplayRefreshRateFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRate"></param>
|
||||
/// <returns></returns>
|
||||
public static XrResult RequestDisplayRefreshRate(float displayRefreshRate)
|
||||
{
|
||||
return Interop.RequestDisplayRefreshRate(displayRefreshRate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrGetDisplayRefreshRateFB">xrGetDisplayRefreshRateFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRate"></param>
|
||||
/// <returns></returns>
|
||||
public static XrResult GetDisplayRefreshRate(out float displayRefreshRate)
|
||||
{
|
||||
return Interop.GetDisplayRefreshRate(out displayRefreshRate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refer to OpenXR <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrEnumerateDisplayRefreshRatesFB">xrEnumerateDisplayRefreshRatesFB</see>.
|
||||
/// </summary>
|
||||
/// <param name="displayRefreshRateCapacityInput"></param>
|
||||
/// <param name="displayRefreshRateCountOutput"></param>
|
||||
/// <param name="displayRefreshRates"></param>
|
||||
/// <returns></returns>
|
||||
public static XrResult EnumerateDisplayRefreshRates(UInt32 displayRefreshRateCapacityInput, out UInt32 displayRefreshRateCountOutput, out float displayRefreshRates)
|
||||
{
|
||||
return Interop.EnumerateDisplayRefreshRates(displayRefreshRateCapacityInput, out displayRefreshRateCountOutput, out displayRefreshRates);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8862d382ed6b93d499db2e5724af1939
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.XR.OpenXR;
|
||||
|
||||
using VIVE.OpenXR.DisplayRefreshRate;
|
||||
|
||||
|
||||
namespace VIVE.OpenXR
|
||||
{
|
||||
public class XR_FB_display_refresh_rate_impls : XR_FB_display_refresh_rate_defs
|
||||
{
|
||||
const string LOG_TAG = "VIVE.OpenXR.XR_FB_display_refresh_rate_impls";
|
||||
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
|
||||
|
||||
private ViveDisplayRefreshRate feature = null;
|
||||
private void ASSERT_FEATURE() {
|
||||
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<ViveDisplayRefreshRate>(); }
|
||||
}
|
||||
|
||||
public override XrResult RequestDisplayRefreshRate(float displayRefreshRate)
|
||||
{
|
||||
DEBUG("RequestDisplayRefreshRate");
|
||||
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
|
||||
|
||||
ASSERT_FEATURE();
|
||||
if (feature)
|
||||
{
|
||||
result = (XrResult)feature.RequestDisplayRefreshRate(displayRefreshRate);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override XrResult GetDisplayRefreshRate(out float displayRefreshRate)
|
||||
{
|
||||
//DEBUG("GetDisplayRefreshRate");
|
||||
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
|
||||
displayRefreshRate = 0.0f;
|
||||
|
||||
ASSERT_FEATURE();
|
||||
if (feature)
|
||||
{
|
||||
result = (XrResult)feature.GetDisplayRefreshRate(out displayRefreshRate);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override XrResult EnumerateDisplayRefreshRates(UInt32 displayRefreshRateCapacityInput, out UInt32 displayRefreshRateCountOutput, out float displayRefreshRates)
|
||||
{
|
||||
DEBUG("EnumerateDisplayRefreshRates");
|
||||
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
|
||||
displayRefreshRateCountOutput = 0;
|
||||
displayRefreshRates = 90.0f;
|
||||
|
||||
ASSERT_FEATURE();
|
||||
if (feature)
|
||||
{
|
||||
result = (XrResult)feature.EnumerateDisplayRefreshRates(displayRefreshRateCapacityInput, out displayRefreshRateCountOutput, out displayRefreshRates);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4578bfda663cfda4a9ae76831b9ecc8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user