Skip to content

Commit

Permalink
hal/vk: check for optimus in addition to NV adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Nov 29, 2021
1 parent 4abbc95 commit 28ba9d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ impl crate::Instance<super::Api> for super::Instance {
}

unsafe fn enumerate_adapters(&self) -> Vec<crate::ExposedAdapter<super::Api>> {
use crate::auxil::db;

let raw_devices = match self.shared.raw.enumerate_physical_devices() {
Ok(devices) => devices,
Err(err) => {
Expand All @@ -604,8 +606,11 @@ impl crate::Instance<super::Api> for super::Instance {
.collect::<Vec<_>>();

// Detect if it's an Intel + NVidia configuration with Optimus
if cfg!(target_os = "linux") && self.shared.has_nv_optimus {
use crate::auxil::db;
let has_nvidia_dgpu = exposed_adapters.iter().any(|exposed| {
exposed.info.device_type == wgt::DeviceType::DiscreteGpu
&& exposed.info.vendor == db::nvidia::VENDOR as usize
});
if cfg!(target_os = "linux") && has_nvidia_dgpu && self.shared.has_nv_optimus {
for exposed in exposed_adapters.iter_mut() {
if exposed.info.device_type == wgt::DeviceType::IntegratedGpu
&& exposed.info.vendor == db::intel::VENDOR as usize
Expand Down

0 comments on commit 28ba9d8

Please sign in to comment.