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

This commit is contained in:
Florian RICHER 2024-11-17 14:07:37 +01:00
parent e9ce480f96
commit 210a5504ab
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
6 changed files with 162 additions and 90 deletions

View file

@ -7,7 +7,12 @@ pub struct VkDevice {
instance: Arc<VkInstance>,
pub(super) handle: ash::Device,
pub(super) swapchain_loader: ash::khr::swapchain::Device,
queue_family_index: u32,
// Arc not used because vk::Queue is destroyed with Device automatically
// so any references of vk::Queue must be destroyed with VkDevice
queues: Vec<vk::Queue>,
}
impl VkDevice {
@ -25,11 +30,11 @@ impl VkDevice {
shader_clip_distance: 1,
..Default::default()
};
let priorities = [1.0];
let queues_priorities = [1.0];
let queue_info = vk::DeviceQueueCreateInfo::default()
.queue_family_index(queue_family_index)
.queue_priorities(&priorities);
.queue_priorities(&queues_priorities);
let device_create_info = vk::DeviceCreateInfo::default()
.queue_create_infos(std::slice::from_ref(&queue_info))
@ -43,6 +48,12 @@ impl VkDevice {
};
log::debug!(target: LOG_TARGET, "Device created ({:?})", device.handle());
let queues = queues_priorities
.iter()
.enumerate()
.map(|(index, _)| unsafe { device.get_device_queue(queue_family_index, index as u32) })
.collect::<Vec<_>>();
let swapchain_loader = ash::khr::swapchain::Device::new(&instance.handle, &device);
Ok(Self {
@ -50,14 +61,12 @@ impl VkDevice {
handle: device,
swapchain_loader,
queue_family_index,
queues,
})
}
pub(super) fn get_device_queue(&self, queue_index: u32) -> vk::Queue {
unsafe {
self.handle
.get_device_queue(self.queue_family_index, queue_index)
}
pub(super) fn get_device_queue(&self, queue_index: u32) -> Option<&vk::Queue> {
self.queues.get(queue_index as usize)
}
pub(super) fn create_image_view(