From patchwork Fri Dec 4 03:18:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29161 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 D6D31C3300 for ; Fri, 4 Dec 2026 03:20:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BD546AB62; Fri, 4 Dec 2026 04:20:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="E99X49Na"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="E0TrkpX/"; dkim-atps=neutral Received: from mail.coolgi.dev (mail.coolgi.dev [IPv6:2a02:c206:2202:9155::1]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A3AEC6AB62 for ; Fri, 4 Dec 2026 04:20:14 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GD7oX1ka+z+c6mJu9HTIHPqdOSYrB8TPq5RTHVoEbyQ=; b=E99X49NabGmxc4pKoOaLh2G5fiv9Jh7/xflA9r7QmD6ybqDdhdIUrMqWXh+BQYGwVuYGrm nCaDpJ9kOqWR6MS+UabZJeMsFxJLNEceEg1c8+6MWisulXUMI3qm/Q/AbwJDNsMSafoJgJ zGPRnlA7GKZJ3WnvqvZzir7iJIsJysUT6clRZ1U1SGA9bMvR5NjzZ6IgLP8s7sz8nm0xER YTrQG/0UDZ1CMgk4Y0y9smNuxX/hP4uADouEMBedqtp3fnrooVO+gLne6O+iUtwcQ0SVdW /C4QP25q4lg61ZNFj9gTTzk+ftXx9o5G2koLpnYWO71gQPveh4CSy6ZXKox4qg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GD7oX1ka+z+c6mJu9HTIHPqdOSYrB8TPq5RTHVoEbyQ=; b=E0TrkpX/sVlBIjdVDw/yYrp2v9i9xhpETKUhkxh38ZoVVhElI+bkN1LTMNaCnVvALJDR6+ aymKFuJmDiicwfK0E/zK8k4Aov4v3cPYjxrzNertWdIxDBeuXu6hr1TN2yRxrqs5vUG1Dz H765xgxJ1aQa4NNpRafkN2lIdfUilc0Ovu+SGz289kEUr2HSXrPSlgHRcgtq+cuuDm0Asv ZOgnXZCRcQos2kmJX8Uj0bPq6/Qw7C32bW/sC6f9OHhSsc+9k0j8wTscjlm5hI4TeahVCb sEnyhrq2pxgcO9jvJDSZ1Va8j5Psrhn9wrcl1Y5QfpHSkv0vik1NhTBsQt1xeQ== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 4/6] libcamera: egl: Separate proc address search into its own function Date: Fri, 4 Dec 2026 16:18:56 +1300 Message-ID: <20261204031914.117401-5-me@coolgi.dev> In-Reply-To: <20261204031914.117401-1-me@coolgi.dev> References: <20261204031914.117401-1-me@coolgi.dev> 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 From: Remy Alipoursafari Separates searching for proc addresses using eglGetProcAddress into its own function so that future searches can be more easily added. Initialisation is also no longer fails if the function addresses' does not exist, so extension support must be checked before proc addresses are used. 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 0f45c29b..1d1c530c 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -164,5 +164,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 1a0b6c37..df5b542d 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -417,23 +417,7 @@ int eGL::initEGLContext() for (auto &&extName : utils::split(eglExtensions, " ")) eglExtensions_.insert(std::move(extName)); - vtable.eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - if (!vtable.eglCreateImageKHR) { - LOG(eGL, Error) << "eglCreateImageKHR not found"; - return -ENODEV; - } - - vtable.eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - if (!vtable.eglDestroyImageKHR) { - LOG(eGL, Error) << "eglDestroyImageKHR not found"; - return -ENODEV; - } - - vtable.glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - if (!vtable.glEGLImageTargetTexture2DOES) { - LOG(eGL, Error) << "glEGLImageTargetTexture2DOES not found"; - return -ENODEV; - } + locateProcAddresses(&vtable); if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { LOG(eGL, Error) << "eglChooseConfig fail"; @@ -562,6 +546,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) ({ \ + location = reinterpret_cast(eglGetProcAddress(name)); \ + if (!location) { \ + LOG(eGL, Debug) << name << " not found"; \ + } \ +}) + + GET_PROC_ADDRESS(vtable->eglCreateImageKHR, "eglCreateImageKHR"); + GET_PROC_ADDRESS(vtable->eglDestroyImageKHR, "eglDestroyImageKHR"); + GET_PROC_ADDRESS(vtable->glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES"); +} + /** * \brief Add a preprocessor definition to shader environment * \param[in,out] shaderEnv Vector of shader environment strings