1 // Copyright (C) 2018 The Android Open Source Project
2 // Copyright (C) 2018 Google Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 #pragma once
16 
17 #include <vulkan/vulkan.h>
18 
19 #ifdef __cplusplus
20 #include <algorithm>
21 extern "C" {
22 #endif
23 
24 #define VK_ANDROID_native_buffer 1
25 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 11
26 
27 /* NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 6
28  *
29  * This version of the extension transitions from gralloc0 to gralloc1 usage
30  * flags (int -> 2x uint64_t). The WSI implementation will temporarily continue
31  * to fill out deprecated fields in VkNativeBufferANDROID, and will call the
32  * deprecated vkGetSwapchainGrallocUsageANDROID if the new
33  * vkGetSwapchainGrallocUsage2ANDROID is not supported. This transitionary
34  * backwards-compatibility support is temporary, and will likely be removed in
35  * (along with all gralloc0 support) in a future release.
36  */
37 #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION     7
38 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME   "VK_ANDROID_native_buffer"
39 
40 #define VK_ANDROID_NATIVE_BUFFER_ENUM(type,id)    ((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id)))
41 #define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID   VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0)
42 #define VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1)
43 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2)
44 
45 typedef enum VkSwapchainImageUsageFlagBitsANDROID {
46     VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID = 0x00000001,
47     VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
48 } VkSwapchainImageUsageFlagBitsANDROID;
49 typedef VkFlags VkSwapchainImageUsageFlagsANDROID;
50 
51 typedef struct {
52     VkStructureType             sType; // must be VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID
53     const void*                 pNext;
54 
55     // Buffer handle and stride returned from gralloc alloc()
56     const uint32_t*             handle;
57     int                         stride;
58 
59     // Gralloc format and usage requested when the buffer was allocated.
60     int                         format;
61     int                         usage; // DEPRECATED in SPEC_VERSION 6
62     // -- Added in SPEC_VERSION 6 --
63     uint64_t                consumer;
64     uint64_t                producer;
65 } VkNativeBufferANDROID;
66 
67 typedef struct {
68     VkStructureType                        sType; // must be VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID
69     const void*                            pNext;
70 
71     VkSwapchainImageUsageFlagsANDROID      usage;
72 } VkSwapchainImageCreateInfoANDROID;
73 
74 typedef struct {
75     VkStructureType                        sType; // must be VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID
76     const void*                            pNext;
77 
78     VkBool32                               sharedImage;
79 } VkPhysicalDevicePresentationPropertiesANDROID;
80 
81 // -- DEPRECATED in SPEC_VERSION 6 --
82 typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
83 // -- ADDED in SPEC_VERSION 6 --
84 typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage);
85 typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
86 typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalReleaseImageANDROID)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
87 
88 #define VK_GOOGLE_address_space 1
89 
90 typedef VkResult (VKAPI_PTR *PFN_vkMapMemoryIntoAddressSpaceGOOGLE)(VkDevice device, VkDeviceMemory memory, uint64_t* pAddress);
91 
92 #define VK_GOOGLE_color_buffer 1
93 #define VK_GOOGLE_COLOR_BUFFER_EXTENSION_NUMBER 219
94 
95 #define VK_GOOGLE_COLOR_BUFFER_ENUM(type,id)    ((type)(1000000000 + (1000 * (VK_GOOGLE_COLOR_BUFFER_EXTENSION_NUMBER - 1)) + (id)))
96 #define VK_STRUCTURE_TYPE_IMPORT_COLOR_BUFFER_GOOGLE   VK_GOOGLE_COLOR_BUFFER_ENUM(VkStructureType, 0)
97 #define VK_STRUCTURE_TYPE_IMPORT_PHYSICAL_ADDRESS_GOOGLE   VK_GOOGLE_COLOR_BUFFER_ENUM(VkStructureType, 1)
98 #define VK_STRUCTURE_TYPE_IMPORT_BUFFER_GOOGLE   VK_GOOGLE_COLOR_BUFFER_ENUM(VkStructureType, 2)
99 
100 typedef struct {
101     VkStructureType sType; // must be VK_STRUCTURE_TYPE_IMPORT_COLOR_BUFFER_GOOGLE
102     const void* pNext;
103     uint32_t colorBuffer;
104 } VkImportColorBufferGOOGLE;
105 
106 typedef struct {
107     VkStructureType sType; // must be VK_STRUCTURE_TYPE_IMPORT_PHYSICAL_ADDRESS_GOOGLE
108     const void* pNext;
109     uint64_t physicalAddress;
110     VkDeviceSize size;
111     VkFormat format;
112     VkImageTiling tiling;
113     uint32_t tilingParameter;
114 } VkImportPhysicalAddressGOOGLE;
115 
116 typedef struct {
117     VkStructureType sType; // must be VK_STRUCTURE_TYPE_IMPORT_BUFFER_GOOGLE
118     const void* pNext;
119     uint32_t buffer;
120 } VkImportBufferGOOGLE;
121 
122 typedef VkResult (VKAPI_PTR *PFN_vkRegisterImageColorBufferGOOGLE)(VkDevice device, VkImage image, uint32_t colorBuffer);
123 typedef VkResult (VKAPI_PTR *PFN_vkRegisterBufferColorBufferGOOGLE)(VkDevice device, VkBuffer image, uint32_t colorBuffer);
124 
125 #define VK_GOOGLE_address_space_info 1
126 
127 typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryHostAddressInfoGOOGLE)(VkDevice device, VkDeviceMemory memory, uint64_t* pAddress, uint64_t* pSize);
128 
129 #define VK_GOOGLE_free_memory_sync 1
130 
131 typedef VkResult (VKAPI_PTR *PFN_vkFreeMemorySyncGOOGLE)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocationCallbacks);
132 
133 #define VK_ANDROID_external_memory_android_hardware_buffer 1
134 struct AHardwareBuffer;
135 struct VkAndroidHardwareBufferPropertiesANDROID;
136 struct VkMemoryGetAndroidHardwareBufferInfoANDROID;
137 
138 #ifdef __Fuchsia__
139 
140 typedef struct VkAndroidHardwareBufferUsageANDROID {
141     VkStructureType    sType;
142     void*              pNext;
143     uint64_t           androidHardwareBufferUsage;
144 } VkAndroidHardwareBufferUsageANDROID;
145 
146 typedef struct VkAndroidHardwareBufferPropertiesANDROID {
147     VkStructureType    sType;
148     void*              pNext;
149     VkDeviceSize       allocationSize;
150     uint32_t           memoryTypeBits;
151 } VkAndroidHardwareBufferPropertiesANDROID;
152 
153 typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID {
154     VkStructureType                  sType;
155     void*                            pNext;
156     VkFormat                         format;
157     uint64_t                         externalFormat;
158     VkFormatFeatureFlags             formatFeatures;
159     VkComponentMapping               samplerYcbcrConversionComponents;
160     VkSamplerYcbcrModelConversion    suggestedYcbcrModel;
161     VkSamplerYcbcrRange              suggestedYcbcrRange;
162     VkChromaLocation                 suggestedXChromaOffset;
163     VkChromaLocation                 suggestedYChromaOffset;
164 } VkAndroidHardwareBufferFormatPropertiesANDROID;
165 
166 typedef struct VkImportAndroidHardwareBufferInfoANDROID {
167     VkStructureType            sType;
168     const void*                pNext;
169     struct AHardwareBuffer*    buffer;
170 } VkImportAndroidHardwareBufferInfoANDROID;
171 
172 typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID {
173     VkStructureType    sType;
174     const void*        pNext;
175     VkDeviceMemory     memory;
176 } VkMemoryGetAndroidHardwareBufferInfoANDROID;
177 
178 typedef struct VkExternalFormatANDROID {
179     VkStructureType    sType;
180     void*              pNext;
181     uint64_t           externalFormat;
182 } VkExternalFormatANDROID;
183 
184 
185 typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
186 typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);
187 
188 #ifndef VK_NO_PROTOTYPES
189 VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(
190     VkDevice                                    device,
191     const struct AHardwareBuffer*               buffer,
192     VkAndroidHardwareBufferPropertiesANDROID*   pProperties);
193 
194 VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(
195     VkDevice                                    device,
196     const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo,
197     struct AHardwareBuffer**                    pBuffer);
198 #endif
199 
200 /**
201  * Buffer pixel formats.
202  */
203 enum AHardwareBuffer_Format {
204     /**
205      * Corresponding formats:
206      *   Vulkan: VK_FORMAT_R8G8B8A8_UNORM
207      *   OpenGL ES: GL_RGBA8
208      */
209     AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM           = 1,
210     /**
211      * 32 bits per pixel, 8 bits per channel format where alpha values are
212      * ignored (always opaque).
213      * Corresponding formats:
214      *   Vulkan: VK_FORMAT_R8G8B8A8_UNORM
215      *   OpenGL ES: GL_RGB8
216      */
217     AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM           = 2,
218     /**
219      * Corresponding formats:
220      *   Vulkan: VK_FORMAT_R8G8B8_UNORM
221      *   OpenGL ES: GL_RGB8
222      */
223     AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM             = 3,
224     /**
225      * Corresponding formats:
226      *   Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16
227      *   OpenGL ES: GL_RGB565
228      */
229     AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM             = 4,
230     /**
231      * Corresponding formats:
232      *   Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT
233      *   OpenGL ES: GL_RGBA16F
234      */
235     AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT       = 0x16,
236     /**
237      * Corresponding formats:
238      *   Vulkan: VK_FORMAT_A2B10G10R10_UNORM_PACK32
239      *   OpenGL ES: GL_RGB10_A2
240      */
241     AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM        = 0x2b,
242     /**
243      * Opaque binary blob format.
244      * Must have height 1 and one layer, with width equal to the buffer
245      * size in bytes. Corresponds to Vulkan buffers and OpenGL buffer
246      * objects. Can be bound to the latter using GL_EXT_external_buffer.
247      */
248     AHARDWAREBUFFER_FORMAT_BLOB                     = 0x21,
249     /**
250      * Corresponding formats:
251      *   Vulkan: VK_FORMAT_D16_UNORM
252      *   OpenGL ES: GL_DEPTH_COMPONENT16
253      */
254     AHARDWAREBUFFER_FORMAT_D16_UNORM                = 0x30,
255     /**
256      * Corresponding formats:
257      *   Vulkan: VK_FORMAT_X8_D24_UNORM_PACK32
258      *   OpenGL ES: GL_DEPTH_COMPONENT24
259      */
260     AHARDWAREBUFFER_FORMAT_D24_UNORM                = 0x31,
261     /**
262      * Corresponding formats:
263      *   Vulkan: VK_FORMAT_D24_UNORM_S8_UINT
264      *   OpenGL ES: GL_DEPTH24_STENCIL8
265      */
266     AHARDWAREBUFFER_FORMAT_D24_UNORM_S8_UINT        = 0x32,
267     /**
268      * Corresponding formats:
269      *   Vulkan: VK_FORMAT_D32_SFLOAT
270      *   OpenGL ES: GL_DEPTH_COMPONENT32F
271      */
272     AHARDWAREBUFFER_FORMAT_D32_FLOAT                = 0x33,
273     /**
274      * Corresponding formats:
275      *   Vulkan: VK_FORMAT_D32_SFLOAT_S8_UINT
276      *   OpenGL ES: GL_DEPTH32F_STENCIL8
277      */
278     AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT        = 0x34,
279     /**
280      * Corresponding formats:
281      *   Vulkan: VK_FORMAT_S8_UINT
282      *   OpenGL ES: GL_STENCIL_INDEX8
283      */
284     AHARDWAREBUFFER_FORMAT_S8_UINT                  = 0x35,
285 };
286 /**
287  * Buffer usage flags, specifying how the buffer will be accessed.
288  */
289 enum AHardwareBuffer_UsageFlags {
290     /// The buffer will never be locked for direct CPU reads using the
291     /// AHardwareBuffer_lock() function. Note that reading the buffer
292     /// using OpenGL or Vulkan functions or memory mappings is still
293     /// allowed.
294     AHARDWAREBUFFER_USAGE_CPU_READ_NEVER        = 0UL,
295     /// The buffer will sometimes be locked for direct CPU reads using
296     /// the AHardwareBuffer_lock() function. Note that reading the
297     /// buffer using OpenGL or Vulkan functions or memory mappings
298     /// does not require the presence of this flag.
299     AHARDWAREBUFFER_USAGE_CPU_READ_RARELY       = 2UL,
300     /// The buffer will often be locked for direct CPU reads using
301     /// the AHardwareBuffer_lock() function. Note that reading the
302     /// buffer using OpenGL or Vulkan functions or memory mappings
303     /// does not require the presence of this flag.
304     AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN        = 3UL,
305     /// CPU read value mask.
306     AHARDWAREBUFFER_USAGE_CPU_READ_MASK         = 0xFUL,
307     /// The buffer will never be locked for direct CPU writes using the
308     /// AHardwareBuffer_lock() function. Note that writing the buffer
309     /// using OpenGL or Vulkan functions or memory mappings is still
310     /// allowed.
311     AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER       = 0UL << 4,
312     /// The buffer will sometimes be locked for direct CPU writes using
313     /// the AHardwareBuffer_lock() function. Note that writing the
314     /// buffer using OpenGL or Vulkan functions or memory mappings
315     /// does not require the presence of this flag.
316     AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY      = 2UL << 4,
317     /// The buffer will often be locked for direct CPU writes using
318     /// the AHardwareBuffer_lock() function. Note that writing the
319     /// buffer using OpenGL or Vulkan functions or memory mappings
320     /// does not require the presence of this flag.
321     AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN       = 3UL << 4,
322     /// CPU write value mask.
323     AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK        = 0xFUL << 4,
324     /// The buffer will be read from by the GPU as a texture.
325     AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE      = 1UL << 8,
326     /**
327      * The buffer will be written to by the GPU as a framebuffer
328      * attachment.
329      *
330      * Note that the name of this flag is somewhat misleading: it does
331      * not imply that the buffer contains a color format. A buffer with
332      * depth or stencil format that will be used as a framebuffer
333      * attachment should also have this flag.
334      */
335     AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT       = 1UL << 9,
336     /**
337      * The buffer is protected from direct CPU access or being read by
338      * non-secure hardware, such as video encoders.
339      *
340      * This flag is incompatible with CPU read and write flags. It is
341      * mainly used when handling DRM video. Refer to the EGL extension
342      * EGL_EXT_protected_content and GL extension
343      * GL_EXT_protected_textures for more information on how these
344      * buffers are expected to behave.
345      */
346     AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT      = 1UL << 14,
347     /// The buffer will be read by a hardware video encoder.
348     AHARDWAREBUFFER_USAGE_VIDEO_ENCODE           = 1UL << 16,
349     /**
350      * The buffer will be used for direct writes from sensors.
351      * When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB.
352      */
353     AHARDWAREBUFFER_USAGE_SENSOR_DIRECT_DATA     = 1UL << 23,
354     /**
355      * The buffer will be used as a shader storage or uniform buffer object.
356      * When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB.
357      */
358     AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER        = 1UL << 24,
359     /**
360      * The buffer will be used as a cube map texture.
361      * When this flag is present, the buffer must have a layer count
362      * that is a multiple of 6. Note that buffers with this flag must be
363      * bound to OpenGL textures using the extension
364      * GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image.
365      */
366     AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP               = 1UL << 25,
367     /**
368      * The buffer contains a complete mipmap hierarchy.
369      * Note that buffers with this flag must be bound to OpenGL textures using
370      * the extension GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image.
371      */
372     AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE        = 1UL << 26,
373     AHARDWAREBUFFER_USAGE_VENDOR_0  = 1ULL << 28,
374     AHARDWAREBUFFER_USAGE_VENDOR_1  = 1ULL << 29,
375     AHARDWAREBUFFER_USAGE_VENDOR_2  = 1ULL << 30,
376     AHARDWAREBUFFER_USAGE_VENDOR_3  = 1ULL << 31,
377     AHARDWAREBUFFER_USAGE_VENDOR_4  = 1ULL << 48,
378     AHARDWAREBUFFER_USAGE_VENDOR_5  = 1ULL << 49,
379     AHARDWAREBUFFER_USAGE_VENDOR_6  = 1ULL << 50,
380     AHARDWAREBUFFER_USAGE_VENDOR_7  = 1ULL << 51,
381     AHARDWAREBUFFER_USAGE_VENDOR_8  = 1ULL << 52,
382     AHARDWAREBUFFER_USAGE_VENDOR_9  = 1ULL << 53,
383     AHARDWAREBUFFER_USAGE_VENDOR_10 = 1ULL << 54,
384     AHARDWAREBUFFER_USAGE_VENDOR_11 = 1ULL << 55,
385     AHARDWAREBUFFER_USAGE_VENDOR_12 = 1ULL << 56,
386     AHARDWAREBUFFER_USAGE_VENDOR_13 = 1ULL << 57,
387     AHARDWAREBUFFER_USAGE_VENDOR_14 = 1ULL << 58,
388     AHARDWAREBUFFER_USAGE_VENDOR_15 = 1ULL << 59,
389     AHARDWAREBUFFER_USAGE_VENDOR_16 = 1ULL << 60,
390     AHARDWAREBUFFER_USAGE_VENDOR_17 = 1ULL << 61,
391     AHARDWAREBUFFER_USAGE_VENDOR_18 = 1ULL << 62,
392     AHARDWAREBUFFER_USAGE_VENDOR_19 = 1ULL << 63,
393 };
394 /**
395  * Buffer description. Used for allocating new buffers and querying
396  * parameters of existing ones.
397  */
398 typedef struct AHardwareBuffer_Desc {
399     uint32_t    width;      ///< Width in pixels.
400     uint32_t    height;     ///< Height in pixels.
401     /**
402      * Number of images in an image array. AHardwareBuffers with one
403      * layer correspond to regular 2D textures. AHardwareBuffers with
404      * more than layer correspond to texture arrays. If the layer count
405      * is a multiple of 6 and the usage flag
406      * AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP is present, the buffer is
407      * a cube map or a cube map array.
408      */
409     uint32_t    layers;
410     uint32_t    format;     ///< One of AHardwareBuffer_Format.
411     uint64_t    usage;      ///< Combination of AHardwareBuffer_UsageFlags.
412     uint32_t    stride;     ///< Row stride in pixels, ignored for AHardwareBuffer_allocate()
413     uint32_t    rfu0;       ///< Initialize to zero, reserved for future use.
414     uint64_t    rfu1;       ///< Initialize to zero, reserved for future use.
415 } AHardwareBuffer_Desc;
416 
417 #endif // __Fuchsia__
418 
419 #define VK_GOOGLE_sized_descriptor_update_template 1
420 
421 typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplateSizedGOOGLE)(
422     VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate,
423     uint32_t imageInfoCount,
424     uint32_t bufferInfoCount,
425     uint32_t bufferViewCount,
426     const uint32_t* pImageInfoEntryIndices,
427     const uint32_t* pBufferInfoEntryIndices,
428     const uint32_t* pBufferViewEntryIndices,
429     const VkDescriptorImageInfo* pImageInfos,
430     const VkDescriptorBufferInfo* pBufferInfos,
431     const VkBufferView* pBufferViews);
432 
433 #define VK_GOOGLE_async_command_buffers 1
434 
435 typedef void (VKAPI_PTR *PFN_vkBeginCommandBufferAsyncGOOGLE)(
436     VkCommandBuffer commandBuffer,
437     const VkCommandBufferBeginInfo* pBeginInfo);
438 typedef void (VKAPI_PTR *PFN_vkEndCommandBufferAsyncGOOGLE)(
439     VkCommandBuffer commandBuffer);
440 typedef void (VKAPI_PTR *PFN_vkResetCommandBufferAsyncGOOGLE)(
441     VkCommandBuffer commandBuffer,
442     VkCommandBufferResetFlags flags);
443 typedef void (VKAPI_PTR *PFN_vkCommandBufferHostSyncGOOGLE)(
444     VkCommandBuffer commandBuffer,
445     uint32_t needHostSync,
446     uint32_t sequenceNumber);
447 
448 #define VK_GOOGLE_create_resources_with_requirements 1
449 
450 typedef void (VKAPI_PTR *PFN_vkCreateImageWithRequirementsGOOGLE)(
451     VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage, VkMemoryRequirements* pMemoryRequirements);
452 
453 #ifndef VK_FUCHSIA_buffer_collection
454 #define VK_FUCHSIA_buffer_collection 1
455 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA)
456 
457 #define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 1
458 #define VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME "VK_FUCHSIA_buffer_collection"
459 
460 typedef struct VkBufferCollectionCreateInfoFUCHSIA {
461     VkStructureType    sType;
462     const void*        pNext;
463     uint32_t           collectionToken;
464 } VkBufferCollectionCreateInfoFUCHSIA;
465 
466 typedef struct VkImportMemoryBufferCollectionFUCHSIA {
467     VkStructureType              sType;
468     const void*                  pNext;
469     VkBufferCollectionFUCHSIA    collection;
470     uint32_t                     index;
471 } VkImportMemoryBufferCollectionFUCHSIA;
472 
473 typedef struct VkBufferCollectionImageCreateInfoFUCHSIA {
474     VkStructureType              sType;
475     const void*                  pNext;
476     VkBufferCollectionFUCHSIA    collection;
477     uint32_t                     index;
478 } VkBufferCollectionImageCreateInfoFUCHSIA;
479 
480 typedef struct VkBufferCollectionBufferCreateInfoFUCHSIA {
481     VkStructureType              sType;
482     const void*                  pNext;
483     VkBufferCollectionFUCHSIA    collection;
484     uint32_t                     index;
485 } VkBufferCollectionBufferCreateInfoFUCHSIA;
486 
487 typedef struct VkBufferCollectionPropertiesFUCHSIA {
488     VkStructureType    sType;
489     void*              pNext;
490     uint32_t           memoryTypeBits;
491     uint32_t           count;
492 } VkBufferCollectionPropertiesFUCHSIA;
493 
494 #define VK_STRUCTURE_TYPE_IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA       \
495     ((VkStructureType)1001004004)
496 #define VK_STRUCTURE_TYPE_BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA \
497     ((VkStructureType)1001004005)
498 #define VK_STRUCTURE_TYPE_BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA \
499     ((VkStructureType)1001004008)
500 #endif  // VK_FUCHSIA_buffer_collection
501 
502 #ifndef VK_FUCHSIA_external_memory
503 #define VK_FUCHSIA_external_memory 1
504 #define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1
505 #define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory"
506 
507 typedef struct VkBufferConstraintsInfoFUCHSIA {
508     VkStructureType sType;
509     const void* pNext;
510     const VkBufferCreateInfo* pBufferCreateInfo;
511     VkFormatFeatureFlags requiredFormatFeatures;
512     uint32_t minCount;
513 } VkBufferConstraintsInfoFUCHSIA;
514 
515 typedef struct VkImportMemoryZirconHandleInfoFUCHSIA {
516     VkStructureType                       sType;
517     const void*                           pNext;
518     VkExternalMemoryHandleTypeFlagBits    handleType;
519     uint32_t                              handle;
520 } VkImportMemoryZirconHandleInfoFUCHSIA;
521 
522 typedef struct VkMemoryZirconHandlePropertiesFUCHSIA {
523     VkStructureType    sType;
524     void*              pNext;
525     uint32_t           memoryTypeBits;
526 } VkMemoryZirconHandlePropertiesFUCHSIA;
527 
528 typedef struct VkMemoryGetZirconHandleInfoFUCHSIA {
529     VkStructureType                       sType;
530     const void*                           pNext;
531     VkDeviceMemory                        memory;
532     VkExternalMemoryHandleTypeFlagBits    handleType;
533 } VkMemoryGetZirconHandleInfoFUCHSIA;
534 
535 #define VK_STRUCTURE_TYPE_BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA \
536     ((VkStructureType)1001004008)
537 #define VK_STRUCTURE_TYPE_TEMP_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA \
538     ((VkStructureType)1001005000)
539 #define VK_STRUCTURE_TYPE_TEMP_MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA \
540     ((VkStructureType)1001005001)
541 #define VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA \
542     ((VkExternalMemoryHandleTypeFlagBits)0x00100000)
543 #endif  // VK_FUCHSIA_external_memory
544 
545 #ifndef VK_FUCHSIA_external_semaphore
546 #define VK_FUCHSIA_external_semaphore 1
547 #define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1
548 #define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore"
549 
550 typedef struct VkImportSemaphoreZirconHandleInfoFUCHSIA {
551     VkStructureType                          sType;
552     const void*                              pNext;
553     VkSemaphore                              semaphore;
554     VkSemaphoreImportFlags                   flags;
555     VkExternalSemaphoreHandleTypeFlagBits    handleType;
556     uint32_t                                 handle;
557 } VkImportSemaphoreZirconHandleInfoFUCHSIA;
558 
559 typedef struct VkSemaphoreGetZirconHandleInfoFUCHSIA {
560     VkStructureType                          sType;
561     const void*                              pNext;
562     VkSemaphore                              semaphore;
563     VkExternalSemaphoreHandleTypeFlagBits    handleType;
564 } VkSemaphoreGetZirconHandleInfoFUCHSIA;
565 
566 #define VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA \
567     ((VkExternalSemaphoreHandleTypeFlagBits)0x00100000)
568 #endif  // VK_FUCHSIA_external_semaphore
569 
570 // VulkanStream features
571 #define VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT (1 << 0)
572 #define VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT (1 << 1)
573 #define VULKAN_STREAM_FEATURE_SHADER_FLOAT16_INT8_BIT (1 << 2)
574 
575 #define VK_YCBCR_CONVERSION_DO_NOTHING ((VkSamplerYcbcrConversion)0x1111111111111111)
576 
577 // Stuff we advertised but didn't define the structs for it yet because
578 // we also needed to update our vulkan headers and xml
579 
580 #ifndef VK_VERSION_1_2
581 
582 typedef struct VkPhysicalDeviceShaderFloat16Int8Features {
583     VkStructureType    sType;
584     void*              pNext;
585     VkBool32           shaderFloat16;
586     VkBool32           shaderInt8;
587 } VkPhysicalDeviceShaderFloat16Int8Features;
588 
589 
590 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES \
591     ((VkStructureType)1000082000)
592 
593 #endif
594 
595 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR \
596     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES
597 
598 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR \
599     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES
600 
601 #ifndef VK_KHR_shader_float16_int8
602 
603 #define VK_KHR_shader_float16_int8 1
604 #define VK_KHR_SHADER_FLOAT16_INT8_SPEC_VERSION 1
605 #define VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME "VK_KHR_shader_float16_int8"
606 typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceShaderFloat16Int8FeaturesKHR;
607 typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceFloat16Int8FeaturesKHR;
608 
609 #endif
610 
611 #define VK_GOOGLE_async_queue_submit 1
612 
613 typedef void (VKAPI_PTR *PFN_vkQueueHostSyncGOOGLE)(
614     VkQueue queue, uint32_t needHostSync, uint32_t sequenceNumber);
615 typedef void (VKAPI_PTR *PFN_vkQueueSubmitAsyncGOOGLE)(
616     VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
617 typedef void (VKAPI_PTR *PFN_vkQueueWaitIdleAsyncGOOGLE)(VkQueue queue);
618 typedef void (VKAPI_PTR *PFN_vkQueueBindSparseAsyncGOOGLE)(
619     VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence);
620 
621 #ifdef __cplusplus
622 } // extern "C"
623 #endif
624 
625 #ifdef __cplusplus
626 
627 template<class T, typename F>
arrayany(const T * arr,uint32_t begin,uint32_t end,const F & func)628 bool arrayany(const T* arr, uint32_t begin, uint32_t end, const F& func) {
629     const T* e = arr + end;
630     return std::find_if(arr + begin, e, func) != e;
631 }
632 
633 #endif
634