Skip to content

Commit

Permalink
Whoops
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Oct 18, 2023
1 parent f9e9435 commit 256d3aa
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions wgpu-hal/src/auxil/dxgi/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ pub enum DxgiFactoryType {
Factory6,
}

fn filter_adapter(adapter: &dxgi::IDXGIAdapter1) -> bool {
let mut desc = unsafe { std::mem::zeroed() };
unsafe { adapter.GetDesc1(&mut desc) };

// If run completely headless, windows will show two different WARP adapters, one
// which is lying about being an integrated card. This is so that programs
// that ignore software adapters will actually run on headless/gpu-less machines.
//
// We don't want that and discorage that kind of filtering anyway, so we skip the integrated WARP.
if desc.VendorId == 5140 && (desc.Flags & dxgi::DXGI_ADAPTER_FLAG_SOFTWARE) == 0 {
let adapter_name = super::conv::map_adapter_name(desc.Description);
if adapter_name.contains("Microsoft Basic Render Driver") {
return false;
}
}

true
}

pub fn enumerate_adapters(factory: d3d12::DxgiFactory) -> Vec<d3d12::DxgiAdapter> {
let mut adapters = Vec::with_capacity(8);

Expand All @@ -39,6 +58,10 @@ pub fn enumerate_adapters(factory: d3d12::DxgiFactory) -> Vec<d3d12::DxgiAdapter
break;
}

if !filter_adapter(&adapter4) {
continue;
}

adapters.push(d3d12::DxgiAdapter::Adapter4(adapter4));
continue;
}
Expand All @@ -55,22 +78,8 @@ pub fn enumerate_adapters(factory: d3d12::DxgiFactory) -> Vec<d3d12::DxgiAdapter
break;
}

let mut desc = unsafe { std::mem::zeroed() };
unsafe { adapter1.GetDesc1(&mut desc) };

// If run completely headless, windows will show two different WARP adapters, one
// which is lying about being an integrated card. This is so that programs
// that ignore software adapters will actually run on headless/gpu-less machines.
//
// We don't want that and discorage that kind of filtering anyway, so we skip the integrated WARP.
dbg!(desc.VendorId);
dbg!(desc.Flags);
if desc.VendorId == 5140 && (desc.Flags & dxgi::DXGI_ADAPTER_FLAG_SOFTWARE) == 0 {
let adapter_name = super::conv::map_adapter_name(desc.Description);
dbg!(&adapter_name);
if adapter_name.contains("Microsoft Basic Render Driver") {
continue;
}
if !filter_adapter(&adapter4) {
continue;
}

// Do the most aggressive casts first, skipping Adpater4 as we definitely don't have dxgi1_6.
Expand Down

0 comments on commit 256d3aa

Please sign in to comment.