From 346df4cb3fbd2f81f014ee0d9328bd33b8975edc Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sat, 1 Jun 2024 21:35:26 +1000 Subject: [PATCH] vulkan: support not having glslc available for building vulkan plugin Part-of: --- .../gst-plugins-bad/ext/vulkan/gstvulkan.c | 13 +++-- .../gst-plugins-bad/ext/vulkan/meson.build | 49 ++++++++++++------- .../gst-libs/gst/vulkan/meson.build | 6 +-- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/vulkan/gstvulkan.c b/subprojects/gst-plugins-bad/ext/vulkan/gstvulkan.c index fd40591a48..023dd30f55 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/gstvulkan.c +++ b/subprojects/gst-plugins-bad/ext/vulkan/gstvulkan.c @@ -31,14 +31,17 @@ #include "vksink.h" #include "vkupload.h" +#include "vkdownload.h" +#include "vkdeviceprovider.h" +#include "gstvulkanelements.h" + +#if defined(HAVE_GLSLC) #include "vkimageidentity.h" #include "vkcolorconvert.h" #include "vkshaderspv.h" -#include "vkdownload.h" #include "vkviewconvert.h" -#include "vkdeviceprovider.h" -#include "gstvulkanelements.h" #include "vkoverlaycompositor.h" +#endif #if GST_VULKAN_HAVE_VIDEO_EXTENSIONS #include "vkh264dec.h" @@ -57,7 +60,7 @@ plugin_init (GstPlugin * plugin) ret |= GST_ELEMENT_REGISTER (vulkanupload, plugin); ret |= GST_ELEMENT_REGISTER (vulkandownload, plugin); - +#if defined(HAVE_GLSLC) ret |= GST_ELEMENT_REGISTER (vulkancolorconvert, plugin); ret |= GST_ELEMENT_REGISTER (vulkanimageidentity, plugin); @@ -67,7 +70,7 @@ plugin_init (GstPlugin * plugin) ret |= GST_ELEMENT_REGISTER (vulkanviewconvert, plugin); ret |= GST_ELEMENT_REGISTER (vulkanoverlaycompositor, plugin); - +#endif #if GST_VULKAN_HAVE_VIDEO_EXTENSIONS GST_ELEMENT_REGISTER (vulkanh264dec, plugin); GST_ELEMENT_REGISTER (vulkanh265dec, plugin); diff --git a/subprojects/gst-plugins-bad/ext/vulkan/meson.build b/subprojects/gst-plugins-bad/ext/vulkan/meson.build index 1d4d0ddcaf..a88bd31bbb 100644 --- a/subprojects/gst-plugins-bad/ext/vulkan/meson.build +++ b/subprojects/gst-plugins-bad/ext/vulkan/meson.build @@ -10,42 +10,53 @@ if not gstvulkan_dep.found() endif endif -# Should already have checked for this -assert(glslc.found(), 'Expected glslc to be available') - -subdir('shaders') +extra_deps = [] +extra_args = [] vulkan_sources = files( 'gstvulkan.c', 'gstvulkanelement.c', - 'vkcolorconvert.c', 'vkdownload.c', 'vkdeviceprovider.c', - 'vkimageidentity.c', - 'vkshaderspv.c', 'vksink.c', 'vkupload.c', - 'vkviewconvert.c', - 'vkoverlaycompositor.c', ) +vulkan_plugin_enums = [] -vulkan_plugin_enum_headers = files( - 'vkviewconvert.h', -) +glslc = find_program('glslc', required: get_option('vulkan')) +if not glslc.found() + if get_option('vulkan').enabled() + error('GStreamer Vulkan plugin required via options, but glslc was not found.') + else + subdir_done() + endif + vulkan_compiled_shader_sources = [] +else + extra_args += ['-DHAVE_GLSLC'] + subdir('shaders') + + vulkan_sources += files( + 'vkcolorconvert.c', + 'vkimageidentity.c', + 'vkshaderspv.c', + 'vkviewconvert.c', + 'vkoverlaycompositor.c', + ) + vulkan_plugin_enum_headers = files( + 'vkviewconvert.h', + ) + vulkan_plugin_enums += gnome.mkenums_simple('gstvulkan-plugins-enumtypes', + sources : vulkan_plugin_enum_headers, + body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', + header_prefix : '#include ') +endif -extra_deps = [] -extra_args = [] if vulkan_conf.get('GST_VULKAN_HAVE_VIDEO_EXTENSIONS') == 1 vulkan_sources += files('vkh264dec.c', 'vkh265dec.c') extra_deps += gstcodecs_dep extra_args += ['-DGST_USE_UNSTABLE_API'] endif -vulkan_plugin_enums = gnome.mkenums_simple('gstvulkan-plugins-enumtypes', - sources : vulkan_plugin_enum_headers, - body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', - header_prefix : '#include ') - gstvulkan_plugin = library('gstvulkan', vulkan_sources, vulkan_compiled_shader_sources, vulkan_plugin_enums, c_args : gst_plugins_bad_args + extra_args, diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/meson.build index 1d4d76ad79..92347a8007 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/meson.build @@ -298,11 +298,7 @@ if not vulkan_windowing endif endif -# Only needed for the vulkan plugin, but doesn't make sense to build -# anything else vulkan related if we are not going to build the plugin -glslc = find_program('glslc', required: get_option('vulkan')) - -if not vulkan_dep.found() or not has_vulkan_header or not glslc.found() +if not vulkan_dep.found() or not has_vulkan_header if get_option('vulkan').enabled() error('GStreamer Vulkan integration required via options, but needed dependencies not found.') else