C Specification
The VkSwapchainCreateInfoKHR
structure is defined as:
// Provided by VK_KHR_swapchain
typedef struct VkSwapchainCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkSwapchainCreateFlagsKHR flags;
VkSurfaceKHR surface;
uint32_t minImageCount;
VkFormat imageFormat;
VkColorSpaceKHR imageColorSpace;
VkExtent2D imageExtent;
uint32_t imageArrayLayers;
VkImageUsageFlags imageUsage;
VkSharingMode imageSharingMode;
uint32_t queueFamilyIndexCount;
const uint32_t* pQueueFamilyIndices;
VkSurfaceTransformFlagBitsKHR preTransform;
VkCompositeAlphaFlagBitsKHR compositeAlpha;
VkPresentModeKHR presentMode;
VkBool32 clipped;
VkSwapchainKHR oldSwapchain;
} VkSwapchainCreateInfoKHR;
Members
-
sType
is the type of this structure. -
pNext
isNULL
or a pointer to a structure extending this structure. -
flags
is a bitmask of VkSwapchainCreateFlagBitsKHR indicating parameters of the swapchain creation. -
surface
is the surface onto which the swapchain will present images. If the creation succeeds, the swapchain becomes associated withsurface
. -
minImageCount
is the minimum number of presentable images that the application needs. The implementation will either create the swapchain with at least that many images, or it will fail to create the swapchain. -
imageFormat
is a VkFormat value specifying the format the swapchain image(s) will be created with. -
imageColorSpace
is a VkColorSpaceKHR value specifying the way the swapchain interprets image data. -
imageExtent
is the size (in pixels) of the swapchain image(s). The behavior is platform-dependent if the image extent does not match the surface’scurrentExtent
as returned byvkGetPhysicalDeviceSurfaceCapabilitiesKHR
.NoteOn some platforms, it is normal that
maxImageExtent
may become(0, 0)
, for example when the window is minimized. In such a case, it is not possible to create a swapchain due to the Valid Usage requirements , unless scaling is selected through VkSwapchainPresentScalingCreateInfoEXT, if supported . -
imageArrayLayers
is the number of views in a multiview/stereo surface. For non-stereoscopic-3D applications, this value is 1. -
imageUsage
is a bitmask of VkImageUsageFlagBits describing the intended usage of the (acquired) swapchain images. -
imageSharingMode
is the sharing mode used for the image(s) of the swapchain. -
queueFamilyIndexCount
is the number of queue families having access to the image(s) of the swapchain whenimageSharingMode
isVK_SHARING_MODE_CONCURRENT
. -
pQueueFamilyIndices
is a pointer to an array of queue family indices having access to the images(s) of the swapchain whenimageSharingMode
isVK_SHARING_MODE_CONCURRENT
. -
preTransform
is a VkSurfaceTransformFlagBitsKHR value describing the transform, relative to the presentation engine’s natural orientation, applied to the image content prior to presentation. If it does not match thecurrentTransform
value returned byvkGetPhysicalDeviceSurfaceCapabilitiesKHR
, the presentation engine will transform the image content as part of the presentation operation. -
compositeAlpha
is a VkCompositeAlphaFlagBitsKHR value indicating the alpha compositing mode to use when this surface is composited together with other surfaces on certain window systems. -
presentMode
is the presentation mode the swapchain will use. A swapchain’s present mode determines how incoming present requests will be processed and queued internally. -
clipped
specifies whether the Vulkan implementation is allowed to discard rendering operations that affect regions of the surface that are not visible.-
If set to
VK_TRUE
, the presentable images associated with the swapchain may not own all of their pixels. Pixels in the presentable images that correspond to regions of the target surface obscured by another window on the desktop, or subject to some other clipping mechanism will have undefined content when read back. Fragment shaders may not execute for these pixels, and thus any side effects they would have had will not occur. SettingVK_TRUE
does not guarantee any clipping will occur, but allows more efficient presentation methods to be used on some platforms. -
If set to
VK_FALSE
, presentable images associated with the swapchain will own all of the pixels they contain.NoteApplications should set this value to
VK_TRUE
if they do not expect to read back the content of presentable images before presenting them or after reacquiring them, and if their fragment shaders do not have any side effects that require them to run for all pixels in the presentable image.
-
-
oldSwapchain
is VK_NULL_HANDLE, or the existing non-retired swapchain currently associated withsurface
. Providing a validoldSwapchain
may aid in the resource reuse, and also allows the application to still present any images that are already acquired from it.
Description
Upon calling vkCreateSwapchainKHR
with an oldSwapchain
that is
not VK_NULL_HANDLE, oldSwapchain
is retired — even if creation
of the new swapchain fails.
The new swapchain is created in the non-retired state whether or not
oldSwapchain
is VK_NULL_HANDLE.
Upon calling vkCreateSwapchainKHR
with an oldSwapchain
that is
not VK_NULL_HANDLE, any images from oldSwapchain
that are not
acquired by the application may be freed by the implementation, which may
occur even if creation of the new swapchain fails.
The application can destroy oldSwapchain
to free all memory
associated with oldSwapchain
.
Note
Multiple retired swapchains can be associated with the same
After The application can continue to use a shared presentable image obtained
from |
See Also
VK_KHR_swapchain, VkBool32, VkColorSpaceKHR, VkCompositeAlphaFlagBitsKHR, VkExtent2D, VkFormat, VkImageUsageFlags, VkPresentModeKHR, VkSharingMode, VkStructureType, VkSurfaceKHR, VkSurfaceTransformFlagBitsKHR, VkSwapchainCreateFlagsKHR, VkSwapchainKHR, vkCreateSharedSwapchainsKHR, vkCreateSwapchainKHR
Document Notes
For more information, see the Vulkan Specification
This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.