This commit is contained in:
parent
7c072d60e2
commit
e26f40ea74
2 changed files with 22 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::ffi::CStr;
|
use std::ffi::CString;
|
||||||
use ash::{vk, Entry};
|
use ash::{vk, Entry};
|
||||||
|
|
||||||
pub fn use_layers(
|
pub fn use_layers(
|
||||||
|
@ -11,13 +11,18 @@ pub fn use_layers(
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut selected_layers = Vec::<&CStr>::new();
|
let mut selected_layers = Vec::<String>::new();
|
||||||
|
|
||||||
log::info!("Available layers ({}):", layers_available.len());
|
log::info!("Available layers ({}):", layers_available.len());
|
||||||
for l in layers_available {
|
for l in layers_available {
|
||||||
let layer_name = l.layer_name_as_c_str().unwrap_or_default();
|
let layer_name = l
|
||||||
if layers_to_select.iter().any(|ln| (*ln).eq(layer_name)) {
|
.layer_name_as_c_str()
|
||||||
selected_layers.push(layer_name.clone());
|
.unwrap_or_default()
|
||||||
|
.to_string_lossy()
|
||||||
|
.into_owned();
|
||||||
|
|
||||||
|
if layers_to_select.iter().any(|ln| (*ln).eq(&layer_name)) {
|
||||||
|
selected_layers.push(layer_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
|
@ -30,22 +35,24 @@ pub fn use_layers(
|
||||||
}
|
}
|
||||||
log::info!(""); // Add blank line
|
log::info!(""); // Add blank line
|
||||||
|
|
||||||
log::info!("Layers to select ({}):", layers_to_select.len());
|
log::info!("Layers wanted ({}):", layers_to_select.len());
|
||||||
for l in layers_to_select {
|
for l in layers_to_select {
|
||||||
let selected = selected_layers.contains(&l);
|
let selected = selected_layers.iter().any(|sl| sl.eq(l));
|
||||||
log::info!("\t{:?}\tSelected: {}", l, selected);
|
log::info!("\t{:?}\tSelected: {}", l, selected);
|
||||||
}
|
}
|
||||||
log::info!(""); // Add blank line
|
log::info!(""); // Add blank line
|
||||||
|
|
||||||
selected_layers.iter().map(|sl| sl.as_ptr()).collect()
|
selected_layers.iter().map(|sl| {
|
||||||
|
let c_string = CString::new(sl.clone().as_bytes()).unwrap();
|
||||||
|
c_string.as_ptr()
|
||||||
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_version(version: u32) -> String {
|
pub fn print_version(version: u32) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{}.{}.{}.{}",
|
"{}.{}.{}",
|
||||||
vk::api_version_major(version),
|
vk::api_version_major(version),
|
||||||
vk::api_version_minor(version),
|
vk::api_version_minor(version),
|
||||||
vk::api_version_patch(version),
|
vk::api_version_patch(version)
|
||||||
vk::api_version_variant(version)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@ impl VkInstance {
|
||||||
|
|
||||||
// Layers
|
// Layers
|
||||||
let layers = use_layers(&entry, vec![
|
let layers = use_layers(&entry, vec![
|
||||||
"VK_LAYER_MANGOHUD_overlay_x86_64"
|
"VK_LAYER_MANGOHUD_overlay_x86_64",
|
||||||
|
"VK_LAYER_NV_optimus"
|
||||||
]);
|
]);
|
||||||
let layer_names = Vec::<*const std::ffi::c_char>::new();
|
|
||||||
|
|
||||||
// Extensions
|
// Extensions
|
||||||
let mut extension_names =
|
let mut extension_names =
|
||||||
|
@ -50,7 +50,7 @@ impl VkInstance {
|
||||||
// Instance Info
|
// Instance Info
|
||||||
let create_info = vk::InstanceCreateInfo::default()
|
let create_info = vk::InstanceCreateInfo::default()
|
||||||
.application_info(&appinfo)
|
.application_info(&appinfo)
|
||||||
.enabled_layer_names(&layer_names)
|
.enabled_layer_names(&layers)
|
||||||
.enabled_extension_names(&extension_names)
|
.enabled_extension_names(&extension_names)
|
||||||
.flags(create_flags);
|
.flags(create_flags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue