From patchwork Tue Aug 4 10:19:40 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: 27603 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 CE91CC3301 for ; Tue, 4 Aug 2026 10:19:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8D42E6808A; Tue, 4 Aug 2026 12:19:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NtUQA11Q"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A0396807C for ; Tue, 4 Aug 2026 12:19:52 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D69B91CDD for ; Tue, 4 Aug 2026 12:18:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838722; bh=7VqqfGmzBTKtmeNiIcMS4kf7Ey5jqn2XzCeznL+segA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NtUQA11Qh52LSI8oAvKhFHhaBQy9XjDbV8wFKGb5fTl2CuCgA+B7CexokLMHjHnIV +asqy2hsVKGIS6bROdlaOKrgUq0CEU4sX8Zj97Ynq/s65WrFoyTVM7dIKWoy7PLtpc YugqNG/Fgx4uefMh+/MPNfWuq0dh0+NPc6dc4fuk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 01/10] libcamera: egl: Remove `gl{Use, Delete}Program()` Date: Tue, 4 Aug 2026 12:19:40 +0200 Message-ID: <20260804101949.353266-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" `eGL::deleteProgram()` is currently unused, and the only user of `eGL::useProgram()` is `debayer_egl.cpp`, which is already using numerous gl calls directly without going through the `eGL` type. So remove these trivial wrappers. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 2 -- src/libcamera/egl.cpp | 28 ---------------------- src/libcamera/software_isp/debayer_egl.cpp | 2 +- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 7ef1ca0d93..c43684808d 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -123,8 +123,6 @@ public: Span shaderEnv); int linkProgram(GLuint &programId, GLuint fragmentshaderId, GLuint vertexshaderId); void dumpShaderSource(GLuint shaderId); - void useProgram(GLuint programId); - void deleteProgram(GLuint programId); void syncOutput(); void flushOutput(); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 01e51cda8e..780b7bc2d5 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -464,34 +464,6 @@ void eGL::makeCurrent() } } -/** - * \brief Activate a shader program for rendering - * \param[in] programId OpenGL program object ID - * - * Sets the specified program as the current rendering program. All - * subsequent draw calls will use this program's shaders. - */ -void eGL::useProgram(GLuint programId) -{ - ASSERT(tid_ == Thread::currentId()); - - glUseProgram(programId); -} - -/** - * \brief Delete a shader program - * \param[in] programId OpenGL program object ID - * - * Deletes a shader program and frees associated resources. The program - * must not be currently in use. - */ -void eGL::deleteProgram(GLuint programId) -{ - ASSERT(tid_ == Thread::currentId()); - - glDeleteProgram(programId); -} - /** * \brief Add a preprocessor definition to shader environment * \param[in,out] shaderEnv Vector of shader environment strings diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 20b478b1c3..ede3be2352 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -261,7 +261,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm egl_.dumpShaderSource(fragmentShaderId_); /* Ensure we set the programId_ */ - egl_.useProgram(programId_); + glUseProgram(programId_); err = glGetError(); if (err != GL_NO_ERROR) { LOG(Debayer, Error) << "Use program error " << err; From patchwork Tue Aug 4 10:19:41 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: 27604 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 6B658C3306 for ; Tue, 4 Aug 2026 10:20:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E1D768095; Tue, 4 Aug 2026 12:19:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JRLIgAfj"; 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 9F37B6807E for ; Tue, 4 Aug 2026 12:19:52 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E5381CE8 for ; Tue, 4 Aug 2026 12:18:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838723; bh=j5yrrH8lQnXg+4XigDmOL+688pX+fiWNnS2tVNsCcR8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JRLIgAfjnfEvqHSFT7tkkXsC5you1EeLS7U2D4YxXDy9Na2irczHRHHvcnNRQt5mk q/iqVmwuP37Uw6HAKuqk8oi9m+w5X2PvjltlE0GIfWpYgDNEPRpnRhvjRv60P4gT+i bKP8XLdsOmZHEfT1scIpdSJubbEZQYgke+BfrWa8= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 02/10] libcamera: egl: Remove `eGL::surface_` Date: Tue, 4 Aug 2026 12:19:41 +0200 Message-ID: <20260804101949.353266-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" This member has always been unused, so remove it. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 1 - src/libcamera/egl.cpp | 8 -------- 2 files changed, 9 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index c43684808d..f8ae486a8d 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -133,7 +133,6 @@ private: EGLDisplay display_ = EGL_NO_DISPLAY; EGLContext context_ = EGL_NO_CONTEXT; - EGLSurface surface_ = EGL_NO_SURFACE; int compileShader(int shaderType, GLuint &shaderId, Span shaderData, Span shaderEnv); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 780b7bc2d5..900d2174df 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -57,11 +57,6 @@ LOG_DEFINE_CATEGORY(eGL) *\brief EGL context handle */ -/** - *\var eGL::surface_ - *\brief EGL sufrace handle - */ - /** * \brief Construct an EGL helper * \param[in] display The EGL display to use @@ -84,9 +79,6 @@ eGL::~eGL() { if (context_ != EGL_NO_CONTEXT) eglDestroyContext(display_, context_); - - if (surface_ != EGL_NO_SURFACE) - eglDestroySurface(display_, surface_); } /** From patchwork Tue Aug 4 10:19:42 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: 27605 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 8B325C3301 for ; Tue, 4 Aug 2026 10:20:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4CB4F680B3; Tue, 4 Aug 2026 12:19:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PCkJA+iD"; 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 0DD4968083 for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 85754DA8 for ; Tue, 4 Aug 2026 12:18:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838723; bh=xUiaQZd5tzlL4fxEfKE3i0B6g9ntU+CSgwbX3/eG+E4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PCkJA+iDUltDUttSeFRihECa2EIvk261F0txCySx1mhCxn2oN1Hm24mYEpWOXNE9P 4OhgJvXlmeQ1IuPudOIFjUG3idtvy1RjPl5/dQVMEGdUbuTHL5XbxohYyGflfeyCaG P3BMyyfDiGuTBn2ALiDALlRrQFZY6IQL84vx1rz0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 03/10] libcamera: egl: Do not load `glGetString` dynamically Date: Tue, 4 Aug 2026 12:19:42 +0200 Message-ID: <20260804101949.353266-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" `glGetString()` should be available in all version of OpenGL and OpenGL ES, so there should be no need to load it with `eglGetProcAddress()` like it is done for extension functions. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 1 - src/libcamera/egl.cpp | 6 ------ 2 files changed, 7 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index f8ae486a8d..6abb02bf3b 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -142,6 +142,5 @@ private: PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; - PFNGLGETSTRINGPROC glGetString; }; } //namespace libcamera diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 900d2174df..0768a840e6 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -410,12 +410,6 @@ int eGL::initEGLContext() goto fail; } - glGetString = (PFNGLGETSTRINGPROC)eglGetProcAddress("glGetString"); - if (!glGetString) { - LOG(eGL, Error) << "glGetString not found"; - goto fail; - } - if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { LOG(eGL, Error) << "eglChooseConfig fail"; goto fail; From patchwork Tue Aug 4 10:19:43 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: 27606 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 5A265C3308 for ; Tue, 4 Aug 2026 10:20:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B6F768085; Tue, 4 Aug 2026 12:19:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RK6ZrayC"; 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 3958567F9E for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B21F71C76 for ; Tue, 4 Aug 2026 12:18:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838723; bh=DEKD1Mki7mJpqM+ax+zPvZpCyHbeldmZ/Mnao76jE6g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RK6ZrayC0s3qy5OaEi58dAPquMcMY0H58vt08FgZVE7tad/Kx384kt7mvf4ckycqG OSOjMkBfkkMm59R+2ZJA/6TCjILjfKVG1JhQTRdDrcE4K8UoQpMAanSiZSuq/AGV5/ 571qfdyxSv9jvj6Ofq1n4gDgVWvjS66iL5Xa06fw= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 04/10] libcamera: egl: Ensure all members are always initialized Date: Tue, 4 Aug 2026 12:19:43 +0200 Message-ID: <20260804101949.353266-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" The `tid_` and function pointer members were not previously initialize before calling `initEGLContext()`, fix that. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 10 ++++++---- src/libcamera/egl.cpp | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 6abb02bf3b..fb77225ac4 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -129,7 +129,7 @@ public: private: LIBCAMERA_DISABLE_COPY_AND_MOVE(eGL) - pid_t tid_; + pid_t tid_ = -1; EGLDisplay display_ = EGL_NO_DISPLAY; EGLContext context_ = EGL_NO_CONTEXT; @@ -139,8 +139,10 @@ private: int createDMABufTexture2D(eGLImage &eglImage, int fd, bool output); - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; - PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + struct VTable { + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; + PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + } vtable_ = {}; }; } //namespace libcamera diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 0768a840e6..3de5fab816 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -199,9 +199,9 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) }; // clang-format on - EGLImageKHR image = eglCreateImageKHR(display_, EGL_NO_CONTEXT, - EGL_LINUX_DMA_BUF_EXT, - NULL, image_attrs); + EGLImageKHR image = vtable_.eglCreateImageKHR(display_, EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + NULL, image_attrs); if (image == EGL_NO_IMAGE_KHR) { LOG(eGL, Debug) << "eglCreateImageKHR fail"; @@ -212,8 +212,8 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) activateBindTexture(eglImage); // Generate texture with filter semantics - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); - eglDestroyImageKHR(display_, image); + vtable_.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + vtable_.eglDestroyImageKHR(display_, image); // Nearest filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -379,6 +379,7 @@ int eGL::initEGLContext() EGL_NONE }; + VTable vtable = {}; EGLint numConfigs; EGLConfig config; @@ -392,20 +393,20 @@ int eGL::initEGLContext() LOG(eGL, Info) << "EGL: EGL_CLIENT_APIS: " << eglQueryString(display_, EGL_CLIENT_APIS); LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglQueryString(display_, EGL_EXTENSIONS); - eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - if (!eglCreateImageKHR) { + vtable.eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + if (!vtable.eglCreateImageKHR) { LOG(eGL, Error) << "eglCreateImageKHR not found"; goto fail; } - eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - if (!eglDestroyImageKHR) { + vtable.eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + if (!vtable.eglDestroyImageKHR) { LOG(eGL, Error) << "eglDestroyImageKHR not found"; goto fail; } - glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - if (!glEGLImageTargetTexture2DOES) { + vtable.glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + if (!vtable.glEGLImageTargetTexture2DOES) { LOG(eGL, Error) << "glEGLImageTargetTexture2DOES not found"; goto fail; } @@ -422,6 +423,7 @@ int eGL::initEGLContext() } tid_ = Thread::currentId(); + vtable_ = vtable; makeCurrent(); From patchwork Tue Aug 4 10:19:44 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: 27607 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 F1608C330A for ; Tue, 4 Aug 2026 10:20:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E7ED680A3; Tue, 4 Aug 2026 12:19:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OF5aKbJH"; 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 666726807C for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DE95ADA8 for ; Tue, 4 Aug 2026 12:18:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838723; bh=/FOOkT8HkB0/KvseZFNzxHMIiyA7lcxFFBeOKQD5Z/U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OF5aKbJHj7g9dYC2F77mJ+BQiTlIcfxX8n+oNL1UYI9WuZ6BOIqViDjLCh9/e/kgm YKFT68YdZ9HfhnBYjTfNvPTUeJCYzwZHAgAEMfrbp1sI61XzQdfdEUzVpug6LG2rjW FjRVh81dxhNl+/jFTQcSycro9hz3HnBWLZnctv5g= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 05/10] libcamera: egl: Add `resetEGLContext()` Date: Tue, 4 Aug 2026 12:19:44 +0200 Message-ID: <20260804101949.353266-6-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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 a function that undoes the effects of `initEGLContext()`. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index fb77225ac4..e18bb91f4d 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -103,6 +103,7 @@ public: ~eGL(); int initEGLContext(); + void resetEGLContext(); static EGLDisplay probeDisplay(); int createInputDMABufTexture2D(eGLImage &eglImage, int fd); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 3de5fab816..6b50e7bb77 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -71,14 +71,13 @@ eGL::eGL(EGLDisplay display) } /** - * \brief Destroy the EGL helper + * \brief Release all EGL resources * - * Destroys the EGL context and surface if they were successfully created. + * Equivalent to calling resetEGLContext(). */ eGL::~eGL() { - if (context_ != EGL_NO_CONTEXT) - eglDestroyContext(display_, context_); + resetEGLContext(); } /** @@ -436,6 +435,20 @@ fail: return -ENODEV; } +/** + * \brief Destroy the EGL context + * + * This function destroys the EGL context created by initEGLContext(). + */ +void eGL::resetEGLContext() +{ + if (context_ != EGL_NO_CONTEXT) + eglDestroyContext(display_, std::exchange(context_, EGL_NO_CONTEXT)); + + tid_ = -1; + vtable_ = {}; +} + /** * \brief Make the EGL context current for the calling thread * From patchwork Tue Aug 4 10:19:45 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: 27608 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 6C56DC330F for ; Tue, 4 Aug 2026 10:20:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C3EE0680A9; Tue, 4 Aug 2026 12:19:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="r0QwUHy8"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 914E76807E for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 161EC1C76 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=Id7xqghVaeXT+Zg8lRqqErOX4XtitDddZ5Co3+gzDa4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=r0QwUHy883pPf18CvB7hSduCXm1qvCRTgdgND26uoNG/urJ3YJYjzqvOfZfmY1ine HELDuN4ylz9+EHTnGOdy1+NqRjY8/AlB6GMvEypSJHyY/7LclWrGk2yIk6d6wKGz25 8ABVaJy33uKH9HOvKWM3Nvdh1PqQH/8My4bRUZTE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 06/10] libcamera: software_isp: debayer_egl: Avoid EGL context leaks Date: Tue, 4 Aug 2026 12:19:45 +0200 Message-ID: <20260804101949.353266-7-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" Currently each `start()` invocation causes a new EGL context to be acquired, and only the last allocation will be properly freed in the `eGL` destructor. To avoid that, call `eGL::resetEGLContext()` in `stop()`. Signed-off-by: Barnabás Pőcze --- src/libcamera/software_isp/debayer_egl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index ede3be2352..35a5c56321 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -682,6 +682,8 @@ void DebayerEGL::stop() if (programId_) glDeleteProgram(programId_); + + egl_.resetEGLContext(); } SizeRange DebayerEGL::sizes(PixelFormat inputFormat, const Size &inputSize) From patchwork Tue Aug 4 10:19:46 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: 27609 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 D84D3C3333 for ; Tue, 4 Aug 2026 10:20:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 463F8680B9; Tue, 4 Aug 2026 12:20:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BvKE62LW"; 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 C21E368087 for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4254FDA8 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=g4jt54kXxvnWrcff0ensF6BIPmkQQbdUZ7xO/oY1Wb8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BvKE62LWFuSVsZFwF0tnFlxQXiSbzFSn6Ps7/cD9W9rya7Zff9IOSxbnK7yGQ4lrz x+Fdmo5ezf7LPe6LBE0s4aAXu4LERfIUdLLXIrrNtYPMEvGNoX/HC3tIyJXPRYWYEF UqhvFeZzqW1uVpICsqoZ6o7VV6BmI96PMvbBHPEk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 07/10] libcamera: egl: initEGLContext(): Avoid double init Date: Tue, 4 Aug 2026 12:19:46 +0200 Message-ID: <20260804101949.353266-8-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" If the initialization is already done, reject further attempts, otherwise resources would be leaked. Signed-off-by: Barnabás Pőcze --- src/libcamera/egl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 6b50e7bb77..5e75c3a6d2 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -359,7 +359,7 @@ void eGL::createOutputTexture2D(eGLImage &eglImage) * - eglCreateImageKHR / eglDestroyImageKHR * - glEGLImageTargetTexture2DOES * - * \return 0 on success, or -ENODEV on failure + * \return 0 on success, or negative error code on failure */ int eGL::initEGLContext() { @@ -382,6 +382,9 @@ int eGL::initEGLContext() EGLint numConfigs; EGLConfig config; + if (context_ != EGL_NO_CONTEXT) + return -EEXIST; + if (!eglBindAPI(EGL_OPENGL_ES_API)) { LOG(eGL, Error) << "API bind fail"; goto fail; From patchwork Tue Aug 4 10:19:47 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: 27610 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 6515DC3334 for ; Tue, 4 Aug 2026 10:20:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB9D8680BC; Tue, 4 Aug 2026 12:20:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fE+A35ye"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE11768083 for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 71EF41C76 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=5kyk6g9ZciZV8zJYPsph3AROjuOkkVLMrlT+94HKTHE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fE+A35yezNiYT+1A8SZYosxtRqoskZwsFEpky2U85tl4wQDviNDsdoNA9BO23pc6D BOnbISR/ej6M7afdwDcZjst1QYKe+t6CNIPcR6tvvSnGPCp+g/OS6UCXhMdIx42hR/ 9Y1KHCAU0+FMhEWdeu+2mGSRR16uqNXJmC403si0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 08/10] libcamera: software_isp: debayer_egl: Remove EGL context switch Date: Tue, 4 Aug 2026 12:19:47 +0200 Message-ID: <20260804101949.353266-9-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" `eGL::initEGLContext()`, which is called from the worker thread already includes a call to `eGL::makeCurrent()`, so calling it for each `process()` is not necessary, so skip it. Signed-off-by: Barnabás Pőcze --- src/libcamera/software_isp/debayer_egl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 35a5c56321..afc6b02748 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -578,9 +578,6 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye eGLImage *eglImageIn; eGLImage *eglImageOut; - /* eGL context switch */ - egl_.makeCurrent(); - eglImageIn = getCachedInputFrameBuffer(input, inMapped, inDmaSyncer); if (!eglImageIn) return -ENOMEM; From patchwork Tue Aug 4 10:19:48 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: 27611 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 D7C64C3336 for ; Tue, 4 Aug 2026 10:20:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 48CE96808A; Tue, 4 Aug 2026 12:20:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L+rKbkEh"; 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 2CCC267F9E for ; Tue, 4 Aug 2026 12:19:54 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D42FDA8 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=sm8eRvBcgM+v78i9vMsRX7Ix/YevzdQ9LiDLdV4PPyI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L+rKbkEh63WR+m8YkIHcStMI+YVXHc/IH+QigRfkD4HIVKJO3FsfmKtqKqnneLSEI 6Ggz4tfh/c5ao9GCZ3MD3M0bC7n6tA47YyrtxVVvuLSY46iWg84I++5bsBp5NRgluc 9IuzFv78zHWd4E0RMSPCVjXdv4MrJLlxOE/BZznk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 09/10] libcamera: egl: Make it possible to unmake the context Date: Tue, 4 Aug 2026 12:19:48 +0200 Message-ID: <20260804101949.353266-10-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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 a parameter to `makeCurrent()` to make it possible to remove the currently bound context. Signed-off-by: Barnabás Pőcze --- 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 e18bb91f4d..a3218af9ef 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -116,7 +116,7 @@ public: void activateBindTexture(eGLImage &eglImage); void pushEnv(std::vector &shaderEnv, const char *str); - void makeCurrent(); + void makeCurrent(bool make); int compileVertexShader(GLuint &shaderId, Span shaderData, Span shaderEnv); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 5e75c3a6d2..f351bcf52c 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -427,7 +427,7 @@ int eGL::initEGLContext() tid_ = Thread::currentId(); vtable_ = vtable; - makeCurrent(); + makeCurrent(true); LOG(eGL, Info) << "EGL: GL_RENDERER: " << glGetString(GL_RENDERER); LOG(eGL, Info) << "EGL: GL_VERSION: " << glGetString(GL_VERSION); @@ -454,16 +454,17 @@ void eGL::resetEGLContext() /** * \brief Make the EGL context current for the calling thread + * \param[in] make Whether to make/unmake the EGL context * * Binds the EGL context to the current thread, allowing OpenGL ES * operations to be performed. Must be called from the thread that * will perform rendering operations. */ -void eGL::makeCurrent() +void eGL::makeCurrent(bool make) { ASSERT(tid_ == Thread::currentId()); - if (eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, context_) != EGL_TRUE) { + if (eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, make ? context_ : EGL_NO_CONTEXT) != EGL_TRUE) { LOG(eGL, Error) << "eglMakeCurrent fail"; } } From patchwork Tue Aug 4 10:19:49 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: 27612 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 80FE2C3338 for ; Tue, 4 Aug 2026 10:20:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF05B680CB; Tue, 4 Aug 2026 12:20:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vyj8PQ8N"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5244068092 for ; Tue, 4 Aug 2026 12:19:54 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC6811C76 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=eKbs0dx0FOSTp6FPFSVQcaueeOppVZZBqA8/xDNN/KE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vyj8PQ8Ncsx8QLTP5EKujDC8vj3wf0zCKg7ur2S16g7EgULhb1sXoqd7hxytubPXj J0aceyC4DJWFlJ4WBlWaFvka1seAl+LRWMux5WXs+7w/kpyMhSFjVKLe2LGRukMrzV QSpe1SWzdZPr8cykbf2zti3l09B+xsqS6yZdI03o= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 10/10] libcamera: software_isp: debayer_egl: Unmake EGL context Date: Tue, 4 Aug 2026 12:19:49 +0200 Message-ID: <20260804101949.353266-11-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" In `SoftwareIsp`, the worker thread is recreated each time it is started. In order to avoid any potential leaks from the egl implementation, remove the currently bound egl context in `DebayerEGL::stop()`. Mesa does not seem to have any destructors for its egl thread data, so the context in those cases does not seem to be properly destroyed. Signed-off-by: Barnabás Pőcze --- src/libcamera/software_isp/debayer_egl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index afc6b02748..3405cdd56a 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -680,6 +680,7 @@ void DebayerEGL::stop() if (programId_) glDeleteProgram(programId_); + egl_.makeCurrent(false); egl_.resetEGLContext(); }