Skip to content

Commit

Permalink
Merge pull request #18939 from lvonasek/legal-openxr-sdk
Browse files Browse the repository at this point in the history
OpenXR - Migrate to official SDK
  • Loading branch information
hrydgard authored Mar 20, 2024
2 parents fe5fd4a + 7e8319e commit a2fe2f4
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 8,574 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@
[submodule "ext/libadrenotools"]
path = ext/libadrenotools
url = https://github.com/bylaws/libadrenotools.git
[submodule "ext/OpenXR-SDK"]
path = ext/OpenXR-SDK
url = https://github.com/KhronosGroup/OpenXR-SDK.git
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")

if(OPENXR)
add_definitions(-DOPENXR)
add_library(openxr SHARED IMPORTED)
set_property(TARGET openxr PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/ext/openxr/stub/arm64-v8a/libopenxr_loader.so")
add_subdirectory(ext/OpenXR-SDK)
message("OpenXR enabled")
endif()

Expand Down Expand Up @@ -587,7 +586,7 @@ set(CommonVR
Common/VR/VRRenderer.cpp
Common/VR/VRRenderer.h
)
include_directories(ext/openxr)
include_directories(ext/OpenXR-SDK/include)

add_library(Common STATIC
${CommonX86}
Expand Down Expand Up @@ -1247,6 +1246,10 @@ set(BASISU_LIBRARIES basis_universal)
set(nativeExtra)
set(nativeExtraLibs)

if (OPENXR)
set(nativeExtraLibs ${nativeExtraLibs} openxr_loader)
endif()

if(ANDROID)
set(NativeAppSource ${NativeAppSource}
android/jni/app-android.cpp
Expand All @@ -1260,9 +1263,6 @@ if(ANDROID)
android/jni/OpenSLContext.cpp
android/jni/OpenSLContext.h
)
if (OPENXR)
set(nativeExtraLibs ${nativeExtraLibs} openxr)
endif()
# No target
elseif(IOS AND NOT LIBRETRO)
set(nativeExtra ${nativeExtra}
Expand Down
18 changes: 9 additions & 9 deletions Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
Expand All @@ -163,7 +163,7 @@
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand Down Expand Up @@ -191,7 +191,7 @@
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand Down Expand Up @@ -220,7 +220,7 @@
</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<OmitFramePointers>false</OmitFramePointers>
Expand Down Expand Up @@ -254,7 +254,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
Expand Down Expand Up @@ -285,7 +285,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -321,7 +321,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -357,7 +357,7 @@
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../ext/OpenXR-SDK/include;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Precise</FloatingPointModel>
Expand Down Expand Up @@ -1039,4 +1039,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions Common/VR/OpenXRLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ using namespace PPSSPP_VK;
#define XR_NO_PROTOTYPES 1
#endif

#include <openxr.h>
#include <openxr_platform.h>
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>

#ifdef XR_NO_PROTOTYPES

Expand Down
4 changes: 2 additions & 2 deletions Common/VR/VRFramebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) {

#ifdef ANDROID
if (app->SessionActive && VR_GetPlatformFlag(VR_PLATFORM_EXTENSION_PERFORMANCE)) {
XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_PERFORMANCE_MAX_EXT;
XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_PERFORMANCE_MAX_EXT;
XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT;

PFN_xrPerfSettingsSetPerformanceLevelEXT pfnPerfSettingsSetPerformanceLevelEXT = NULL;
OXR(xrGetInstanceProcAddr(
Expand Down
2 changes: 1 addition & 1 deletion Common/VR/VRMath.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <math.h>
#include <openxr.h>
#include <openxr/openxr.h>

#ifndef EPSILON
#define EPSILON 0.001f
Expand Down
28 changes: 14 additions & 14 deletions Common/VR/VRRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) {
}

projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView)));
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
memset(&projections[eye], 0, sizeof(XrView));
projections[eye].type = XR_TYPE_VIEW;
}

void* vulkanContext = nullptr;
if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) {
Expand All @@ -241,7 +245,7 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) {
multiview, vulkanContext);
#ifdef ANDROID
if (VR_GetPlatformFlag(VR_PLATFORM_EXTENSION_FOVEATION)) {
ovrRenderer_SetFoveation(&engine->appState.Instance, &engine->appState.Session, &engine->appState.Renderer, XR_FOVEATION_LEVEL_HIGH_TOP_FB, 0, XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_FB);
ovrRenderer_SetFoveation(&engine->appState.Instance, &engine->appState.Session, &engine->appState.Renderer, XR_FOVEATION_LEVEL_HIGH_FB, 0, XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_FB);
}
#endif

