pub fn new(window_surface: &dyn WindowSurface) -> Result<Arc<Device>> {
        let instance = window_surface.clone_vulkan_instance();
        let physical_device =
            physical_device::find_optimal(&instance, window_surface)?;
        let queue_family_indices = QueueFamilyIndices::find(
            &physical_device,
            instance.raw(),
            window_surface,
        )?;
        let logical_device = instance.create_logical_device(
            &physical_device,
            physical_device::required_features(),
            &physical_device::required_extensions(),
            &queue_family_indices.as_queue_create_infos(),
        )?;

        let (graphics_queue, present_queue) =
            queue_family_indices.get_queues(&logical_device)?;

        let allocator = device_allocator::build_standard_allocator(
            instance.ash.clone(),
            logical_device.clone(),
            physical_device,
        );

        let shared_graphics_pool = Mutex::new(OwnedCommandPool::new(
            &logical_device,
            graphics_queue.family_id,
        )?);

        let device = Arc::new(Self {
            physical_device,
            logical_device,
            graphics_queue,
            present_queue,
            shared_graphics_pool,
            allocator: Mutex::new(allocator),
            instance,
        });

        device.name_vulkan_object(
            "Application Logical Device",
            vk::ObjectType::DEVICE,
            &device.logical_device.handle(),
        )?;

        device.name_vulkan_object(
            "Shared Graphics Pool",
            vk::ObjectType::COMMAND_POOL,
            unsafe { device.shared_graphics_pool.lock().unwrap().raw() },
        )?;

        if device.graphics_queue.is_same(&device.present_queue) {
            device
                .graphics_queue
                .name_vulkan_object("graphics/present queue", &device)?;
        } else {
            device
                .graphics_queue
                .name_vulkan_object("graphics queue", &device)?;
            device
                .present_queue
                .name_vulkan_object("present queue", &device)?;
        }

        Ok(device)
    }
/// Create a new device based on this application's required features and
/// properties.
Create a new device based on this application's required features and
properties.
Create a new device based on this application ' s required features and properties .
pub fn new(window_surface: &dyn WindowSurface) -> Result<Arc<Device>> {
        let instance = window_surface.clone_vulkan_instance();
        let physical_device =
            physical_device::find_optimal(&instance, window_surface)?;
        let queue_family_indices = QueueFamilyIndices::find(
            &physical_device,
            instance.raw(),
            window_surface,
        )?;
        let logical_device = instance.create_logical_device(
            &physical_device,
            physical_device::required_features(),
            &physical_device::required_extensions(),
            &queue_family_indices.as_queue_create_infos(),
        )?;
        let (graphics_queue, present_queue) =
            queue_family_indices.get_queues(&logical_device)?;
        let allocator = device_allocator::build_standard_allocator(
            instance.ash.clone(),
            logical_device.clone(),
            physical_device,
        );
        let shared_graphics_pool = Mutex::new(OwnedCommandPool::new(
            &logical_device,
            graphics_queue.family_id,
        )?);
        let device = Arc::new(Self {
            physical_device,
            logical_device,
            graphics_queue,
            present_queue,
            shared_graphics_pool,
            allocator: Mutex::new(allocator),
            instance,
        });
        device.name_vulkan_object(
            "Application Logical Device",
            vk::ObjectType::DEVICE,
            &device.logical_device.handle(),
        )?;
        device.name_vulkan_object(
            "Shared Graphics Pool",
            vk::ObjectType::COMMAND_POOL,
            unsafe { device.shared_graphics_pool.lock().unwrap().raw() },
        )?;
        if device.graphics_queue.is_same(&device.present_queue) {
            device
                .graphics_queue
                .name_vulkan_object("graphics/present queue", &device)?;
        } else {
            device
                .graphics_queue
                .name_vulkan_object("graphics queue", &device)?;
            device
                .present_queue
                .name_vulkan_object("present queue", &device)?;
        }
        Ok(device)
    }
pub fn new ( window_surface : & dyn WindowSurface ) -> Result < Arc < Device > > { let instance = window_surface . clone_vulkan_instance ( ) ; let physical_device = physical_device :: find_optimal ( & instance , window_surface ) ? ; let queue_family_indices = QueueFamilyIndices :: find ( & physical_device , instance . raw ( ) , window_surface , ) ? ; let logical_device = instance . create_logical_device ( & physical_device , physical_device :: required_features ( ) , & physical_device :: required_extensions ( ) , & queue_family_indices . as_queue_create_infos ( ) , ) ? ; let ( graphics_queue , present_queue ) = queue_family_indices . get_queues ( & logical_device ) ? ; let allocator = device_allocator :: build_standard_allocator ( instance . ash . clone ( ) , logical_device . clone ( ) , physical_device , ) ; let shared_graphics_pool = Mutex :: new ( OwnedCommandPool :: new ( & logical_device , graphics_queue . family_id , ) ? ) ; let device = Arc :: new ( Self { physical_device , logical_device , graphics_queue , present_queue , shared_graphics_pool , allocator : Mutex :: new ( allocator ) , instance , } ) ; device . name_vulkan_object ( " " , vk :: ObjectType :: DEVICE , & device . logical_device . handle ( ) , ) ? ; device . name_vulkan_object ( " " , vk :: ObjectType :: COMMAND_POOL , unsafe { device . shared_graphics_pool . lock ( ) . unwrap ( ) . raw ( ) } , ) ? ; if device . graphics_queue . is_same ( & device . present_queue ) { device . graphics_queue . name_vulkan_object ( " " , & device ) ? ; } else { device . graphics_queue . name_vulkan_object ( " " , & device ) ? ; device . present_queue . name_vulkan_object ( " " , & device ) ? ; } Ok ( device ) }
Create a new device based on this application's required features and
properties.
Create a new device based on this application ' s required features and properties .
window_surface
&dyn WindowSurface