-
Notifications
You must be signed in to change notification settings - Fork 65
Add android support #83
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
Conversation
Thanks! An initial concern: as illustrated in the linked reference, don't we also need an As I'm not qualified to review JNI esoterica myself, I'd like success reports from manual testing on android at minimum. |
Yes, in the work I'm doing on bevy I'm also sending the same Java pointers to the loader using the extension. It is easy enough to do with the function pointers and it doesn't require extra modifications to openxrs. I could also contribute it directly to openxrs (inside the entry creation call), but I should definitely have something running first (which I'm deferring because I currently don't have the software + hardware ready). |
I added This PR is now ready for review, with some caveats:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, left some comments. Please split the changes to the example out into a separate PR (or, if you're comfortable with history rewrites, maintain them in a separate commit) so that they can be easily reverted once Oculus updates their runtimes.
openxr/examples/vulkan.rs
Outdated
|
||
// Initialize OpenXR with the extensions we've found! | ||
let mut enabled_extensions = xr::ExtensionSet::default(); | ||
enabled_extensions.khr_vulkan_enable2 = true; | ||
enabled_extensions.khr_vulkan_enable = available_extensions.khr_vulkan_enable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not enable version 1 if version 2 is available. Additionally, a comment should be added documenting that the fallback path is a temporary compatibility measure for Oculus runtimes.
openxr/examples/vulkan.rs
Outdated
panic!("{}", res); | ||
} | ||
let vk_instance_exts = | ||
String::from_utf8_unchecked(buffer[0..data_len as usize - 1].to_vec()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use str::from_utf8
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this code when I add proper support for khr_vulkan_enable
.
openxr/examples/vulkan.rs
Outdated
buffer.len() as _, | ||
&mut data_len as _, | ||
&mut buffer as *mut _ as _, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the later call for device extensions) should use the proper two-call pattern and a Vec
buffer to ensure sufficient space is allocated. It's fine to copy the internal helpers to accomplish this (though we might want to consider bundling them into the sys
crate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this code when I add proper support for khr_vulkan_enable
.
I'm going to add here commits related to the implementation of the |
The Oculus Go is probably compatible with OpenXR and this crate (I'm waiting for some last reports). The problem is that it supports only Vulkan 1.0 so the example doesn't run without heavy modifications, so I'm not listing it as compatible (but it will be compatible on bevy). |
It might not be too bad to refactor the example to use the multiview extension explicitly assuming the Go implements it, but I'm just as happy to keep things more concise/modern. |
I'm ok with keeping the example on Vulkan 1.1 (without Oculus Go support). Another argument is that the cargo-apk metadata was a mashup of old and new entries for the sake of the Oculus Go support, when the user would probably decide to maintain separate Cargo.toml files for different headsets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
653152f
to
04f905e
Compare
c547de4
to
bb1f7e6
Compare
bb1f7e6
to
46c7644
Compare
I fixed the examples README with the crates.io link for cargo-apk. I think now it's all ready for merging. |
This is inspired from @blaind's work: https://github.com/blaind/bevy_openxr/blob/main/crates/bevy_openxr/src/platform/oculus_android/mod.rs
While @blaind work is known to be working, I didn't provide any testing for this code. If you want, I'm ok for waiting to have a working example before merging.