Skip to content

Commit

Permalink
Fix crashing on outdated error with Nvidia 550
Browse files Browse the repository at this point in the history
  • Loading branch information
eero-lehtinen committed Mar 23, 2024
1 parent 7c7d1e8 commit 584f230
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions crates/bevy_render/src/view/window/mod.rs
Expand Up @@ -304,19 +304,33 @@ pub fn prepare_windows(
})
};

#[cfg(target_os = "linux")]
let is_nvidia = || {
render_instance
.enumerate_adapters(wgpu::Backends::VULKAN)
.iter()
.any(|adapter| adapter.get_info().name.starts_with("NVIDIA"))
};

let not_already_configured = window_surfaces.configured_windows.insert(window.entity);

let surface = &surface_data.surface;
if not_already_configured || window.size_changed || window.present_mode_changed {
let frame = surface
.get_current_texture()
.expect("Error configuring surface");
window.set_swapchain_texture(frame);
match surface.get_current_texture() {
Ok(frame) => {
window.set_swapchain_texture(frame);
}
#[cfg(target_os = "linux")]
Err(wgpu::SurfaceError::Outdated) if is_nvidia() => {}
Err(err) => panic!("Error configuring surface: {err}"),
};
} else {
match surface.get_current_texture() {
Ok(frame) => {
window.set_swapchain_texture(frame);
}
#[cfg(target_os = "linux")]
Err(wgpu::SurfaceError::Outdated) if is_nvidia() => {}
Err(wgpu::SurfaceError::Outdated) => {
render_device.configure_surface(surface, &surface_data.configuration);
let frame = surface
Expand Down

0 comments on commit 584f230

Please sign in to comment.