This commit is contained in:
parent
d0c6f31a1a
commit
caa79270db
5 changed files with 58 additions and 42 deletions
|
@ -1,9 +1,9 @@
|
|||
use crate::vulkan::{VkDevice, VkInstance, VkPhysicalDevice, VkSurface};
|
||||
use ash::vk::QueueFlags;
|
||||
use crate::vulkan::{VkDevice, VkInstance, VkSurface};
|
||||
|
||||
pub struct VkRenderContext {
|
||||
surface: VkSurface,
|
||||
instance: VkInstance,
|
||||
surface: VkSurface,
|
||||
}
|
||||
|
||||
impl VkRenderContext {
|
||||
|
@ -17,13 +17,11 @@ impl VkRenderContext {
|
|||
let mut physical_devices = instance.get_physical_devices();
|
||||
physical_devices.sort_by(|a, b| b.priority().cmp(&a.priority()));
|
||||
|
||||
let (physical_device, (queue_family_index, _)) = physical_devices
|
||||
.iter()
|
||||
.find_map(|physical_device| {
|
||||
physical_device.find_queue_family_by(Some(QueueFlags::GRAPHICS), Some(&surface))
|
||||
.and_then(|queue_index| Some((physical_device, queue_index)))
|
||||
})
|
||||
.expect("Unable to find suitable device");
|
||||
let (physical_device, queue_family_index, _) = VkPhysicalDevice::pick_physical_device_and_queue_by(
|
||||
&physical_devices,
|
||||
Some(QueueFlags::GRAPHICS),
|
||||
Some(&surface),
|
||||
).expect("Unable to find physical device");
|
||||
|
||||
let device = VkDevice::new_graphics_device(&instance, &physical_device, queue_family_index)
|
||||
.expect("Unable to create device");
|
||||
|
@ -38,9 +36,9 @@ impl VkRenderContext {
|
|||
let surface_capabilities = surface.get_physical_device_surface_capabilities(physical_device)
|
||||
.expect("Unable to get surface capabilities");
|
||||
|
||||
Ok(Self{
|
||||
Ok(Self {
|
||||
instance,
|
||||
surface
|
||||
surface,
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue