Skip to content

Commit b973ffd

Browse files
committed
improve adapter info log prints
1 parent bb92590 commit b973ffd

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

crates/egui-wgpu/src/lib.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,11 @@ fn describe_adapters(adapters: &[Arc<wgpu::Adapter>]) -> String {
272272
} else if adapters.len() == 1 {
273273
adapter_info_summary(&adapters[0].get_info())
274274
} else {
275-
let mut list_string = String::new();
276-
for adapter in adapters {
277-
if !list_string.is_empty() {
278-
list_string += ", ";
279-
}
280-
list_string += &format!("{{{}}}", adapter_info_summary(&adapter.get_info()));
281-
}
282-
list_string
275+
adapters
276+
.iter()
277+
.map(|a| format!("{{{}}}", adapter_info_summary(&a.get_info())))
278+
.collect::<Vec<_>>()
279+
.join(", ")
283280
}
284281
}
285282

@@ -646,12 +643,27 @@ pub fn adapter_info_summary(info: &wgpu::AdapterInfo) -> String {
646643
summary += &format!(", driver_info: {driver_info:?}");
647644
}
648645
if *vendor != 0 {
649-
// TODO(emilk): decode using https://github.com/gfx-rs/wgpu/blob/767ac03245ee937d3dc552edc13fe7ab0a860eec/wgpu-hal/src/auxil/mod.rs#L7
650-
summary += &format!(", vendor: 0x{vendor:04X}");
646+
summary += &format!(", vendor: {} (0x{vendor:04X})", parse_vendor_id(*vendor));
651647
}
652648
if *device != 0 {
653649
summary += &format!(", device: 0x{device:02X}");
654650
}
655651

656652
summary
657653
}
654+
655+
/// Tries to parse the adapter's vendor ID to a human-readable string.
656+
pub fn parse_vendor_id(vendor_id: u32) -> &'static str {
657+
match vendor_id {
658+
wgpu::hal::auxil::db::amd::VENDOR => "AMD",
659+
wgpu::hal::auxil::db::apple::VENDOR => "Apple",
660+
wgpu::hal::auxil::db::arm::VENDOR => "ARM",
661+
wgpu::hal::auxil::db::broadcom::VENDOR => "Broadcom",
662+
wgpu::hal::auxil::db::imgtec::VENDOR => "Imagination Technologies",
663+
wgpu::hal::auxil::db::intel::VENDOR => "Intel",
664+
wgpu::hal::auxil::db::mesa::VENDOR => "Mesa",
665+
wgpu::hal::auxil::db::nvidia::VENDOR => "NVIDIA",
666+
wgpu::hal::auxil::db::qualcomm::VENDOR => "Qualcomm",
667+
_ => "Unknown",
668+
}
669+
}

0 commit comments

Comments
 (0)