pub struct FramesInFlight { /* private fields */ }
Expand description

A utility for synchronizing graphics commands and submission for multiple in-flight frames.

Implementations§

source§

impl FramesInFlight

source

pub unsafe fn new( render_device: Arc<RenderDevice>, framebuffer_size: (i32, i32), frame_count: usize ) -> Result<Self, GraphicsError>

Create resources for synchronizing multiple in-flight frames.

Params
  • render_device - used to create all Vulkan resources
  • framebuffer_size - the size of the framebuffer in pixels. This is used to create the swapchain and acompanying images.
  • frame_count - the number of in-flight frames to support. Typically this is 2 for double-buffering or 3 for triple-buffering in-filght frames.
Safety

Unsafe because the application must destroy this struct prior to exiting. Furthermore, destruction of Vulkan resources which are used by in-flight frames should be delayed until all frames have finished executing or until the device is idle.

source

pub unsafe fn wait_for_all_frames_to_complete( &self ) -> Result<(), GraphicsError>

Wait for every frame’s commands to finish executing on the GPU.

Params
  • render_device - the render device used to create the frames in flight.
Safety

It is an error to wait for frames while recording commands for a frame. e.g. do not call this function between calls to acquire_frame and present_frame.

source

pub unsafe fn stall_and_rebuild_swapchain( &mut self, framebuffer_size: (i32, i32) ) -> Result<(), GraphicsError>

Wait for every frame to finish executing then rebuild the swapchain.

Safety

Unsafe because:

  • it is invalid to rebuild the swapchain while recording a frame. In other words, never call this function after getting a frame from acquire_frame and before returning that frame with present_frame.
source

pub fn swapchain(&self) -> &Swapchain

Get the current swapchain.

source

pub fn invalidate_swapchain(&mut self)

Manually invalidate the swapchain so it is forced to be rebuilt the next time a frame is requested.

This can be useful in cases where it’s known that the swapchain will need to be rebuilt (like when the application window is resized).

source

pub fn frame_count(&self) -> usize

The maximum number of in-flight frames.

source

pub fn acquire_frame(&mut self) -> Result<FrameStatus, GraphicsError>

Acquire the next frame for rendering.

Params
  • render_device - the render device used to create the frames in flight.
source

pub fn present_frame(&mut self, frame: Frame) -> Result<(), GraphicsError>

Submit a frame’s commands to the graphics queue and schedule the swapchain image for presentation.

Params
  • render_device - the render device used to create the frames in flight.
  • frame - the frame to present

Trait Implementations§

source§

impl Drop for FramesInFlight

source§

fn drop(&mut self)

Destroy all frame resources.

Safety

Unsafe because:

  • The application should drop this before any resources which are used by any frames.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.