[v3,03/22] meson: Automatically generate glsl_shaders.h from specified shader programs
diff mbox series

Message ID 20251202133157.661407-4-bryan.odonoghue@linaro.org
State Superseded
Headers show
Series
  • GPUISP precursor series
Related show

Commit Message

Bryan O'Donoghue Dec. 2, 2025, 1:31 p.m. UTC
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.

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/meson.build         | 11 +++++++++++
 src/libcamera/shaders/meson.build | 10 ++++++++++
 utils/meson.build                 |  2 ++
 3 files changed, 23 insertions(+)
 create mode 100644 src/libcamera/shaders/meson.build

Comments

Milan Zamazal Dec. 3, 2025, 1:33 p.m. UTC | #1
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> 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.
>
> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

I'm not a meson expert but the patch looks plausible and building
libcamera with this works fine for me.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> ---
>  src/libcamera/meson.build         | 11 +++++++++++
>  src/libcamera/shaders/meson.build | 10 ++++++++++
>  utils/meson.build                 |  2 ++
>  3 files changed, 23 insertions(+)
>  create mode 100644 src/libcamera/shaders/meson.build
>
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index 34e20f557..90d434a5a 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -76,6 +76,7 @@ subdir('ipa')
>  subdir('pipeline')
>  subdir('proxy')
>  subdir('sensor')
> +subdir('shaders')
>  subdir('software_isp')
>  
>  libdl = dependency('dl')
> @@ -182,6 +183,16 @@ libcamera_deps += [
>      libyaml,
>  ]
>  
> +# Generate headers from shaders
> +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
> +
>  # We add '/' to the build_rpath as a 'safe' path to act as a boolean flag.
>  # The build_rpath is stripped at install time by meson, so we determine at
>  # runtime if the library is running from an installed location by checking
> diff --git a/src/libcamera/shaders/meson.build b/src/libcamera/shaders/meson.build
> new file mode 100644
> index 000000000..386b342d0
> --- /dev/null
> +++ b/src/libcamera/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 95d657ac9..3deed8ad4 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')

Patch
diff mbox series

diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 34e20f557..90d434a5a 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -76,6 +76,7 @@  subdir('ipa')
 subdir('pipeline')
 subdir('proxy')
 subdir('sensor')
+subdir('shaders')
 subdir('software_isp')
 
 libdl = dependency('dl')
@@ -182,6 +183,16 @@  libcamera_deps += [
     libyaml,
 ]
 
+# Generate headers from shaders
+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
+
 # We add '/' to the build_rpath as a 'safe' path to act as a boolean flag.
 # The build_rpath is stripped at install time by meson, so we determine at
 # runtime if the library is running from an installed location by checking
diff --git a/src/libcamera/shaders/meson.build b/src/libcamera/shaders/meson.build
new file mode 100644
index 000000000..386b342d0
--- /dev/null
+++ b/src/libcamera/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 95d657ac9..3deed8ad4 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')