diff --git a/configure b/configure index a6ac2c8b0b..0a7ce31e09 100755 --- a/configure +++ b/configure @@ -363,6 +363,7 @@ External library support: --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect] --disable-vulkan disable Vulkan code [autodetect] + --enable-vulkan-static statically link to libvulkan [no] Toolchain options: --arch=ARCH select architecture [$arch] @@ -1987,6 +1988,7 @@ EXTERNAL_LIBRARY_LIST=" openssl pocketsphinx vapoursynth + vulkan_static " HWACCEL_AUTODETECT_LIBRARY_LIST=" @@ -7379,7 +7381,10 @@ enabled vdpau && enabled vdpau && check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11 -if enabled vulkan; then +if enabled_all vulkan vulkan_static; then + check_pkg_config vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || + check_lib vulkan "vulkan/vulkan.h" vkGetInstanceProcAddr -lvulkan +elif enabled vulkan; then check_pkg_config_header_only vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 277)" fi diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index d32a685383..bc7c258ebb 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -533,11 +533,19 @@ static int vkfmt_from_pixfmt2(AVHWDeviceContext *dev_ctx, enum AVPixelFormat p, return AVERROR(EINVAL); } +#if CONFIG_VULKAN_STATIC +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, + const char *pName); +#endif + static int load_libvulkan(AVHWDeviceContext *ctx) { VulkanDevicePriv *p = ctx->hwctx; AVVulkanDeviceContext *hwctx = &p->p; +#if CONFIG_VULKAN_STATIC + hwctx->get_proc_addr = vkGetInstanceProcAddr; +#else static const char *lib_names[] = { #if defined(_WIN32) "vulkan-1.dll", @@ -563,6 +571,7 @@ static int load_libvulkan(AVHWDeviceContext *ctx) } hwctx->get_proc_addr = (PFN_vkGetInstanceProcAddr)dlsym(p->libvulkan, "vkGetInstanceProcAddr"); +#endif /* CONFIG_VULKAN_STATIC */ return 0; }