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

[wgpu-hal] fall back from broken VK_KHR_timeline_semaphore impls. #3693

Closed
wants to merge 1 commit into from

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Apr 15, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories

Description
I encountered this while testing an wgpu example on the Oculus Quest 2, but the important part is this:

04-14 14:43:26.051 11925 11925 W Thread-1: type=1400 audit(0.0:321): avc: denied { ioctl } for path="/dev/kgsl-3d0" dev="tmpfs" ino=1206 ioctlcmd=0x958 scontext=u:r:untrusted_app:s0:c94,c256,c512,c768 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=0
...
04-14 14:43:26.054 11925 11950 I AdrenoVK-0: QUALCOMM build          : d66bb48e17, I18aabff2be
04-14 14:43:26.054 11925 11950 I AdrenoVK-0: Build Date              : 11/28/22
...
04-14 14:43:26.057 11925 11950 D wgpu_hal::vulkan::ada..: Supported extensions: ["VK_KHR_swapchain", "VK_KHR_image_format_list", "VK_KHR_imageless_framebuffer", "VK_KHR_driver_properties", "VK_KHR_timeline_semaphore", "VK_EXT_image_robustness", "VK_EXT_robustness2"]
04-14 14:43:26.059 11925 11950 W wgpu_hal::vulkan: Unrecognized device error ERROR_INITIALIZATION_FAILED
04-15 10:42:47.264 11611 11635 E wgpu::backend::direct: Error in Adapter::request_device: Not enough memory left

So my understanding is roughly as follows:

  • Oculus Quest 2's latest update includes an AdrenoVK version that advertises VK_KHR_timeline_semaphore
  • calling VkCreateSemaphore to use the extension fails due to SELinux(?) rules not having been updated
  • before this PR: VkCreateSemaphore failing w/ ERROR_INITIALIZATION_FAILED leads to wgpu::Adapter::request_device returning Err(RequestDeviceError)
  • after this PR: that specific error is special-cased and the fallback (fence pool) implementation is used
    • more logging would probably be a good idea, also treating unknown errors as "out of memory" seems wrong?

Testing
The same wgpu-using demo that failed with the above, works with this change, and as expected it logs:

04-15 11:11:13.472 13889 13915 W wgpu_hal::vulkan::dev..: `VkCreateSemaphore` failed with `ERROR_INITIALIZATION_FAILED`, falling back to fence pool

let raw = unsafe { self.shared.raw.create_semaphore(&vk_info, None) };
match raw {
Ok(raw) => super::Fence::TimelineSemaphore(raw),
Err(err @ vk::Result::ERROR_INITIALIZATION_FAILED) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you link back to the issue explaining why this is needed?

match raw {
Ok(raw) => super::Fence::TimelineSemaphore(raw),
Err(err @ vk::Result::ERROR_INITIALIZATION_FAILED) => {
log::warn!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually isn't really a warning, it's at most an info, maybe even a debug. The user can't do anything about it, and it has absolutely no effect on the user either.

@cwfitzgerald
Copy link
Member

Poke from triage

@cwfitzgerald
Copy link
Member

As this MR is currently stale, I'm going to close it for triage purposes. Please feel-free to re-open there is renewed interest in landing these changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants