Enhance vulkan instance and physical device display formatting
Refactor Vulkan instance and physical device formatting for better clarity. Added formatter utilities to encapsulate version and property formatting. Updated logging to use the new formatted output for improved debug readability.
This commit is contained in:
parent
b7d0abb9ed
commit
b91571e777
5 changed files with 88 additions and 19 deletions
50
src/vulkan/utils/formatter.rs
Normal file
50
src/vulkan/utils/formatter.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
use ash::vk::LayerProperties;
|
||||
|
||||
pub fn format_vulkan_version(version: u32) -> String {
|
||||
format!(
|
||||
"{}.{}.{}",
|
||||
ash::vk::api_version_major(version),
|
||||
ash::vk::api_version_minor(version),
|
||||
ash::vk::api_version_patch(version)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn format_driver_version(vendor_id: u32, driver_version_raw: u32) -> String {
|
||||
if vendor_id == 0x10de { // NVIDIA
|
||||
format!(
|
||||
"{}.{}.{}.{}",
|
||||
(driver_version_raw >> 22) & 0x3ff,
|
||||
(driver_version_raw >> 14) & 0x0ff,
|
||||
(driver_version_raw >> 6) & 0x0ff,
|
||||
(driver_version_raw) & 0x003f
|
||||
)
|
||||
} else if vendor_id == 0x8086 { // Intel
|
||||
format!(
|
||||
"{}.{}",
|
||||
driver_version_raw >> 14,
|
||||
driver_version_raw & 0x3fff
|
||||
)
|
||||
} else {
|
||||
format_vulkan_version(driver_version_raw)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_instance_layer(instance_layer: &LayerProperties) -> String {
|
||||
let layer_name = instance_layer
|
||||
.layer_name_as_c_str()
|
||||
.and_then(|s| Ok(s.to_string_lossy()))
|
||||
.and_then(|s| Ok(s.to_string()))
|
||||
.unwrap_or(String::from("No layer name"));
|
||||
|
||||
let description = instance_layer
|
||||
.description_as_c_str()
|
||||
.and_then(|s| Ok(s.to_string_lossy()))
|
||||
.and_then(|s| Ok(s.to_string()))
|
||||
.unwrap_or(String::from("No layer name"));
|
||||
|
||||
format!(
|
||||
"Name: {layer_name} Vulkan Version: {} Revision: {} Description: {description}",
|
||||
format_vulkan_version(instance_layer.spec_version),
|
||||
instance_layer.implementation_version,
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue