{"id":26516,"url":"https://patchwork.libcamera.org/api/patches/26516/?format=json","web_url":"https://patchwork.libcamera.org/patch/26516/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260413114713.426459-1-barnabas.pocze@ideasonboard.com>","date":"2026-04-13T11:47:11","name":"[v1,1/3] libcamera: egl: Remove `eGLImage::image_`","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"839163ee8aaeb06d2cc7d8f2962fdf20d0c3a4f0","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26516/mbox/","series":[{"id":5880,"url":"https://patchwork.libcamera.org/api/series/5880/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5880","date":"2026-04-13T11:47:11","name":"[v1,1/3] libcamera: egl: Remove `eGLImage::image_`","version":1,"mbox":"https://patchwork.libcamera.org/series/5880/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26516/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26516/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 40A99BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Apr 2026 11:47:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 16E5062E93;\n\tMon, 13 Apr 2026 13:47:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 927F26271A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Apr 2026 13:47:16 +0200 (CEST)","from pb-laptop.local (185.182.214.8.nat.pool.zt.hu [185.182.214.8])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 94C3B348;\n\tMon, 13 Apr 2026 13:45:44 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"WSVtMt+x\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1776080744;\n\tbh=tzZPWJh47oPU61f0y/DUwO+gdeXfDmAy52lij0Tkd10=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=WSVtMt+xienoJ/SF6DsF/OzIaMFOEFYZEIS33cdQXD+ZoBc2ba4HqTKYufKkB1Pf7\n\ttSwnTDN1HdC7zYfmGCDzOg7VTeoUWXMDXaVOcBRH6fow7oNOVs+WA16vOQI24Tmjg2\n\tSrLWn7pmPv96yTva7sgE9r3eGROXK3qCIWAqVyhY=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>","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","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>\n\nThis member stores an egl image handle, but currently there is no need for it\nsince the image handle is only really used in `createDMABufTexture2D()`.\n(`destroyDMABufTexture()` is an unused function.)\n\nSo remove the member (and the unused function), and instead destroy the image\nimmediately after calling `glEGLImageTargetTexture2DOES()`. The texture will\nkeep a reference to the image, so this is safe to do. In fact, this solves\nan issue, specifically, the egl images were never destroyed, and continuously\nleaked during streaming.\n\nFixes: f520b29fe9e6 (\"libcamera: software_isp: debayer_egl: Add an eGL Debayer class\")\nCloses: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/322\nSigned-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n\nSupersedes https://patchwork.libcamera.org/patch/26319/\n\n---\n include/libcamera/internal/egl.h |  2 --\n src/libcamera/egl.cpp            | 37 +++++++++-----------------------\n 2 files changed, 10 insertions(+), 29 deletions(-)\n\n--\n2.53.0","diff":"diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\nindex 8a2d96d7a..0ad2320b1 100644\n--- a/include/libcamera/internal/egl.h\n+++ b/include/libcamera/internal/egl.h\n@@ -88,7 +88,6 @@ public:\n \tGLenum texture_unit_; /**< Texture unit associated with this image eg (GL_TEXTURE0) */\n \tGLuint texture_; /**< OpenGL texture object ID */\n \tGLuint fbo_; /**< OpenGL frame buffer object ID */\n-\tEGLImageKHR image_; /**< EGL Image handle */\n\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(eGLImage)\n@@ -104,7 +103,6 @@ public:\n\n \tint createInputDMABufTexture2D(eGLImage &eglImage, int fd);\n \tint createOutputDMABufTexture2D(eGLImage &eglImage, int fd);\n-\tvoid destroyDMABufTexture(eGLImage &eglImage);\n \tvoid createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data);\n\n \tvoid pushEnv(std::vector<std::string> &shaderEnv, const char *str);\ndiff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\nindex 5b9bbf410..f65929470 100644\n--- a/src/libcamera/egl.cpp\n+++ b/src/libcamera/egl.cpp\n@@ -112,8 +112,6 @@ void eGL::syncOutput()\n  */\n int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n {\n-\tint ret = 0;\n-\n \tASSERT(tid_ == Thread::currentId());\n\n \t// clang-format off\n@@ -130,14 +128,13 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n \t};\n \t// clang-format on\n\n-\teglImage.image_ = eglCreateImageKHR(display_, EGL_NO_CONTEXT,\n-\t\t\t\t\t    EGL_LINUX_DMA_BUF_EXT,\n-\t\t\t\t\t    NULL, image_attrs);\n+\tEGLImageKHR image = eglCreateImageKHR(display_, EGL_NO_CONTEXT,\n+\t\t\t\t\t      EGL_LINUX_DMA_BUF_EXT,\n+\t\t\t\t\t      NULL, image_attrs);\n\n-\tif (eglImage.image_ == EGL_NO_IMAGE_KHR) {\n+\tif (image == EGL_NO_IMAGE_KHR) {\n \t\tLOG(eGL, Error) << \"eglCreateImageKHR fail\";\n-\t\tret = -ENODEV;\n-\t\tgoto done;\n+\t\treturn -ENODEV;\n \t}\n\n \t// Bind texture unit and texture\n@@ -145,7 +142,8 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n \tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n\n \t// Generate texture with filter semantics\n-\tglEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage.image_);\n+\tglEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);\n+\teglDestroyImageKHR(display_, image);\n\n \t// Nearest filtering\n \tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n@@ -163,13 +161,11 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n \t\tGLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n \t\tif (err != GL_FRAMEBUFFER_COMPLETE) {\n \t\t\tLOG(eGL, Error) << \"glFrameBufferTexture2D error \" << err;\n-\t\t\teglDestroyImageKHR(display_, eglImage.image_);\n-\t\t\tret = -ENODEV;\n-\t\t\tgoto done;\n+\t\t\treturn -ENODEV;\n \t\t}\n \t}\n-done:\n-\treturn ret;\n+\n+\treturn 0;\n }\n\n /**\n@@ -209,19 +205,6 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)\n \treturn createDMABufTexture2D(eglImage, fd, true);\n }\n\n-/**\n- * \\brief Destroy a DMA-BUF texture's EGL image\n- * \\param[in,out] eglImage EGL image to destroy\n- *\n- * Destroys the EGL image associated with a DMA-BUF texture. The OpenGL\n- * texture and framebuffer objects are destroyed separately in the\n- * eGLImage destructor.\n- */\n-void eGL::destroyDMABufTexture(eGLImage &eglImage)\n-{\n-\teglDestroyImage(display_, std::exchange(eglImage.image_, EGL_NO_IMAGE_KHR));\n-}\n-\n /**\n  * \\brief Create a 2D texture from a memory buffer\n  * \\param[in,out] eglImage EGL image to associate with the texture\n","prefixes":["v1","1/3"]}