[v4,2/5] egl: Remove some parameters from createTexture2D()
diff mbox series

Message ID 20260521155906.120373-3-robert.mader@collabora.com
State Superseded
Headers show
Series
  • software_isp: Implement DMABuf import for input buffers
Related show

Commit Message

Robert Mader May 21, 2026, 3:59 p.m. UTC
And use the values set in the constructor instead, bringing the
function in line with createInputDMABufTexture2D() and
createOutputDMABufTexture2D().

Adopt the value passed into the constructor accordingly, which
previously was never used.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
---
 include/libcamera/internal/egl.h           | 2 +-
 src/libcamera/egl.cpp                      | 7 ++-----
 src/libcamera/software_isp/debayer_egl.cpp | 4 ++--
 3 files changed, 5 insertions(+), 8 deletions(-)

Comments

Bryan O'Donoghue May 26, 2026, 5:32 p.m. UTC | #1
On 21/05/2026 16:59, Robert Mader wrote:
> And use the values set in the constructor instead, bringing the
> function in line with createInputDMABufTexture2D() and
> createOutputDMABufTexture2D().
> 
> Adopt the value passed into the constructor accordingly, which
> previously was never used.
> 
> Signed-off-by: Robert Mader <robert.mader@collabora.com>
> ---
>   include/libcamera/internal/egl.h           | 2 +-
>   src/libcamera/egl.cpp                      | 7 ++-----
>   src/libcamera/software_isp/debayer_egl.cpp | 4 ++--
>   3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
> index 825240dbb..bcf09b475 100644
> --- a/include/libcamera/internal/egl.h
> +++ b/include/libcamera/internal/egl.h
> @@ -105,7 +105,7 @@ 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, void *data);
> 
>   	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 2aabfc2e0..267d22c8b 100644
> --- a/src/libcamera/egl.cpp
> +++ b/src/libcamera/egl.cpp
> @@ -240,9 +240,6 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
>   /**
>    * \brief Create a 2D texture from a memory buffer
>    * \param[in,out] eglImage EGL image to associate with the texture
> - * \param[in] format OpenGL internal format (e.g., GL_RGB, GL_RGBA)
> - * \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
>    *
>    * Creates a 2D texture from a CPU-accessible memory buffer. The texture
> @@ -250,7 +247,7 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
>    * 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, void *data)
>   {
>   	ASSERT(tid_ == Thread::currentId());
> 
> @@ -258,7 +255,7 @@ void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint
>   	glBindTexture(GL_TEXTURE_2D, eglImage.texture_);
> 
>   	// Generate texture, bind, associate image to texture, configure, unbind
> -	glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
> +	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, eglImage.format_, GL_UNSIGNED_BYTE, data);
> 
>   	// Nearest filtering
>   	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
> index 8c1f2074d..696498a58 100644
> --- a/src/libcamera/software_isp/debayer_egl.cpp
> +++ b/src/libcamera/software_isp/debayer_egl.cpp
> @@ -506,7 +506,7 @@ 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_, in.planes()[0].data());
> 
>   	/* Generate the output render framebuffer as render to texture */
>   	egl_.createOutputDMABufTexture2D(*eglImageBayerOut_, out_fd);
> @@ -587,7 +587,7 @@ int DebayerEGL::start()
>   		return -EINVAL;
> 
>   	/* Raw bayer input as texture */
> -	eglImageBayerIn_ = std::make_unique<eGLImage>(glFormat_, width_, height_, inputConfig_.stride, GL_TEXTURE0, 0);
> +	eglImageBayerIn_ = std::make_unique<eGLImage>(glFormat_, inputConfig_.stride / bytesPerPixel_, height_, inputConfig_.stride, GL_TEXTURE0, 0);
> 
>   	/* Texture we will render to */
>   	eglImageBayerOut_ = std::make_unique<eGLImage>(GL_RGBA, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE1, 1);
> --
> 2.54.0
> 

I think the parameter should stay since for multipass we need to create 
textures of different sizes.

---
bod
Robert Mader May 27, 2026, 8:20 a.m. UTC | #2
On 26.05.26 19:32, Bryan O'Donoghue wrote:
> I think the parameter should stay since for multipass we need to create
> textures of different sizes.
As discussed offline this should work with the upcoming multi-pass work 
as well and we can thus move forward with the patch as is - therefor no 
changes to the patch in v5.

Patch
diff mbox series

diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
index 825240dbb..bcf09b475 100644
--- a/include/libcamera/internal/egl.h
+++ b/include/libcamera/internal/egl.h
@@ -105,7 +105,7 @@  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, void *data);
 
 	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 2aabfc2e0..267d22c8b 100644
--- a/src/libcamera/egl.cpp
+++ b/src/libcamera/egl.cpp
@@ -240,9 +240,6 @@  int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
 /**
  * \brief Create a 2D texture from a memory buffer
  * \param[in,out] eglImage EGL image to associate with the texture
- * \param[in] format OpenGL internal format (e.g., GL_RGB, GL_RGBA)
- * \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
  *
  * Creates a 2D texture from a CPU-accessible memory buffer. The texture
@@ -250,7 +247,7 @@  int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
  * 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, void *data)
 {
 	ASSERT(tid_ == Thread::currentId());
 
@@ -258,7 +255,7 @@  void eGL::createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint
 	glBindTexture(GL_TEXTURE_2D, eglImage.texture_);
 
 	// Generate texture, bind, associate image to texture, configure, unbind
-	glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
+	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, eglImage.format_, GL_UNSIGNED_BYTE, data);
 
 	// Nearest filtering
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 8c1f2074d..696498a58 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -506,7 +506,7 @@  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_, in.planes()[0].data());
 
 	/* Generate the output render framebuffer as render to texture */
 	egl_.createOutputDMABufTexture2D(*eglImageBayerOut_, out_fd);
@@ -587,7 +587,7 @@  int DebayerEGL::start()
 		return -EINVAL;
 
 	/* Raw bayer input as texture */
-	eglImageBayerIn_ = std::make_unique<eGLImage>(glFormat_, width_, height_, inputConfig_.stride, GL_TEXTURE0, 0);
+	eglImageBayerIn_ = std::make_unique<eGLImage>(glFormat_, inputConfig_.stride / bytesPerPixel_, height_, inputConfig_.stride, GL_TEXTURE0, 0);
 
 	/* Texture we will render to */
 	eglImageBayerOut_ = std::make_unique<eGLImage>(GL_RGBA, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE1, 1);