-
Notifications
You must be signed in to change notification settings - Fork 953
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
Acquire texture: Option<std::time::Duration>
timeouts
#2724
Acquire texture: Option<std::time::Duration>
timeouts
#2724
Conversation
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 is great! One nit, but otherwise LGTM
9105c39
to
abd6f05
Compare
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.
Sorry two more nits I missed on the first pass
abd6f05
to
e982fd4
Compare
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.
Third times the charm
ah, oops I also missed removing the the |
A std::time::Duration allows for timeouts to be specified more clearly in Rust using whatever units are convenient for the caller, and an Option also makes it clearer in case no timeout is wanted, as opposed to passing a bitwise !0 as special timeout value. Notably there was an impedance mismatch with the Vulkan backend that takes a 64bit timeout in nanoseconds and uses u64::MAX to indicate no timeout and the backend was not mapping a given u32::MAX into a u64::MAX
e982fd4
to
b60aaf1
Compare
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!
Prior to Android 11 then Android's vkAcquireNextImageKHR implementation was non-conformant and didn't support timeouts and additionally would log a verbose warning if a timeout was requested. For reference this version of AcquireNextImageKHR doesn't support timeouts: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-10.0.0_r13/vulkan/libvulkan/swapchain.cpp#1426 and this version does: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-11.0.0_r45/vulkan/libvulkan/swapchain.cpp#1438 (i.e. timeout support was added in Android 11) This patch adds a dependency on the `android-properties` crate that provides a simple wrapper for the `__system_property_set` syscall so that the platform version can be read via the `ro.build.version.sdk` property and then for versions < 30 (corresponds to Android 11) any timeout given to `acquire_texture` will be ignored (and `u64::MAX` will be passed to Vulkan)
Head branch was pushed to by a user without write access
b60aaf1
to
ea233d2
Compare
btw just pushed a last second tweak to include the value of the property in the log message in case of parse failure, as suggested |
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!
Description
The Vulkan backend wasn't correctly interpreting the u32 timeout value for Surface
acquire_texture
considering the special meaning foru32::MAX
that should mean 'no timeout'.The Vulkan
vkAcquireNextImageKHR
API takes a 64bit timeout in nanoseconds andu32::MAX
timeout in milliseconds should have been converted to au64::MAX
.Prior to Android 11 then Android's
vkAcquireNextImageKHR
implementation is also non-conformant and doesn't support timeouts (and will also output verbose log messages if timeouts are given).To make the intent clearer, this updates the
acquire_texture
API to take astd::time::Duration
that allows the caller to use whatever units are convenient. Additionally the duration is wrapped in anOption
so it's clearer to see when no timeout is wanted without needing to reserve a special value to indicate this.On Android < 11 then any given timeout is now ignored (as with the egl / web / metal backends) and
u64::MAX
is always passed tovkAcquireNextImageKHR
For reference this version of AcquireNextImageKHR doesn't support timeouts: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-10.0.0_r13/vulkan/libvulkan/swapchain.cpp#1426 and this version does: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-11.0.0_r45/vulkan/libvulkan/swapchain.cpp#1438 (i.e. timeout support was added in Android 11)
Testing
I have tested this via an egui Android application I have been working on recently, and this can also be tested with this minimal winit + wgpu Android application: https://github.com/rib/agdk-rust/tree/main/examples/na-winit-wgpu and these same patches based on the 0.12 branch of wgpu: https://github.com/rib/wgpu/tree/acquire_texture_duration_timeouts_v0.12