[RFC,v4,1/7] libcamera: software_isp: egl: Add filter parameter to createTexture2D()
diff mbox series

Message ID 20260504182658.590233-2-mzamazal@redhat.com
State New
Headers show
Series
  • LSC for SoftISP simple pipeline
Related show

Commit Message

Milan Zamazal May 4, 2026, 6:26 p.m. UTC
From: Xander Pronk <xander.c.pronk@gmail.com>

Add `filter' parameter to createTexture2D() to allow overriding
the currently hardcoded GL_NEAREST value.  This is needed for
grid-based lens shading interpolation, which is implemented in followup
patches.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Co-developed-by: Rick ten Wolde <rick_libcamera@wolde.info>
Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>
Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 include/libcamera/internal/egl.h           |  3 ++-
 src/libcamera/egl.cpp                      | 10 ++++++----
 src/libcamera/software_isp/debayer_egl.cpp |  4 +++-
 3 files changed, 11 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
index 0ad2320b1..6402dd5c7 100644
--- a/include/libcamera/internal/egl.h
+++ b/include/libcamera/internal/egl.h
@@ -103,7 +103,8 @@  public:
 
 	int createInputDMABufTexture2D(eGLImage &eglImage, int fd);
 	int createOutputDMABufTexture2D(eGLImage &eglImage, int fd);
-	void createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data);
+	void createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height,
+			     const void *data, GLint filter);
 
 	void pushEnv(std::vector<std::string> &shaderEnv, const char *str);
 	void makeCurrent();
diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
index f65929470..93778acb8 100644
--- a/src/libcamera/egl.cpp
+++ b/src/libcamera/egl.cpp
@@ -212,13 +212,15 @@  int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
  * \param[in] width Texture width in pixels
  * \param[in] height Texture height in pixels
  * \param[in] data Pointer to pixel data, or nullptr for uninitialised texture
+ * \param[in] filter GL texture filter setting
  *
  * Creates a 2D texture from a CPU-accessible memory buffer. The texture
- * is configured with nearest filtering and clamp-to-edge wrapping. This
+ * is configured the specified filtering and clamp-to-edge wrapping. This
  * is useful for uploading static data like lookup tables or uniform color
  * matrices to the GPU.
  */
-void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data)
+void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height,
+			  const void *data, GLint filter)
 {
 	ASSERT(tid_ == Thread::currentId());
 
@@ -229,8 +231,8 @@  void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint
 	glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
 
 	// Nearest filtering
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
 
 	// Wrap to edge to avoid edge artifacts
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 8f0c229fd..f10f372c6 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -501,7 +501,9 @@  int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParam
 	egl_.makeCurrent();
 
 	/* Create a standard texture input */
-	egl_.createTexture2D(*eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data());
+	egl_.createTexture2D(*eglImageBayerIn_, glFormat_,
+			     inputConfig_.stride / bytesPerPixel_, height_,
+			     in.planes()[0].data(), GL_NEAREST);
 
 	/* Generate the output render framebuffer as render to texture */
 	egl_.createOutputDMABufTexture2D(*eglImageBayerOut_, out_fd);