From patchwork Mon Apr 13 11:47:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26516 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 40A99BDCBD for ; Mon, 13 Apr 2026 11:47:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 16E5062E93; Mon, 13 Apr 2026 13:47:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WSVtMt+x"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 927F26271A for ; Mon, 13 Apr 2026 13:47:16 +0200 (CEST) Received: from pb-laptop.local (185.182.214.8.nat.pool.zt.hu [185.182.214.8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 94C3B348; Mon, 13 Apr 2026 13:45:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1776080744; bh=tzZPWJh47oPU61f0y/DUwO+gdeXfDmAy52lij0Tkd10=; h=From:To:Cc:Subject:Date:From; b=WSVtMt+xienoJ/SF6DsF/OzIaMFOEFYZEIS33cdQXD+ZoBc2ba4HqTKYufKkB1Pf7 tSwnTDN1HdC7zYfmGCDzOg7VTeoUWXMDXaVOcBRH6fow7oNOVs+WA16vOQI24Tmjg2 SrLWn7pmPv96yTva7sgE9r3eGROXK3qCIWAqVyhY= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Gianfranco Mariotti Subject: [PATCH v1 1/3] libcamera: egl: Remove `eGLImage::image_` Date: Mon, 13 Apr 2026 13:47:11 +0200 Message-ID: <20260413114713.426459-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Gianfranco Mariotti This member stores an egl image handle, but currently there is no need for it since the image handle is only really used in `createDMABufTexture2D()`. (`destroyDMABufTexture()` is an unused function.) So remove the member (and the unused function), and instead destroy the image immediately after calling `glEGLImageTargetTexture2DOES()`. The texture will keep a reference to the image, so this is safe to do. In fact, this solves an issue, specifically, the egl images were never destroyed, and continuously leaked during streaming. Fixes: f520b29fe9e6 ("libcamera: software_isp: debayer_egl: Add an eGL Debayer class") Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/322 Signed-off-by: Gianfranco Mariotti Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- Supersedes https://patchwork.libcamera.org/patch/26319/ --- include/libcamera/internal/egl.h | 2 -- src/libcamera/egl.cpp | 37 +++++++++----------------------- 2 files changed, 10 insertions(+), 29 deletions(-) -- 2.53.0 diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 8a2d96d7a..0ad2320b1 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -88,7 +88,6 @@ public: GLenum texture_unit_; /**< Texture unit associated with this image eg (GL_TEXTURE0) */ GLuint texture_; /**< OpenGL texture object ID */ GLuint fbo_; /**< OpenGL frame buffer object ID */ - EGLImageKHR image_; /**< EGL Image handle */ private: LIBCAMERA_DISABLE_COPY_AND_MOVE(eGLImage) @@ -104,7 +103,6 @@ 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 pushEnv(std::vector &shaderEnv, const char *str); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 5b9bbf410..f65929470 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -112,8 +112,6 @@ void eGL::syncOutput() */ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) { - int ret = 0; - ASSERT(tid_ == Thread::currentId()); // clang-format off @@ -130,14 +128,13 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) }; // clang-format on - eglImage.image_ = eglCreateImageKHR(display_, EGL_NO_CONTEXT, - EGL_LINUX_DMA_BUF_EXT, - NULL, image_attrs); + EGLImageKHR image = eglCreateImageKHR(display_, EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + NULL, image_attrs); - if (eglImage.image_ == EGL_NO_IMAGE_KHR) { + if (image == EGL_NO_IMAGE_KHR) { LOG(eGL, Error) << "eglCreateImageKHR fail"; - ret = -ENODEV; - goto done; + return -ENODEV; } // Bind texture unit and texture @@ -145,7 +142,8 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) glBindTexture(GL_TEXTURE_2D, eglImage.texture_); // Generate texture with filter semantics - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage.image_); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + eglDestroyImageKHR(display_, image); // Nearest filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -163,13 +161,11 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) GLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (err != GL_FRAMEBUFFER_COMPLETE) { LOG(eGL, Error) << "glFrameBufferTexture2D error " << err; - eglDestroyImageKHR(display_, eglImage.image_); - ret = -ENODEV; - goto done; + return -ENODEV; } } -done: - return ret; + + return 0; } /** @@ -209,19 +205,6 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd) return createDMABufTexture2D(eglImage, fd, true); } -/** - * \brief Destroy a DMA-BUF texture's EGL image - * \param[in,out] eglImage EGL image to destroy - * - * Destroys the EGL image associated with a DMA-BUF texture. The OpenGL - * texture and framebuffer objects are destroyed separately in the - * eGLImage destructor. - */ -void eGL::destroyDMABufTexture(eGLImage &eglImage) -{ - eglDestroyImage(display_, std::exchange(eglImage.image_, EGL_NO_IMAGE_KHR)); -} - /** * \brief Create a 2D texture from a memory buffer * \param[in,out] eglImage EGL image to associate with the texture From patchwork Mon Apr 13 11:47:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26517 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1FD8CC32F6 for ; Mon, 13 Apr 2026 11:47:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75B6562E95; Mon, 13 Apr 2026 13:47:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MQT1dJyF"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B44FE62E7F for ; Mon, 13 Apr 2026 13:47:16 +0200 (CEST) Received: from pb-laptop.local (185.182.214.8.nat.pool.zt.hu [185.182.214.8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D44927FE for ; Mon, 13 Apr 2026 13:45:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1776080744; bh=GPaHluTYFpcJK9VAXq+rFZ4cZl9SHze8WpG44US1exw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MQT1dJyFkLXDMgCqMLUKh7BKasX5i/ExCSyPee7rhlC0z8Ba6Lg8pl5uyTW4q1Wyf dvSFE1EQP7PtcXZWB6EDPy7Rljf/49vtQrLSe6PMiE5m+SSj7OP9yoYBeJBMtN8Zjv gA+gS5tkYgu6v4dJ8Z23BWh5AIIhyiSdMkCoIELQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/3] libcamera: software_isp: debayer: Add missing `override` Date: Mon, 13 Apr 2026 13:47:12 +0200 Message-ID: <20260413114713.426459-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413114713.426459-1-barnabas.pocze@ideasonboard.com> References: <20260413114713.426459-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the missing `override` specifiers in the derived classes of `Debayer`. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer_cpu.h | 18 +++++++++--------- src/libcamera/software_isp/debayer_egl.h | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 05fecc8fe..39a0ea6ea 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -36,16 +36,16 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, - bool ccmEnabled); - Size patternSize(PixelFormat inputFormat); - std::vector formats(PixelFormat input); + bool ccmEnabled) override; + Size patternSize(PixelFormat inputFormat) override; + std::vector formats(PixelFormat input) override; std::tuple - strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); - void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms); - int start(); - void stop(); - SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); - const SharedFD &getStatsFD() { return stats_->getStatsFD(); } + strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) override; + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) override; + int start() override; + void stop() override; + SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override; + const SharedFD &getStatsFD() override { return stats_->getStatsFD(); } private: friend class DebayerCpuThread; diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index bdde676f2..d563bfa55 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -43,20 +43,20 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, - bool ccmEnabled); + bool ccmEnabled) override; - Size patternSize(PixelFormat inputFormat); + Size patternSize(PixelFormat inputFormat) override; - std::vector formats(PixelFormat input); - std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); + std::vector formats(PixelFormat input) override; + std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) override; - void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms); - int start(); - void stop(); + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) override; + int start() override; + void stop() override; - const SharedFD &getStatsFD() { return stats_->getStatsFD(); } + const SharedFD &getStatsFD() override { return stats_->getStatsFD(); } - SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); + SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override; private: static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); From patchwork Mon Apr 13 11:47:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26518 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 00FDDBDCBD for ; Mon, 13 Apr 2026 11:47:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0720E62E8B; Mon, 13 Apr 2026 13:47:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ftCi3jEA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D161862E84 for ; Mon, 13 Apr 2026 13:47:16 +0200 (CEST) Received: from pb-laptop.local (185.182.214.8.nat.pool.zt.hu [185.182.214.8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1425497F for ; Mon, 13 Apr 2026 13:45:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1776080745; bh=g7bdFfCaZt/3JjuJ0+x9HrvE7K+5UN2oktIBvhJFuac=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ftCi3jEAT0ZAFNG+lRuTkuEmdON5o6afVwmeR5+moEZFmksJZjoLQiDPyEwgrl/oQ Xtbgrgh3T1rqu6SmVq3skMzCBSfpHi7wCkmykwSoymPuJ9sKilKPqaQF0+dA4KGpUB isbd9G7WQEu2ATFbuLSI1XmD0wCEjaMZNHTSKcYg= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 3/3] libcamera: software_isp: debayer_egl: Remove unnecessary declarations Date: Mon, 13 Apr 2026 13:47:13 +0200 Message-ID: <20260413114713.426459-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413114713.426459-1-barnabas.pocze@ideasonboard.com> References: <20260413114713.426459-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" These functions are not defined, so remove them. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer_egl.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index d563bfa55..644f6604e 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -61,18 +61,9 @@ public: private: static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); - int setupStandardBayerOrder(BayerFormat::Order order); - void pushEnv(std::vector &shaderEnv, const char *str); int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat); - int initEGLContext(); - int generateTextures(); - int compileShaderProgram(GLuint &shaderId, GLenum shaderType, - unsigned char *shaderData, int shaderDataLen, - std::vector shaderEnv); - int linkShaderProgram(void); int getShaderVariableLocations(); void setShaderVariableValues(const DebayerParams ¶ms); - void configureTexture(GLuint &texture); int debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms); /* Shader program identifiers */