pub fn acquire_frame(&mut self) -> Result<Frame, SwapchainState> {
        if self.swapchain_state == SwapchainState::NeedsRebuild {
            return Err(SwapchainState::NeedsRebuild);
        }

        self.current_image_acquired_semaphore = self.frames_in_flight
            [self.current_frame_index]
            .as_ref()
            .expect("the current frame was never ended!")
            .sync
            .image_available_semaphore;

        let result = unsafe {
            self.swapchain.swapchain_loader.acquire_next_image(
                self.swapchain.swapchain,
                u64::MAX,
                self.current_image_acquired_semaphore,
                vk::Fence::null(),
            )
        };
        if let Err(vk::Result::ERROR_OUT_OF_DATE_KHR) = result {
            return Err(SwapchainState::NeedsRebuild);
        }
        if let Ok((_, true)) = result {
            return Err(SwapchainState::NeedsRebuild);
        }

        let (index, _) = result.ok().unwrap();
        self.current_frame_index = index as usize;

        let mut current_frame = self.frames_in_flight[self.current_frame_index]
            .take()
            .expect("the current frame was never returned!");

        current_frame
            .begin_frame()
            .expect("unable to begin the current frame!");

        Ok(current_frame)
    }
/// Acquire the next swapchain image and select the frame-specific
/// resources which are now ready to be used.
Acquire the next swapchain image and select the frame-specific
resources which are now ready to be used.
Acquire the next swapchain image and select the frame - specific resources which are now ready to be used .
pub fn acquire_frame(&mut self) -> Result<Frame, SwapchainState> {
        if self.swapchain_state == SwapchainState::NeedsRebuild {
            return Err(SwapchainState::NeedsRebuild);
        }
        self.current_image_acquired_semaphore = self.frames_in_flight
            [self.current_frame_index]
            .as_ref()
            .expect("the current frame was never ended!")
            .sync
            .image_available_semaphore;
        let result = unsafe {
            self.swapchain.swapchain_loader.acquire_next_image(
                self.swapchain.swapchain,
                u64::MAX,
                self.current_image_acquired_semaphore,
                vk::Fence::null(),
            )
        };
        if let Err(vk::Result::ERROR_OUT_OF_DATE_KHR) = result {
            return Err(SwapchainState::NeedsRebuild);
        }
        if let Ok((_, true)) = result {
            return Err(SwapchainState::NeedsRebuild);
        }
        let (index, _) = result.ok().unwrap();
        self.current_frame_index = index as usize;
        let mut current_frame = self.frames_in_flight[self.current_frame_index]
            .take()
            .expect("the current frame was never returned!");
        current_frame
            .begin_frame()
            .expect("unable to begin the current frame!");
        Ok(current_frame)
    }
pub fn acquire_frame ( & mut self ) -> Result < Frame , SwapchainState > { if self . swapchain_state == SwapchainState :: NeedsRebuild { return Err ( SwapchainState :: NeedsRebuild ) ; } self . current_image_acquired_semaphore = self . frames_in_flight [ self . current_frame_index ] . as_ref ( ) . expect ( " " ) . sync . image_available_semaphore ; let result = unsafe { self . swapchain . swapchain_loader . acquire_next_image ( self . swapchain . swapchain , u64 :: MAX , self . current_image_acquired_semaphore , vk :: Fence :: null ( ) , ) } ; if let Err ( vk :: Result :: ERROR_OUT_OF_DATE_KHR ) = result { return Err ( SwapchainState :: NeedsRebuild ) ; } if let Ok ( ( _ , true ) ) = result { return Err ( SwapchainState :: NeedsRebuild ) ; } let ( index , _ ) = result . ok ( ) . unwrap ( ) ; self . current_frame_index = index as usize ; let mut current_frame = self . frames_in_flight [ self . current_frame_index ] . take ( ) . expect ( " " ) ; current_frame . begin_frame ( ) . expect ( " " ) ; Ok ( current_frame ) }
Acquire the next swapchain image and select the frame-specific
resources which are now ready to be used.
Acquire the next swapchain image and select the frame - specific resources which are now ready to be used .
&mut self