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 #include "goldfish_vk_private_defs.h"
20 #include "vk_android_native_buffer_gfxstream.h"
21 #include "vulkan_gfxstream.h"
22 
23 #if defined(LINUX_GUEST_BUILD)
24 #include "vulkan/wsi/wsi_common.h"
25 #endif
26 
27 // anonymous
28 namespace {
29 
30 template <class T>
31 struct vk_get_vk_struct_id;
32 
33 #define REGISTER_VK_STRUCT_ID(T, ID)              \
34     template <>                                   \
35     struct vk_get_vk_struct_id<T> {               \
36         static constexpr VkStructureType id = ID; \
37     }
38 
39 #ifdef VK_USE_PLATFORM_ANDROID_KHR
40 REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferPropertiesANDROID,
41                       VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID);
42 REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferFormatPropertiesANDROID,
43                       VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID);
44 REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferUsageANDROID,
45                       VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID);
46 #endif
47 REGISTER_VK_STRUCT_ID(VkBufferCreateInfo, VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
48 REGISTER_VK_STRUCT_ID(VkImageCreateInfo, VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
49 REGISTER_VK_STRUCT_ID(VkImageFormatProperties2, VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2);
50 #ifdef VK_USE_PLATFORM_ANDROID_KHR
51 REGISTER_VK_STRUCT_ID(VkNativeBufferANDROID, VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID);
52 REGISTER_VK_STRUCT_ID(VkExternalFormatANDROID, VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID);
53 #endif
54 REGISTER_VK_STRUCT_ID(VkExternalMemoryBufferCreateInfo,
55                       VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO);
56 REGISTER_VK_STRUCT_ID(VkExternalMemoryImageCreateInfo,
57                       VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
58 REGISTER_VK_STRUCT_ID(VkMemoryAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO);
59 REGISTER_VK_STRUCT_ID(VkMemoryDedicatedAllocateInfo,
60                       VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO);
61 REGISTER_VK_STRUCT_ID(VkMemoryDedicatedRequirements,
62                       VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS);
63 #ifdef VK_USE_PLATFORM_ANDROID_KHR
64 REGISTER_VK_STRUCT_ID(VkImportAndroidHardwareBufferInfoANDROID,
65                       VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID);
66 #endif
67 REGISTER_VK_STRUCT_ID(VkImportMemoryFdInfoKHR, VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR);
68 REGISTER_VK_STRUCT_ID(VkExportMemoryAllocateInfo, VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO);
69 REGISTER_VK_STRUCT_ID(VkMemoryRequirements2, VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2);
70 REGISTER_VK_STRUCT_ID(VkSemaphoreCreateInfo, VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
71 REGISTER_VK_STRUCT_ID(VkExportSemaphoreCreateInfoKHR,
72                       VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR);
73 REGISTER_VK_STRUCT_ID(VkSamplerYcbcrConversionCreateInfo,
74                       VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
75 REGISTER_VK_STRUCT_ID(VkImportColorBufferGOOGLE, VK_STRUCTURE_TYPE_IMPORT_COLOR_BUFFER_GOOGLE);
76 REGISTER_VK_STRUCT_ID(VkImageViewCreateInfo, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
77 #ifdef VK_USE_PLATFORM_FUCHSIA
78 REGISTER_VK_STRUCT_ID(VkImportMemoryBufferCollectionFUCHSIA,
79                       VK_STRUCTURE_TYPE_IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA);
80 REGISTER_VK_STRUCT_ID(VkImportMemoryZirconHandleInfoFUCHSIA,
81                       VK_STRUCTURE_TYPE_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA);
82 REGISTER_VK_STRUCT_ID(VkBufferCollectionImageCreateInfoFUCHSIA,
83                       VK_STRUCTURE_TYPE_BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA);
84 REGISTER_VK_STRUCT_ID(VkBufferCollectionBufferCreateInfoFUCHSIA,
85                       VK_STRUCTURE_TYPE_BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA);
86 #endif  // VK_USE_PLATFORM_FUCHSIA
87 REGISTER_VK_STRUCT_ID(VkSamplerCreateInfo, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
88 REGISTER_VK_STRUCT_ID(VkSamplerCustomBorderColorCreateInfoEXT,
89                       VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
90 REGISTER_VK_STRUCT_ID(VkSamplerYcbcrConversionInfo,
91                       VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO);
92 REGISTER_VK_STRUCT_ID(VkFenceCreateInfo, VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
93 REGISTER_VK_STRUCT_ID(VkExportFenceCreateInfo, VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO);
94 REGISTER_VK_STRUCT_ID(VkImportBufferGOOGLE, VK_STRUCTURE_TYPE_IMPORT_BUFFER_GOOGLE);
95 REGISTER_VK_STRUCT_ID(VkCreateBlobGOOGLE, VK_STRUCTURE_TYPE_CREATE_BLOB_GOOGLE);
96 REGISTER_VK_STRUCT_ID(VkExternalImageFormatProperties,
97                       VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES);
98 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceImageFormatInfo2,
99                       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2);
100 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceExternalImageFormatInfo,
101                       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO);
102 REGISTER_VK_STRUCT_ID(VkSemaphoreTypeCreateInfo, VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO);
103 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceFeatures2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2);
104 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceProperties2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2);
105 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceDeviceMemoryReportFeaturesEXT,
106                       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT);
107 REGISTER_VK_STRUCT_ID(VkMemoryAllocateFlagsInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO);
108 REGISTER_VK_STRUCT_ID(VkMemoryOpaqueCaptureAddressAllocateInfo,
109                       VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
110 REGISTER_VK_STRUCT_ID(VkBindImageMemoryInfo, VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO);
111 REGISTER_VK_STRUCT_ID(VkBindImageMemorySwapchainInfoKHR,
112                       VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
113 REGISTER_VK_STRUCT_ID(VkBufferOpaqueCaptureAddressCreateInfo,
114                       VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
115 REGISTER_VK_STRUCT_ID(VkBufferDeviceAddressCreateInfoEXT,
116                       VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT);
117 REGISTER_VK_STRUCT_ID(VkGraphicsPipelineCreateInfo,
118                       VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
119 REGISTER_VK_STRUCT_ID(VkPipelineRenderingCreateInfo,
120                       VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO);
121 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceExternalSemaphoreInfo,
122                       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO);
123 REGISTER_VK_STRUCT_ID(VkRenderPassBeginInfo, VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO);
124 REGISTER_VK_STRUCT_ID(VkRenderPassAttachmentBeginInfo,
125                       VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO);
126 REGISTER_VK_STRUCT_ID(VkImportMemoryHostPointerInfoEXT,
127                       VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT);
128 REGISTER_VK_STRUCT_ID(VkDeviceCreateInfo, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
129 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceGroupProperties,
130                       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES);
131 REGISTER_VK_STRUCT_ID(VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT);
132 #if defined(LINUX_GUEST_BUILD)
133 REGISTER_VK_STRUCT_ID(wsi_image_create_info, VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA);
134 #endif
135 
136 #undef REGISTER_VK_STRUCT_ID
137 
138 }  // namespace
139