Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify Apple M1 GPU as integrated #2429

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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