Struct ccthw::graphics::vulkan_api::Swapchain
source · pub struct Swapchain { /* private fields */ }
Expand description
The Vulkan swapchain, loader, images, image views, and related data.
It’s often useful to keep the raw Vulkan swapchain together with all of it’s related information. It’s also helpful to have a newtype which can define some helper functions for working with swapchain resources.
Implementations§
source§impl Swapchain
impl Swapchain
sourcepub unsafe fn acquire_swapchain_image(
&self,
semaphore: Semaphore,
fence: Fence
) -> Result<SwapchainStatus, GraphicsError>
pub unsafe fn acquire_swapchain_image( &self, semaphore: Semaphore, fence: Fence ) -> Result<SwapchainStatus, GraphicsError>
sourcepub unsafe fn present_swapchain_image(
&self,
index: usize,
wait_semaphores: &[Semaphore]
) -> Result<SwapchainStatus, GraphicsError>
pub unsafe fn present_swapchain_image( &self, index: usize, wait_semaphores: &[Semaphore] ) -> Result<SwapchainStatus, GraphicsError>
Present a swapchain image to the screen.
Safety
Unsafe because:
- the application must correctly handle a swapchain acquisition failure and rebuild the swapchain on demand
- the application must transition the swapchain image to the correct image layout. Typically this is done with a Render Pass.
source§impl Swapchain
impl Swapchain
sourcepub unsafe fn new(
render_device: Arc<RenderDevice>,
framebuffer_size: (u32, u32),
previous_swapchain: Option<Self>
) -> Result<Self, GraphicsError>
pub unsafe fn new( render_device: Arc<RenderDevice>, framebuffer_size: (u32, u32), previous_swapchain: Option<Self> ) -> Result<Self, GraphicsError>
Create a new swapchain and acompanying resources.
Params
render_device
- the device used to create vulkan resourcesframebuffer_size
- the size of the window’s framebuffer in device pixels.previous_swapchain
- the previous swapchain (if any). This is provided to the new swapchain and will be destroyed inside this method.
Safety
Unsafe because:
- the application must destroy the swapchain before the render device
- the application must synchronize access to GPU resources
- the application is responsible for ensuring no GPU resources still reference the previous swapchain when it is provided to this method. The previous swapchain will be destroyed when the new swapchain is constructed.
sourcepub unsafe fn images(&self) -> &[Image]
pub unsafe fn images(&self) -> &[Image]
Access the raw Swapchain images.
Safety
Unsafe because:
- the application must synchronize access to swapchain images
- the images are destroyed when the swapchain is replaced, the application must ensure the image handles are not referenced after any calls to destroy.
sourcepub fn image_format(&self) -> Format
pub fn image_format(&self) -> Format
The format used by images in the swapchain.
sourcepub fn present_mode(&self) -> PresentModeKHR
pub fn present_mode(&self) -> PresentModeKHR
The presentation mode used by this swapchain.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Swapchain
impl !Send for Swapchain
impl !Sync for Swapchain
impl Unpin for Swapchain
impl UnwindSafe for Swapchain
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.