libcamera: software_isp: debayer_egl: Teardown the output texture
diff mbox series

Message ID 20260320214102.11844-1-gianfranco.mariotti94@gmail.com
State New
Headers show
Series
  • libcamera: software_isp: debayer_egl: Teardown the output texture
Related show

Commit Message

Gianfranco Mariotti March 20, 2026, 9:41 p.m. UTC
Destroy the EGL image associated with the output DMA-BUF texture
after processing the frame.

Without this change memory can be seen building up while running
a gstreamer pipeline using GPUISP, and on end of available memory
the stream freezes and the error message `eglCreateImageKHR fail`
is reported repeatedly.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 src/libcamera/software_isp/debayer_egl.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Barnabás Pőcze March 20, 2026, 10:32 p.m. UTC | #1
Hi

2026. 03. 20. 22:41 keltezéssel, Gianfranco Mariotti írta:
> Destroy the EGL image associated with the output DMA-BUF texture
> after processing the frame.
> 
> Without this change memory can be seen building up while running
> a gstreamer pipeline using GPUISP, and on end of available memory
> the stream freezes and the error message `eglCreateImageKHR fail`
> is reported repeatedly.
> 
> Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
> ---
>   src/libcamera/software_isp/debayer_egl.cpp | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
> index 8147eca1..db7e35e5 100644
> --- a/src/libcamera/software_isp/debayer_egl.cpp
> +++ b/src/libcamera/software_isp/debayer_egl.cpp
> @@ -498,6 +498,8 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams &params)
>   
>   int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams &params)
>   {
> +	int ret = 0;
> +
>   	/* eGL context switch */
>   	egl_.makeCurrent();
>   
> @@ -515,12 +517,14 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParam
>   	GLenum err = glGetError();
>   	if (err != GL_NO_ERROR) {
>   		LOG(eGL, Error) << "Drawing scene fail " << err;
> -		return -ENODEV;
> +		ret = -ENODEV;
>   	} else {
>   		egl_.syncOutput();
>   	}
>   
> -	return 0;
> +	/* Teardown the output texture */
> +	egl_.destroyDMABufTexture(*eglImageBayerOut_);

Thanks for the patch. I brought this up as well some time ago: https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056455.html
Please see the proposed change, and send a v2 that uses `utils::scope_exit`.


Regards,
Barnabás Pőcze


> +	return ret;
>   }
>   
>   void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params)

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 8147eca1..db7e35e5 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -498,6 +498,8 @@  void DebayerEGL::setShaderVariableValues(const DebayerParams &params)
 
 int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams &params)
 {
+	int ret = 0;
+
 	/* eGL context switch */
 	egl_.makeCurrent();
 
@@ -515,12 +517,14 @@  int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParam
 	GLenum err = glGetError();
 	if (err != GL_NO_ERROR) {
 		LOG(eGL, Error) << "Drawing scene fail " << err;
-		return -ENODEV;
+		ret = -ENODEV;
 	} else {
 		egl_.syncOutput();
 	}
 
-	return 0;
+	/* Teardown the output texture */
+	egl_.destroyDMABufTexture(*eglImageBayerOut_);
+	return ret;
 }
 
 void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams &params)