/// Accepts ownership of the image and generates the requested number of mip
/// levels using a blit.
Accepts ownership of the image and generates the requested number of mip
levels using a blit.
Accepts ownership of the image and generates the requested number of mip levels using a blit .
unsafe fn accept_image_transfer_and_generate_mipmaps(
    &self, gpu_image: &ImageOrBuffer, mip_levels: Option<u32>, src_queue_family: u32,
    dst_queue_family: u32,
  ) -> SarektResult<()> {
    match gpu_image {
      ImageOrBuffer::Image(gpu_image, format, extent) => {
        let command_begin_info = vk::CommandBufferBeginInfo::builder()
          .flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT)
          .build();
        self
          .logical_device
          .begin_command_buffer(self.graphics_command_buffer, &command_begin_info)?;
        self.transfer_image_queue_ownership_if_necessary(
          *gpu_image,
          src_queue_family,
          dst_queue_family,
          mip_levels,
        )?;
        // This is an image with mipmaps, generate them now that image is owned by
        // graphics command queue and can therefore do blit operations.
        self.generate_mipmaps_shader_ro_optimal(
          self.graphics_command_buffer,
          *gpu_image,
          *format,
          extent.width,
          extent.height,
          mip_levels.unwrap_or(1),
        )?;
      }
      _ => (),
    }
    if src_queue_family == dst_queue_family {
      // No transfer needed.
      return Ok(());
    }
    self
      .logical_device
      .end_command_buffer(self.graphics_command_buffer)?;
    let command_buffers = [self.graphics_command_buffer];
    let mut submit_info = [vk::SubmitInfo::builder()
      .command_buffers(&command_buffers)
      .wait_semaphores(&self.ownership_semaphore)
      .wait_dst_stage_mask(&[vk::PipelineStageFlags::TOP_OF_PIPE])
      .build()];
    if src_queue_family == dst_queue_family {
      submit_info[0].wait_semaphore_count = 0;
    }
    self.logical_device.queue_submit(
      self.graphics_command_queue,
      &submit_info,
      vk::Fence::null(),
    )?;
    Ok(())
  }
unsafe fn accept_image_transfer_and_generate_mipmaps ( & self , gpu_image : & ImageOrBuffer , mip_levels : Option < u32 > , src_queue_family : u32 , dst_queue_family : u32 , ) -> SarektResult < ( ) > { match gpu_image { ImageOrBuffer :: Image ( gpu_image , format , extent ) => { let command_begin_info = vk :: CommandBufferBeginInfo :: builder ( ) . flags ( vk :: CommandBufferUsageFlags :: ONE_TIME_SUBMIT ) . build ( ) ; self . logical_device . begin_command_buffer ( self . graphics_command_buffer , & command_begin_info ) ? ; self . transfer_image_queue_ownership_if_necessary ( * gpu_image , src_queue_family , dst_queue_family , mip_levels , ) ? ; // This is an image with mipmaps, generate them now that image is owned by // graphics command queue and can therefore do blit operations. self . generate_mipmaps_shader_ro_optimal ( self . graphics_command_buffer , * gpu_image , * format , extent . width , extent . height , mip_levels . unwrap_or ( 1 ) , ) ? ; } _ => ( ) , } if src_queue_family == dst_queue_family { // No transfer needed. return Ok ( ( ) ) ; } self . logical_device . end_command_buffer ( self . graphics_command_buffer ) ? ; let command_buffers = [ self . graphics_command_buffer ] ; let mut submit_info = [ vk :: SubmitInfo :: builder ( ) . command_buffers ( & command_buffers ) . wait_semaphores ( & self . ownership_semaphore ) . wait_dst_stage_mask ( & [ vk :: PipelineStageFlags :: TOP_OF_PIPE ] ) . build ( ) ] ; if src_queue_family == dst_queue_family { submit_info [ 0 ] . wait_semaphore_count = 0 ; } self . logical_device . queue_submit ( self . graphics_command_queue , & submit_info , vk :: Fence :: null ( ) , ) ? ; Ok ( ( ) ) }
Accepts ownership of the image and generates the requested number of mip
levels using a blit.
Accepts ownership of the image and generates the requested number of mip levels using a blit .
&self
gpu_image
&ImageOrBuffer
mip_levels
Option<u32>
src_queue_family
u32
dst_queue_family
u32