| Message ID | 20260126104256.119697-2-rick.w.ten.wolde@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi 2026. 01. 26. 11:42 keltezéssel, Rick ten Wolde írta: > From: Xander Pronk <xander.c.pronk@gmail.com> > > Add a gl_scale_param to createTexture2D() to allow overriding > the currently hardcoded GL_NEAREST value. > > Co-authored-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> > --- > include/libcamera/internal/egl.h | 2 +- > src/libcamera/egl.cpp | 7 ++++--- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h > index a9292112..9c0504fb 100644 > --- a/include/libcamera/internal/egl.h > +++ b/include/libcamera/internal/egl.h > @@ -113,7 +113,7 @@ public: > int createInputDMABufTexture2D(eGLImage &eglImage, int fd); > int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); > void destroyDMABufTexture(eGLImage &eglImage); > - 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, void *data, GLint gl_scale_param=GL_NEAREST); Please camel case: GLint glScaleParam = GL_NEAREST although to me "filtering" or similar sounds like a more appropriate name. Regards, Barnabás Pőcze > > 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 0544056b..3565bfd3 100644 > --- a/src/libcamera/egl.cpp > +++ b/src/libcamera/egl.cpp > @@ -229,13 +229,14 @@ void eGL::destroyDMABufTexture(eGLImage &eglImage) > * \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] gl_scale_param 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, void *data, GLint gl_scale_param) > { > ASSERT(tid_ == Thread::currentId()); > > @@ -246,8 +247,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, gl_scale_param); > + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_scale_param); > > // Wrap to edge to avoid edge artifacts > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index a9292112..9c0504fb 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -113,7 +113,7 @@ public: int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void destroyDMABufTexture(eGLImage &eglImage); - 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, void *data, GLint gl_scale_param=GL_NEAREST); 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 0544056b..3565bfd3 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -229,13 +229,14 @@ void eGL::destroyDMABufTexture(eGLImage &eglImage) * \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] gl_scale_param 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, void *data, GLint gl_scale_param) { ASSERT(tid_ == Thread::currentId()); @@ -246,8 +247,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, gl_scale_param); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_scale_param); // Wrap to edge to avoid edge artifacts glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);