diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 908f6e50648..726cefc5f05 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -1,6 +1,7 @@ use std::{ ffi::{c_void, CStr, CString}, slice, + str::FromStr, sync::Arc, thread, }; @@ -806,11 +807,16 @@ impl crate::Instance for super::Instance { { // Check if mesa driver and version less than 21.2 if let Some(version) = exposed.info.driver_info.split_once("Mesa ").map(|s| { - s.1.rsplit_once('.') - .map(|v| v.0.parse::().unwrap_or_default()) - .unwrap_or_default() + let mut components = s.1.split('.'); + let major = components.next().and_then(|s| u8::from_str(s).ok()); + let minor = components.next().and_then(|s| u8::from_str(s).ok()); + if let (Some(major), Some(minor)) = (major, minor) { + (major, minor) + } else { + (0, 0) + } }) { - if version < 21.2 { + if version < (21, 2) { // See https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688 log::warn!( "Disabling presentation on '{}' (id {:?}) due to NV Optimus and Intel Mesa < v21.2",