上传YomovSDK
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
namespace VIVE.OpenXR
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "VIVE XR Foveation",
|
||||
Desc = "Support the HTC foveation extension.",
|
||||
Company = "HTC",
|
||||
DocumentationLink = "..\\Documentation",
|
||||
OpenxrExtensionStrings = kOpenxrExtensionString,
|
||||
Version = "1.0.0",
|
||||
BuildTargetGroups = new[] { BuildTargetGroup.Android },
|
||||
FeatureId = featureId
|
||||
)]
|
||||
#endif
|
||||
public class ViveFoveation : OpenXRFeature
|
||||
{
|
||||
const string LOG_TAG = "VIVE.OpenXR.ViveFoveation";
|
||||
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>
|
||||
/// Flag bits for XrFoveationDynamicFlagsHTC
|
||||
/// </summary>
|
||||
public const UInt64 XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_BIT_HTC = 0x00000001;
|
||||
public const UInt64 XR_FOVEATION_DYNAMIC_CLEAR_FOV_ENABLED_BIT_HTC = 0x00000002;
|
||||
public const UInt64 XR_FOVEATION_DYNAMIC_FOCAL_CENTER_OFFSET_ENABLED_BIT_HTC = 0x00000004;
|
||||
|
||||
/// <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.foveation";
|
||||
|
||||
/// <summary>
|
||||
/// OpenXR specification <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_HTC_foveation">12.90. XR_HTC_foveation</see>.
|
||||
/// </summary>
|
||||
public const string kOpenxrExtensionString = "XR_HTC_foveation";
|
||||
|
||||
#region OpenXR Life Cycle
|
||||
/// <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;
|
||||
}
|
||||
|
||||
DEBUG("OnInstanceCreate() " + xrInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override IntPtr HookGetInstanceProcAddr(IntPtr func)
|
||||
{
|
||||
Debug.Log("EXT: registering our own xrGetInstanceProcAddr");
|
||||
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan)
|
||||
{
|
||||
Debug.Log("Vulkan no hook foveation");
|
||||
return func;
|
||||
}
|
||||
return intercept_xrGetInstanceProcAddr(func);
|
||||
}
|
||||
|
||||
private const string ExtLib = "viveopenxr";
|
||||
[DllImport(ExtLib, EntryPoint = "intercept_xrGetInstanceProcAddr")]
|
||||
private static extern IntPtr intercept_xrGetInstanceProcAddr(IntPtr func);
|
||||
|
||||
[DllImport(ExtLib, EntryPoint = "applyFoveationHTC")]
|
||||
private static extern XrResult applyFoveationHTC(Foveation.XrFoveationModeHTC mode, UInt32 configCount, Foveation.XrFoveationConfigurationHTC[] configs, UInt64 flags);
|
||||
|
||||
/// <summary>
|
||||
/// function to apply HTC Foveation
|
||||
/// </summary>
|
||||
public static XrResult ApplyFoveationHTC(Foveation.XrFoveationModeHTC mode, UInt32 configCount, Foveation.XrFoveationConfigurationHTC[] configs, UInt64 flags = 0)
|
||||
{
|
||||
//Debug.Log("Unity HTCFoveat:configCount " + configCount);
|
||||
//if (configCount >=2) {
|
||||
//Debug.Log("Unity HTCFoveat:configs[0].clearFovDegree " + configs[0].clearFovDegree);
|
||||
//Debug.Log("Unity HTCFoveat:configs[0].level " + configs[0].level);
|
||||
//Debug.Log("Unity HTCFoveat:configs[1].clearFovDegree " + configs[1].clearFovDegree);
|
||||
//Debug.Log("Unity HTCFoveat:configs[1].level " + configs[1].level);
|
||||
//}
|
||||
return applyFoveationHTC(mode, configCount, configs, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17b6a897c202288439905d3efb0e006f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
namespace VIVE.OpenXR.Foveation
|
||||
{
|
||||
#region 12.86. XR_HTC_foveation
|
||||
/// <summary>
|
||||
/// The XrFoveationModeHTC identifies the different foveation modes.
|
||||
/// </summary>
|
||||
public enum XrFoveationModeHTC
|
||||
{
|
||||
XR_FOVEATION_MODE_DISABLE_HTC = 0,
|
||||
XR_FOVEATION_MODE_FIXED_HTC = 1,
|
||||
XR_FOVEATION_MODE_DYNAMIC_HTC = 2,
|
||||
XR_FOVEATION_MODE_CUSTOM_HTC = 3,
|
||||
XR_FOVEATION_MODE_MAX_ENUM_HTC = 0x7FFFFFFF
|
||||
}
|
||||
/// <summary>
|
||||
/// The XrFoveationLevelHTC identifies the pixel density drop level of periphery area.
|
||||
/// </summary>
|
||||
public enum XrFoveationLevelHTC
|
||||
{
|
||||
XR_FOVEATION_LEVEL_NONE_HTC = 0,
|
||||
XR_FOVEATION_LEVEL_LOW_HTC = 1,
|
||||
XR_FOVEATION_LEVEL_MEDIUM_HTC = 2,
|
||||
XR_FOVEATION_LEVEL_HIGH_HTC = 3,
|
||||
XR_FOVEATION_LEVEL_MAX_ENUM_HTC = 0x7FFFFFFF
|
||||
}
|
||||
/// <summary>
|
||||
/// The XrFoveationConfigurationHTC structure contains the custom foveation settings for the corresponding views.
|
||||
/// </summary>
|
||||
public struct XrFoveationConfigurationHTC
|
||||
{
|
||||
public XrFoveationLevelHTC level;
|
||||
public float clearFovDegree;
|
||||
public XrVector2f focalCenterOffset;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b3c2ad651da4e5498f49d3a26038620
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user