pub unsafe fn upload_mipmaps_from_buffer(
        &mut self,
        src: &impl Buffer,
        mipmap_sizes: &[MipmapExtent],
    ) -> Result<()> {
        let required_size: u64 = mipmap_sizes
            .iter()
            .map(|mipmap_size| mipmap_size.size_in_bytes(self.bytes_per_pixel))
            .sum();
        if required_size > src.size_in_bytes() {
            bail!(
                "The texture expects {:?} bytes, but the provided buffer includes only {:?} bytes of data!",
                required_size,
                src.size_in_bytes()
            );
        }

        self.device.sync_graphics_commands(|command_buffer| {
            let mut mip_level = 0;
            let mut offset: u64 = 0;

            for extent in mipmap_sizes {
                self.write_barrier(command_buffer, mip_level);
                self.copy_buffer_to_image(
                    command_buffer,
                    src.raw(),
                    offset,
                    extent,
                    mip_level,
                );
                self.read_barrier(command_buffer, mip_level);

                mip_level += 1;
                offset += extent.size_in_bytes(self.bytes_per_pixel);
            }

            Ok(())
        })
    }
/// Upload a texture's mipmaps from a buffer.
///
/// * This method assumes that each mipmap has the same `bytes_per_pixel`
///   as the texture image.
/// * Order is super important. The first entry in `mipmap_sizes`
///   corresponds to the first region of memory in the src bufer. The
///   mipmap extents are used to compute the byte offset and size of each
///   mipmap region.
Upload a texture's mipmaps from a buffer.
This method assumes that each mipmap has the same `bytes_per_pixel`
as the texture image.
Order is super important. The first entry in `mipmap_sizes`
corresponds to the first region of memory in the src bufer. The
mipmap extents are used to compute the byte offset and size of each
mipmap region.
Upload a texture ' s mipmaps from a buffer . This method assumes that each mipmap has the same ` bytes_per_pixel ` as the texture image . Order is super important . The first entry in ` mipmap_sizes ` corresponds to the first region of memory in the src bufer . The mipmap extents are used to compute the byte offset and size of each mipmap region .
pub unsafe fn upload_mipmaps_from_buffer(
        &mut self,
        src: &impl Buffer,
        mipmap_sizes: &[MipmapExtent],
    ) -> Result<()> {
        let required_size: u64 = mipmap_sizes
            .iter()
            .map(|mipmap_size| mipmap_size.size_in_bytes(self.bytes_per_pixel))
            .sum();
        if required_size > src.size_in_bytes() {
            bail!(
                "The texture expects {:?} bytes, but the provided buffer includes only {:?} bytes of data!",
                required_size,
                src.size_in_bytes()
            );
        }
        self.device.sync_graphics_commands(|command_buffer| {
            let mut mip_level = 0;
            let mut offset: u64 = 0;
            for extent in mipmap_sizes {
                self.write_barrier(command_buffer, mip_level);
                self.copy_buffer_to_image(
                    command_buffer,
                    src.raw(),
                    offset,
                    extent,
                    mip_level,
                );
                self.read_barrier(command_buffer, mip_level);
                mip_level += 1;
                offset += extent.size_in_bytes(self.bytes_per_pixel);
            }
            Ok(())
        })
    }
pub unsafe fn upload_mipmaps_from_buffer ( & mut self , src : & impl Buffer , mipmap_sizes : & [ MipmapExtent ] , ) -> Result < ( ) > { let required_size : u64 = mipmap_sizes . iter ( ) . map ( | mipmap_size | mipmap_size . size_in_bytes ( self . bytes_per_pixel ) ) . sum ( ) ; if required_size > src . size_in_bytes ( ) { bail ! ( " " required_size src size_in_bytes ( ) ) ; } self . device . sync_graphics_commands ( | command_buffer | { let mut mip_level = 0 ; let mut offset : u64 = 0 ; for extent in mipmap_sizes { self . write_barrier ( command_buffer , mip_level ) ; self . copy_buffer_to_image ( command_buffer , src . raw ( ) , offset , extent , mip_level , ) ; self . read_barrier ( command_buffer , mip_level ) ; mip_level += 1 ; offset += extent . size_in_bytes ( self . bytes_per_pixel ) ; } Ok ( ( ) ) } ) }
Upload a texture's mipmaps from a buffer.
Upload a texture ' s mipmaps from a buffer .
&mut self
src
&impl Buffer
mipmap_sizes
&[MipmapExtent]