Struct ccthw::graphics::vulkan_api::FramesInFlight
source · pub struct FramesInFlight { /* private fields */ }
Expand description
A utility for synchronizing graphics commands and submission for multiple in-flight frames.
Implementations§
source§impl FramesInFlight
impl FramesInFlight
sourcepub unsafe fn new(
render_device: Arc<RenderDevice>,
framebuffer_size: (i32, i32),
frame_count: usize
) -> Result<Self, GraphicsError>
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 resourcesframebuffer_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.
sourcepub unsafe fn wait_for_all_frames_to_complete(
&self
) -> Result<(), GraphicsError>
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
.
sourcepub unsafe fn stall_and_rebuild_swapchain(
&mut self,
framebuffer_size: (i32, i32)
) -> Result<(), GraphicsError>
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 withpresent_frame
.
sourcepub fn invalidate_swapchain(&mut self)
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).
sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
The maximum number of in-flight frames.
sourcepub fn acquire_frame(&mut self) -> Result<FrameStatus, GraphicsError>
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.
sourcepub fn present_frame(&mut self, frame: Frame) -> Result<(), GraphicsError>
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§
Auto Trait Implementations§
impl RefUnwindSafe for FramesInFlight
impl !Send for FramesInFlight
impl !Sync for FramesInFlight
impl Unpin for FramesInFlight
impl UnwindSafe for FramesInFlight
Blanket Implementations§
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.