Run cargo fmt
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s

This commit is contained in:
Florian RICHER 2024-11-16 22:45:22 +01:00
parent bc94b68c0c
commit e9ce480f96
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
10 changed files with 175 additions and 136 deletions

View file

@ -11,20 +11,22 @@ pub struct VkInstance {
}
impl VkInstance {
pub fn new(
required_extensions: &Vec<*const c_char>,
) -> Self {
pub fn new(required_extensions: &Vec<*const c_char>) -> Self {
let entry = Entry::linked();
log::debug!(target: LOG_TARGET, "Initializing Vulkan instance");
if log::log_enabled!(target: LOG_TARGET, log::Level::Debug) {
let layer_properties = unsafe { entry.enumerate_instance_layer_properties() }
.unwrap_or_default();
let layer_properties =
unsafe { entry.enumerate_instance_layer_properties() }.unwrap_or_default();
for layer_property in layer_properties {
let layer_extensions = unsafe { entry.enumerate_instance_extension_properties(layer_property.layer_name_as_c_str().ok()) }
.unwrap_or_default();
let layer_extensions = unsafe {
entry.enumerate_instance_extension_properties(
layer_property.layer_name_as_c_str().ok(),
)
}
.unwrap_or_default();
log::debug!(target: LOG_TARGET, "{layer_property:#?} {layer_extensions:#?}");
}
}
@ -44,12 +46,13 @@ impl VkInstance {
LayersSelector::SpecificLayers(vec![
"VK_LAYER_KHRONOS_validation",
"VK_LAYER_MANGOHUD_overlay_x86_64",
"VK_LAYER_NV_optimus"
"VK_LAYER_NV_optimus",
]),
);
{
let layers = layers.iter()
let layers = layers
.iter()
.map(|layer| layer.to_string_lossy())
.collect::<Vec<_>>();
log::debug!(target: LOG_TARGET, "Selected debug layers : {}", layers.join(", "))
@ -92,7 +95,7 @@ impl VkInstance {
Self {
entry,
handle: instance,
surface_loader
surface_loader,
}
}
@ -100,14 +103,17 @@ impl VkInstance {
let physical_devices = unsafe { self.handle.enumerate_physical_devices() };
physical_devices
.unwrap_or_default()
.iter().map(|physical_device| VkPhysicalDevice::new(&self.handle, *physical_device))
.iter()
.map(|physical_device| VkPhysicalDevice::new(&self.handle, *physical_device))
.collect()
}
}
impl Drop for VkInstance {
fn drop(&mut self) {
unsafe { self.handle.destroy_instance(None); }
unsafe {
self.handle.destroy_instance(None);
}
log::debug!(target: LOG_TARGET, "Vulkan instance destroyed ({:?})", self.handle.handle());
}
}