KhronosGroup / OpenXR-SDK-Source

Sources for OpenXR loader, basic API layers, and example code.
https://khronos.org/openxr
Apache License 2.0
662 stars 246 forks source link

Why is setprop `debug.xr.graphicsPlugin` required on Android? #281

Closed daj closed 2 years ago

daj commented 2 years ago

For running the hello_xr sample code, various docs (e.g. here and here) require this manual config step:

Before running hello_xr, make sure to specify the graphic plugin to use with one of the following adb commands:

adb shell setprop debug.xr.graphicsPlugin OpenGLES
adb shell setprop debug.xr.graphicsPlugin Vulkan

To make it simpler to run the sample app, could we set a fallback default in main.cpp to avoid needing to run the adb shell setprop step? We can output a log to let the developer know that a fallback was chosen for them.

If a different graphics plugin is required for different device models (e.g. Oculus Quest 2 vs Hololens), then we could check the ro.product.name or ro.product.name system property and choose a fallback value based on the device?

I could probably create a pull request if I am given some guidance on what you would like implemented here.

utzcoz commented 2 years ago

Maybe debug.xr.graphicsPlugin is not really needed for Android now. After https://github.com/KhronosGroup/OpenXR-SDK-Source/commit/3071c9c82e2d7dcc41eb7ddc5b5ae6f9f48e0af6, there are two Android build flavors: one for OpenGLES and one for Vulkan. We can install different generated apk to test different APIs.

daj commented 2 years ago

Ok, good to know.

For now I created my own copy of the sample app in https://github.com/daj/OculusHelloXR, I updated it to not require the setprop step, and I created what I hope is a minimal set of instructions for people to follow to build and run it: https://daj.medium.com/oculus-vr-for-android-developers-a38134c759b0

rpavlik-bot commented 2 years ago

An issue (number 1633) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#1633 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

rpavlik commented 2 years ago

So the Gradle builds that are in this tree actually do have a fallback, and a configuration for each graphics plugin: ./gradlew buildVulkanDebug for example will build an APK that defaults to Vulkan if you don't setprop. There's even binaries for it in the latest release: https://github.com/KhronosGroup/OpenXR-SDK-Source/releases/tag/release-1.0.20 - see the two APK files. Does that meet your needs?

I don't have control over either of the docs you linked, unfortunately. Pico has not yet submitted their runtime's conformance tests, so their system is not officially OpenXR conformant. I'd like to get in touch with them and work with them to help fix that and their instructions but do not have a current contact. They have re-joined the working group, however, so I'm hopeful this will be cleared up soon.

The blog post is (as far as I know) still relatively accurate for Oculus, as I don't think they are yet using the unified cross-vendor loader for Android, but hopefully soon there will be no need for separate Oculus instructions.

daj commented 2 years ago

Nice, thanks for all the detailed answers! Feel free to close this issue (I left it open in case you want to use it for any of your own tracking).