Skip to content

Commit

Permalink
Identify Apple M1 GPU as integrated (#2429)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
superdump authored Jan 28, 2022
1 parent 9219489 commit 766c6cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ impl super::Adapter {
"mali",
"intel",
"v3d",
"apple m1",
];
let strings_that_imply_cpu = ["mesa offscreen", "swiftshader", "llvmpipe"];

Expand Down
15 changes: 15 additions & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
7 changes: 2 additions & 5 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 766c6cd

Please sign in to comment.