| Message ID | 20260424200255.356798-2-mzamazal@redhat.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi Milan, Thank you for the patch. On Fri, Apr 24, 2026 at 10:02:47PM +0200, Milan Zamazal wrote: > From: Xander Pronk <xander.c.pronk@gmail.com> > > Add a gl_scale_param to createTexture2D() to allow overriding s/gl_scale_param/glFilterParam/ Although I wonder if the parameter shouldn't be called just filter. The "gl" prefix is quite redundant as the function is part of a class called "eGL", and the "param" suffix seems redundant too. Up to you. > 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 | 8 +++++--- > src/libcamera/software_isp/debayer_egl.cpp | 4 +++- > 3 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h > index 0ad2320b1..2496679b2 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 glFilterParam); > > 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..9b50111a4 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] glFilterParam 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 This is not true any more. > * 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 glFilterParam) > { > 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, glFilterParam); > + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glFilterParam); > > // 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 2ad258bca..08e513eaf 100644 > --- a/src/libcamera/software_isp/debayer_egl.cpp > +++ b/src/libcamera/software_isp/debayer_egl.cpp > @@ -502,7 +502,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);
diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 0ad2320b1..2496679b2 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 glFilterParam); 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..9b50111a4 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] glFilterParam 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 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 glFilterParam) { 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, glFilterParam); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glFilterParam); // 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 2ad258bca..08e513eaf 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -502,7 +502,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);