C Specification
To create a swapchain, call:
// Provided by VK_KHR_swapchain
VkResult vkCreateSwapchainKHR(
VkDevice device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSwapchainKHR* pSwapchain);
Parameters
-
device
is the device to create the swapchain for. -
pCreateInfo
is a pointer to a VkSwapchainCreateInfoKHR structure specifying the parameters of the created swapchain. -
pAllocator
is the allocator used for host memory allocated for the swapchain object when there is no more specific allocator available (see Memory Allocation). -
pSwapchain
is a pointer to a VkSwapchainKHR handle in which the created swapchain object will be returned.
Description
As mentioned above, if vkCreateSwapchainKHR
succeeds, it will return a
handle to a swapchain containing an array of at least
pCreateInfo->minImageCount
presentable images.
While acquired by the application, presentable images can be used in any way that equivalent non-presentable images can be used. A presentable image is equivalent to a non-presentable image created with the following VkImageCreateInfo parameters:
VkImageCreateInfo Field |
Value |
---|---|
|
all other bits are unset |
|
|
|
|
|
{ |
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The pCreateInfo->surface
must not be destroyed until after the
swapchain is destroyed.
If
the native window referred to by pCreateInfo->surface
is already
associated with a Vulkan swapchain, VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
must be returned.
If the native window referred to by pCreateInfo->surface
is already
associated with a non-Vulkan graphics API surface,
VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
must be returned.
The native window referred to by pCreateInfo->surface
must not become
associated with a non-Vulkan graphics API surface before all associated
Vulkan swapchains have been destroyed.
vkCreateSwapchainKHR
will return VK_ERROR_DEVICE_LOST
if the
logical device was lost.
However, VkSurfaceKHR
is not a child of any VkDevice
and is not
affected by the lost device.
After successfully recreating a VkDevice
, the same VkSurfaceKHR
can be used to create a new VkSwapchainKHR
, provided the previous one
was destroyed.
If
VkPhysicalDeviceVulkanSC10Properties::deviceNoDynamicHostAllocations
is VK_TRUE
, vkCreateSwapchainKHR
must not return
VK_ERROR_OUT_OF_HOST_MEMORY
.
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.