Add log + Cleanup

This commit is contained in:
Florian RICHER 2024-11-15 23:16:18 +01:00
parent 21195b57e6
commit bc94b68c0c
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
8 changed files with 46 additions and 131 deletions

View file

@ -1,7 +1,6 @@
use crate::vulkan::utils::formatter::{format_driver_version, format_vulkan_version};
use crate::vulkan::vk_surface::VkSurface;
use ash::vk;
use std::fmt::{Display, Formatter};
use crate::vulkan::LOG_TARGET;
pub struct VkPhysicalDevice {
// Vulkan properties
@ -13,10 +12,14 @@ pub struct VkPhysicalDevice {
impl VkPhysicalDevice {
pub fn new(instance: &ash::Instance, physical_device: vk::PhysicalDevice) -> Self {
log::debug!(target: LOG_TARGET, "New physical device");
let device_properties = unsafe { instance.get_physical_device_properties(physical_device) };
log::debug!(target: LOG_TARGET, "{device_properties:#?}");
let device_features = unsafe { instance.get_physical_device_features(physical_device) };
log::debug!(target: LOG_TARGET, "{device_features:#?}");
let device_queue_families =
unsafe { instance.get_physical_device_queue_family_properties(physical_device) };
log::debug!(target: LOG_TARGET, "{device_queue_families:#?}");
Self {
handle: physical_device,
@ -82,22 +85,3 @@ impl VkPhysicalDevice {
}
}
}
impl Display for VkPhysicalDevice {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let device_name = self.properties
.device_name_as_c_str()
.and_then(|s| Ok(s.to_string_lossy()))
.and_then(|s| Ok(s.to_string()))
.unwrap_or(String::from("No device name"));
writeln!(f, "Nom: {device_name}")?;
writeln!(f, "Vendor ID: {:#x}", self.properties.vendor_id)?;
writeln!(f, "Device ID: {:#x}", self.properties.device_id)?;
writeln!(f, "Driver version: {}", format_driver_version(self.properties.vendor_id, self.properties.driver_version))?;
writeln!(f, "Vulkan version: {}", format_vulkan_version(self.properties.api_version))?;
writeln!(f, "Device type: {:?}", self.properties.device_type)?;
Ok(())
}
}