mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
OpenXR - Introduce platform flags
This commit is contained in:
parent
f8d29e0d19
commit
aafa17fa73
@ -103,12 +103,21 @@ bool IsVRBuild() {
|
|||||||
|
|
||||||
#if PPSSPP_PLATFORM(ANDROID)
|
#if PPSSPP_PLATFORM(ANDROID)
|
||||||
void InitVROnAndroid(void* vm, void* activity, int version, char* name) {
|
void InitVROnAndroid(void* vm, void* activity, int version, char* name) {
|
||||||
bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN;
|
|
||||||
|
//TODO:get the flags in runtime
|
||||||
|
#ifdef OPENXR_PLATFORM_PICO
|
||||||
|
VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO, true);
|
||||||
|
VR_SetPlatformFLag(VR_PLATFORM_PICO_INIT, true);
|
||||||
|
#elifdef OPENXR_PLATFORM_QUEST
|
||||||
|
VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST, true);
|
||||||
|
VR_SetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT, true);
|
||||||
|
#endif
|
||||||
|
VR_SetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN, (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN);
|
||||||
|
|
||||||
ovrJava java;
|
ovrJava java;
|
||||||
java.Vm = (JavaVM*)vm;
|
java.Vm = (JavaVM*)vm;
|
||||||
java.ActivityObject = (jobject)activity;
|
java.ActivityObject = (jobject)activity;
|
||||||
VR_Init(&java, useVulkan, name, version);
|
VR_Init(&java, name, version);
|
||||||
|
|
||||||
__DisplaySetFramerate(72);
|
__DisplaySetFramerate(72);
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,11 @@ PFN_xrSetEngineVersionPico pfnXrSetEngineVersionPico = nullptr;
|
|||||||
PFN_xrStartCVControllerThreadPico pfnXrStartCVControllerThreadPico = nullptr;
|
PFN_xrStartCVControllerThreadPico pfnXrStartCVControllerThreadPico = nullptr;
|
||||||
PFN_xrStopCVControllerThreadPico pfnXrStopCVControllerThreadPico = nullptr;
|
PFN_xrStopCVControllerThreadPico pfnXrStopCVControllerThreadPico = nullptr;
|
||||||
|
|
||||||
|
static bool vr_platform[VR_PLATFORM_MAX];
|
||||||
static engine_t vr_engine;
|
static engine_t vr_engine;
|
||||||
int vr_initialized = 0;
|
int vr_initialized = 0;
|
||||||
|
|
||||||
void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
void VR_Init( void* system, char* name, int version ) {
|
||||||
if (vr_initialized)
|
if (vr_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -62,24 +63,24 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<const char *> extensions;
|
std::vector<const char *> extensions;
|
||||||
if (useVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
|
extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
|
||||||
} else {
|
} else {
|
||||||
extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME);
|
extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME);
|
extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME);
|
||||||
#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION
|
if (VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) {
|
||||||
extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
|
extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
|
||||||
extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME);
|
extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME);
|
||||||
#endif
|
}
|
||||||
#ifdef OPENXR_PLATFORM_PICO
|
if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) {
|
||||||
extensions.push_back(XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME);
|
extensions.push_back(XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME);
|
||||||
extensions.push_back("XR_PICO_android_controller_function_ext_enable");
|
extensions.push_back("XR_PICO_android_controller_function_ext_enable");
|
||||||
extensions.push_back("XR_PICO_view_state_ext_enable");
|
extensions.push_back("XR_PICO_view_state_ext_enable");
|
||||||
extensions.push_back("XR_PICO_frame_end_info_ext");
|
extensions.push_back("XR_PICO_frame_end_info_ext");
|
||||||
extensions.push_back("XR_PICO_configs_ext");
|
extensions.push_back("XR_PICO_configs_ext");
|
||||||
extensions.push_back("XR_PICO_reset_sensor");
|
extensions.push_back("XR_PICO_reset_sensor");
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// Create the OpenXR instance.
|
// Create the OpenXR instance.
|
||||||
XrApplicationInfo appInfo;
|
XrApplicationInfo appInfo;
|
||||||
@ -101,12 +102,14 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
|||||||
instanceCreateInfo.enabledExtensionCount = extensions.size();
|
instanceCreateInfo.enabledExtensionCount = extensions.size();
|
||||||
instanceCreateInfo.enabledExtensionNames = extensions.data();
|
instanceCreateInfo.enabledExtensionNames = extensions.data();
|
||||||
|
|
||||||
#if defined(ANDROID) && defined(OPENXR_PLATFORM_PICO)
|
#ifdef ANDROID
|
||||||
ovrJava* java = (ovrJava*)system;
|
if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) {
|
||||||
XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
ovrJava* java = (ovrJava*)system;
|
||||||
instanceCreateInfoAndroid.applicationVM = java->Vm;
|
XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
||||||
instanceCreateInfoAndroid.applicationActivity = java->ActivityObject;
|
instanceCreateInfoAndroid.applicationVM = java->Vm;
|
||||||
instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid;
|
instanceCreateInfoAndroid.applicationActivity = java->ActivityObject;
|
||||||
|
instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XrResult initResult;
|
XrResult initResult;
|
||||||
@ -116,14 +119,14 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENXR_PLATFORM_PICO
|
if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) {
|
||||||
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico));
|
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico));
|
||||||
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico));
|
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico));
|
||||||
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStopCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStopCVControllerThreadPico));
|
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStopCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStopCVControllerThreadPico));
|
||||||
xrGetInstanceProcAddr(vr_engine.appState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO));
|
xrGetInstanceProcAddr(vr_engine.appState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO));
|
||||||
if (pfnXrSetEngineVersionPico != nullptr) pfnXrSetEngineVersionPico(vr_engine.appState.Instance, "2.8.0.1");
|
if (pfnXrSetEngineVersionPico != nullptr) pfnXrSetEngineVersionPico(vr_engine.appState.Instance, "2.8.0.1");
|
||||||
if (pfnXrStartCVControllerThreadPico != nullptr) pfnXrStartCVControllerThreadPico(vr_engine.appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF);
|
if (pfnXrStartCVControllerThreadPico != nullptr) pfnXrStartCVControllerThreadPico(vr_engine.appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
XrInstanceProperties instanceInfo;
|
XrInstanceProperties instanceInfo;
|
||||||
instanceInfo.type = XR_TYPE_INSTANCE_PROPERTIES;
|
instanceInfo.type = XR_TYPE_INSTANCE_PROPERTIES;
|
||||||
@ -150,7 +153,7 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the graphics requirements.
|
// Get the graphics requirements.
|
||||||
if (useVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL;
|
PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL;
|
||||||
OXR(xrGetInstanceProcAddr(
|
OXR(xrGetInstanceProcAddr(
|
||||||
vr_engine.appState.Instance,
|
vr_engine.appState.Instance,
|
||||||
@ -174,17 +177,17 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) {
|
|||||||
|
|
||||||
vr_engine.appState.MainThreadTid = gettid();
|
vr_engine.appState.MainThreadTid = gettid();
|
||||||
vr_engine.appState.SystemId = systemId;
|
vr_engine.appState.SystemId = systemId;
|
||||||
vr_engine.useVulkan = useVulkan;
|
|
||||||
vr_initialized = 1;
|
vr_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VR_Destroy( engine_t* engine ) {
|
void VR_Destroy( engine_t* engine ) {
|
||||||
if (engine == &vr_engine) {
|
if (engine == &vr_engine) {
|
||||||
#ifdef OPENXR_PLATFORM_PICO
|
if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) {
|
||||||
if (pfnXrStopCVControllerThreadPico != nullptr) {
|
if (pfnXrStopCVControllerThreadPico != nullptr) {
|
||||||
pfnXrStopCVControllerThreadPico(engine->appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF);
|
pfnXrStopCVControllerThreadPico(engine->appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
xrDestroyInstance(engine->appState.Instance);
|
xrDestroyInstance(engine->appState.Instance);
|
||||||
ovrApp_Destroy(&engine->appState);
|
ovrApp_Destroy(&engine->appState);
|
||||||
}
|
}
|
||||||
@ -199,17 +202,25 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu
|
|||||||
|
|
||||||
// Create the OpenXR Session.
|
// Create the OpenXR Session.
|
||||||
XrSessionCreateInfo sessionCreateInfo = {};
|
XrSessionCreateInfo sessionCreateInfo = {};
|
||||||
XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {};
|
#ifdef ANDROID
|
||||||
|
XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingGL = {};
|
||||||
|
#else
|
||||||
|
XrGraphicsBindingOpenGLWin32KHR graphicsBindingGL = {};
|
||||||
|
#endif
|
||||||
memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo));
|
memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo));
|
||||||
if (engine->useVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
sessionCreateInfo.next = graphicsBindingVulkan;
|
sessionCreateInfo.next = graphicsBindingVulkan;
|
||||||
} else {
|
} else {
|
||||||
graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR;
|
#ifdef ANDROID
|
||||||
graphicsBindingAndroidGLES.next = NULL;
|
graphicsBindingGL.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR;
|
||||||
graphicsBindingAndroidGLES.display = eglGetCurrentDisplay();
|
graphicsBindingGL.next = NULL;
|
||||||
graphicsBindingAndroidGLES.config = eglGetCurrentSurface(EGL_DRAW);
|
graphicsBindingGL.display = eglGetCurrentDisplay();
|
||||||
graphicsBindingAndroidGLES.context = eglGetCurrentContext();
|
graphicsBindingGL.config = eglGetCurrentSurface(EGL_DRAW);
|
||||||
sessionCreateInfo.next = &graphicsBindingAndroidGLES;
|
graphicsBindingGL.context = eglGetCurrentContext();
|
||||||
|
#else
|
||||||
|
//TODO:PCVR definition
|
||||||
|
#endif
|
||||||
|
sessionCreateInfo.next = &graphicsBindingGL;
|
||||||
}
|
}
|
||||||
sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO;
|
sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO;
|
||||||
sessionCreateInfo.createFlags = 0;
|
sessionCreateInfo.createFlags = 0;
|
||||||
@ -221,9 +232,9 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu
|
|||||||
ALOGE("Failed to create XR session: %d.", initResult);
|
ALOGE("Failed to create XR session: %d.", initResult);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef OPENXR_PLATFORM_PICO
|
if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) {
|
||||||
pfnXrSetConfigPICO(engine->appState.Session, TRACKING_ORIGIN, "1");
|
pfnXrSetConfigPICO(engine->appState.Session, TRACKING_ORIGIN, "1");
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// Create a space to the first path
|
// Create a space to the first path
|
||||||
XrReferenceSpaceCreateInfo spaceCreateInfo = {};
|
XrReferenceSpaceCreateInfo spaceCreateInfo = {};
|
||||||
@ -251,4 +262,12 @@ engine_t* VR_GetEngine( void ) {
|
|||||||
return &vr_engine;
|
return &vr_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VR_GetPlatformFLag(VRPlatformFlag flag) {
|
||||||
|
return vr_platform[flag];
|
||||||
|
}
|
||||||
|
|
||||||
|
void VR_SetPlatformFLag(VRPlatformFlag flag, bool value) {
|
||||||
|
vr_platform[flag] = value;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -100,10 +100,6 @@ static void OXR_CheckErrors(XrInstance instance, XrResult result, const char* fu
|
|||||||
#define OXR(func) func;
|
#define OXR(func) func;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPENXR_PLATFORM_QUEST
|
|
||||||
#define OPENXR_HAS_PERFORMANCE_EXTENSION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { ovrMaxLayerCount = 2 };
|
enum { ovrMaxLayerCount = 2 };
|
||||||
enum { ovrMaxNumEyes = 2 };
|
enum { ovrMaxNumEyes = 2 };
|
||||||
|
|
||||||
@ -133,7 +129,6 @@ typedef struct {
|
|||||||
VkImageView* VKDepthImages;
|
VkImageView* VKDepthImages;
|
||||||
|
|
||||||
bool Acquired;
|
bool Acquired;
|
||||||
bool UseVulkan;
|
|
||||||
XrGraphicsBindingVulkanKHR* VKContext;
|
XrGraphicsBindingVulkanKHR* VKContext;
|
||||||
} ovrFramebuffer;
|
} ovrFramebuffer;
|
||||||
|
|
||||||
@ -178,16 +173,27 @@ typedef struct {
|
|||||||
uint64_t frameIndex;
|
uint64_t frameIndex;
|
||||||
ovrApp appState;
|
ovrApp appState;
|
||||||
float predictedDisplayTime;
|
float predictedDisplayTime;
|
||||||
bool useVulkan;
|
|
||||||
XrGraphicsBindingVulkanKHR graphicsBindingVulkan;
|
XrGraphicsBindingVulkanKHR graphicsBindingVulkan;
|
||||||
} engine_t;
|
} engine_t;
|
||||||
|
|
||||||
void VR_Init( void* system, bool useVulkan, char* name, int version );
|
enum VRPlatformFlag {
|
||||||
|
VR_PLATFORM_CONTROLLER_PICO,
|
||||||
|
VR_PLATFORM_CONTROLLER_QUEST,
|
||||||
|
VR_PLATFORM_PERFORMANCE_EXT,
|
||||||
|
VR_PLATFORM_PICO_INIT,
|
||||||
|
VR_PLATFORM_RENDERER_VULKAN,
|
||||||
|
VR_PLATFORM_TRACKING_FLOOR,
|
||||||
|
VR_PLATFORM_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
void VR_Init( void* system, char* name, int version );
|
||||||
void VR_Destroy( engine_t* engine );
|
void VR_Destroy( engine_t* engine );
|
||||||
void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan );
|
void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan );
|
||||||
void VR_LeaveVR( engine_t* engine );
|
void VR_LeaveVR( engine_t* engine );
|
||||||
|
|
||||||
engine_t* VR_GetEngine( void );
|
engine_t* VR_GetEngine( void );
|
||||||
|
bool VR_GetPlatformFLag(VRPlatformFlag flag);
|
||||||
|
void VR_SetPlatformFLag(VRPlatformFlag flag, bool value);
|
||||||
|
|
||||||
void ovrApp_Clear(ovrApp* app);
|
void ovrApp_Clear(ovrApp* app);
|
||||||
void ovrApp_Destroy(ovrApp* app);
|
void ovrApp_Destroy(ovrApp* app);
|
||||||
|
@ -49,7 +49,6 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int
|
|||||||
|
|
||||||
frameBuffer->Width = width;
|
frameBuffer->Width = width;
|
||||||
frameBuffer->Height = height;
|
frameBuffer->Height = height;
|
||||||
frameBuffer->UseVulkan = false;
|
|
||||||
|
|
||||||
if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview2") == nullptr)
|
if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview2") == nullptr)
|
||||||
{
|
{
|
||||||
@ -142,7 +141,6 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int
|
|||||||
|
|
||||||
frameBuffer->Width = width;
|
frameBuffer->Width = width;
|
||||||
frameBuffer->Height = height;
|
frameBuffer->Height = height;
|
||||||
frameBuffer->UseVulkan = true;
|
|
||||||
frameBuffer->VKContext = (XrGraphicsBindingVulkanKHR*)context;
|
frameBuffer->VKContext = (XrGraphicsBindingVulkanKHR*)context;
|
||||||
|
|
||||||
XrSwapchainCreateInfo swapChainCreateInfo;
|
XrSwapchainCreateInfo swapChainCreateInfo;
|
||||||
@ -242,7 +240,7 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) {
|
void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) {
|
||||||
if (frameBuffer->UseVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) {
|
for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) {
|
||||||
vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr);
|
vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr);
|
||||||
vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr);
|
vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr);
|
||||||
@ -266,7 +264,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) {
|
void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) {
|
||||||
if (frameBuffer->UseVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex];
|
return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex];
|
||||||
} else {
|
} else {
|
||||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||||
@ -298,7 +296,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) {
|
|||||||
|
|
||||||
ovrFramebuffer_SetCurrent(frameBuffer);
|
ovrFramebuffer_SetCurrent(frameBuffer);
|
||||||
|
|
||||||
if (frameBuffer->UseVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
//TODO:implement
|
//TODO:implement
|
||||||
} else {
|
} else {
|
||||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||||
@ -320,7 +318,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) {
|
|||||||
frameBuffer->Acquired = false;
|
frameBuffer->Acquired = false;
|
||||||
|
|
||||||
// Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully
|
// Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully
|
||||||
if (frameBuffer->UseVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
//TODO:implement
|
//TODO:implement
|
||||||
} else {
|
} else {
|
||||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||||
@ -369,7 +367,7 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) {
|
void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) {
|
||||||
if (renderer->FrameBuffer[0].UseVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
//TODO:implement
|
//TODO:implement
|
||||||
} else {
|
} else {
|
||||||
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
||||||
@ -428,14 +426,9 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) {
|
|||||||
|
|
||||||
XrResult result;
|
XrResult result;
|
||||||
OXR(result = xrBeginSession(app->Session, &sessionBeginInfo));
|
OXR(result = xrBeginSession(app->Session, &sessionBeginInfo));
|
||||||
|
|
||||||
app->SessionActive = (result == XR_SUCCESS);
|
app->SessionActive = (result == XR_SUCCESS);
|
||||||
|
|
||||||
// Set session state once we have entered VR mode and have a valid session object.
|
if (app->SessionActive && VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) {
|
||||||
|
|
||||||
// TODO: This should be a runtime check of the extension's presence, no?
|
|
||||||
#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION
|
|
||||||
if (app->SessionActive) {
|
|
||||||
XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
|
XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
|
||||||
XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
|
XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
|
||||||
|
|
||||||
@ -457,7 +450,6 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) {
|
|||||||
OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, app->MainThreadTid));
|
OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, app->MainThreadTid));
|
||||||
OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, app->RenderThreadTid));
|
OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, app->RenderThreadTid));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else if (state == XR_SESSION_STATE_STOPPING) {
|
} else if (state == XR_SESSION_STATE_STOPPING) {
|
||||||
assert(app->SessionActive);
|
assert(app->SessionActive);
|
||||||
|
|
||||||
|
@ -268,25 +268,27 @@ void IN_VRInit( engine_t *engine ) {
|
|||||||
handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath);
|
handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath);
|
||||||
|
|
||||||
XrPath interactionProfilePath = XR_NULL_PATH;
|
XrPath interactionProfilePath = XR_NULL_PATH;
|
||||||
#ifdef OPENXR_PLATFORM_QUEST
|
if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) {
|
||||||
OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/oculus/touch_controller", &interactionProfilePath));
|
OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/oculus/touch_controller", &interactionProfilePath));
|
||||||
#elif OPENXR_PLATFORM_PICO
|
} else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) {
|
||||||
OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/pico/neo3_controller", &interactionProfilePath));
|
OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/pico/neo3_controller", &interactionProfilePath));
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// Map bindings
|
// Map bindings
|
||||||
XrActionSuggestedBinding bindings[32]; // large enough for all profiles
|
XrActionSuggestedBinding bindings[32]; // large enough for all profiles
|
||||||
int currBinding = 0;
|
int currBinding = 0;
|
||||||
|
|
||||||
#ifdef OPENXR_PLATFORM_QUEST
|
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger");
|
if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) {
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger");
|
bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/menu/click");
|
bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger");
|
||||||
#elif OPENXR_PLATFORM_PICO
|
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/menu/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger/click");
|
} else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) {
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger/click");
|
bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/back/click");
|
bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/right/input/back/click");
|
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/back/click");
|
||||||
#endif
|
bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/right/input/back/click");
|
||||||
|
}
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(buttonXAction, "/user/hand/left/input/x/click");
|
bindings[currBinding++] = ActionSuggestedBinding(buttonXAction, "/user/hand/left/input/x/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(buttonYAction, "/user/hand/left/input/y/click");
|
bindings[currBinding++] = ActionSuggestedBinding(buttonYAction, "/user/hand/left/input/y/click");
|
||||||
bindings[currBinding++] = ActionSuggestedBinding(buttonAAction, "/user/hand/right/input/a/click");
|
bindings[currBinding++] = ActionSuggestedBinding(buttonAAction, "/user/hand/right/input/a/click");
|
||||||
|
@ -152,9 +152,10 @@ void VR_Recenter(engine_t* engine) {
|
|||||||
// Create a default stage space to use if SPACE_TYPE_STAGE is not
|
// Create a default stage space to use if SPACE_TYPE_STAGE is not
|
||||||
// supported, or calls to xrGetReferenceSpaceBoundsRect fail.
|
// supported, or calls to xrGetReferenceSpaceBoundsRect fail.
|
||||||
spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
|
spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
|
||||||
#ifdef OPENXR_FLOOR_STAGE
|
if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR))
|
||||||
spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f;
|
{
|
||||||
#endif
|
spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f;
|
||||||
|
}
|
||||||
OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.FakeStageSpace));
|
OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.FakeStageSpace));
|
||||||
ALOGV("Created fake stage space from local space with offset");
|
ALOGV("Created fake stage space from local space with offset");
|
||||||
engine->appState.CurrentSpace = engine->appState.FakeStageSpace;
|
engine->appState.CurrentSpace = engine->appState.FakeStageSpace;
|
||||||
@ -164,9 +165,10 @@ void VR_Recenter(engine_t* engine) {
|
|||||||
spaceCreateInfo.poseInReferenceSpace.position.y = 0.0;
|
spaceCreateInfo.poseInReferenceSpace.position.y = 0.0;
|
||||||
OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.StageSpace));
|
OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.StageSpace));
|
||||||
ALOGV("Created stage space");
|
ALOGV("Created stage space");
|
||||||
#ifdef OPENXR_FLOOR_STAGE
|
if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR))
|
||||||
engine->appState.CurrentSpace = engine->appState.StageSpace;
|
{
|
||||||
#endif
|
engine->appState.CurrentSpace = engine->appState.StageSpace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update menu orientation
|
// Update menu orientation
|
||||||
@ -209,7 +211,7 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) {
|
|||||||
projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView)));
|
projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView)));
|
||||||
|
|
||||||
void* vulkanContext = nullptr;
|
void* vulkanContext = nullptr;
|
||||||
if (engine->useVulkan) {
|
if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) {
|
||||||
vulkanContext = &engine->graphicsBindingVulkan;
|
vulkanContext = &engine->graphicsBindingVulkan;
|
||||||
}
|
}
|
||||||
ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer,
|
ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer,
|
||||||
|
Loading…
Reference in New Issue
Block a user