This commit is contained in:
parent
e9ce480f96
commit
210a5504ab
6 changed files with 162 additions and 90 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue