libcamera: software_isp: debayer_egl: Fix texture sampling steps
diff mbox series

Message ID 20261029142649.388275-1-halfline@gmail.com
State New
Headers show
Series
  • libcamera: software_isp: debayer_egl: Fix texture sampling steps
Related show

Commit Message

Ray Strode Oct. 29, 2026, 2:26 p.m. UTC
From: Ray Strode <rstrode@redhat.com>

This commit removes thin horizontal color artifacts caused by the GPU
debayer sampling the wrong Bayer rows.

The shader samples neighboring Bayer pixels using offsets in normalized
texture coordinates. The step denominators currently subtract one from the
input byte stride and image height, making the offsets larger than one
texel. Scaling can then place a lookup on the wrong side of a texel
boundary. A uniform synthetic Bayer image reproduces the lines seen in live
GPU captures.

The offsets now match the reciprocal texture dimensions: bytes per pixel
divided by byte stride horizontally, and one divided by image height
vertically.

Fixes: f520b29fe9e6 ("libcamera: software_isp: debayer_egl: Add an eGL Debayer class")
Signed-off-by: Ray Strode <rstrode@redhat.com>
---
 src/libcamera/software_isp/debayer_egl.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


base-commit: 5670220c89cf772e7302d4e0ef6c716c31c00b46

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 33933b11..e6df04da 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -394,8 +394,8 @@  void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara
 	GLfloat firstRed[] = { firstRed_x_, firstRed_y_ };
 	GLfloat imgSize[] = { (GLfloat)width_,
 			      (GLfloat)height_ };
-	GLfloat Step[] = { static_cast<float>(bytesPerPixel_) / (inputConfig_.stride - 1),
-			   1.0f / (height_ - 1) };
+	GLfloat Step[] = { static_cast<float>(bytesPerPixel_) / inputConfig_.stride,
+			   1.0f / height_ };
 	GLfloat Stride = (GLfloat)width_ / (shaderStridePixels_ / bytesPerPixel_);
 	/*
 	 * Scale the output size from the native size the algorithm produces for