[FFmpeg-cvslog] avutil/vulkan: load win32 external memory functions

Timo Rothenpieler git at videolan.org
Sun Nov 14 14:02:58 EET 2021


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Sat Nov 13 18:59:07 2021 +0100| [fedf4ff85c325fa164a5646785104aaa292c877b] | committer: Timo Rothenpieler

avutil/vulkan: load win32 external memory functions

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fedf4ff85c325fa164a5646785104aaa292c877b
---

 libavutil/hwcontext_vulkan.h |  3 +++
 libavutil/vulkan_functions.h | 12 ++++++++++++
 libavutil/vulkan_loader.h    |  9 ++++++++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h
index c83fe3fb1d..fdf2a60156 100644
--- a/libavutil/hwcontext_vulkan.h
+++ b/libavutil/hwcontext_vulkan.h
@@ -19,6 +19,9 @@
 #ifndef AVUTIL_HWCONTEXT_VULKAN_H
 #define AVUTIL_HWCONTEXT_VULKAN_H
 
+#if defined(_WIN32) && !defined(VK_USE_PLATFORM_WIN32_KHR)
+#define VK_USE_PLATFORM_WIN32_KHR
+#endif
 #include <vulkan/vulkan.h>
 
 #include "pixfmt.h"
diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h
index 913667befb..f6881d8959 100644
--- a/libavutil/vulkan_functions.h
+++ b/libavutil/vulkan_functions.h
@@ -27,6 +27,10 @@ typedef enum FFVulkanExtensions {
     FF_VK_EXT_EXTERNAL_FD_SEM        = 1ULL <<  3, /* VK_KHR_external_semaphore_fd */
     FF_VK_EXT_EXTERNAL_HOST_MEMORY   = 1ULL <<  4, /* VK_EXT_external_memory_host */
     FF_VK_EXT_DEBUG_UTILS            = 1ULL <<  5, /* VK_EXT_debug_utils */
+#ifdef _WIN32
+    FF_VK_EXT_EXTERNAL_WIN32_MEMORY  = 1ULL <<  6, /* VK_KHR_external_memory_win32 */
+    FF_VK_EXT_EXTERNAL_WIN32_SEM     = 1ULL <<  7, /* VK_KHR_external_semaphore_win32 */
+#endif
 
     FF_VK_EXT_NO_FLAG                = 1ULL << 63,
 } FFVulkanExtensions;
@@ -151,6 +155,11 @@ typedef enum FFVulkanExtensions {
     MACRO(1, 1, FF_VK_EXT_NO_FLAG,              CreateShaderModule)                      \
     MACRO(1, 1, FF_VK_EXT_NO_FLAG,              DestroyShaderModule)
 
+/* Macro containing every win32 specific function that we utilize in our codebase */
+#define FN_LIST_WIN32(MACRO)                                                             \
+    MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_SEM,    GetSemaphoreWin32HandleKHR)             \
+    MACRO(1, 1, FF_VK_EXT_EXTERNAL_WIN32_MEMORY, GetMemoryWin32HandleKHR)
+
 /* Macro to turn a function name into a definition */
 #define PFN_DEF(req_inst, req_dev, ext_flag, name) \
     PFN_vk##name name;
@@ -158,6 +167,9 @@ typedef enum FFVulkanExtensions {
 /* Structure with the definition of all listed functions */
 typedef struct FFVulkanFunctions {
     FN_LIST(PFN_DEF)
+#ifdef _WIN32
+    FN_LIST_WIN32(PFN_DEF)
+#endif
 } FFVulkanFunctions;
 
 #endif /* AVUTIL_VULKAN_FUNCTIONS_H */
diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h
index 838d26d271..d4e05e62d7 100644
--- a/libavutil/vulkan_loader.h
+++ b/libavutil/vulkan_loader.h
@@ -43,7 +43,11 @@ static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions,
         { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,        FF_VK_EXT_EXTERNAL_FD_MEMORY     },
         { VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,     FF_VK_EXT_EXTERNAL_FD_SEM        },
         { VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME,      FF_VK_EXT_EXTERNAL_HOST_MEMORY   },
-        { VK_EXT_DEBUG_UTILS_EXTENSION_NAME,               FF_VK_EXT_DEBUG_UTILS            }
+        { VK_EXT_DEBUG_UTILS_EXTENSION_NAME,               FF_VK_EXT_DEBUG_UTILS            },
+#ifdef _WIN32
+        { VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,     FF_VK_EXT_EXTERNAL_WIN32_MEMORY  },
+        { VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,  FF_VK_EXT_EXTERNAL_WIN32_SEM     },
+#endif
     };
 
     FFVulkanExtensions mask = 0x0;
@@ -88,6 +92,9 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx,
         const char *names[3];
     } vk_load_info[] = {
         FN_LIST(PFN_LOAD_INFO)
+#ifdef _WIN32
+        FN_LIST_WIN32(PFN_LOAD_INFO)
+#endif
     };
 
     for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); i++) {



More information about the ffmpeg-cvslog mailing list