From patchwork Mon Aug 10 10:59:38 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: 27726 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 B17F3BE080 for ; Mon, 10 Aug 2026 10:59:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3DE1E68203; Mon, 10 Aug 2026 12:59:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lbKuPw5L"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F410B681B7 for ; Mon, 10 Aug 2026 12:59:46 +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 021AF887; Mon, 10 Aug 2026 12:58:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1786359513; bh=ETgfREqfXJEar8GnJwST8O23mQ/NQ6vjCwtuJN3WpsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbKuPw5LhYw9y/GtEOVGDPkRSVnZGZsptVjEgiY7rquwvpsPVV/y6JFrUwVXifZxD 7/16Z+xfKOoPoceMbDwbNhxELgbt1olINIaSrGpTbEYIT7AxD7BhuCbG+JnXXAh7Z8 rj9tXi1+Mgd6JJeZULw/ua5TXNAa+6JA2o/5Wv6M= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 4/8] libcamera: egl: Ensure all members are always initialized Date: Mon, 10 Aug 2026 12:59:38 +0200 Message-ID: <20260810105942.1098192-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260810105942.1098192-1-barnabas.pocze@ideasonboard.com> References: <20260810105942.1098192-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 Reviewed-by: Milan Zamazal --- 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();