wgpu
wgpu copied to clipboard
Fifo present mode occasionally returns VK_TIMEOUT without blocking in wgpu-rs examples on certain systems
Description
wgpu provides a 1s timeout which ends up being passed to Swapchain::acquire_next_image in ash however on my system sometimes VK_TIMEOUT will be returned within ~20-200µs when using the Fifo present mode. This occurs every few seconds for me on the wgpu-rs water example (Note: most of the examples use Mailbox by default so to test this the present mode needs to be changed).
Repro steps
Modify the example framework of wgpu-rs to use PresentMode::Fifo and to print errors from swapchain.get_current_frame(). Then run the water example and look for any timeout errors.
Expected vs observed behavior
get_current_frame() blocks until a frame is available or has a timeout error after 1 second when using Fifo.
Extra materials
Platform
OS: Manjaro 20.2.1 Nibia
Kernel: x86_64 Linux 5.10.7-3-MANJARO
DE: Xfce4
CPU: Intel Core i5-4690 @ 4x 3.9GHz
GPU: AMD Radeon HD 7900 Series (TAHITI, DRM 3.40.0, 5.10.7-3-MANJARO, LLVM 11.0.1)
drivers tested: radv, amdvlk, vulkan-amdgpu-pro
wgpu version is the git version a little bit after 0.7 release
I was also able to test on a newish intel iGPU laptop with the same OS and did not see the issue. I believe @kvark also tested on another device and the issue wasn't present. Thus, so far it seems like a quirk of this particular device/drivers.
Here is the diff for testing to see if it reproduces:
diff --git a/examples/framework.rs b/examples/framework.rs
index 69d7ed4..208916a 100644
--- a/examples/framework.rs
+++ b/examples/framework.rs
@@ -205,7 +205,7 @@ fn start<E: Example>(
format: adapter.get_swap_chain_preferred_format(&surface),
width: size.width,
height: size.height,
- present_mode: wgpu::PresentMode::Mailbox,
+ present_mode: wgpu::PresentMode::Fifo,
};
let mut swap_chain = device.create_swap_chain(&surface, &sc_desc);
@@ -280,7 +280,8 @@ fn start<E: Example>(
event::Event::RedrawRequested(_) => {
let frame = match swap_chain.get_current_frame() {
Ok(frame) => frame,
- Err(_) => {
+ Err(err) => {
+ dbg!(err);
swap_chain = device.create_swap_chain(&surface, &sc_desc);
swap_chain
.get_current_frame()
I think I'm running into the same issue. My platform:
- wgpu version: 0.12.0
- OS: Arch Linux
- Kernel: 5.17.1-arch1-1 x86_64
- Desktop environment: Gnome/Wayland
- CPU/GPU: AMD Ryzen 7 5700G with Radeon Graphics
- Driver: amdvlk
Only happens with PresentMode::Fifo. Goes away with Immediate or Mailbox.
FYI my current workaround for this is to skip the frame if this error occurs https://gitlab.com/veloren/veloren/-/blob/d9825d1d38c1d36503142a648880632871f52c58/voxygen/src/render/renderer.rs#L1088
That's good to know, thanks. I just switched to PresentMode::Mailbox, which seems to work fine on all the machines I have access to. But it might be better to specifically ignore the error.
Enabling DPMS reliably causes this timeout to happen with Intel mesa drivers on Linux.
I'm not sure if there's anything we can actually do about this in wgpu, this is something the user potentially needs to deal with.