• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2024 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */
18 
19 // clang-format off
20 
21 #ifndef VULKAN_PROFILES_H_
22 #define VULKAN_PROFILES_H_ 1
23 
24 #define VPAPI_ATTR
25 
26 #ifdef __cplusplus
27     extern "C" {
28 #endif
29 
30 #include <vulkan/vulkan.h>
31 
32 #if defined(VK_VERSION_1_1) && \
33     defined(VK_ANDROID_external_memory_android_hardware_buffer) && \
34     defined(VK_EXT_queue_family_foreign) && \
35     defined(VK_EXT_swapchain_colorspace) && \
36     defined(VK_GOOGLE_display_timing) && \
37     defined(VK_KHR_android_surface) && \
38     defined(VK_KHR_create_renderpass2) && \
39     defined(VK_KHR_dedicated_allocation) && \
40     defined(VK_KHR_descriptor_update_template) && \
41     defined(VK_KHR_driver_properties) && \
42     defined(VK_KHR_external_fence) && \
43     defined(VK_KHR_external_fence_capabilities) && \
44     defined(VK_KHR_external_fence_fd) && \
45     defined(VK_KHR_external_memory) && \
46     defined(VK_KHR_external_memory_capabilities) && \
47     defined(VK_KHR_external_semaphore) && \
48     defined(VK_KHR_external_semaphore_capabilities) && \
49     defined(VK_KHR_external_semaphore_fd) && \
50     defined(VK_KHR_get_memory_requirements2) && \
51     defined(VK_KHR_get_physical_device_properties2) && \
52     defined(VK_KHR_get_surface_capabilities2) && \
53     defined(VK_KHR_incremental_present) && \
54     defined(VK_KHR_maintenance1) && \
55     defined(VK_KHR_sampler_mirror_clamp_to_edge) && \
56     defined(VK_KHR_storage_buffer_storage_class) && \
57     defined(VK_KHR_surface) && \
58     defined(VK_KHR_swapchain) && \
59     defined(VK_KHR_variable_pointers)
60 #define VP_ANDROID_baseline_2022 1
61 #define VP_ANDROID_BASELINE_2022_NAME "VP_ANDROID_baseline_2022"
62 #define VP_ANDROID_BASELINE_2022_SPEC_VERSION 1
63 #define VP_ANDROID_BASELINE_2022_MIN_API_VERSION VK_MAKE_VERSION(1, 1, 106)
64 #endif
65 
66 #if defined(VK_VERSION_1_3) && \
67     defined(VP_ANDROID_baseline_2022) && \
68     defined(VK_ANDROID_external_format_resolve) && \
69     defined(VK_EXT_4444_formats) && \
70     defined(VK_EXT_custom_border_color) && \
71     defined(VK_EXT_device_memory_report) && \
72     defined(VK_EXT_external_memory_acquire_unmodified) && \
73     defined(VK_EXT_index_type_uint8) && \
74     defined(VK_EXT_line_rasterization) && \
75     defined(VK_EXT_load_store_op_none) && \
76     defined(VK_EXT_primitive_topology_list_restart) && \
77     defined(VK_EXT_primitives_generated_query) && \
78     defined(VK_EXT_provoking_vertex) && \
79     defined(VK_EXT_scalar_block_layout) && \
80     defined(VK_EXT_surface_maintenance1) && \
81     defined(VK_EXT_swapchain_maintenance1) && \
82     defined(VK_GOOGLE_surfaceless_query) && \
83     defined(VK_IMG_relaxed_line_rasterization) && \
84     defined(VK_KHR_16bit_storage) && \
85     defined(VK_KHR_maintenance5) && \
86     defined(VK_KHR_shader_float16_int8) && \
87     defined(VK_KHR_vertex_attribute_divisor)
88 #define VP_ANDROID_15_minimums 1
89 #define VP_ANDROID_15_MINIMUMS_NAME "VP_ANDROID_15_minimums"
90 #define VP_ANDROID_15_MINIMUMS_SPEC_VERSION 1
91 #define VP_ANDROID_15_MINIMUMS_MIN_API_VERSION VK_MAKE_VERSION(1, 3, 273)
92 #endif
93 
94 #if defined(VK_VERSION_1_0) && \
95     defined(VK_EXT_swapchain_colorspace) && \
96     defined(VK_GOOGLE_display_timing) && \
97     defined(VK_KHR_android_surface) && \
98     defined(VK_KHR_dedicated_allocation) && \
99     defined(VK_KHR_descriptor_update_template) && \
100     defined(VK_KHR_external_fence) && \
101     defined(VK_KHR_external_fence_capabilities) && \
102     defined(VK_KHR_external_fence_fd) && \
103     defined(VK_KHR_external_memory) && \
104     defined(VK_KHR_external_memory_capabilities) && \
105     defined(VK_KHR_external_semaphore) && \
106     defined(VK_KHR_external_semaphore_capabilities) && \
107     defined(VK_KHR_external_semaphore_fd) && \
108     defined(VK_KHR_get_memory_requirements2) && \
109     defined(VK_KHR_get_physical_device_properties2) && \
110     defined(VK_KHR_get_surface_capabilities2) && \
111     defined(VK_KHR_incremental_present) && \
112     defined(VK_KHR_maintenance1) && \
113     defined(VK_KHR_storage_buffer_storage_class) && \
114     defined(VK_KHR_surface) && \
115     defined(VK_KHR_swapchain) && \
116     defined(VK_KHR_variable_pointers)
117 #define VP_ANDROID_baseline_2021 1
118 #define VP_ANDROID_BASELINE_2021_NAME "VP_ANDROID_baseline_2021"
119 #define VP_ANDROID_BASELINE_2021_SPEC_VERSION 2
120 #define VP_ANDROID_BASELINE_2021_MIN_API_VERSION VK_MAKE_VERSION(1, 0, 68)
121 #endif
122 
123 #if defined(VK_VERSION_1_0) && \
124     defined(VK_EXT_swapchain_colorspace) && \
125     defined(VK_KHR_android_surface) && \
126     defined(VK_KHR_dedicated_allocation) && \
127     defined(VK_KHR_descriptor_update_template) && \
128     defined(VK_KHR_external_fence) && \
129     defined(VK_KHR_external_fence_capabilities) && \
130     defined(VK_KHR_external_memory) && \
131     defined(VK_KHR_external_memory_capabilities) && \
132     defined(VK_KHR_external_semaphore) && \
133     defined(VK_KHR_external_semaphore_capabilities) && \
134     defined(VK_KHR_external_semaphore_fd) && \
135     defined(VK_KHR_get_memory_requirements2) && \
136     defined(VK_KHR_get_physical_device_properties2) && \
137     defined(VK_KHR_get_surface_capabilities2) && \
138     defined(VK_KHR_incremental_present) && \
139     defined(VK_KHR_maintenance1) && \
140     defined(VK_KHR_storage_buffer_storage_class) && \
141     defined(VK_KHR_surface) && \
142     defined(VK_KHR_swapchain)
143 #define VP_ANDROID_baseline_2021_cpu_only 1
144 #define VP_ANDROID_BASELINE_2021_CPU_ONLY_NAME "VP_ANDROID_baseline_2021_cpu_only"
145 #define VP_ANDROID_BASELINE_2021_CPU_ONLY_SPEC_VERSION 1
146 #define VP_ANDROID_BASELINE_2021_CPU_ONLY_MIN_API_VERSION VK_MAKE_VERSION(1, 0, 68)
147 #endif
148 
149 #define VP_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 2, 0, VK_HEADER_VERSION)
150 
151 #define VP_MAX_PROFILE_NAME_SIZE 256U
152 
153 typedef struct VpProfileProperties {
154     char        profileName[VP_MAX_PROFILE_NAME_SIZE];
155     uint32_t    specVersion;
156 } VpProfileProperties;
157 
158 typedef struct VpBlockProperties {
159     VpProfileProperties profiles;
160     uint32_t apiVersion;
161     char blockName[VP_MAX_PROFILE_NAME_SIZE];
162 } VpBlockProperties;
163 
164 typedef enum VpInstanceCreateFlagBits {
165     VP_INSTANCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
166 } VpInstanceCreateFlagBits;
167 typedef VkFlags VpInstanceCreateFlags;
168 
169 typedef struct VpInstanceCreateInfo {
170     const VkInstanceCreateInfo* pCreateInfo;
171     VpInstanceCreateFlags       flags;
172     uint32_t                    enabledFullProfileCount;
173     const VpProfileProperties*  pEnabledFullProfiles;
174     uint32_t                    enabledProfileBlockCount;
175     const VpBlockProperties*    pEnabledProfileBlocks;
176 } VpInstanceCreateInfo;
177 
178 typedef enum VpDeviceCreateFlagBits {
179     VP_DEVICE_CREATE_DISABLE_ROBUST_BUFFER_ACCESS_BIT = 0x0000001,
180     VP_DEVICE_CREATE_DISABLE_ROBUST_IMAGE_ACCESS_BIT = 0x0000002,
181     VP_DEVICE_CREATE_DISABLE_ROBUST_ACCESS =
182         VP_DEVICE_CREATE_DISABLE_ROBUST_BUFFER_ACCESS_BIT | VP_DEVICE_CREATE_DISABLE_ROBUST_IMAGE_ACCESS_BIT,
183 
184     VP_DEVICE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
185 } VpDeviceCreateFlagBits;
186 typedef VkFlags VpDeviceCreateFlags;
187 
188 typedef struct VpDeviceCreateInfo {
189     const VkDeviceCreateInfo*   pCreateInfo;
190     VpDeviceCreateFlags         flags;
191     uint32_t                    enabledFullProfileCount;
192     const VpProfileProperties*  pEnabledFullProfiles;
193     uint32_t                    enabledProfileBlockCount;
194     const VpBlockProperties*    pEnabledProfileBlocks;
195 } VpDeviceCreateInfo;
196 
197 // Query the list of available profiles in the library
198 VPAPI_ATTR VkResult vpGetProfiles(uint32_t *pPropertyCount, VpProfileProperties *pProperties);
199 
200 // List the required profiles of a profile
201 VPAPI_ATTR VkResult vpGetProfileRequiredProfiles(const VpProfileProperties* pProfile, uint32_t* pPropertyCount, VpProfileProperties* pProperties);
202 
203 // Query the profile required Vulkan API version
204 VPAPI_ATTR uint32_t vpGetProfileAPIVersion(const VpProfileProperties* pProfile);
205 
206 // List the recommended fallback profiles of a profile
207 VPAPI_ATTR VkResult vpGetProfileFallbacks(const VpProfileProperties *pProfile, uint32_t *pPropertyCount, VpProfileProperties *pProperties);
208 
209 // Query whether the profile has multiple variants. Profiles with multiple variants can only use vpGetInstanceProfileSupport and vpGetPhysicalDeviceProfileSupport capabilities of the library. Other function will return a VK_ERROR_UNKNOWN error
210 VPAPI_ATTR VkResult vpHasMultipleVariantsProfile(const VpProfileProperties *pProfile, VkBool32 *pHasMultipleVariants);
211 
212 // Check whether a profile is supported at the instance level
213 VPAPI_ATTR VkResult vpGetInstanceProfileSupport(const char *pLayerName, const VpProfileProperties *pProfile, VkBool32 *pSupported);
214 
215 // Check whether a variant of a profile is supported at the instance level and report this list of blocks used to validate the profiles
216 VPAPI_ATTR VkResult vpGetInstanceProfileVariantsSupport(const char *pLayerName, const VpProfileProperties *pProfile, VkBool32 *pSupported, uint32_t *pPropertyCount, VpBlockProperties* pProperties);
217 
218 // Create a VkInstance with the profile instance extensions enabled
219 VPAPI_ATTR VkResult vpCreateInstance(const VpInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
220 
221 // Check whether a profile is supported by the physical device
222 VPAPI_ATTR VkResult vpGetPhysicalDeviceProfileSupport(VkInstance instance, VkPhysicalDevice physicalDevice, const VpProfileProperties *pProfile, VkBool32 *pSupported);
223 
224 // Check whether a variant of a profile is supported by the physical device and report this list of blocks used to validate the profiles
225 VPAPI_ATTR VkResult vpGetPhysicalDeviceProfileVariantsSupport(VkInstance instance, VkPhysicalDevice physicalDevice, const VpProfileProperties *pProfile, VkBool32 *pSupported, uint32_t *pPropertyCount, VpBlockProperties* pProperties);
226 
227 // Create a VkDevice with the profile features and device extensions enabled
228 VPAPI_ATTR VkResult vpCreateDevice(VkPhysicalDevice physicalDevice, const VpDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
229 
230 // Query the list of instance extensions of a profile
231 VPAPI_ATTR VkResult vpGetProfileInstanceExtensionProperties(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
232 
233 // Query the list of device extensions of a profile
234 VPAPI_ATTR VkResult vpGetProfileDeviceExtensionProperties(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
235 
236 // Fill the feature structures with the requirements of a profile
237 VPAPI_ATTR VkResult vpGetProfileFeatures(const VpProfileProperties *pProfile, const char* pBlockName, void *pNext);
238 
239 // Query the list of feature structure types specified by the profile
240 VPAPI_ATTR VkResult vpGetProfileFeatureStructureTypes(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pStructureTypeCount, VkStructureType *pStructureTypes);
241 
242 // Fill the property structures with the requirements of a profile
243 VPAPI_ATTR VkResult vpGetProfileProperties(const VpProfileProperties *pProfile, const char* pBlockName, void *pNext);
244 
245 // Query the list of property structure types specified by the profile
246 VPAPI_ATTR VkResult vpGetProfilePropertyStructureTypes(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pStructureTypeCount, VkStructureType *pStructureTypes);
247 
248 // Query the list of formats with specified requirements by a profile
249 VPAPI_ATTR VkResult vpGetProfileFormats(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pFormatCount, VkFormat *pFormats);
250 
251 // Query the requirements of a format for a profile
252 VPAPI_ATTR VkResult vpGetProfileFormatProperties(const VpProfileProperties *pProfile, const char* pBlockName, VkFormat format, void *pNext);
253 
254 // Query the list of format structure types specified by the profile
255 VPAPI_ATTR VkResult vpGetProfileFormatStructureTypes(const VpProfileProperties *pProfile, const char* pBlockName, uint32_t *pStructureTypeCount, VkStructureType *pStructureTypes);
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 
261 #endif // VULKAN_PROFILES_H_
262 
263 // clang-format on
264