diff --git a/configure b/configure index 32db36cee4..54b760012f 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,12 @@ 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 || + warn "spirv-headers not found, swscale SPIR-V backend unavailable" +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..6f05d80ded 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, @@ -1159,19 +1164,18 @@ static int compile(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out, int glsl } if (glsl) { + err = AVERROR(ENOTSUP); #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG err = add_ops_glsl(p, s, ops, &p->shd); - if (err < 0) - goto fail; -#else - err = AVERROR(ENOTSUP); - goto fail; #endif } else { + err = AVERROR(ENOTSUP); +#if HAVE_SPIRV_HEADERS_SPIRV_H || HAVE_SPIRV_UNIFIED1_SPIRV_H err = add_ops_spirv(p, s, ops, &p->shd); - if (err < 0) - goto fail; +#endif } + if (err < 0) + goto fail; err = ff_vk_shader_register_exec(&s->vkctx, &p->e, &p->shd); if (err < 0) @@ -1196,6 +1200,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 +1211,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) diff --git a/libswscale/vulkan/spvasm.h b/libswscale/vulkan/spvasm.h index 2c40694df4..372163f7bd 100644 --- a/libswscale/vulkan/spvasm.h +++ b/libswscale/vulkan/spvasm.h @@ -23,11 +23,20 @@ #include #include +#include "config.h" #include "libavutil/intreadwrite.h" #include "libavutil/avassert.h" + +#if HAVE_SPIRV_HEADERS_SPIRV_H +#include +#include +#endif + +#if HAVE_SPIRV_UNIFIED1_SPIRV_H #include #include +#endif /* COUNT_ARGS: counts variadic macro arguments, including zero. * The sentinel 0 is prepended so the compound literal is never empty,