Function Prototype

vkCreateAndroidSurfaceKHR

Create a slink:VkSurfaceKHR object for an Android native window

To create a VkSurfaceKHR object for an Android native window, call:

VkResult vkCreateAndroidSurfaceKHR(
    VkInstance instance,
    const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
    const VkAllocationCallbacks* pAllocator,
    VkSurfaceKHR* pSurface);
  • instance is the instance to associate the surface with.
  • pCreateInfo is a pointer to a VkAndroidSurfaceCreateInfoKHR structure containing parameters affecting the creation of the surface object.
  • pAllocator is the allocator used for host memory allocated for the surface object when there is no more specific allocator available (see Memory Allocation).
  • pSurface is a pointer to a VkSurfaceKHR handle in which the created surface object is returned.

During the lifetime of a surface created using a particular ANativeWindow handle any attempts to create another surface for the same ANativeWindow and any attempts to connect to the same ANativeWindow through other platform mechanisms will fail.

In particular, only one VkSurfaceKHR can exist at a time for a given window. Similarly, a native window cannot be used by both a VkSurfaceKHR and EGLSurface simultaneously.

If successful, vkCreateAndroidSurfaceKHR increments the ANativeWindow’s reference count, and vkDestroySurfaceKHR will decrement it.

On Android, when a swapchain’s imageExtent does not match the surface’s currentExtent, the presentable images will be scaled to the surface’s dimensions during presentation. minImageExtent is (1,1), and maxImageExtent is the maximum image size supported by the consumer. For the system compositor, currentExtent is the window size (i.e. the consumer’s preferred size).

Valid Usage (Implicit)

VUID-vkCreateAndroidSurfaceKHR-pCreateInfo-parameter

pCreateInfo must be a valid pointer to a valid VkAndroidSurfaceCreateInfoKHR structure

VUID-vkCreateAndroidSurfaceKHR-pAllocator-parameter

If pAllocator is not NULL, pAllocator must be a valid pointer to a valid VkAllocationCallbacks structure

VUID-vkCreateAndroidSurfaceKHR-pSurface-parameter

pSurface must be a valid pointer to a VkSurfaceKHR handle