aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2021-11-13 18:59:07 +0100
committerTimo Rothenpieler <timo@rothenpieler.org>2021-11-14 12:50:32 +0100
commitfedf4ff85c325fa164a5646785104aaa292c877b (patch)
tree3506826cc6e2eef2bdb0ade2652edb82ba35e944 /libavutil
parentbfbd5954e50e407693932b3900ca77c3daee26d7 (diff)
downloadffmpeg-fedf4ff85c325fa164a5646785104aaa292c877b.tar.gz
avutil/vulkan: load win32 external memory functions
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/hwcontext_vulkan.h3
-rw-r--r--libavutil/vulkan_functions.h12
-rw-r--r--libavutil/vulkan_loader.h9
3 files changed, 23 insertions, 1 deletions
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++) {