Add a dynamic loader for OpenXR so the VR code can link. Make it all build on Windows.

This commit is contained in:
Henrik Rydgård committed 2022-11-06 15:37:58 +01:00
1 parent c44afcf462
commit 0ef39d11d8
12 files changed
+312 -77

No files matched your search

+2
View File
@@ -507,6 +507,8 @@ if(WIN32)
endif()
set(CommonVR
Common/VR/OpenXRLoader.cpp
Common/VR/OpenXRLoader.h
Common/VR/PPSSPPVR.cpp
Common/VR/PPSSPPVR.h
Common/VR/VRBase.cpp
+3 -1
View File
@@ -557,6 +557,7 @@
<ClInclude Include="UI\UIScreen.h" />
<ClInclude Include="UI\View.h" />
<ClInclude Include="UI\ViewGroup.h" />
<ClInclude Include="VR\OpenXRLoader.h" />
<ClInclude Include="VR\PPSSPPVR.h" />
<ClInclude Include="VR\VRBase.h" />
<ClInclude Include="VR\VRFramebuffer.h" />
@@ -995,6 +996,7 @@
<ClCompile Include="UI\UIScreen.cpp" />
<ClCompile Include="UI\View.cpp" />
<ClCompile Include="UI\ViewGroup.cpp" />
<ClCompile Include="VR\OpenXRLoader.cpp" />
<ClCompile Include="VR\PPSSPPVR.cpp" />
<ClCompile Include="VR\VRBase.cpp" />
<ClCompile Include="VR\VRFramebuffer.cpp" />
@@ -1015,4 +1017,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+7 -1
View File
@@ -443,6 +443,9 @@
<ClInclude Include="VR\VRRenderer.h">
<Filter>VR</Filter>
</ClInclude>
<ClInclude Include="VR\OpenXRLoader.h">
<Filter>VR</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ABI.cpp" />
@@ -839,6 +842,9 @@
<ClCompile Include="VR\VRRenderer.cpp">
<Filter>VR</Filter>
</ClCompile>
<ClCompile Include="VR\OpenXRLoader.cpp">
<Filter>VR</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Crypto">
@@ -952,4 +958,4 @@
<Filter>ext\libpng17</Filter>
</Text>
</ItemGroup>
</Project>
</Project>
+160
View File
@@ -0,0 +1,160 @@
#include "Common/VR/OpenXRLoader.h"
#ifdef _WIN32
#include "Common/CommonWindows.h"
#endif
#ifdef XR_NO_PROTOTYPES
PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr;
PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties;
PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties;
PFN_xrCreateInstance xrCreateInstance;
PFN_xrDestroyInstance xrDestroyInstance;
PFN_xrGetInstanceProperties xrGetInstanceProperties;
PFN_xrPollEvent xrPollEvent;
PFN_xrResultToString xrResultToString;
PFN_xrStructureTypeToString xrStructureTypeToString;
PFN_xrGetSystem xrGetSystem;
PFN_xrGetSystemProperties xrGetSystemProperties;
PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes;
PFN_xrCreateSession xrCreateSession;
PFN_xrDestroySession xrDestroySession;
PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces;
PFN_xrCreateReferenceSpace xrCreateReferenceSpace;
PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect;
PFN_xrCreateActionSpace xrCreateActionSpace;
PFN_xrLocateSpace xrLocateSpace;
PFN_xrDestroySpace xrDestroySpace;
PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations;
PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties;
PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews;
PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats;
PFN_xrCreateSwapchain xrCreateSwapchain;
PFN_xrDestroySwapchain xrDestroySwapchain;
PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages;
PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage;
PFN_xrWaitSwapchainImage xrWaitSwapchainImage;
PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage;
PFN_xrBeginSession xrBeginSession;
PFN_xrEndSession xrEndSession;
PFN_xrRequestExitSession xrRequestExitSession;
PFN_xrWaitFrame xrWaitFrame;
PFN_xrBeginFrame xrBeginFrame;
PFN_xrEndFrame xrEndFrame;
PFN_xrLocateViews xrLocateViews;
PFN_xrStringToPath xrStringToPath;
PFN_xrPathToString xrPathToString;
PFN_xrCreateActionSet xrCreateActionSet;
PFN_xrDestroyActionSet xrDestroyActionSet;
PFN_xrCreateAction xrCreateAction;
PFN_xrDestroyAction xrDestroyAction;
PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings;
PFN_xrAttachSessionActionSets xrAttachSessionActionSets;
PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile;
PFN_xrGetActionStateBoolean xrGetActionStateBoolean;
PFN_xrGetActionStateFloat xrGetActionStateFloat;
PFN_xrGetActionStateVector2f xrGetActionStateVector2f;
PFN_xrGetActionStatePose xrGetActionStatePose;
PFN_xrSyncActions xrSyncActions;
PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction;
PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName;
PFN_xrApplyHapticFeedback xrApplyHapticFeedback;
PFN_xrStopHapticFeedback xrStopHapticFeedback;
#ifdef _WIN32
#define dlsym(x, y) GetProcAddress(x, y)
static HMODULE g_xrLibrary;
#else
#define dlsym(x, y) nullptr
void *xrLibrary;
#endif
#define LOAD_INSTANCE_FUNC(name) (PFN_ ## name)xrGetInstanceProcAddr(instance, #name, (PFN_xrVoidFunction *)(&name))
bool XRLoad() {
if (g_xrLibrary) {
// Already loaded. That's OK.
return true;
}
#ifdef _WIN32
g_xrLibrary = LoadLibrary(L"openxr_loader.dll");
if (!g_xrLibrary) {
return false;
}
#else
void *library = nullptr;
#endif
// Load the three basic functions.
xrGetInstanceProcAddr = (PFN_xrGetInstanceProcAddr)dlsym(g_xrLibrary, "xrGetInstanceProcAddr");
xrEnumerateApiLayerProperties = (PFN_xrEnumerateApiLayerProperties)dlsym(g_xrLibrary, "xrEnumerateApiLayerProperties");
xrEnumerateInstanceExtensionProperties = (PFN_xrEnumerateInstanceExtensionProperties)dlsym(g_xrLibrary, "xrEnumerateInstanceExtensionProperties");
// Load the rest.
return true;
}
void XRLoadInstanceFunctions(XrInstance instance) {
LOAD_INSTANCE_FUNC(xrCreateInstance);
LOAD_INSTANCE_FUNC(xrGetInstanceProcAddr);
LOAD_INSTANCE_FUNC(xrEnumerateApiLayerProperties);
LOAD_INSTANCE_FUNC(xrEnumerateInstanceExtensionProperties);
LOAD_INSTANCE_FUNC(xrCreateInstance);
LOAD_INSTANCE_FUNC(xrDestroyInstance);
LOAD_INSTANCE_FUNC(xrGetInstanceProperties);
LOAD_INSTANCE_FUNC(xrPollEvent);
LOAD_INSTANCE_FUNC(xrResultToString);
LOAD_INSTANCE_FUNC(xrStructureTypeToString);
LOAD_INSTANCE_FUNC(xrGetSystem);
LOAD_INSTANCE_FUNC(xrGetSystemProperties);
LOAD_INSTANCE_FUNC(xrEnumerateEnvironmentBlendModes);
LOAD_INSTANCE_FUNC(xrCreateSession);
LOAD_INSTANCE_FUNC(xrDestroySession);
LOAD_INSTANCE_FUNC(xrEnumerateReferenceSpaces);
LOAD_INSTANCE_FUNC(xrCreateReferenceSpace);
LOAD_INSTANCE_FUNC(xrGetReferenceSpaceBoundsRect);
LOAD_INSTANCE_FUNC(xrCreateActionSpace);
LOAD_INSTANCE_FUNC(xrLocateSpace);
LOAD_INSTANCE_FUNC(xrDestroySpace);
LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurations);
LOAD_INSTANCE_FUNC(xrGetViewConfigurationProperties);
LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurationViews);
LOAD_INSTANCE_FUNC(xrEnumerateSwapchainFormats);
LOAD_INSTANCE_FUNC(xrCreateSwapchain);
LOAD_INSTANCE_FUNC(xrDestroySwapchain);
LOAD_INSTANCE_FUNC(xrEnumerateSwapchainImages);
LOAD_INSTANCE_FUNC(xrAcquireSwapchainImage);
LOAD_INSTANCE_FUNC(xrWaitSwapchainImage);
LOAD_INSTANCE_FUNC(xrReleaseSwapchainImage);
LOAD_INSTANCE_FUNC(xrBeginSession);
LOAD_INSTANCE_FUNC(xrEndSession);
LOAD_INSTANCE_FUNC(xrRequestExitSession);
LOAD_INSTANCE_FUNC(xrWaitFrame);
LOAD_INSTANCE_FUNC(xrBeginFrame);
LOAD_INSTANCE_FUNC(xrEndFrame);
LOAD_INSTANCE_FUNC(xrLocateViews);
LOAD_INSTANCE_FUNC(xrStringToPath);
LOAD_INSTANCE_FUNC(xrPathToString);
LOAD_INSTANCE_FUNC(xrCreateActionSet);
LOAD_INSTANCE_FUNC(xrDestroyActionSet);
LOAD_INSTANCE_FUNC(xrCreateAction);
LOAD_INSTANCE_FUNC(xrDestroyAction);
LOAD_INSTANCE_FUNC(xrSuggestInteractionProfileBindings);
LOAD_INSTANCE_FUNC(xrAttachSessionActionSets);
LOAD_INSTANCE_FUNC(xrGetCurrentInteractionProfile);
LOAD_INSTANCE_FUNC(xrGetActionStateBoolean);
LOAD_INSTANCE_FUNC(xrGetActionStateFloat);
LOAD_INSTANCE_FUNC(xrGetActionStateVector2f);
LOAD_INSTANCE_FUNC(xrGetActionStatePose);
LOAD_INSTANCE_FUNC(xrSyncActions);
LOAD_INSTANCE_FUNC(xrEnumerateBoundSourcesForAction);
LOAD_INSTANCE_FUNC(xrGetInputSourceLocalizedName);
LOAD_INSTANCE_FUNC(xrApplyHapticFeedback);
LOAD_INSTANCE_FUNC(xrStopHapticFeedback);
// TODO: Load any extensions we need, too.
}
#endif
+109
View File
@@ -0,0 +1,109 @@
#pragma once
//Vulkan
#ifdef VK_USE_NATIVE_LIB
#include <vulkan/vulkan.h>
#else
#include "Common/GPU/Vulkan/VulkanLoader.h"
using namespace PPSSPP_VK;
#endif
#ifdef ANDROID
//OpenXR
#define XR_USE_PLATFORM_ANDROID 1
#define XR_USE_GRAPHICS_API_OPENGL_ES 1
#define XR_USE_GRAPHICS_API_VULKAN 1
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <jni.h>
#elif defined(_WIN32)
#include "Common/CommonWindows.h"
#include "Common/GPU/OpenGL/GLCommon.h"
#include "Common/VR/OpenXRLoader.h"
#include <unknwn.h>
#define XR_USE_PLATFORM_WIN32 1
#define XR_USE_GRAPHICS_API_OPENGL 1
#define XR_USE_GRAPHICS_API_VULKAN 1
#define XR_NO_PROTOTYPES 1
#else
#define XR_USE_GRAPHICS_API_VULKAN 1
#define XR_NO_PROTOTYPES 1
#endif
#include <openxr.h>
#include <openxr_platform.h>
#ifdef XR_NO_PROTOTYPES
extern PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr;
extern PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties;
extern PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties;
extern PFN_xrCreateInstance xrCreateInstance;
extern PFN_xrDestroyInstance xrDestroyInstance;
extern PFN_xrGetInstanceProperties xrGetInstanceProperties;
extern PFN_xrPollEvent xrPollEvent;
extern PFN_xrResultToString xrResultToString;
extern PFN_xrStructureTypeToString xrStructureTypeToString;
extern PFN_xrGetSystem xrGetSystem;
extern PFN_xrGetSystemProperties xrGetSystemProperties;
extern PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes;
extern PFN_xrCreateSession xrCreateSession;
extern PFN_xrDestroySession xrDestroySession;
extern PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces;
extern PFN_xrCreateReferenceSpace xrCreateReferenceSpace;
extern PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect;
extern PFN_xrCreateActionSpace xrCreateActionSpace;
extern PFN_xrLocateSpace xrLocateSpace;
extern PFN_xrDestroySpace xrDestroySpace;
extern PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations;
extern PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties;
extern PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews;
extern PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats;
extern PFN_xrCreateSwapchain xrCreateSwapchain;
extern PFN_xrDestroySwapchain xrDestroySwapchain;
extern PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages;
extern PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage;
extern PFN_xrWaitSwapchainImage xrWaitSwapchainImage;
extern PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage;
extern PFN_xrBeginSession xrBeginSession;
extern PFN_xrEndSession xrEndSession;
extern PFN_xrRequestExitSession xrRequestExitSession;
extern PFN_xrWaitFrame xrWaitFrame;
extern PFN_xrBeginFrame xrBeginFrame;
extern PFN_xrEndFrame xrEndFrame;
extern PFN_xrLocateViews xrLocateViews;
extern PFN_xrStringToPath xrStringToPath;
extern PFN_xrPathToString xrPathToString;
extern PFN_xrCreateActionSet xrCreateActionSet;
extern PFN_xrDestroyActionSet xrDestroyActionSet;
extern PFN_xrCreateAction xrCreateAction;
extern PFN_xrDestroyAction xrDestroyAction;
extern PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings;
extern PFN_xrAttachSessionActionSets xrAttachSessionActionSets;
extern PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile;
extern PFN_xrGetActionStateBoolean xrGetActionStateBoolean;
extern PFN_xrGetActionStateFloat xrGetActionStateFloat;
extern PFN_xrGetActionStateVector2f xrGetActionStateVector2f;
extern PFN_xrGetActionStatePose xrGetActionStatePose;
extern PFN_xrSyncActions xrSyncActions;
extern PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction;
extern PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName;
extern PFN_xrApplyHapticFeedback xrApplyHapticFeedback;
extern PFN_xrStopHapticFeedback xrStopHapticFeedback;
// Dynamic loader for OpenXR on desktop platforms.
// On Quest/Pico, we use statically linked loaders provided by the platform owners.
// On Windows (and Linux etc), we're not so lucky - we could link to static libraries, but we really
// don't want to as we still want to function when one is not present.
//
// Similar to our dynamic Vulkan loader.
bool XRLoad();
void XRLoadInstanceFunctions(XrInstance instance);
#else
inline bool XRLoad() { return true; }
inline void XRLoadInstanceFunctions(XrInstance instance) {}
#endif
+10 -8
View File
@@ -1,5 +1,3 @@
#ifdef OPENXR
#include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/GPU/Vulkan/VulkanContext.h"
@@ -396,6 +394,12 @@ void* BindVRFramebuffer() {
return VR_BindFramebuffer(VR_GetEngine());
}
inline float clampFloat(float x, float minValue, float maxValue) {
if (x < minValue) return minValue;
if (x > maxValue) return maxValue;
return x;
}
bool StartVRRender() {
if (!VR_GetConfig(VR_CONFIG_VIEWPORT_VALID)) {
VR_InitRenderer(VR_GetEngine(), IsMultiviewSupported());
@@ -430,8 +434,8 @@ bool StartVRRender() {
height = 0;
side = 0;
}
g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f);
g_Config.fCameraSide = std::clamp(side, -10.0f, 10.0f);
g_Config.fCameraHeight = clampFloat(height, -10.0f, 10.0f);
g_Config.fCameraSide = clampFloat(side, -10.0f, 10.0f);
//right joystick controls distance and fov
float dst = g_Config.fCameraDistance;
@@ -445,8 +449,8 @@ bool StartVRRender() {
fov = 100;
dst = 0;
}
g_Config.fCameraDistance = std::clamp(dst, -10.0f, 10.0f);
g_Config.fFieldOfViewPercentage = std::clamp(fov, 100.0f, 200.0f);
g_Config.fCameraDistance = clampFloat(dst, -10.0f, 10.0f);
g_Config.fFieldOfViewPercentage = clampFloat(fov, 100.0f, 200.0f);
}
// Set customizations
@@ -599,5 +603,3 @@ void UpdateVRView(float* leftEye, float* rightEye) {
memcpy(dst[index], renderView.M, 16 * sizeof(float));
}
}
#endif
-33
View File
@@ -17,8 +17,6 @@ enum VRCompatFlag {
VR_COMPAT_MAX
};
#ifdef OPENXR
// VR app flow integration
bool IsVREnabled();
void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name);
@@ -45,34 +43,3 @@ bool Is2DVRObject(float* projMatrix, bool ortho);
void UpdateVRParams(float* projMatrix);
void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye);
void UpdateVRView(float* leftEye, float* rightEye);
#else //dummy integration
// VR app flow integration
inline bool IsVREnabled() { return false; }
inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name) {}
inline void EnterVR(bool firstTime, void* vulkanContext) {}
inline void GetVRResolutionPerEye(int* width, int* height) {}
inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {}
inline void UpdateVRSpecialKeys(const KeyInput &key) {}
// VR games compatibility
inline void PreprocessStepVR(void* step) {}
inline void SetVRCompat(VRCompatFlag flag, long value) {}
// VR rendering integration
inline void* BindVRFramebuffer() { return nullptr; }
inline bool StartVRRender() { return false; }
inline void FinishVRRender() {}
inline void PreVRFrameRender(int fboIndex) {}
inline void PostVRFrameRender() {}
inline int GetVRFBOIndex() { return 0; }
inline int GetVRPassesCount() { return 1; }
inline bool IsMultiviewSupported() { return false; }
inline bool IsFlatVRScene() { return true; }
inline bool Is2DVRObject(float* projMatrix, bool ortho) { return false; }
inline void UpdateVRParams(float* projMatrix) {}
inline void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) {}
inline void UpdateVRView(float* leftEye, float* rightEye) {}
#endif
+15 -5
View File
@@ -41,12 +41,14 @@ static bool vr_platform[VR_PLATFORM_MAX];
static engine_t vr_engine;
int vr_initialized = 0;
#if defined(OPENXR)
void VR_Init( void* system, const char* name, int version ) {
if (vr_initialized)
return;
if (!XRLoad()) {
return;
}
ovrApp_Clear(&vr_engine.appState);
#ifdef ANDROID
@@ -68,9 +70,12 @@ void VR_Init( void* system, const char* name, int version ) {
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
} else {
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME);
#endif
}
extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME);
#ifdef ANDROID
if (VR_GetPlatformFlag(VR_PLATFORM_PERFORMANCE_EXT)) {
extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME);
@@ -83,6 +88,7 @@ void VR_Init( void* system, const char* name, int version ) {
extensions.push_back("XR_PICO_configs_ext");
extensions.push_back("XR_PICO_reset_sensor");
}
#endif
// Create the OpenXR instance.
XrApplicationInfo appInfo;
@@ -101,7 +107,7 @@ void VR_Init( void* system, const char* name, int version ) {
instanceCreateInfo.applicationInfo = appInfo;
instanceCreateInfo.enabledApiLayerCount = 0;
instanceCreateInfo.enabledApiLayerNames = NULL;
instanceCreateInfo.enabledExtensionCount = extensions.size();
instanceCreateInfo.enabledExtensionCount = (uint32_t)extensions.size();
instanceCreateInfo.enabledExtensionNames = extensions.data();
#ifdef ANDROID
@@ -121,6 +127,8 @@ void VR_Init( void* system, const char* name, int version ) {
exit(1);
}
XRLoadInstanceFunctions(vr_engine.appState.Instance);
if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) {
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico));
xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico));
@@ -166,6 +174,7 @@ void VR_Init( void* system, const char* name, int version ) {
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR;
OXR(pfnGetVulkanGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements));
} else {
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL;
OXR(xrGetInstanceProcAddr(
vr_engine.appState.Instance,
@@ -175,15 +184,16 @@ void VR_Init( void* system, const char* name, int version ) {
XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {};
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR;
OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements));
#endif
}
#ifdef ANDROID
vr_engine.appState.MainThreadTid = gettid();
#endif
vr_engine.appState.SystemId = systemId;
vr_initialized = 1;
}
#endif
void VR_Destroy( engine_t* engine ) {
if (engine == &vr_engine) {
if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) {
+3 -29
View File
@@ -10,36 +10,10 @@
#define ALOGV(...) printf(__VA_ARGS__)
#endif
//Vulkan
#ifdef VK_USE_NATIVE_LIB
#include <vulkan/vulkan.h>
#else
#include "Common/GPU/Vulkan/VulkanLoader.h"
using namespace PPSSPP_VK;
#endif
#include "Common/VR/OpenXRLoader.h"
#ifdef ANDROID
//OpenXR
#define XR_USE_PLATFORM_ANDROID 1
#define XR_USE_GRAPHICS_API_OPENGL_ES 1
#define XR_USE_GRAPHICS_API_VULKAN 1
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <jni.h>
#elif defined(_WIN32)
#include "Common/CommonWindows.h"
#include "Common/GPU/OpenGL/GLCommon.h"
#include <unknwn.h>
#define XR_USE_PLATFORM_WIN32 1
#define XR_USE_GRAPHICS_API_OPENGL 1
#define XR_USE_GRAPHICS_API_VULKAN 1
#else
#define XR_USE_GRAPHICS_API_VULKAN 1
#endif
#include <math.h>
#include <openxr.h>
#include <openxr_platform.h>
#define _USE_MATH_DEFINES
#include <cmath>
#ifdef ANDROID
+1
View File
@@ -4,6 +4,7 @@
#include "VRBase.h"
#include "VRInput.h"
#include "VRRenderer.h"
#include "OpenXRLoader.h"
#include <cassert>
#include <cstdlib>
+1
View File
@@ -72,6 +72,7 @@ SPIRV_CROSS_FILES := \
$(SRC)/ext/SPIRV-Cross/spirv_cross_parsed_ir.cpp
VR_FILES := \
$(SRC)/Common/VR/OpenXRLoader.cpp \
$(SRC)/Common/VR/PPSSPPVR.cpp \
$(SRC)/Common/VR/VRBase.cpp \
$(SRC)/Common/VR/VRFramebuffer.cpp \
+1
View File
@@ -314,6 +314,7 @@ SOURCES_CXX += \
$(COMMONDIR)/TimeUtil.cpp
SOURCES_CXX += \
$(COMMONDIR)/VR/OpenXRLoader.cpp \
$(COMMONDIR)/VR/PPSSPPVR.cpp \
$(COMMONDIR)/VR/VRBase.cpp \
$(COMMONDIR)/VR/VRMath.cpp \