Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Khronos' OpenXR loader from Maven when supported #1405

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ git clone https://github.com/Igalia/wolvic-third-parties.git third_party

This repo is only available to Igalia members. If you have access to the relevant SDK but not this repo, you can manually place them here:

- `third_party/ovr_mobile/` for Oculus (should contain a `VrApi` folder)
- `third_party/OVRPlatformSDK/` for Oculus (should contain a `Android` and `include` folders)
- `third_party/ovr_openxr_mobile_sdk/` for Oculus (should contain an `OpenXR` folder)
- `third_party/hvr/` for Huawei (should contain `arm64-v8a`, `armeabi-v7a` and `include` folders)
- `third_party/wavesdk/` for Vive (should contain a `build` folder, among other things)
- `third_party/picoxr` [Pico OpenXR Mobile SDK](https://developer-global.pico-interactive.com/sdk?deviceId=1&platformId=3&itemId=11) (should contain `include` and `libs` folders, among other things that are not necessary for Wolvic)
- `third_party/lynx` [for Lynx](https://portal.lynx-r.com)(should contain a `loader-release.aar` file)
- `third_party/picoxr` [Pico OpenXR Mobile SDK](https://developer-global.pico-interactive.com/sdk?deviceId=1&platformId=3&itemId=11) (should contain `libs` folders, among other things that are not necessary for Wolvic)
- `third_party/spaces` [for Snapdragon Spaces](https://spaces.qualcomm.com/)(should contain `libopenxr_loader.aar`)
- `third_party/OpenXR-SDK/` [OpenXR-SDK](https://github.com/KhronosGroup/OpenXR-SDK) (should contain an `include` folder)
- `third_party/OpenXR-SDK/` [OpenXR-SDK](https://github.com/KhronosGroup/OpenXR-SDK) (should contain an `include` folder). This is used by HVR and PicoXR flavours. The other flavours using OpenXR use the include files provided by the Khronos OpenXR loader AAR from Maven.
- `third_party/aliceimu/` for [Huawei Vision Glass](https://consumer.huawei.com/cn/wearables/vision-glass/) (should contain an `.aar` file with the IMU library for the glasses)

The [repo in `third_party`](https://github.com/Igalia/wolvic-third-parties) can be updated like so:
Expand Down
52 changes: 13 additions & 39 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,41 +88,30 @@ target_sources(

include(AndroidNdkModules)
android_ndk_import_module_native_app_glue()
target_link_libraries(native-lib native_app_glue)
target_link_libraries(native-lib PRIVATE native_app_glue)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
endif()


if(OPENXR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXR_USE_PLATFORM_ANDROID -DXR_USE_GRAPHICS_API_OPENGL_ES")
include_directories(
${CMAKE_SOURCE_DIR}/../third_party/OpenXR-SDK/include
${CMAKE_SOURCE_DIR}/../app/src/openxr/cpp
)
if (OCULUSVR)
include_directories(
${CMAKE_SOURCE_DIR}/../third_party/OVRPlatformSDK/Include
)
add_custom_command(TARGET native-lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/../third_party/ovr_openxr_mobile_sdk/OpenXR/Libs/Android/${ANDROID_ABI}/Release/libopenxr_loader.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopenxr_loader.so
)
elseif (HVR)
find_package(OpenXR REQUIRED CONFIG)
include_directories(${CMAKE_SOURCE_DIR}/../app/src/openxr/cpp)
if (HVR)
include_directories(${CMAKE_SOURCE_DIR}/../third_party/OpenXR-SDK/include)
add_custom_command(TARGET native-lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/../third_party/hvr/${ANDROID_ABI}/libxr_loader.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libxr_loader.so
)
elseif (PICOXR)
include_directories(
${CMAKE_SOURCE_DIR}/../third_party/picoxr/include
)
include_directories(${CMAKE_SOURCE_DIR}/../third_party/OpenXR-SDK/include)
add_custom_command(TARGET native-lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/../third_party/picoxr/libs/android.${ANDROID_ABI}/libopenxr_loader.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopenxr_loader.so
)
else ()
target_link_libraries(native-lib PRIVATE OpenXR::openxr_loader)
endif ()
target_sources(
native-lib
Expand All @@ -140,6 +129,7 @@ if(OPENXR)
endif()

if(OCULUSVR)
include_directories(${CMAKE_SOURCE_DIR}/../third_party/OVRPlatformSDK/Include)
add_custom_command(TARGET native-lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/../third_party/OVRPlatformSDK/Android/libs/${ANDROID_ABI}/libovrplatformloader.so
Expand All @@ -161,10 +151,6 @@ find_library( # Sets the name of the path variable.
android-lib
android )

add_library(oculusvr-lib SHARED IMPORTED)
set_target_properties(oculusvr-lib PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../third_party/ovr_openxr_mobile_sdk/OpenXR/Libs/Android/${ANDROID_ABI}/Release/libopenxr_loader.so )

add_library(ovrplatform-lib SHARED IMPORTED)
set_target_properties(ovrplatform-lib PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../third_party/OVRPlatformSDK/Android/libs/${ANDROID_ABI}/libovrplatformloader.so )
Expand All @@ -181,22 +167,10 @@ add_library(picoxr-lib SHARED IMPORTED)
set_target_properties(picoxr-lib PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../third_party/picoxr/libs/android.${ANDROID_ABI}/libopenxr_loader.so)

if (LYNX OR SPACES)
if(SPACES)
find_package(loader REQUIRED CONFIG)
target_link_libraries(native-lib loader::openxr_loader)
endif()

if (AOSP)
# Each module in an Android project can link to only one CMake or ndk-build script file. Given
# that we already have the native-lib, we need to add other the OpenXR loaded CMake project
#to the top level CMakeLists.txt file, i.e., this one.
set(lib_src_DIR ${CMAKE_SOURCE_DIR}/../third_party/OpenXR-SDK)
set(lib_build_DIR ${CMAKE_SOURCE_DIR}/../third_party/OpenXR-SDK/build)
file(MAKE_DIRECTORY ${lib_build_DIR})

add_subdirectory(${lib_src_DIR} ${lib_build_DIR})
target_link_libraries(native-lib openxr_loader)
endif()
target_link_libraries(native-lib PRIVATE loader::openxr_loader)
endif ()

# Add dependency on tinygltf library, which is used to load hand models
# from .glb assets. Since it is only a single C++ source and header,
Expand All @@ -212,7 +186,7 @@ include_directories(
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
native-lib
native-lib PRIVATE
vrb

# Link VR_SDK_LIB exported from gradle flavors
Expand Down
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ android {
externalNativeBuild {
cmake {
cppFlags "-DOCULUSVR -DOPENXR"
arguments "-DVR_SDK_LIB=oculusvr-lib", "-DVR_SDK_EXTRA_LIB=ovrplatform-lib", "-DOCULUSVR=ON", "-DOPENXR=ON"
arguments "-DVR_SDK_EXTRA_LIB=ovrplatform-lib", "-DOCULUSVR=ON", "-DOPENXR=ON"
}
}
manifestPlaceholders = [ headtrackingRequired:"false", permissionToRemove:"android.permission.RECEIVE_BOOT_COMPLETED" ]
Expand Down Expand Up @@ -683,6 +683,8 @@ dependencies {
implementation deps.work.runtime
implementation deps.work.runtime_ktx

// OpenXR standard loader
implementation 'org.khronos.openxr:openxr_loader_for_android:1.0.34'

// Testing
androidTestImplementation deps.atsl.runner
Expand Down Expand Up @@ -714,9 +716,6 @@ dependencies {
hvrImplementation 'com.huawei.hms:location:6.2.0.300'
hvrImplementation 'com.huawei.hms:push:6.5.0.300'

// Lynx
lynxImplementation fileTree(dir: "${project.rootDir}/third_party/lynx", include: ['*.aar'])

// Snapdragon Spaces
spacesImplementation fileTree(dir: "${project.rootDir}/third_party/spaces", include: ['*.aar'])

Expand Down