1// Copyright 2014-2023 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[platformCreateSurface_android]] 6=== Android Platform 7 8[open,refpage='vkCreateAndroidSurfaceKHR',desc='Create a slink:VkSurfaceKHR object for an Android native window',type='protos'] 9-- 10:refpage: vkCreateAndroidSurfaceKHR 11 12To create a sname:VkSurfaceKHR object for an Android native window, call: 13 14include::{generated}/api/protos/vkCreateAndroidSurfaceKHR.adoc[] 15 16 * pname:instance is the instance to associate the surface with. 17 * pname:pCreateInfo is a pointer to a sname:VkAndroidSurfaceCreateInfoKHR 18 structure containing parameters affecting the creation of the surface 19 object. 20 * pname:pAllocator is the allocator used for host memory allocated for the 21 surface object when there is no more specific allocator available (see 22 <<memory-allocation,Memory Allocation>>). 23 * pname:pSurface is a pointer to a slink:VkSurfaceKHR handle in which the 24 created surface object is returned. 25 26During the lifetime of a surface created using a particular 27basetype:ANativeWindow handle any attempts to create another surface for the 28same basetype:ANativeWindow and any attempts to connect to the same 29basetype:ANativeWindow through other platform mechanisms will fail. 30 31[NOTE] 32.Note 33==== 34In particular, only one sname:VkSurfaceKHR can: exist at a time for a given 35window. 36Similarly, a native window cannot: be used by both a sname:VkSurfaceKHR and 37code:EGLSurface simultaneously. 38==== 39 40If successful, fname:vkCreateAndroidSurfaceKHR increments the 41basetype:ANativeWindow's reference count, and fname:vkDestroySurfaceKHR will 42decrement it. 43 44On Android, when a swapchain's pname:imageExtent does not match the 45surface's pname:currentExtent, the presentable images will be scaled to the 46surface's dimensions during presentation. 47pname:minImageExtent is [eq]#(1,1)#, and pname:maxImageExtent is the maximum 48image size supported by the consumer. 49For the system compositor, pname:currentExtent is the window size (i.e. the 50consumer's preferred size). 51 52include::{generated}/validity/protos/vkCreateAndroidSurfaceKHR.adoc[] 53-- 54 55[open,refpage='VkAndroidSurfaceCreateInfoKHR',desc='Structure specifying parameters of a newly created Android surface object',type='structs'] 56-- 57The sname:VkAndroidSurfaceCreateInfoKHR structure is defined as: 58 59include::{generated}/api/structs/VkAndroidSurfaceCreateInfoKHR.adoc[] 60 61 * pname:sType is a elink:VkStructureType value identifying this structure. 62 * pname:pNext is `NULL` or a pointer to a structure extending this 63 structure. 64 * pname:flags is reserved for future use. 65 * pname:window is a pointer to the basetype:ANativeWindow to associate the 66 surface with. 67 68.Valid Usage 69**** 70 * [[VUID-VkAndroidSurfaceCreateInfoKHR-window-01248]] 71 pname:window must: point to a valid Android basetype:ANativeWindow 72**** 73 74include::{generated}/validity/structs/VkAndroidSurfaceCreateInfoKHR.adoc[] 75-- 76 77[open,refpage='ANativeWindow',desc='Android native window type',type='basetypes'] 78-- 79To remove an unnecessary compile time dependency, an incomplete type 80definition of basetype:ANativeWindow is provided in the Vulkan headers: 81 82include::{generated}/api/basetypes/ANativeWindow.adoc[] 83 84The actual basetype:ANativeWindow type is defined in Android NDK headers. 85-- 86 87[open,refpage='VkAndroidSurfaceCreateFlagsKHR',desc='Reserved for future use',type='flags'] 88-- 89include::{generated}/api/flags/VkAndroidSurfaceCreateFlagsKHR.adoc[] 90 91tname:VkAndroidSurfaceCreateFlagsKHR is a bitmask type for setting a mask, 92but is currently reserved for future use. 93-- 94