Add logical device struct and surface handling for Vulkan
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
Introduce the VkLogicalDevice struct and add surface creation logic in VkInstance. Also, import necessary extensions and refine Vulkan physical device and window handling. Included a dependency on 'anyhow' for error management.
This commit is contained in:
parent
4048937a6c
commit
da0be47b14
14 changed files with 258 additions and 153 deletions
38
src/vulkan/utils/layers.rs
Normal file
38
src/vulkan/utils/layers.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use std::ffi::CString;
|
||||
|
||||
pub fn use_layers(
|
||||
entry: &ash::Entry,
|
||||
layers_to_select: Vec<&str>,
|
||||
) -> Vec<CString> {
|
||||
let layers_available = get_layers_available(entry);
|
||||
|
||||
let selected_layers = select_layers(&layers_available, &layers_to_select);
|
||||
|
||||
selected_layers
|
||||
.iter()
|
||||
.map(|sl| CString::new(sl.clone().as_bytes()).unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn get_layers_available(entry: &ash::Entry) -> Vec<ash::vk::LayerProperties> {
|
||||
unsafe { entry.enumerate_instance_layer_properties().unwrap_or_default() }
|
||||
}
|
||||
|
||||
fn select_layers(
|
||||
layers_available: &[ash::vk::LayerProperties],
|
||||
layers_to_select: &[&str],
|
||||
) -> Vec<String> {
|
||||
layers_available
|
||||
.iter()
|
||||
.filter_map(|l| {
|
||||
let layer_name = l
|
||||
.layer_name_as_c_str()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy();
|
||||
layers_to_select
|
||||
.iter()
|
||||
.find(|&&ln| ln == layer_name)
|
||||
.map(|_| layer_name.into_owned())
|
||||
})
|
||||
.collect()
|
||||
}
|
11
src/vulkan/utils/mod.rs
Normal file
11
src/vulkan/utils/mod.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
mod layers;
|
||||
pub use layers::use_layers;
|
||||
|
||||
pub fn print_version(version: u32) -> String {
|
||||
format!(
|
||||
"{}.{}.{}",
|
||||
ash::vk::api_version_major(version),
|
||||
ash::vk::api_version_minor(version),
|
||||
ash::vk::api_version_patch(version)
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue