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

source

pub unsafe fn acquire_swapchain_image( &self, semaphore: Semaphore, fence: Fence ) -> Result<SwapchainStatus, GraphicsError>

Acquire the next swapchain image.

Params
  • semaphore - a semaphore to signal when the swapchain image is available.
Safety

The application must correctly handle a swapchain acquisition failure and rebuild the swapchain on demand.

source

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

source

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 resources
  • framebuffer_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.
source

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.
source

pub fn image_format(&self) -> Format

The format used by images in the swapchain.

source

pub fn extent(&self) -> Extent2D

The extent for all swapchain images.

source

pub fn present_mode(&self) -> PresentModeKHR

The presentation mode used by this swapchain.

Trait Implementations§

source§

impl Debug for Swapchain

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Swapchain

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Swapchain

source§

fn drop(&mut self)

Destroy the swapchain.

Safety

Unsafe because:

  • the application must drop the swapchain before the logical device and vulkan instance
  • the application must synchronize access to GPU resources and ensure no pending operations still depend on the swapchain
source§

impl VulkanHandle for Swapchain

§

type Handle = SwapchainKHR

source§

unsafe fn raw(&self) -> &Self::Handle

Get the raw resource handle. Read more

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.