[PATCH 26/27] meson: Automatically generate glsl_shaders.h from specified shader programs

Bryan O'Donoghue bryan.odonoghue at linaro.org
Tue Apr 22 23:59:19 CEST 2025


Encode the bayer shader files into a header as part of the build process.
Qcam already compiles the shader files down into a QT resource file which
it references internally.

In order to share the debayering shader programs outside of qcam create a
generic header which both qcam and libcamera can operate from.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 include/libcamera/internal/meson.build         | 10 ++++++++++
 include/libcamera/internal/shaders/meson.build | 10 ++++++++++
 utils/meson.build                              |  2 ++
 3 files changed, 22 insertions(+)
 create mode 100644 include/libcamera/internal/shaders/meson.build

diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build
index 45408b31..10cd4930 100644
--- a/include/libcamera/internal/meson.build
+++ b/include/libcamera/internal/meson.build
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: CC0-1.0
 
 subdir('tracepoints')
+subdir('shaders')
 
 libcamera_internal_headers = files([
     'bayer_format.h',
@@ -56,5 +57,14 @@ tracepoints_h = custom_target(
 
 libcamera_internal_headers += tracepoints_h
 
+libcamera_shader_headers = custom_target(
+    'gen-shader-headers',
+    input : [shader_files],
+    output : 'glsl_shaders.h',
+    command : [gen_shader_headers, meson.project_source_root(), meson.project_build_root(), '@OUTPUT@', '@INPUT@'],
+)
+
+libcamera_internal_headers += libcamera_shader_headers
+
 subdir('converter')
 subdir('software_isp')
diff --git a/include/libcamera/internal/shaders/meson.build b/include/libcamera/internal/shaders/meson.build
new file mode 100644
index 00000000..386b342d
--- /dev/null
+++ b/include/libcamera/internal/shaders/meson.build
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: CC0-1.0
+
+# List of shader files to convert to header hex
+# for the purposes of inclusion in OpenGL debayering
+shader_files = files([
+    'bayer_1x_packed.frag',
+    'bayer_8.frag',
+    'bayer_8.vert',
+    'identity.vert',
+])
diff --git a/utils/meson.build b/utils/meson.build
index 95d657ac..3deed8ad 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -3,5 +3,7 @@
 subdir('codegen')
 subdir('ipu3')
 
+gen_shader_headers = files('gen-shader-headers.sh')
+
 ## Module signing
 gen_ipa_priv_key = files('gen-ipa-priv-key.sh')
-- 
2.49.0



More information about the libcamera-devel mailing list