Skip to content

Commit 0b8f82e

Browse files
committed
Add OpenXR + Wgpu example
This tests being able to write an OpenXR application based on Wgpu (using the Vulkan HAL backend) for the Oculus Quest.
1 parent fe1ff40 commit 0b8f82e

29 files changed

+1858
-11
lines changed

agdk-oboe/.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

na-openxr-info/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,31 @@ To build for the Oculus Quest then you first need to download
1111
the Oculus OpenXR Mobile SDK from:
1212
https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/
1313

14-
unpack the zip file and then set the OVR_OPENXR_LIBDIR environment variable
15-
to point at the directory with libopenxr_loader.so
14+
and after unpacking the zip file you need to copy a suitable `libopenxr_loader.so`
15+
library to `app/src/main/jniLibs/<abi>`
16+
17+
For example if building for arm64-v8a:
18+
`cp path/to/ovr_openxr_mobile_sdk_42.0/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so app/src/main/jniLibs/arm64-v8a`
1619

1720
```
18-
export export OVR_OPENXR_LIBDIR="path/to/ovr_openxr_mobile_sdk_42.0/OpenXR/Libs/Android/arm64-v8a/Debug"
1921
export ANDROID_NDK_HOME="path/to/ndk"
2022
export ANDROID_HOME="path/to/sdk"
2123
2224
rustup target add aarch64-linux-android
2325
cargo install cargo-ndk
2426
25-
cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ build --features=android
27+
cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ build
2628
./gradlew build
2729
./gradlew installDebug
2830
```
2931

32+
# Oculus Quest: Vulkan Validation Layer
33+
34+
To enable the Vulkan validation layer on the Oculus Quest run:
35+
```
36+
adb shell setprop debug.oculus.loadandinjectpackagedvvl.co.realfit.naopenxrwgpu 1
37+
```
38+
3039
# Desktop
3140

3241
To build for PC you need to build with the "desktop" feature

na-openxr-info/build.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
fn main()
2-
{
1+
fn main() {
32
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
4-
println!("cargo:rustc-link-search={:}", std::env::var("OVR_OPENXR_LIBDIR").unwrap());
3+
let android_abi = match std::env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() {
4+
"aarch64" => "arm64-v8a",
5+
"arm" => "armeabi-v7a",
6+
"x86" => "x86",
7+
"x86_64" => "x86_64",
8+
arch => {
9+
panic!("Unsupported architecture for Android {arch}");
10+
}
11+
};
12+
13+
let libdir = std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
14+
.join(format!("app/src/main/jniLibs/{android_abi}/lib"));
15+
println!("cargo:rustc-link-search={}", libdir.to_string_lossy());
516
}
6-
}
17+
}

na-openxr-info/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
///! Based on https://github.com/Ralith/openxrs/blob/master/openxr/examples/hello.rs
2-
32
use openxr as xr;
43

54
#[cfg(target_os = "android")]
@@ -77,4 +76,4 @@ fn main() {
7776
.init();
7877

7978
_main();
80-
}
79+
}

na-openxr-wgpu/.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
*.so
17+
18+
19+
# Added by cargo
20+
21+
/target
22+
Cargo.lock

na-openxr-wgpu/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

na-openxr-wgpu/.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

na-openxr-wgpu/.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

na-openxr-wgpu/.idea/misc.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

na-openxr-wgpu/.idea/vcs.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)