Skip to content

Commit

Permalink
wgpu-hal: Fix Mesa version check for version with suffix containing `…
Browse files Browse the repository at this point in the history
….` (gfx-rs#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>
  • Loading branch information
2 people authored and jackpot51 committed Feb 3, 2024
1 parent daedf03 commit a757033
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
ffi::{c_void, CStr, CString},
slice,
str::FromStr,
sync::Arc,
thread,
};
Expand Down Expand Up @@ -806,11 +807,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",
Expand Down

0 comments on commit a757033

Please sign in to comment.