Identify Apple M1 GPU as integrated (#2429)

* Identify Apple M1 GPU as integrated

* metal: Call has_unified_memory conditional on OS version

Fall back to current low_power implies integrated GPU for older OSes.
This commit is contained in:
Robert Swain
2022-01-29 00:40:26 +01:00
committed by GitHub
parent 9219489894
commit 766c6cda19
3 changed files with 18 additions and 5 deletions

View File

@@ -118,6 +118,7 @@ impl super::Adapter {
"mali",
"intel",
"v3d",
"apple m1",
];
let strings_that_imply_cpu = ["mesa offscreen", "swiftshader", "llvmpipe"];

View File

@@ -988,6 +988,21 @@ impl super::PrivateCapabilities {
} else {
Self::version_at_least(major, minor, 13, 0)
},
has_unified_memory: if (os_is_mac && Self::version_at_least(major, minor, 10, 15))
|| (!os_is_mac && Self::version_at_least(major, minor, 13, 0))
{
Some(device.has_unified_memory())
} else {
None
},
}
}
pub fn device_type(&self) -> wgt::DeviceType {
if self.has_unified_memory.unwrap_or(self.low_power) {
wgt::DeviceType::IntegratedGpu
} else {
wgt::DeviceType::DiscreteGpu
}
}

View File

@@ -114,11 +114,7 @@ impl crate::Instance<Api> for Instance {
name,
vendor: 0,
device: 0,
device_type: if shared.private_caps.low_power {
wgt::DeviceType::IntegratedGpu
} else {
wgt::DeviceType::DiscreteGpu
},
device_type: shared.private_caps.device_type(),
backend: wgt::Backend::Metal,
},
features: shared.private_caps.features(),
@@ -230,6 +226,7 @@ struct PrivateCapabilities {
supports_mutability: bool,
supports_depth_clip_control: bool,
supports_preserve_invariance: bool,
has_unified_memory: Option<bool>,
}
#[derive(Clone, Debug)]