[v2,32/37] libcamera: shaders: Extend bayer shaders to support swapping R and B on output
diff mbox series

Message ID 20250824-b4-v0-5-2-gpuisp-v2-a-v2-32-96f4576c814e@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Aug. 24, 2025, 12:48 a.m. UTC
We can easily facilitate swapping R and B on output. Pivot on an
environment define for this purpose.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++
 include/libcamera/internal/shaders/bayer_8.frag         | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag
index 90bd645709e02d8cf9bee112b25cbb26c681db0a..c0632eb1f2089522cadb548a163607354bf7688f 100644
--- a/include/libcamera/internal/shaders/bayer_1x_packed.frag
+++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag
@@ -268,5 +268,9 @@  void main(void)
 	rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;
 #endif
 
+#if defined (SWAP_BLUE)
+	gl_FragColor = vec4(rgb.bgr, 1.0);
+#else
 	gl_FragColor = vec4(rgb, 1.0);
+#endif
 }
diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag
index 5955c2eafbe03678158b240740e18c7f00e58057..74ce15096ac0b8a221175d111d982d1222b7db38 100644
--- a/include/libcamera/internal/shaders/bayer_8.frag
+++ b/include/libcamera/internal/shaders/bayer_8.frag
@@ -163,5 +163,9 @@  void main(void) {
 	rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;
 #endif
 
-    gl_FragColor.rgb = rgb;
+#if defined (SWAP_BLUE)
+	gl_FragColor = vec4(rgb.bgr, 1.0);
+#else
+	gl_FragColor = vec4(rgb, 1.0);
+#endif
 }