mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
wgpu-hal: Fix Mesa version check for version with suffix containing . (#4959)
On Pop!_OS we have versions like `Mesa 23.3.0-1pop0~1702935939~22.04~67e417a`. This failed to parse here since it tried to split at the `.` in the suffix. Not sure if other distros use a suffix with a `.`, but splitting from the left and comparing as a tuple instead of a float seems cleaner overall. Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4431114ddf
commit
771f64917c
@@ -1,6 +1,7 @@
|
||||
use std::{
|
||||
ffi::{c_void, CStr, CString},
|
||||
slice,
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
thread,
|
||||
};
|
||||
@@ -855,11 +856,16 @@ impl crate::Instance<super::Api> 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::<f32>().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",
|
||||
|
||||
Reference in New Issue
Block a user