Getting the capabilities of a presentation surface
When we create a swapchain, we need to specify creation parameters. But we can't choose whatever values we want. We must provide values that fit into supported limits, which can be obtained from a presentation surface. So in order to properly create a swapchain, we need to acquire the surface's capabilities.
How to do it...
- Take the handle of a selected physical device enumerated using the
vkEnumeratePhysicalDevices()
function and store it in a variable of typeVkPhysicalDevice
namedphysical_device
. - Take the handle of a created presentation surface. Store it in a variable of type
VkSurfaceKHR
namedpresentation_surface
. - Create a variable of type
VkSurfaceCapabilitiesKHR
namedsurface_capabilities
. - Call
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, presentation_surface, &surface_capabilities)
for which provide the handles of the physical device and a presentation surface, and a pointer to thesurface_capabilities
variable. - If...