PR #22704 opened by Lynne URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22704 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22704.patch
Instead of making Vulkan depend on the headers, make the compilation of the SPIR-V backend depend on the headers. >From 491b39ab5bb5f4a69c82a5f49036ea821def48a0 Mon Sep 17 00:00:00 2001 From: Lynne <[email protected]> Date: Sat, 4 Apr 2026 11:02:32 +0200 Subject: [PATCH] swscale/vulkan: compile SPIR-V backed only if SPIR-V headers are found Instead of making Vulkan depend on the headers, make the compilation of the SPIR-V backend depend on the headers. Sponsored-by: Sovereign Tech Fund --- configure | 10 +++++++--- libswscale/ops.c | 6 ++++-- libswscale/vulkan/ops.c | 7 +++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 32db36cee4..a645143081 100755 --- a/configure +++ b/configure @@ -2496,6 +2496,8 @@ HEADERS_LIST=" valgrind_valgrind_h windows_h winsock2_h + spirv_headers_spirv_h + spirv_unified1_spirv_h " INTRINSICS_LIST=" @@ -7796,9 +7798,6 @@ enabled vdpau && check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11 # Check for the Vulkan headers -if enabled vulkan; then - check_cpp_condition vulkan "spirv/unified1/spirv.h" "defined(SPV_VERSION)" -fi 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 @@ -7856,6 +7855,11 @@ else disable libglslang libshaderc spirv_library spirv_compiler fi +if enabled vulkan; then + check_headers spirv-headers/spirv.h + check_headers spirv/unified1/spirv.h +fi + if enabled x86; then case $target_os in freebsd|mingw32*|mingw64*|win32|win64|linux|cygwin*) diff --git a/libswscale/ops.c b/libswscale/ops.c index 5d7e70c133..0d792a86ec 100644 --- a/libswscale/ops.c +++ b/libswscale/ops.c @@ -34,7 +34,9 @@ extern const SwsOpBackend backend_c; extern const SwsOpBackend backend_murder; extern const SwsOpBackend backend_aarch64; extern const SwsOpBackend backend_x86; +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H extern const SwsOpBackend backend_spirv; +#endif #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG extern const SwsOpBackend backend_glsl; #endif @@ -47,11 +49,11 @@ const SwsOpBackend * const ff_sws_op_backends[] = { &backend_x86, #endif &backend_c, -#if CONFIG_VULKAN +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H &backend_spirv, +#endif #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG &backend_glsl, -#endif #endif NULL }; diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c index f81b78e52d..ec260a5ce3 100644 --- a/libswscale/vulkan/ops.c +++ b/libswscale/vulkan/ops.c @@ -25,7 +25,10 @@ #include "../swscale_internal.h" #include "ops.h" + +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H #include "spvasm.h" +#endif static void ff_sws_vk_uninit(AVRefStructOpaque opaque, void *obj) { @@ -204,6 +207,7 @@ fail: return err; } +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H struct DitherData { int size; int arr_1d_id; @@ -883,6 +887,7 @@ static int add_ops_spirv(VulkanPriv *p, FFVulkanOpsCtx *s, return ff_vk_shader_link(&s->vkctx, shd, spvbuf, len, "main"); } +#endif #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG static void add_desc_read_write(FFVulkanDescriptorSetBinding *out_desc, @@ -1196,6 +1201,7 @@ fail: return err; } +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H static int compile_spirv(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out) { return compile(sws, ops, out, 0); @@ -1206,6 +1212,7 @@ const SwsOpBackend backend_spirv = { .compile = compile_spirv, .hw_format = AV_PIX_FMT_VULKAN, }; +#endif #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG static int compile_glsl(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
