From patchwork Thu Nov 26 11:03:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29094 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 CE4A0BDE17 for ; Thu, 26 Nov 2026 11:05:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E51066AA2A; Thu, 26 Nov 2026 12:05:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="ReF4j+C7"; dkim-atps=neutral Received: from sender6-pp-f112.zoho.com (sender6-pp-f112.zoho.com [165.173.180.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D5E06AA21 for ; Thu, 26 Nov 2026 12:05:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; t=1795691106; cv=none; d=zohomail.com; s=zohoarc; b=UPa0tCrKY2RYkxDsaGlGcZydiG32kHuUlcbJXnxv+TVVBz34BGtfRd0+AMWylBUQZB7pO/KCfqd/7AiLNtHqavNFphmWZPw0rrtJttfR6ILzhtFZMzKNsysNBjl2I5Fb8Q7ey5FI8qk7UxOaKDXU8BBmuJ1EmPcnTM3aMr3MNvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795691106; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=ABqjkLFhogY6BMiEfPBAFj4WRyQSBeH3nsF6lfCJ1Pw=; b=SKy2TnhFKUcTooWFTZT+E8SEK2kgGBVpEZzGctwXPtXL1+C9hW2GAv0IN1I/aY6WoEBhDCXOemZ/1IiIWA9CEi99yi8gdTZZD5EiARblQsl1Dy2eKtW08yqIIC/g+JpiGGLBOKHGfuJccKYzh1SwAa0crSoGYbze+XzYQFwD1H0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=remy.alipoursafari@collabora.com; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=ReF4j+C7KKFhRghNVF1dQs3RYLKziGAlQQFR+DXFdv4fFlDJI/s8nMTYKXHhZzVF3GzLLhbzOnhdCxqAaRkVWUTtj9/9QD5Tb2CsHZL7ugKidoVsJXNGuFLqKr2O5bOOWKlJe01ayYkWyl8IPeiOI69jsPVtr0OWBbyKa2WYuU0=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=ABqjkLFhogY6BMiEfPBAFj4WRyQSBeH3nsF6lfCJ1Pw=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1795691105657417.59321187963064; Thu, 26 Nov 2026 03:05:05 -0800 (PST) From: Remy Alipoursafari To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Lo=C3=AFc_Molinari?= , Robert Mader , Remy Alipoursafari Subject: [PATCH 4/6] libcamera: egl: Separate proc address search into its own function Date: Fri, 27 Nov 2026 00:03:42 +1300 Message-ID: <20261126110422.362455-5-remy.alipoursafari@collabora.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126110422.362455-1-remy.alipoursafari@collabora.com> References: <20261126110422.362455-1-remy.alipoursafari@collabora.com> MIME-Version: 1.0 X-ZohoMailClient: External 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" Separates searching for proc addresses using eglGetProcAddress into its own function so that future searches can be more easily added. Signed-off-by: Remy Alipoursafari Reviewed-by: Robert Mader --- include/libcamera/internal/egl.h | 2 ++ src/libcamera/egl.cpp | 41 +++++++++++++++++++------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 10a9a3c5..6a146405 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -165,5 +165,7 @@ private: PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; } vtable_ = {}; + + void locateProcAddresses(VTable *vtable); }; } //namespace libcamera diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index f88fb7c4..df0bba8e 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -414,23 +414,7 @@ int eGL::initEGLContext() eglExtensions_ = eglQueryString(display_, EGL_EXTENSIONS); LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglExtensions_; - vtable.eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - if (!vtable.eglCreateImageKHR) { - LOG(eGL, Error) << "eglCreateImageKHR not found"; - goto fail; - } - - vtable.eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - if (!vtable.eglDestroyImageKHR) { - LOG(eGL, Error) << "eglDestroyImageKHR not found"; - goto fail; - } - - vtable.glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - if (!vtable.glEGLImageTargetTexture2DOES) { - LOG(eGL, Error) << "glEGLImageTargetTexture2DOES not found"; - goto fail; - } + locateProcAddresses(&vtable); if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { LOG(eGL, Error) << "eglChooseConfig fail"; @@ -586,6 +570,29 @@ void eGL::makeCurrent() } } +/** + * \brief Gets the addresses for EGL extension functions + * \param[in,out] vtable VTable to store the function addresses + * + * Locates the relevant runtime function addresses needed to fill the VTable. + * This does not fail when a function pointer is not found, nor does it validate + * the functions are available for the GL context, so it is also expected to + * also check the extension availability. + */ +void eGL::locateProcAddresses(VTable *vtable) +{ +#define GET_PROC_ADDRESS(location, name, type) ({ \ + location = (type)eglGetProcAddress(name); \ + if (!location) { \ + LOG(eGL, Debug) << name << " not found"; \ + } \ +}) + + GET_PROC_ADDRESS(vtable->eglCreateImageKHR, "eglCreateImageKHR", PFNEGLCREATEIMAGEKHRPROC); + GET_PROC_ADDRESS(vtable->eglDestroyImageKHR, "eglDestroyImageKHR", PFNEGLDESTROYIMAGEKHRPROC); + GET_PROC_ADDRESS(vtable->glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", PFNGLEGLIMAGETARGETTEXTURE2DOESPROC); +} + /** * \brief Add a preprocessor definition to shader environment * \param[in,out] shaderEnv Vector of shader environment strings