FFmpeg
vulkan_functions.h
Go to the documentation of this file.
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 enum FFVulkanExtensions {
30  FF_VK_EXT_EXTERNAL_DMABUF_MEMORY = 1ULL << 0, /* VK_EXT_external_memory_dma_buf */
31  FF_VK_EXT_DRM_MODIFIER_FLAGS = 1ULL << 1, /* VK_EXT_image_drm_format_modifier */
32  FF_VK_EXT_EXTERNAL_FD_MEMORY = 1ULL << 2, /* VK_KHR_external_memory_fd */
33  FF_VK_EXT_EXTERNAL_FD_SEM = 1ULL << 3, /* VK_KHR_external_semaphore_fd */
34  FF_VK_EXT_EXTERNAL_HOST_MEMORY = 1ULL << 4, /* VK_EXT_external_memory_host */
35  FF_VK_EXT_DEBUG_UTILS = 1ULL << 5, /* VK_EXT_debug_utils */
36 #ifdef _WIN32
37  FF_VK_EXT_EXTERNAL_WIN32_MEMORY = 1ULL << 6, /* VK_KHR_external_memory_win32 */
38  FF_VK_EXT_EXTERNAL_WIN32_SEM = 1ULL << 7, /* VK_KHR_external_semaphore_win32 */
39 #endif
40  FF_VK_EXT_DESCRIPTOR_BUFFER = 1ULL << 8, /* VK_EXT_descriptor_buffer */
41  FF_VK_EXT_DEVICE_DRM = 1ULL << 9, /* VK_EXT_physical_device_drm */
42  FF_VK_EXT_VIDEO_QUEUE = 1ULL << 10, /* VK_KHR_video_queue */
43  FF_VK_EXT_VIDEO_DECODE_QUEUE = 1ULL << 11, /* VK_KHR_video_decode_queue */
44  FF_VK_EXT_VIDEO_DECODE_H264 = 1ULL << 12, /* VK_EXT_video_decode_h264 */
45  FF_VK_EXT_VIDEO_DECODE_H265 = 1ULL << 13, /* VK_EXT_video_decode_h265 */
46  FF_VK_EXT_VIDEO_DECODE_AV1 = 1ULL << 14, /* VK_KHR_video_decode_av1 */
47  FF_VK_EXT_ATOMIC_FLOAT = 1ULL << 15, /* VK_EXT_shader_atomic_float */
48  FF_VK_EXT_COOP_MATRIX = 1ULL << 16, /* VK_KHR_cooperative_matrix */
49 
50  FF_VK_EXT_NO_FLAG = 1ULL << 31,
52 
53 /* Macro containing every function that we utilize in our codebase */
54 #define FN_LIST(MACRO) \
55  /* Instance */ \
56  MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceExtensionProperties) \
57  MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceLayerProperties) \
58  MACRO(0, 0, FF_VK_EXT_NO_FLAG, CreateInstance) \
59  MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyInstance) \
60  \
61  /* Debug */ \
62  MACRO(1, 0, FF_VK_EXT_NO_FLAG, CreateDebugUtilsMessengerEXT) \
63  MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyDebugUtilsMessengerEXT) \
64  \
65  /* Device */ \
66  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetDeviceProcAddr) \
67  MACRO(1, 0, FF_VK_EXT_NO_FLAG, CreateDevice) \
68  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceFeatures2) \
69  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceProperties) \
70  MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE, GetPhysicalDeviceVideoCapabilitiesKHR) \
71  MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE, GetPhysicalDeviceVideoFormatPropertiesKHR) \
72  MACRO(1, 0, FF_VK_EXT_NO_FLAG, DeviceWaitIdle) \
73  MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyDevice) \
74  \
75  MACRO(1, 0, FF_VK_EXT_NO_FLAG, EnumeratePhysicalDevices) \
76  MACRO(1, 0, FF_VK_EXT_NO_FLAG, EnumerateDeviceExtensionProperties) \
77  \
78  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceProperties2) \
79  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceMemoryProperties) \
80  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceFormatProperties2) \
81  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceImageFormatProperties2) \
82  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceQueueFamilyProperties) \
83  MACRO(1, 0, FF_VK_EXT_NO_FLAG, GetPhysicalDeviceQueueFamilyProperties2) \
84  MACRO(1, 0, FF_VK_EXT_COOP_MATRIX, GetPhysicalDeviceCooperativeMatrixPropertiesKHR) \
85  \
86  /* Command pool */ \
87  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateCommandPool) \
88  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyCommandPool) \
89  \
90  /* Command buffer */ \
91  MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateCommandBuffers) \
92  MACRO(1, 1, FF_VK_EXT_NO_FLAG, BeginCommandBuffer) \
93  MACRO(1, 1, FF_VK_EXT_NO_FLAG, EndCommandBuffer) \
94  MACRO(1, 1, FF_VK_EXT_NO_FLAG, FreeCommandBuffers) \
95  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdDispatch) \
96  \
97  /* Queue */ \
98  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetDeviceQueue) \
99  MACRO(1, 1, FF_VK_EXT_NO_FLAG, QueueSubmit) \
100  MACRO(1, 1, FF_VK_EXT_NO_FLAG, QueueSubmit2) \
101  \
102  /* Fences */ \
103  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateFence) \
104  MACRO(1, 1, FF_VK_EXT_NO_FLAG, WaitForFences) \
105  MACRO(1, 1, FF_VK_EXT_NO_FLAG, ResetFences) \
106  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyFence) \
107  \
108  /* Semaphores */ \
109  MACRO(1, 1, FF_VK_EXT_EXTERNAL_FD_SEM, GetSemaphoreFdKHR) \
110  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSemaphore) \
111  MACRO(1, 1, FF_VK_EXT_NO_FLAG, WaitSemaphores) \
112  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySemaphore) \
113  \
114  /* Memory */ \
115  MACRO(1, 1, FF_VK_EXT_EXTERNAL_FD_MEMORY, GetMemoryFdKHR) \
116  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetMemoryFdPropertiesKHR) \
117  MACRO(1, 1, FF_VK_EXT_EXTERNAL_HOST_MEMORY, GetMemoryHostPointerPropertiesEXT) \
118  MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateMemory) \
119  MACRO(1, 1, FF_VK_EXT_NO_FLAG, MapMemory) \
120  MACRO(1, 1, FF_VK_EXT_NO_FLAG, FlushMappedMemoryRanges) \
121  MACRO(1, 1, FF_VK_EXT_NO_FLAG, InvalidateMappedMemoryRanges) \
122  MACRO(1, 1, FF_VK_EXT_NO_FLAG, UnmapMemory) \
123  MACRO(1, 1, FF_VK_EXT_NO_FLAG, FreeMemory) \
124  \
125  /* Commands */ \
126  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBindDescriptorSets) \
127  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPushConstants) \
128  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBindPipeline) \
129  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPipelineBarrier) \
130  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdCopyBufferToImage) \
131  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdCopyImageToBuffer) \
132  \
133  /* Buffer */ \
134  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetBufferMemoryRequirements2) \
135  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateBuffer) \
136  MACRO(1, 1, FF_VK_EXT_NO_FLAG, BindBufferMemory) \
137  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetBufferDeviceAddress) \
138  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdFillBuffer) \
139  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyBuffer) \
140  \
141  /* Image */ \
142  MACRO(1, 1, FF_VK_EXT_DRM_MODIFIER_FLAGS, GetImageDrmFormatModifierPropertiesEXT) \
143  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetImageMemoryRequirements2) \
144  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateImage) \
145  MACRO(1, 1, FF_VK_EXT_NO_FLAG, BindImageMemory2) \
146  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetImageSubresourceLayout) \
147  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyImage) \
148  \
149  /* ImageView */ \
150  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateImageView) \
151  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyImageView) \
152  \
153  /* DescriptorSet */ \
154  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorSetLayout) \
155  MACRO(1, 1, FF_VK_EXT_NO_FLAG, AllocateDescriptorSets) \
156  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorPool) \
157  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorPool) \
158  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorSetLayout) \
159  \
160  /* Descriptor buffers */ \
161  MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorSetLayoutSizeEXT) \
162  MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorSetLayoutBindingOffsetEXT) \
163  MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, GetDescriptorEXT) \
164  MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, CmdBindDescriptorBuffersEXT) \
165  MACRO(1, 1, FF_VK_EXT_DESCRIPTOR_BUFFER, CmdSetDescriptorBufferOffsetsEXT) \
166  \
167  /* DescriptorUpdateTemplate */ \
168  MACRO(1, 1, FF_VK_EXT_NO_FLAG, UpdateDescriptorSetWithTemplate) \
169  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateDescriptorUpdateTemplate) \
170  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyDescriptorUpdateTemplate) \
171  \
172  /* Queries */ \
173  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateQueryPool) \
174  MACRO(1, 1, FF_VK_EXT_NO_FLAG, GetQueryPoolResults) \
175  MACRO(1, 1, FF_VK_EXT_NO_FLAG, ResetQueryPool) \
176  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdBeginQuery) \
177  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdEndQuery) \
178  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdResetQueryPool) \
179  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyQueryPool) \
180  \
181  /* sync2 */ \
182  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CmdPipelineBarrier2) \
183  \
184  /* Video queue */ \
185  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CreateVideoSessionKHR) \
186  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CreateVideoSessionParametersKHR) \
187  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, GetVideoSessionMemoryRequirementsKHR) \
188  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, BindVideoSessionMemoryKHR) \
189  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdBeginVideoCodingKHR) \
190  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdControlVideoCodingKHR) \
191  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, CmdEndVideoCodingKHR) \
192  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, DestroyVideoSessionParametersKHR) \
193  MACRO(1, 1, FF_VK_EXT_VIDEO_QUEUE, DestroyVideoSessionKHR) \
194  \
195  /* Video decoding */ \
196  MACRO(1, 1, FF_VK_EXT_VIDEO_DECODE_QUEUE, CmdDecodeVideoKHR) \
197  \
198  /* Pipeline */ \
199  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreatePipelineLayout) \
200  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyPipelineLayout) \
201  \
202  /* PipelineLayout */ \
203  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateComputePipelines) \
204  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyPipeline) \
205  \
206  /* Sampler */ \
207  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSamplerYcbcrConversion) \
208  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySamplerYcbcrConversion) \
209  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateSampler) \
210  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroySampler) \
211  \
212  /* Shaders */ \
213  MACRO(1, 1, FF_VK_EXT_NO_FLAG, CreateShaderModule) \
214  MACRO(1, 1, FF_VK_EXT_NO_FLAG, DestroyShaderModule)
215 
216 /* Macro containing every win32 specific function that we utilize in our codebase */
217 #define FN_LIST_WIN32(MACRO) \
218  MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_SEM, GetSemaphoreWin32HandleKHR) \
219  MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_MEMORY, GetMemoryWin32HandleKHR)
220 
221 /* Macro to turn a function name into a definition */
222 #define PFN_DEF(req_inst, req_dev, ext_flag, name) \
223  PFN_vk##name name;
224 
225 /* Structure with the definition of all listed functions */
226 typedef struct FFVulkanFunctions {
228 #ifdef _WIN32
230 #endif
232 
233 #endif /* AVUTIL_VULKAN_FUNCTIONS_H */
FF_VK_EXT_NO_FLAG
@ FF_VK_EXT_NO_FLAG
Definition: vulkan_functions.h:50
FF_VK_EXT_VIDEO_DECODE_H264
@ FF_VK_EXT_VIDEO_DECODE_H264
Definition: vulkan_functions.h:44
FF_VK_EXT_VIDEO_DECODE_AV1
@ FF_VK_EXT_VIDEO_DECODE_AV1
Definition: vulkan_functions.h:46
FF_VK_EXT_DESCRIPTOR_BUFFER
@ FF_VK_EXT_DESCRIPTOR_BUFFER
Definition: vulkan_functions.h:40
FF_VK_EXT_VIDEO_DECODE_H265
@ FF_VK_EXT_VIDEO_DECODE_H265
Definition: vulkan_functions.h:45
FF_VK_EXT_VIDEO_DECODE_QUEUE
@ FF_VK_EXT_VIDEO_DECODE_QUEUE
Definition: vulkan_functions.h:43
FF_VK_EXT_COOP_MATRIX
@ FF_VK_EXT_COOP_MATRIX
Definition: vulkan_functions.h:48
FN_LIST_WIN32
#define FN_LIST_WIN32(MACRO)
Definition: vulkan_functions.h:217
FF_VK_EXT_VIDEO_QUEUE
@ FF_VK_EXT_VIDEO_QUEUE
Definition: vulkan_functions.h:42
FN_LIST
#define FN_LIST(MACRO)
Definition: vulkan_functions.h:54
FF_VK_EXT_EXTERNAL_HOST_MEMORY
@ FF_VK_EXT_EXTERNAL_HOST_MEMORY
Definition: vulkan_functions.h:34
hwcontext_vulkan.h
FF_VK_EXT_DRM_MODIFIER_FLAGS
@ FF_VK_EXT_DRM_MODIFIER_FLAGS
Definition: vulkan_functions.h:31
FF_VK_EXT_EXTERNAL_DMABUF_MEMORY
@ FF_VK_EXT_EXTERNAL_DMABUF_MEMORY
Definition: vulkan_functions.h:30
FF_VK_EXT_EXTERNAL_FD_MEMORY
@ FF_VK_EXT_EXTERNAL_FD_MEMORY
Definition: vulkan_functions.h:32
PFN_DEF
#define PFN_DEF(req_inst, req_dev, ext_flag, name)
Definition: vulkan_functions.h:222
FF_VK_EXT_DEBUG_UTILS
@ FF_VK_EXT_DEBUG_UTILS
Definition: vulkan_functions.h:35
FFVulkanExtensions
FFVulkanExtensions
Definition: vulkan_functions.h:29
FF_VK_EXT_EXTERNAL_FD_SEM
@ FF_VK_EXT_EXTERNAL_FD_SEM
Definition: vulkan_functions.h:33
FF_VK_EXT_DEVICE_DRM
@ FF_VK_EXT_DEVICE_DRM
Definition: vulkan_functions.h:41
FF_VK_EXT_ATOMIC_FLOAT
@ FF_VK_EXT_ATOMIC_FLOAT
Definition: vulkan_functions.h:47
hwcontext.h
FFVulkanFunctions
Definition: vulkan_functions.h:226