Skip to content

Commit

Permalink
Ignore outdated always with linux nvidia
Browse files Browse the repository at this point in the history
  • Loading branch information
eero-lehtinen committed Mar 19, 2024
1 parent 2f5db2d commit 05e1444
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions crates/bevy_render/src/view/window/mod.rs
Expand Up @@ -304,18 +304,12 @@ pub fn prepare_windows(
})
};

// Linux Nvidia 550.54.14 driver introduced a change, where it returns
// `wgpu::SurfaceError::Outdated` after the window is resized and
// configure called. It can be ignored.
#[cfg(target_os = "linux")]
let ignore_outdated = || {
let is_nvidia = || {
render_instance
.enumerate_adapters(wgpu::Backends::VULKAN)
.iter()
.any(|adapter| {
let info = adapter.get_info();
info.name.starts_with("NVIDIA") && info.driver_info.starts_with("550")
})
.any(|adapter| adapter.get_info().name.starts_with("NVIDIA"))
};

window_surfaces.configured_windows.insert(window.entity);
Expand All @@ -325,14 +319,19 @@ pub fn prepare_windows(
Ok(frame) => {
window.set_swapchain_texture(frame);
}
#[cfg(target_os = "linux")]
Err(wgpu::SurfaceError::Outdated) if is_nvidia() => {
bevy_utils::tracing::trace!(
"Couldn't get swap chain texture. This often happens with Linux \
Nvidia 550 driver when resizing, but can be ignored."
);
}
Err(wgpu::SurfaceError::Outdated) => {
render_device.configure_surface(surface, &surface_data.configuration);
match surface.get_current_texture() {
Ok(frame) => window.set_swapchain_texture(frame),
#[cfg(target_os = "linux")]
Err(wgpu::SurfaceError::Outdated) if ignore_outdated() => {}
Err(err) => panic!("Error reconfiguring surface: {err}"),
}
let frame = surface
.get_current_texture()
.expect("Error reconfiguring surface");
window.set_swapchain_texture(frame);
}
#[cfg(target_os = "linux")]
Err(wgpu::SurfaceError::Timeout) if may_erroneously_timeout() => {
Expand Down

0 comments on commit 05e1444

Please sign in to comment.