avfilter/avfiltergraph: fix constant string comparision
[ffmpeg.git] / libavutil / vulkan_functions.h
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVUTIL_VULKAN_FUNCTIONS_H
20 #define AVUTIL_VULKAN_FUNCTIONS_H
21
22 #define VK_NO_PROTOTYPES
23 #define VK_ENABLE_BETA_EXTENSIONS
24
25 #include "hwcontext.h"
26 #include "hwcontext_vulkan.h"
27
28 /* An enum of bitflags for every optional extension we need */
29 typedef uint64_t FFVulkanExtensions;
30
31 /* NOTE: when adding new entries, make sure to update ff_vk_extensions_to_mask */
32 #define FF_VK_EXT_EXTERNAL_DMABUF_MEMORY (1ULL << 0) /* VK_EXT_external_memory_dma_buf */
33 #define FF_VK_EXT_DRM_MODIFIER_FLAGS (1ULL << 1) /* VK_EXT_image_drm_format_modifier */
34 #define FF_VK_EXT_EXTERNAL_FD_MEMORY (1ULL << 2) /* VK_KHR_external_memory_fd */
35 #define FF_VK_EXT_EXTERNAL_FD_SEM (1ULL << 3) /* VK_KHR_external_semaphore_fd */
36 #define FF_VK_EXT_EXTERNAL_HOST_MEMORY (1ULL << 4) /* VK_EXT_external_memory_host */
37 #define FF_VK_EXT_DEBUG_UTILS (1ULL << 5) /* VK_EXT_debug_utils */
38
39 #define FF_VK_EXT_EXTERNAL_WIN32_MEMORY (1ULL << 6) /* VK_KHR_external_memory_win32 */
40 #define FF_VK_EXT_EXTERNAL_WIN32_SEM (1ULL << 7) /* VK_KHR_external_semaphore_win32 */
41
42 #define FF_VK_EXT_DESCRIPTOR_BUFFER (1ULL << 8) /* VK_EXT_descriptor_buffer */
43 #define FF_VK_EXT_DEVICE_DRM (1ULL << 9) /* VK_EXT_physical_device_drm */
44 #define FF_VK_EXT_ATOMIC_FLOAT (1ULL << 10) /* VK_EXT_shader_atomic_float */
45 #define FF_VK_EXT_COOP_MATRIX (1ULL << 11) /* VK_KHR_cooperative_matrix */
46 #define FF_VK_EXT_OPTICAL_FLOW (1ULL << 12) /* VK_NV_optical_flow */
47 #define FF_VK_EXT_SHADER_OBJECT (1ULL << 13) /* VK_EXT_shader_object */
48 #define FF_VK_EXT_PUSH_DESCRIPTOR (1ULL << 14) /* VK_KHR_push_descriptor */
49 #define FF_VK_EXT_RELAXED_EXTENDED_INSTR (1ULL << 15) /* VK_KHR_shader_relaxed_extended_instruction */
50 #define FF_VK_EXT_EXPECT_ASSUME (1ULL << 16) /* VK_KHR_shader_expect_assume */
51 #define FF_VK_EXT_SUBGROUP_ROTATE (1ULL << 17) /* VK_KHR_shader_subgroup_rotate */
52 #define FF_VK_EXT_HOST_IMAGE_COPY (1ULL << 18) /* VK_EXT_host_image_copy */
53 #define FF_VK_EXT_ZERO_INITIALIZE (1ULL << 19) /* VK_EXT_zero_initialize_device_memory */
54
55 /* Video extensions */
56 #define FF_VK_EXT_VIDEO_QUEUE (1ULL << 36) /* VK_KHR_video_queue */
57 #define FF_VK_EXT_VIDEO_MAINTENANCE_1 (1ULL << 37) /* VK_KHR_video_maintenance1 */
58 #define FF_VK_EXT_VIDEO_MAINTENANCE_2 (1ULL << 38) /* VK_KHR_video_maintenance2 */
59
60 #define FF_VK_EXT_VIDEO_DECODE_QUEUE (1ULL << 40) /* VK_KHR_video_decode_queue */
61 #define FF_VK_EXT_VIDEO_DECODE_H264 (1ULL << 41) /* VK_KHR_video_decode_h264 */
62 #define FF_VK_EXT_VIDEO_DECODE_H265 (1ULL << 42) /* VK_KHR_video_decode_h265 */
63 #define FF_VK_EXT_VIDEO_DECODE_VP9 (1ULL << 43) /* VK_KHR_video_decode_vp9 */
64 #define FF_VK_EXT_VIDEO_DECODE_AV1 (1ULL << 44) /* VK_KHR_video_decode_av1 */
65
66 #define FF_VK_EXT_VIDEO_ENCODE_QUEUE (1ULL << 50) /* VK_KHR_video_encode_queue */
67 #define FF_VK_EXT_VIDEO_ENCODE_H264 (1ULL << 51) /* VK_KHR_video_encode_h264 */
68 #define FF_VK_EXT_VIDEO_ENCODE_H265 (1ULL << 52) /* VK_KHR_video_encode_h265 */
69 #define FF_VK_EXT_VIDEO_ENCODE_AV1 (1ULL << 53) /* VK_KHR_video_encode_av1 */
70
71 #define FF_VK_EXT_PORTABILITY_SUBSET (1ULL << 62)
72 #define FF_VK_EXT_NO_FLAG (1ULL << 63)
73
74 /* Macro containing every function that we utilize in our codebase */
75 #define FN_LIST(MACRO) \
76 /* Instance */ \
77 MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceExtensionProperties) \
78 MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceLayerProperties) \
79 MACRO(0, 0, FF_VK_EXT_NO_FLAG, CreateInstance) \
80 MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyInstance) \
81 \
82 /* Debug */ \
83 MACRO(1, 0, FF_VK_EXT_NO_FLAG, CreateDebugUtilsMessengerEXT) \
84 MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyDebugUtilsMessengerEXT) \
85 \
86 /* Device */ \
87 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetDeviceProcAddr) \
88 MACRO(1, 0, FF_VK_EXT_NO_FLAG, CreateDevice) \
89 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceFeatures2) \
90 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceProperties) \
91 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceExternalSemaphoreProperties) \
92 MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE, GetPhysicalDeviceVideoCapabilitiesKHR) \
93 MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE, GetPhysicalDeviceVideoFormatPropertiesKHR) \
94 MACRO(1, 0, FF_VK_EXT_NO_FLAG, DeviceWaitIdle) \
95 MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyDevice) \
96 \
97 MACRO(1, 0, FF_VK_EXT_NO_FLAG, EnumeratePhysicalDevices) \
98 MACRO(1, 0, FF_VK_EXT_NO_FLAG, EnumerateDeviceExtensionProperties) \
99 \
100 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceProperties2) \
101 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceMemoryProperties) \
102 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceFormatProperties2) \
103 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceImageFormatProperties2) \
104 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceQueueFamilyProperties) \
105 MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceQueueFamilyProperties2) \
106 MACRO(1, 0, FF_VK_EXT_COOP_MATRIX, GetPhysicalDeviceCooperativeMatrixPropertiesKHR) \
107 \
108 /* Command pool */ \
109 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateCommandPool) \
110 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyCommandPool) \
111 \
112 /* Command buffer */ \
113 MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateCommandBuffers) \
114 MACRO(1, 1, FF_VK_EXT_NO_FLAG, BeginCommandBuffer) \
115 MACRO(1, 1, FF_VK_EXT_NO_FLAG, EndCommandBuffer) \
116 MACRO(1, 1, FF_VK_EXT_NO_FLAG, FreeCommandBuffers) \
117 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdDispatch) \
118 \
119 /* Queue */ \
120 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetDeviceQueue) \
121 MACRO(1, 1, FF_VK_EXT_NO_FLAG, QueueSubmit) \
122 MACRO(1, 1, FF_VK_EXT_NO_FLAG, QueueSubmit2) \
123 \
124 /* Fences */ \
125 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateFence) \
126 MACRO(1, 1, FF_VK_EXT_NO_FLAG, WaitForFences) \
127 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetFenceStatus) \
128 MACRO(1, 1, FF_VK_EXT_NO_FLAG, ResetFences) \
129 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyFence) \
130 \
131 /* Semaphores */ \
132 MACRO(1, 1, FF_VK_EXT_EXTERNAL_FD_SEM, GetSemaphoreFdKHR) \
133 MACRO(1, 1, FF_VK_EXT_EXTERNAL_FD_SEM, ImportSemaphoreFdKHR) \
134 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSemaphore) \
135 MACRO(1, 1, FF_VK_EXT_NO_FLAG, WaitSemaphores) \
136 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySemaphore) \
137 \
138 /* Memory */ \
139 MACRO(1, 1, FF_VK_EXT_EXTERNAL_FD_MEMORY, GetMemoryFdKHR) \
140 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetMemoryFdPropertiesKHR) \
141 MACRO(1, 1, FF_VK_EXT_EXTERNAL_HOST_MEMORY, GetMemoryHostPointerPropertiesEXT) \
142 MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateMemory) \
143 MACRO(1, 1, FF_VK_EXT_NO_FLAG, MapMemory) \
144 MACRO(1, 1, FF_VK_EXT_NO_FLAG, FlushMappedMemoryRanges) \
145 MACRO(1, 1, FF_VK_EXT_NO_FLAG, InvalidateMappedMemoryRanges) \
146 MACRO(1, 1, FF_VK_EXT_NO_FLAG, UnmapMemory) \
147 MACRO(1, 1, FF_VK_EXT_NO_FLAG, FreeMemory) \
148 \
149 /* Commands */ \
150 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBindDescriptorSets) \
151 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPushConstants) \
152 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBindPipeline) \
153 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPipelineBarrier) \
154 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdCopyBufferToImage) \
155 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdCopyImageToBuffer) \
156 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdClearColorImage) \
157 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdCopyBuffer) \
158 \
159 /* Buffer */ \
160 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetBufferMemoryRequirements2) \
161 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateBuffer) \
162 MACRO(1, 1, FF_VK_EXT_NO_FLAG, BindBufferMemory) \
163 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetBufferDeviceAddress) \
164 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdFillBuffer) \
165 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyBuffer) \
166 \
167 /* Image */ \
168 MACRO(1, 1, FF_VK_EXT_DRM_MODIFIER_FLAGS, GetImageDrmFormatModifierPropertiesEXT) \
169 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetImageMemoryRequirements2) \
170 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateImage) \
171 MACRO(1, 1, FF_VK_EXT_NO_FLAG, BindImageMemory2) \
172 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetImageSubresourceLayout) \
173 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyImage) \
174 \
175 /* ImageView */ \
176 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateImageView) \
177 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyImageView) \
178 \
179 /* DescriptorSet */ \
180 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorSetLayout) \
181 MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateDescriptorSets) \
182 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorPool) \
183 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorPool) \
184 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorSetLayout) \
185 \
186 /* Descriptor buffers */ \
187 MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorSetLayoutSizeEXT) \
188 MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorSetLayoutBindingOffsetEXT) \
189 MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorEXT) \
190 MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, CmdBindDescriptorBuffersEXT) \
191 MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, CmdSetDescriptorBufferOffsetsEXT) \
192 \
193 /* DescriptorUpdateTemplate */ \
194 MACRO(1, 1, FF_VK_EXT_NO_FLAG, UpdateDescriptorSetWithTemplate) \
195 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorUpdateTemplate) \
196 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorUpdateTemplate) \
197 \
198 /* Descriptors */ \
199 MACRO(1, 1, FF_VK_EXT_NO_FLAG, UpdateDescriptorSets) \
200 MACRO(1, 1, FF_VK_EXT_PUSH_DESCRIPTOR, CmdPushDescriptorSetKHR) \
201 \
202 /* Queries */ \
203 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateQueryPool) \
204 MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetQueryPoolResults) \
205 MACRO(1, 1, FF_VK_EXT_NO_FLAG, ResetQueryPool) \
206 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBeginQuery) \
207 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdEndQuery) \
208 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdResetQueryPool) \
209 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyQueryPool) \
210 \
211 /* sync2 */ \
212 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPipelineBarrier2) \
213 \
214 /* Host image copy */ \
215 MACRO(1, 1, FF_VK_EXT_HOST_IMAGE_COPY, TransitionImageLayoutEXT) \
216 MACRO(1, 1, FF_VK_EXT_HOST_IMAGE_COPY, CopyMemoryToImageEXT) \
217 MACRO(1, 1, FF_VK_EXT_HOST_IMAGE_COPY, CopyImageToMemoryEXT) \
218 \
219 /* Video queue */ \
220 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CreateVideoSessionKHR) \
221 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CreateVideoSessionParametersKHR) \
222 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, GetVideoSessionMemoryRequirementsKHR) \
223 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, BindVideoSessionMemoryKHR) \
224 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdBeginVideoCodingKHR) \
225 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdControlVideoCodingKHR) \
226 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdEndVideoCodingKHR) \
227 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, DestroyVideoSessionParametersKHR) \
228 MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, DestroyVideoSessionKHR) \
229 \
230 /* Video decoding */ \
231 MACRO(1, 1, FF_VK_EXT_VIDEO_DECODE_QUEUE, CmdDecodeVideoKHR) \
232 \
233 /* Video encoding */ \
234 MACRO(1, 1, FF_VK_EXT_VIDEO_ENCODE_QUEUE, CmdEncodeVideoKHR) \
235 MACRO(1, 1, FF_VK_EXT_VIDEO_ENCODE_QUEUE, GetEncodedVideoSessionParametersKHR) \
236 MACRO(1, 0, FF_VK_EXT_VIDEO_ENCODE_QUEUE, GetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR) \
237 \
238 /* Pipeline */ \
239 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreatePipelineLayout) \
240 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyPipelineLayout) \
241 \
242 /* PipelineLayout */ \
243 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateComputePipelines) \
244 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyPipeline) \
245 \
246 /* Sampler */ \
247 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSamplerYcbcrConversion) \
248 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySamplerYcbcrConversion) \
249 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSampler) \
250 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySampler) \
251 \
252 /* Optical flow */ \
253 MACRO(1, 1, FF_VK_EXT_OPTICAL_FLOW, BindOpticalFlowSessionImageNV) \
254 MACRO(1, 1, FF_VK_EXT_OPTICAL_FLOW, CmdOpticalFlowExecuteNV) \
255 MACRO(1, 1, FF_VK_EXT_OPTICAL_FLOW, CreateOpticalFlowSessionNV) \
256 MACRO(1, 1, FF_VK_EXT_OPTICAL_FLOW, DestroyOpticalFlowSessionNV) \
257 MACRO(1, 0, FF_VK_EXT_OPTICAL_FLOW, GetPhysicalDeviceOpticalFlowImageFormatsNV)\
258 \
259 /* Shaders */ \
260 MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateShaderModule) \
261 MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyShaderModule) \
262 MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, CmdBindShadersEXT) \
263 MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, CreateShadersEXT) \
264 MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, DestroyShaderEXT) \
265 MACRO(1, 1, FF_VK_EXT_SHADER_OBJECT, GetShaderBinaryDataEXT)
266
267 /* Macro containing every win32 specific function that we utilize in our codebase */
268 #define FN_LIST_WIN32(MACRO) \
269 MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_SEM, GetSemaphoreWin32HandleKHR) \
270 MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_MEMORY, GetMemoryWin32HandleKHR)
271
272 /* Macro to turn a function name into a definition */
273 #define PFN_DEF(req_inst, req_dev, ext_flag, name) \
274 PFN_vk##name name;
275
276 /* Structure with the definition of all listed functions */
277 typedef struct FFVulkanFunctions {
278 FN_LIST(PFN_DEF)
279 #ifdef _WIN32
280 FN_LIST_WIN32(PFN_DEF)
281 #endif
282 } FFVulkanFunctions;
283
284 #endif /* AVUTIL_VULKAN_FUNCTIONS_H */