pub fn new(
        device: Arc<Device>,
        image_create_info: vk::ImageCreateInfo,
        memory_property_flags: vk::MemoryPropertyFlags,
        bytes_per_pixel: u64,
    ) -> Result<Self> {
        let image = unsafe {
            device
                .logical_device
                .create_image(&image_create_info, None)?
        };

        let allocation = unsafe {
            let memory_requirements =
                device.logical_device.get_image_memory_requirements(image);
            device
                .allocate_memory(memory_requirements, memory_property_flags)?
        };

        unsafe {
            device.logical_device.bind_image_memory(
                image,
                allocation.memory,
                allocation.offset,
            )?;
        }

        let view_create_info = vk::ImageViewCreateInfo {
            image,
            view_type: vk::ImageViewType::TYPE_2D,
            format: image_create_info.format,
            subresource_range: vk::ImageSubresourceRange {
                aspect_mask: vk::ImageAspectFlags::COLOR,
                base_mip_level: 0,
                level_count: image_create_info.mip_levels,
                base_array_layer: 0,
                layer_count: 1,
            },
            components: vk::ComponentMapping {
                r: vk::ComponentSwizzle::R,
                g: vk::ComponentSwizzle::G,
                b: vk::ComponentSwizzle::B,
                a: vk::ComponentSwizzle::A,
            },
            ..Default::default()
        };

        let view = unsafe {
            device
                .logical_device
                .create_image_view(&view_create_info, None)?
        };

        Ok(Self {
            bytes_per_pixel,
            image,
            extent: image_create_info.extent,
            view,
            allocation,
            device,
        })
    }
/// Create the image, allocate memory, create a view for the texture.
///
/// Bytes per pixel is used by the various `upload_*` methods when copying
/// data from a buffer into the image. For example, if the image format
/// is R8G8B8A8_SRGB then the bytes per pixel is 4.
Create the image, allocate memory, create a view for the texture.
Bytes per pixel is used by the various `upload_*` methods when copying
data from a buffer into the image. For example, if the image format
is R8G8B8A8_SRGB then the bytes per pixel is 4.
Create the image allocate memory create a view for the texture . Bytes per pixel is used by the various ` upload_ * ` methods when copying data from a buffer into the image . For example if the image format is R8G8B8A8_SRGB then the bytes per pixel is 4 .
pub fn new(
        device: Arc<Device>,
        image_create_info: vk::ImageCreateInfo,
        memory_property_flags: vk::MemoryPropertyFlags,
        bytes_per_pixel: u64,
    ) -> Result<Self> {
        let image = unsafe {
            device
                .logical_device
                .create_image(&image_create_info, None)?
        };
        let allocation = unsafe {
            let memory_requirements =
                device.logical_device.get_image_memory_requirements(image);
            device
                .allocate_memory(memory_requirements, memory_property_flags)?
        };
        unsafe {
            device.logical_device.bind_image_memory(
                image,
                allocation.memory,
                allocation.offset,
            )?;
        }
        let view_create_info = vk::ImageViewCreateInfo {
            image,
            view_type: vk::ImageViewType::TYPE_2D,
            format: image_create_info.format,
            subresource_range: vk::ImageSubresourceRange {
                aspect_mask: vk::ImageAspectFlags::COLOR,
                base_mip_level: 0,
                level_count: image_create_info.mip_levels,
                base_array_layer: 0,
                layer_count: 1,
            },
            components: vk::ComponentMapping {
                r: vk::ComponentSwizzle::R,
                g: vk::ComponentSwizzle::G,
                b: vk::ComponentSwizzle::B,
                a: vk::ComponentSwizzle::A,
            },
            ..Default::default()
        };
        let view = unsafe {
            device
                .logical_device
                .create_image_view(&view_create_info, None)?
        };
        Ok(Self {
            bytes_per_pixel,
            image,
            extent: image_create_info.extent,
            view,
            allocation,
            device,
        })
    }
pub fn new ( device : Arc < Device > , image_create_info : vk :: ImageCreateInfo , memory_property_flags : vk :: MemoryPropertyFlags , bytes_per_pixel : u64 , ) -> Result < Self > { let image = unsafe { device . logical_device . create_image ( & image_create_info , None ) ? } ; let allocation = unsafe { let memory_requirements = device . logical_device . get_image_memory_requirements ( image ) ; device . allocate_memory ( memory_requirements , memory_property_flags ) ? } ; unsafe { device . logical_device . bind_image_memory ( image , allocation . memory , allocation . offset , ) ? ; } let view_create_info = vk :: ImageViewCreateInfo { image , view_type : vk :: ImageViewType :: TYPE_2D , format : image_create_info . format , subresource_range : vk :: ImageSubresourceRange { aspect_mask : vk :: ImageAspectFlags :: COLOR , base_mip_level : 0 , level_count : image_create_info . mip_levels , base_array_layer : 0 , layer_count : 1 , } , components : vk :: ComponentMapping { r : vk :: ComponentSwizzle :: R , g : vk :: ComponentSwizzle :: G , b : vk :: ComponentSwizzle :: B , a : vk :: ComponentSwizzle :: A , } , .. Default :: default ( ) } ; let view = unsafe { device . logical_device . create_image_view ( & view_create_info , None ) ? } ; Ok ( Self { bytes_per_pixel , image , extent : image_create_info . extent , view , allocation , device , } ) }
Create the image, allocate memory, create a view for the texture.
Create the image allocate memory create a view for the texture .
device
Arc<Device>
image_create_info
vk::ImageCreateInfo
memory_property_flags
vk::MemoryPropertyFlags
bytes_per_pixel
u64