Expand Down Expand Up @@ -312,17 +316,9 @@ bool VR_InitFrame( engine_t* engine ) {
OXR(xrWaitFrame(engine->appState.Session, &waitFrameInfo, &frameState));
engine->predictedDisplayTime = frameState.predictedDisplayTime;

// Get the HMD pose, predicted for the middle of the time period during which
// the new eye images will be displayed. The number of frames predicted ahead
// depends on the pipeline depth of the engine and the synthesis rate.
// The better the prediction, the less black will be pulled in at the edges.
XrFrameBeginInfo beginFrameDesc = {};
beginFrameDesc.type = XR_TYPE_FRAME_BEGIN_INFO;
beginFrameDesc.next = NULL;
OXR(xrBeginFrame(engine->appState.Session, &beginFrameDesc));

XrViewLocateInfo projectionInfo = {};
projectionInfo.type = XR_TYPE_VIEW_LOCATE_INFO;
projectionInfo.next = NULL;
projectionInfo.viewConfigurationType = engine->appState.ViewportConfig.viewConfigurationType;
projectionInfo.displayTime = frameState.predictedDisplayTime;
projectionInfo.space = engine->appState.CurrentSpace;
Expand All @@ -339,11 +335,15 @@ bool VR_InitFrame( engine_t* engine ) {
projectionCapacityInput,
&projectionCountOutput,
projections));
if ((viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0 ||
(viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) {
return false; // There is no valid tracking poses for the views.
}

// Get the HMD pose, predicted for the middle of the time period during which
// the new eye images will be displayed. The number of frames predicted ahead
// depends on the pipeline depth of the engine and the synthesis rate.
// The better the prediction, the less black will be pulled in at the edges.
XrFrameBeginInfo beginFrameDesc = {};
beginFrameDesc.type = XR_TYPE_FRAME_BEGIN_INFO;
beginFrameDesc.next = NULL;
OXR(xrBeginFrame(engine->appState.Session, &beginFrameDesc));

fov = {};
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
Expand Down
6 changes: 3 additions & 3 deletions UWP/CommonUWP/CommonUWP.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<ClCompile>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../..;../../ext/OpenXR-SDK/include;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand All @@ -81,7 +81,7 @@
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>false</SDLCheck>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../..;../../ext/OpenXR-SDK/include;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
Expand Down Expand Up @@ -423,4 +423,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ android {
}
}
packagingOptions {
jniLibs {
excludes += ['lib/arm64-v8a/libopenxr_loader.so']
}
jniLibs.useLegacyPackaging = true
}
sourceSets {
Expand All @@ -113,7 +110,6 @@ android {
res.srcDirs = ['gold/res']
}
vr {
jniLibs.srcDirs = ['../ext/openxr/android']
manifest.srcFile 'VRManifest.xml'
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/jni/Locals.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../ext/miniupnp-build \
$(LOCAL_PATH)/../../ext/libpng17 \
$(LOCAL_PATH)/../../ext/libzip \
$(LOCAL_PATH)/../../ext/openxr \
$(LOCAL_PATH)/../../ext/OpenXR-SDK/include \
$(LOCAL_PATH)/../../ext/zstd/lib \
$(LOCAL_PATH)/../../ext/armips \
$(LOCAL_PATH)/../../ext/armips/ext/filesystem/include \
Expand Down
9 changes: 0 additions & 9 deletions android/src/org/ppsspp/ppsspp/PpssppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import androidx.documentfile.provider.DocumentFile;

import java.util.ArrayList;
import java.util.Locale;
import java.util.UUID;
import java.io.File;

Expand Down Expand Up @@ -57,14 +56,6 @@ public static void CheckABIAndLoadLibrary() {
}

static {
if (isVRDevice()) {
String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
if (manufacturer.contains("oculus")) // rename oculus to meta as this will probably happen in the future anyway
manufacturer = "meta";

//Load manufacturer specific loader
System.loadLibrary("openxr_" + manufacturer);
}
CheckABIAndLoadLibrary();
}

Expand Down
1 change: 1 addition & 0 deletions ext/OpenXR-SDK
Submodule OpenXR-SDK added at 288d3a
16 changes: 0 additions & 16 deletions ext/openxr/README.md

This file was deleted.

Binary file removed ext/openxr/android/arm64-v8a/libopenxr_meta.so
Binary file not shown.
Binary file removed ext/openxr/android/arm64-v8a/libopenxr_pico.so
Binary file not shown.
Loading

0 comments on commit a2fe2f4

Please sign in to comment.