unsafe fn transfer_image_queue_ownership_if_necessary(
    &self, gpu_image: vk::Image, src_queue_family: u32, dst_queue_family: u32,
    mip_levels: Option<u32>,
  ) -> SarektResult<()> {
    if src_queue_family == dst_queue_family {
      return Ok(());
    }

    // Do the wait in the dst queue.
    let subresource_range = vk::ImageSubresourceRange::builder()
      .aspect_mask(vk::ImageAspectFlags::COLOR)
      .base_mip_level(0)
      .level_count(mip_levels.unwrap_or(1))
      .base_array_layer(0)
      .layer_count(1)
      .build();
    let barriers = [vk::ImageMemoryBarrier::builder()
        .old_layout(vk::ImageLayout::TRANSFER_DST_OPTIMAL)
        .new_layout(vk::ImageLayout::TRANSFER_DST_OPTIMAL)
        .src_queue_family_index(src_queue_family) // Transfer ownership to graphics queue if necessary.
        .dst_queue_family_index(dst_queue_family)
        .image(gpu_image)
        .subresource_range(subresource_range)
        .src_access_mask(vk::AccessFlags::empty()) // ignored according to the spec.
        .dst_access_mask(vk::AccessFlags::SHADER_READ)
        .build()];
    self.logical_device.cmd_pipeline_barrier(
      self.graphics_command_buffer,
      vk::PipelineStageFlags::TOP_OF_PIPE,
      vk::PipelineStageFlags::FRAGMENT_SHADER,
      vk::DependencyFlags::empty(),
      &[],
      &[],
      &barriers,
    );

    Ok(())
  }
/// When a memory barrier is inserted that transfers queue ownership, the
/// accept end of the memory barrier must also be run in a command buffer of
/// the queue taking ownership of the resource.
When a memory barrier is inserted that transfers queue ownership, the
accept end of the memory barrier must also be run in a command buffer of
the queue taking ownership of the resource.
When a memory barrier is inserted that transfers queue ownership the accept end of the memory barrier must also be run in a command buffer of the queue taking ownership of the resource .
unsafe fn transfer_image_queue_ownership_if_necessary(
    &self, gpu_image: vk::Image, src_queue_family: u32, dst_queue_family: u32,
    mip_levels: Option<u32>,
  ) -> SarektResult<()> {
    if src_queue_family == dst_queue_family {
      return Ok(());
    }
    // Do the wait in the dst queue.
    let subresource_range = vk::ImageSubresourceRange::builder()
      .aspect_mask(vk::ImageAspectFlags::COLOR)
      .base_mip_level(0)
      .level_count(mip_levels.unwrap_or(1))
      .base_array_layer(0)
      .layer_count(1)
      .build();
    let barriers = [vk::ImageMemoryBarrier::builder()
        .old_layout(vk::ImageLayout::TRANSFER_DST_OPTIMAL)
        .new_layout(vk::ImageLayout::TRANSFER_DST_OPTIMAL)
        .src_queue_family_index(src_queue_family) // Transfer ownership to graphics queue if necessary.
        .dst_queue_family_index(dst_queue_family)
        .image(gpu_image)
        .subresource_range(subresource_range)
        .src_access_mask(vk::AccessFlags::empty()) // ignored according to the spec.
        .dst_access_mask(vk::AccessFlags::SHADER_READ)
        .build()];
    self.logical_device.cmd_pipeline_barrier(
      self.graphics_command_buffer,
      vk::PipelineStageFlags::TOP_OF_PIPE,
      vk::PipelineStageFlags::FRAGMENT_SHADER,
      vk::DependencyFlags::empty(),
      &[],
      &[],
      &barriers,
    );
    Ok(())
  }
unsafe fn transfer_image_queue_ownership_if_necessary ( & self , gpu_image : vk :: Image , src_queue_family : u32 , dst_queue_family : u32 , mip_levels : Option < u32 > , ) -> SarektResult < ( ) > { if src_queue_family == dst_queue_family { return Ok ( ( ) ) ; } // Do the wait in the dst queue. let subresource_range = vk :: ImageSubresourceRange :: builder ( ) . aspect_mask ( vk :: ImageAspectFlags :: COLOR ) . base_mip_level ( 0 ) . level_count ( mip_levels . unwrap_or ( 1 ) ) . base_array_layer ( 0 ) . layer_count ( 1 ) . build ( ) ; let barriers = [ vk :: ImageMemoryBarrier :: builder ( ) . old_layout ( vk :: ImageLayout :: TRANSFER_DST_OPTIMAL ) . new_layout ( vk :: ImageLayout :: TRANSFER_DST_OPTIMAL ) . src_queue_family_index ( src_queue_family ) // Transfer ownership to graphics queue if necessary. . dst_queue_family_index ( dst_queue_family ) . image ( gpu_image ) . subresource_range ( subresource_range ) . src_access_mask ( vk :: AccessFlags :: empty ( ) ) // ignored according to the spec. . dst_access_mask ( vk :: AccessFlags :: SHADER_READ ) . build ( ) ] ; self . logical_device . cmd_pipeline_barrier ( self . graphics_command_buffer , vk :: PipelineStageFlags :: TOP_OF_PIPE , vk :: PipelineStageFlags :: FRAGMENT_SHADER , vk :: DependencyFlags :: empty ( ) , & [ ] , & [ ] , & barriers , ) ; Ok ( ( ) ) }
When a memory barrier is inserted that transfers queue ownership, the
accept end of the memory barrier must also be run in a command buffer of
the queue taking ownership of the resource.
When a memory barrier is inserted that transfers queue ownership the accept end of the memory barrier must also be run in a command buffer of the queue taking ownership of the resource .
&self
gpu_image
vk::Image
src_queue_family
u32
dst_queue_family
u32
mip_levels
Option<u32>
&self
gpu_image
vk::Image
src_queue_family
u32
dst_queue_family
u32
mip_levels
Option<u32>