-
Notifications
You must be signed in to change notification settings - Fork 952
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
Fifo present mode occasionally returns VK_TIMEOUT without blocking in wgpu-rs examples on certain systems #1218
Comments
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:
Only happens with |
I'm running into this issue: gfx-rs/wgpu#1218 I'm not aware of any adverse effects of switching to `PresentMode::Mailbox`, except that it's "not optimal for mobile", according to the wgpu documentation. Since we don't currently support any mobile platforms, I think this is fine for now.
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 |
# Objective - Fix #3606 - Fix #4579 - Fix #3380 ## Solution When running on a Linux machine with some AMD or Intel device, when calling `surface.get_current_texture()`, ignore `wgpu::SurfaceError::Timeout` errors. ## Alternative An alternative solution found in the `wgpu` examples is: ```rust let frame = surface .get_current_texture() .or_else(|_| { render_device.configure_surface(surface, &swap_chain_descriptor); surface.get_current_texture() }) .expect("Error reconfiguring surface"); window.swap_chain_texture = Some(TextureView::from(frame)); ``` See: <https://github.com/gfx-rs/wgpu/blob/94ce76391b560a66e36df1300bd684321e57511a/wgpu/examples/framework.rs#L362-L370> Veloren [handles the Timeout error the way this PR proposes to handle it](gfx-rs/wgpu#1218 (comment)). The reason I went with this PR's solution is that `configure_surface` seems to be quite an expensive operation, and it would run every frame with the wgpu framework solution, despite the fact it works perfectly fine without `configure_surface`. I know this looks super hacky with the linux-specific line and the AMD check, but my understanding is that the `Timeout` occurrence is specific to a quirk of some AMD drivers on linux, and if otherwise met should be considered a bug. Co-authored-by: Carter Anderson <[email protected]>
Enabling DPMS reliably causes this timeout to happen with Intel mesa drivers on Linux. |
# Objective - Fix bevyengine#3606 - Fix bevyengine#4579 - Fix bevyengine#3380 ## Solution When running on a Linux machine with some AMD or Intel device, when calling `surface.get_current_texture()`, ignore `wgpu::SurfaceError::Timeout` errors. ## Alternative An alternative solution found in the `wgpu` examples is: ```rust let frame = surface .get_current_texture() .or_else(|_| { render_device.configure_surface(surface, &swap_chain_descriptor); surface.get_current_texture() }) .expect("Error reconfiguring surface"); window.swap_chain_texture = Some(TextureView::from(frame)); ``` See: <https://github.com/gfx-rs/wgpu/blob/94ce76391b560a66e36df1300bd684321e57511a/wgpu/examples/framework.rs#L362-L370> Veloren [handles the Timeout error the way this PR proposes to handle it](gfx-rs/wgpu#1218 (comment)). The reason I went with this PR's solution is that `configure_surface` seems to be quite an expensive operation, and it would run every frame with the wgpu framework solution, despite the fact it works perfectly fine without `configure_surface`. I know this looks super hacky with the linux-specific line and the AMD check, but my understanding is that the `Timeout` occurrence is specific to a quirk of some AMD drivers on linux, and if otherwise met should be considered a bug. Co-authored-by: Carter Anderson <[email protected]>
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. |
Description
wgpu
provides a 1s timeout which ends up being passed toSwapchain::acquire_next_image
inash
however on my system sometimesVK_TIMEOUT
will be returned within ~20-200µs when using the Fifo present mode. This occurs every few seconds for me on thewgpu-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 usePresentMode::Fifo
and to print errors fromswapchain.get_current_frame()
. Then run thewater
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 usingFifo
.Extra materials
Platform
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.
The text was updated successfully, but these errors were encountered: