pub fn ensure_image_resources_ready(
    &self, image_index: usize, current_frame_num: usize,
  ) -> SarektResult<vk::Fence> {
    if current_frame_num >= MAX_FRAMES_IN_FLIGHT || image_index >= self.image_to_frame_fence.len() {
      panic!(
        "Invalid input! image_index: {} current_frame_num: {}",
        image_index, current_frame_num
      );
    }

    unsafe {
      // Wait for swapchain image resources to be ready.
      let image_fence = self.image_to_frame_fence[image_index as usize].get();
      if image_fence != vk::Fence::null() {
        self
          .logical_device
          .wait_for_fences(&[image_fence], true, u64::max_value())?;
      }

      // Wait for the frame in flight to be ready (there are a max number of frames in
      // flight).
      let frame_fence = self.frame_fences[current_frame_num];
      if frame_fence != image_fence {
        // Wait for swap chain image to be ready.
        self
          .logical_device
          .wait_for_fences(&[frame_fence], true, u64::max_value())?;
      }

      self.logical_device.reset_fences(&[frame_fence])?;

      Ok(frame_fence)
    }
  }
/// Ensures that the image is not currently in flight, so the command buffers
/// for it are safe to write to (they are in the ready state).
///
/// Returns the frame fence to submit the next queue with.
Ensures that the image is not currently in flight, so the command buffers
for it are safe to write to (they are in the ready state).

Returns the frame fence to submit the next queue with.
Ensures that the image is not currently in flight so the command buffers for it are safe to write to ( they are in the ready state ) . Returns the frame fence to submit the next queue with .
pub fn ensure_image_resources_ready(
    &self, image_index: usize, current_frame_num: usize,
  ) -> SarektResult<vk::Fence> {
    if current_frame_num >= MAX_FRAMES_IN_FLIGHT || image_index >= self.image_to_frame_fence.len() {
      panic!(
        "Invalid input! image_index: {} current_frame_num: {}",
        image_index, current_frame_num
      );
    }
    unsafe {
      // Wait for swapchain image resources to be ready.
      let image_fence = self.image_to_frame_fence[image_index as usize].get();
      if image_fence != vk::Fence::null() {
        self
          .logical_device
          .wait_for_fences(&[image_fence], true, u64::max_value())?;
      }
      // Wait for the frame in flight to be ready (there are a max number of frames in
      // flight).
      let frame_fence = self.frame_fences[current_frame_num];
      if frame_fence != image_fence {
        // Wait for swap chain image to be ready.
        self
          .logical_device
          .wait_for_fences(&[frame_fence], true, u64::max_value())?;
      }
      self.logical_device.reset_fences(&[frame_fence])?;
      Ok(frame_fence)
    }
  }
pub fn ensure_image_resources_ready ( & self , image_index : usize , current_frame_num : usize , ) -> SarektResult < vk :: Fence > { if current_frame_num >= MAX_FRAMES_IN_FLIGHT || image_index >= self . image_to_frame_fence . len ( ) { panic ! ( " " image_index current_frame_num ) ; } unsafe { // Wait for swapchain image resources to be ready. let image_fence = self . image_to_frame_fence [ image_index as usize ] . get ( ) ; if image_fence != vk :: Fence :: null ( ) { self . logical_device . wait_for_fences ( & [ image_fence ] , true , u64 :: max_value ( ) ) ? ; } // Wait for the frame in flight to be ready (there are a max number of frames in // flight). let frame_fence = self . frame_fences [ current_frame_num ] ; if frame_fence != image_fence { // Wait for swap chain image to be ready. self . logical_device . wait_for_fences ( & [ frame_fence ] , true , u64 :: max_value ( ) ) ? ; } self . logical_device . reset_fences ( & [ frame_fence ] ) ? ; Ok ( frame_fence ) } }
Ensures that the image is not currently in flight, so the command buffers
for it are safe to write to (they are in the ready state).
Ensures that the image is not currently in flight so the command buffers for it are safe to write to ( they are in the ready state ) .
&self
image_index
usize
current_frame_num
usize
&self
image_index
usize
current_frame_num
usize