pub struct Swapchain { /* private fields */ }
Expand description
Contains the swapping system and the images that can be shown on a surface.
Implementations§
source§impl Swapchain
impl Swapchain
sourcepub fn new(
device: Arc<Device>,
surface: Arc<Surface>,
create_info: SwapchainCreateInfo
) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), Validated<VulkanError>>
pub fn new( device: Arc<Device>, surface: Arc<Surface>, create_info: SwapchainCreateInfo ) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), Validated<VulkanError>>
Creates a new Swapchain
.
This function returns the swapchain plus a list of the images that belong to the
swapchain. The order in which the images are returned is important for the
acquire_next_image
and present
functions.
Panics
- Panics if the device and the surface don’t belong to the same instance.
- Panics if
create_info.usage
is empty.
sourcepub fn recreate(
self: &Arc<Self>,
create_info: SwapchainCreateInfo
) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), Validated<VulkanError>>
pub fn recreate( self: &Arc<Self>, create_info: SwapchainCreateInfo ) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), Validated<VulkanError>>
Creates a new swapchain from this one.
Use this when a swapchain has become invalidated, such as due to window resizes.
Panics
- Panics if
create_info.usage
is empty.
sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: SwapchainKHR,
image_handles: impl IntoIterator<Item = Image>,
surface: Arc<Surface>,
create_info: SwapchainCreateInfo
) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), VulkanError>
pub unsafe fn from_handle( device: Arc<Device>, handle: SwapchainKHR, image_handles: impl IntoIterator<Item = Image>, surface: Arc<Surface>, create_info: SwapchainCreateInfo ) -> Result<(Arc<Swapchain>, Vec<Arc<Image>>), VulkanError>
Creates a new Swapchain
from a raw object handle.
Safety
handle
andimage_handles
must be valid Vulkan object handles created fromdevice
.handle
must not be retired.image_handles
must be swapchain images owned byhandle
, in the same order as they were returned byvkGetSwapchainImagesKHR
.surface
andcreate_info
must match the info used to create the object.
sourcepub fn create_info(&self) -> SwapchainCreateInfo
pub fn create_info(&self) -> SwapchainCreateInfo
Returns the creation parameters of the swapchain.
sourcepub fn surface(&self) -> &Arc<Surface>
pub fn surface(&self) -> &Arc<Surface>
Returns the surface that the swapchain was created from.
sourcepub fn flags(&self) -> SwapchainCreateFlags
pub fn flags(&self) -> SwapchainCreateFlags
Returns the flags that the swapchain was created with.
sourcepub fn index_of_image(&self, image: &Image) -> Option<u32>
pub fn index_of_image(&self, image: &Image) -> Option<u32>
If image
is one of the images of this swapchain, returns its index within the swapchain.
sourcepub fn image_count(&self) -> u32
pub fn image_count(&self) -> u32
Returns the number of images of the swapchain.
sourcepub fn image_format(&self) -> Format
pub fn image_format(&self) -> Format
Returns the format of the images of the swapchain.
sourcepub fn image_view_formats(&self) -> &[Format]
pub fn image_view_formats(&self) -> &[Format]
Returns the formats that an image view created from a swapchain image can have.
sourcepub fn image_color_space(&self) -> ColorSpace
pub fn image_color_space(&self) -> ColorSpace
Returns the color space of the images of the swapchain.
sourcepub fn image_extent(&self) -> [u32; 2]
pub fn image_extent(&self) -> [u32; 2]
Returns the extent of the images of the swapchain.
sourcepub fn image_array_layers(&self) -> u32
pub fn image_array_layers(&self) -> u32
Returns the number of array layers of the images of the swapchain.
sourcepub fn image_usage(&self) -> ImageUsage
pub fn image_usage(&self) -> ImageUsage
Returns the usage of the images of the swapchain.
sourcepub fn image_sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
pub fn image_sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
Returns the sharing of the images of the swapchain.
sourcepub fn pre_transform(&self) -> SurfaceTransform
pub fn pre_transform(&self) -> SurfaceTransform
Returns the pre-transform that was passed when creating the swapchain.
sourcepub fn composite_alpha(&self) -> CompositeAlpha
pub fn composite_alpha(&self) -> CompositeAlpha
Returns the alpha mode that was passed when creating the swapchain.
sourcepub fn present_mode(&self) -> PresentMode
pub fn present_mode(&self) -> PresentMode
Returns the present mode that was passed when creating the swapchain.
sourcepub fn present_modes(&self) -> &[PresentMode]
pub fn present_modes(&self) -> &[PresentMode]
Returns the alternative present modes that were passed when creating the swapchain.
sourcepub fn clipped(&self) -> bool
pub fn clipped(&self) -> bool
Returns the value of clipped
that was passed when creating the swapchain.
sourcepub fn scaling_behavior(&self) -> Option<PresentScaling>
pub fn scaling_behavior(&self) -> Option<PresentScaling>
Returns the scaling behavior that was passed when creating the swapchain.
sourcepub fn present_gravity(&self) -> Option<[PresentGravity; 2]>
pub fn present_gravity(&self) -> Option<[PresentGravity; 2]>
Returns the scaling behavior that was passed when creating the swapchain.
sourcepub fn full_screen_exclusive(&self) -> FullScreenExclusive
pub fn full_screen_exclusive(&self) -> FullScreenExclusive
Returns the value of ’full_screen_exclusive` that was passed when creating the swapchain.
sourcepub fn acquire_full_screen_exclusive_mode(
&self
) -> Result<(), Validated<VulkanError>>
pub fn acquire_full_screen_exclusive_mode( &self ) -> Result<(), Validated<VulkanError>>
Acquires full-screen exclusivity.
The swapchain must have been created with FullScreenExclusive::ApplicationControlled
,
and must not already hold full-screen exclusivity. Full-screen exclusivity is held until
either the release_full_screen_exclusive
is called, or if any of the the other Swapchain
functions return FullScreenExclusiveLost
.
sourcepub fn release_full_screen_exclusive_mode(
&self
) -> Result<(), Validated<VulkanError>>
pub fn release_full_screen_exclusive_mode( &self ) -> Result<(), Validated<VulkanError>>
Releases full-screen exclusivity.
The swapchain must have been created with FullScreenExclusive::ApplicationControlled
,
and must currently hold full-screen exclusivity.
sourcepub fn is_full_screen_exclusive(&self) -> bool
pub fn is_full_screen_exclusive(&self) -> bool
FullScreenExclusive::AppControlled
is not the active full-screen exclusivity mode,
then this function will always return false. If true is returned the swapchain
is in FullScreenExclusive::AppControlled
full-screen exclusivity mode and exclusivity
is currently acquired.