pub fn create_image_views(
    device: &Device,
    format: vk::Format,
    swapchain_images: &Vec<vk::Image>,
) -> Result<Vec<vk::ImageView>> {
    let mut image_views = vec![];
    for (i, image) in swapchain_images.iter().enumerate() {
        let create_info = vk::ImageViewCreateInfo {
            image: *image,
            format,
            view_type: vk::ImageViewType::TYPE_2D,
            subresource_range: vk::ImageSubresourceRange {
                aspect_mask: vk::ImageAspectFlags::COLOR,
                base_mip_level: 0,
                level_count: 1,
                base_array_layer: 0,
                layer_count: 1,
            },
            components: vk::ComponentMapping {
                r: vk::ComponentSwizzle::IDENTITY,
                g: vk::ComponentSwizzle::IDENTITY,
                b: vk::ComponentSwizzle::IDENTITY,
                a: vk::ComponentSwizzle::IDENTITY,
            },
            ..Default::default()
        };
        let view = unsafe {
            device
                .logical_device
                .create_image_view(&create_info, None)
                .context("unable to create image view for swapchain image")?
        };
        device.name_vulkan_object(
            format!("Swapchain Image View {}", i),
            vk::ObjectType::IMAGE_VIEW,
            &view,
        )?;
        image_views.push(view);
    }

    Ok(image_views)
}
/// Create image views for each of the swapchain images
///
/// The caller is responsible for destroying the views when they are done
/// being used.
Create image views for each of the swapchain images
The caller is responsible for destroying the views when they are done
being used.
Create image views for each of the swapchain images The caller is responsible for destroying the views when they are done being used .
pub fn create_image_views(
    device: &Device,
    format: vk::Format,
    swapchain_images: &Vec<vk::Image>,
) -> Result<Vec<vk::ImageView>> {
    let mut image_views = vec![];
    for (i, image) in swapchain_images.iter().enumerate() {
        let create_info = vk::ImageViewCreateInfo {
            image: *image,
            format,
            view_type: vk::ImageViewType::TYPE_2D,
            subresource_range: vk::ImageSubresourceRange {
                aspect_mask: vk::ImageAspectFlags::COLOR,
                base_mip_level: 0,
                level_count: 1,
                base_array_layer: 0,
                layer_count: 1,
            },
            components: vk::ComponentMapping {
                r: vk::ComponentSwizzle::IDENTITY,
                g: vk::ComponentSwizzle::IDENTITY,
                b: vk::ComponentSwizzle::IDENTITY,
                a: vk::ComponentSwizzle::IDENTITY,
            },
            ..Default::default()
        };
        let view = unsafe {
            device
                .logical_device
                .create_image_view(&create_info, None)
                .context("unable to create image view for swapchain image")?
        };
        device.name_vulkan_object(
            format!("Swapchain Image View {}", i),
            vk::ObjectType::IMAGE_VIEW,
            &view,
        )?;
        image_views.push(view);
    }
    Ok(image_views)
}
pub fn create_image_views ( device : & Device , format : vk :: Format , swapchain_images : & Vec < vk :: Image > , ) -> Result < Vec < vk :: ImageView > > { let mut image_views = vec ! [ ] ; for ( i , image ) in swapchain_images . iter ( ) . enumerate ( ) { let create_info = vk :: ImageViewCreateInfo { image : * image , format , view_type : vk :: ImageViewType :: TYPE_2D , subresource_range : vk :: ImageSubresourceRange { aspect_mask : vk :: ImageAspectFlags :: COLOR , base_mip_level : 0 , level_count : 1 , base_array_layer : 0 , layer_count : 1 , } , components : vk :: ComponentMapping { r : vk :: ComponentSwizzle :: IDENTITY , g : vk :: ComponentSwizzle :: IDENTITY , b : vk :: ComponentSwizzle :: IDENTITY , a : vk :: ComponentSwizzle :: IDENTITY , } , .. Default :: default ( ) } ; let view = unsafe { device . logical_device . create_image_view ( & create_info , None ) . context ( " " ) ? } ; device . name_vulkan_object ( format ! ( " " i ) , vk :: ObjectType :: IMAGE_VIEW , & view , ) ? ; image_views . push ( view ) ; } Ok ( image_views ) }
Create image views for each of the swapchain images
The caller is responsible for destroying the views when they are done
being used.
Create image views for each of the swapchain images The caller is responsible for destroying the views when they are done being used .
device
&Device
format
vk::Format
swapchain_images
&Vec<vk::Image>