From patchwork Fri Dec 4 03:18:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29158 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 1D62FC3300 for ; Fri, 4 Dec 2026 03:20:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 715EF6AB5C; Fri, 4 Dec 2026 04:20:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="CSXfdS2n"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="TCjD6SJz"; 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 671BC6AB55 for ; Fri, 4 Dec 2026 04:20:07 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KjUvjMQshBuh6J9IXMztvKbiXt1PZ9cqsQUFPUtVlME=; b=CSXfdS2nHz76zais9Z+2pZAo3qe9guBqCDy0PMBD/sIdWdwxeUeqwydA5o/PhJK6yMdJSu wDsjvfCAVLJo73twyKoPDUMo/HKNiDorhTez4wzsEpHyDSLqQm+3QdM2UCpjymLRDRN0eN ky44K22Z8i8YccdveBKqeCho6aTjQKh5M8qyFZkV3UibmMZv0XZ1v7efyQO7kzdnzGpNKj sUus11ZksXH2ZCPBxK4wwWHqeyFvOROxBFr361YtDZGns4b4VY5av7xSGZCBSh+4KVuMA2 RLCPRk2+6EfNYT+dBVy32fo5HxLgETgc2MYdjBhI8WV3co9W9uJwKYUfse6VJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KjUvjMQshBuh6J9IXMztvKbiXt1PZ9cqsQUFPUtVlME=; b=TCjD6SJz7MHJg8A28HSMLFDyCQiu3Hcf2ApB0GHCUpAckOZDCMzsxmATxZnUSvD4zlEJ0K 2yyLHXszwkwDJIL2VAXoA7qLVHJSJgeoNJQPsmFWTIpsUWq5zmv2AtYHvVDnoz2WYlnJ/v PR50MFui/EecJKHylHcKcXU5PuhuJ2XkhhWPT67ZfxDV9owUZSY8Qz+bWfRNyV/e5bBr4U q+6hQtIUeE1qIa8K+aWX+ABXDfet//KIyYZmNHOUvVPYjwpM1SQPSAqlOGmgcij0Ac2yFH cohXe7mHRtfctYdJyUgrrT3BdDM02DuK3oNyjms65F04DI8AzeJ6jfxUsWNvzA== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 1/6] libcamera: egl: Add GL extension & version checks Date: Fri, 4 Dec 2026 16:18:53 +1300 Message-ID: <20261204031914.117401-2-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: Loïc Molinari Allow EGL and OpenGL ES extensions to be queried for whether or not they exist in the current context. Also allows for checking the OpenGL ES context's version. Signed-off-by: Loïc Molinari Signed-off-by: Remy Alipoursafari Reviewed-by: Robert Mader --- include/libcamera/internal/egl.h | 10 ++++ src/libcamera/egl.cpp | 82 ++++++++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 10 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index d6fb6fe0..0f45c29b 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -9,6 +9,7 @@ #pragma once +#include #include #include #include @@ -109,6 +110,10 @@ public: void resetEGLContext(); static EGLDisplay probeDisplay(); + bool hasEGLExtension(const char *name) const; + bool hasGLESExtension(const char *name) const; + bool hasGLESVersion(unsigned int major, unsigned int minor) const; + int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createTexture2D(eGLImage &eglImage, const void *data, GLint filter); @@ -142,6 +147,11 @@ private: EGLDisplay display_ = EGL_NO_DISPLAY; EGLContext context_ = EGL_NO_CONTEXT; + std::set> eglExtensions_ = {}; + std::set> glesExtensions_ = {}; + unsigned int glesMajor_ = 0; + unsigned int glesMinor_ = 0; + int compileShader(int shaderType, GLuint &shaderId, std::span shaderData, std::span shaderEnv); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index ff9e54a1..70f293b7 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -10,6 +10,7 @@ #include "libcamera/internal/egl.h" #include +#include #include #include #include @@ -397,61 +398,117 @@ int eGL::initEGLContext() VTable vtable = {}; EGLint numConfigs; EGLConfig config; + const char *glesVersion; if (context_ != EGL_NO_CONTEXT) return -EEXIST; if (!eglBindAPI(EGL_OPENGL_ES_API)) { LOG(eGL, Error) << "API bind fail"; - goto fail; + return -ENODEV; } LOG(eGL, Info) << "EGL: EGL_VERSION: " << eglQueryString(display_, EGL_VERSION); LOG(eGL, Info) << "EGL: EGL_VENDOR: " << eglQueryString(display_, EGL_VENDOR); LOG(eGL, Info) << "EGL: EGL_CLIENT_APIS: " << eglQueryString(display_, EGL_CLIENT_APIS); - LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglQueryString(display_, EGL_EXTENSIONS); + const char *eglExtensions = eglQueryString(display_, EGL_EXTENSIONS); + LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglExtensions; + + 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"; - goto fail; + return -ENODEV; } vtable.eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); if (!vtable.eglDestroyImageKHR) { LOG(eGL, Error) << "eglDestroyImageKHR not found"; - goto fail; + return -ENODEV; } vtable.glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); if (!vtable.glEGLImageTargetTexture2DOES) { LOG(eGL, Error) << "glEGLImageTargetTexture2DOES not found"; - goto fail; + return -ENODEV; } if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { LOG(eGL, Error) << "eglChooseConfig fail"; - goto fail; + return -ENODEV; } context_ = eglCreateContext(display_, config, EGL_NO_CONTEXT, contextAttribs); if (context_ == EGL_NO_CONTEXT) { LOG(eGL, Error) << "eglContext returned EGL_NO_CONTEXT"; - goto fail; + return -ENODEV; } tid_ = Thread::currentId(); vtable_ = vtable; makeCurrent(); + utils::scope_exit contextGuard([&] { resetEGLContext(); }); LOG(eGL, Info) << "EGL: GL_RENDERER: " << glGetString(GL_RENDERER); - LOG(eGL, Info) << "EGL: GL_VERSION: " << glGetString(GL_VERSION); + glesVersion = (const char *)glGetString(GL_VERSION); + LOG(eGL, Info) << "EGL: GL_VERSION: " << glesVersion; + const char *glesExtensions = (const char *)glGetString(GL_EXTENSIONS); + LOG(eGL, Info) << "EGL: GL_EXTENSIONS: " << glesExtensions; + + for (auto &&extName : utils::split(glesExtensions, " ")) + glesExtensions_.insert(std::move(extName)); + + if (sscanf(glesVersion, "OpenGL ES %u.%u", + &glesMajor_, &glesMinor_) != 2) { + LOG(eGL, Error) << "glGetString(GL_VERSION) invalid"; + return -ENODEV; + } + + contextGuard.release(); return 0; -fail: +} + +/** + * \brief Check EGL extension availability + * \param[in] name Extension name + * + * Checks whether a given EGL extension is currently available. + * + * \return True when available, false if not + */ +bool eGL::hasEGLExtension(const char *name) const +{ + return eglExtensions_.contains(name); +} + +/** + * \brief Check GLES extension availability + * \param[in] name Extension name + * + * Checks whether a given OpenGL ES extension is currently available in the + * context. + * + * \return True when available, false if not + */ +bool eGL::hasGLESExtension(const char *name) const +{ + return glesExtensions_.contains(name); +} - return -ENODEV; +/** + * \brief Whether the GLES version is at or above a minimum version + * \param[in] major Major version number + * \param[in] minor Minor version number + * + * \return True when at or beyond specified version, false otherwise + */ +bool eGL::hasGLESVersion(unsigned int major, unsigned int minor) const +{ + return glesMajor_ > major || (glesMajor_ == major && glesMinor_ >= minor); } /** @@ -468,6 +525,11 @@ void eGL::resetEGLContext() eglDestroyContext(display_, std::exchange(context_, EGL_NO_CONTEXT)); } + eglExtensions_ = {}; + glesExtensions_ = {}; + glesMajor_ = 0; + glesMinor_ = 0; + tid_ = -1; vtable_ = {}; } From patchwork Fri Dec 4 03:18:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29159 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 7470BC3300 for ; Fri, 4 Dec 2026 03:20:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EE7E6AB66; Fri, 4 Dec 2026 04:20:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="lOEBcXv7"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="B6GWKoqJ"; 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 C58BE6AB50 for ; Fri, 4 Dec 2026 04:20:09 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G/h7qjGaFg4+6+lVcMKryQSNQdcpLbK86a0v+cKicT0=; b=lOEBcXv7LPoWH66RtlLemH5SKsdUuiOfEUbF0e624D2DaUZmq2bIlWSxxIGFBbi0oOG7wU oAwGbjTHzUqUj55T/WFYdry2y0+QPJk/sd0WIJC2tK0Gvez7Ahur4tMBCCgc9bkDMGNiSd a/XpQvJgdqQqlPgULQV/tj0TEtfJMzRqZznL7Ecn/b5mvfQtmFElFLVUcIn4oPS01ilCFo nxWPH1OIiTGKOU7EhAhtT+kPCSenpR5C5vZ3fsAzFJ6dvfriRDKXXgpSrNOz7p7mI1VA56 wVG05td7gPID06wmWpweWeDrXuu61cjj2aVQScoZS3yNW+7SRkDFQ62yky3UmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G/h7qjGaFg4+6+lVcMKryQSNQdcpLbK86a0v+cKicT0=; b=B6GWKoqJ57FrGPWsB0zXspDV4huEhHOEvGwsKHaKRneCD0wsstLRk0Dwoqyz/SO9ys1P+6 jxrfgAL9GJSMZdQJmEHIXKb38TvLWizVAO7Nf0Jlc5Ygg9DT8/cJsiGpX0E1XmqSlal8gM 0uOZ+HRhz7OgQvao/Ea0eQP/npcYIEIRcVvk2tj+4SbMH8qDRqeMBC9X/i3B2crnYPc9/h Y5vQhVbVg97JpBUpZMCkyhET2qS5sT13htyVedPQ768oG/v6tNi3yMIkbtHvbUBxALXa+g ZabDwg7mWIWX8TKxeBxpinT83lAh9wC2dK1zaoOhgss/fJUL8N+Ut1yxUkCWwA== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 2/6] libcamera: egl: Ensure required extensions are supported Date: Fri, 4 Dec 2026 16:18:54 +1300 Message-ID: <20261204031914.117401-3-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 Ensures that the EGL context supports EGL_EXT_image_dma_buf_import, and the OpenGL ES context supports GL_OES_EGL_image. Signed-off-by: Loïc Molinari Signed-off-by: Remy Alipoursafari Reviewed-by: Robert Mader --- src/libcamera/egl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 70f293b7..1a0b6c37 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -467,6 +467,18 @@ int eGL::initEGLContext() return -ENODEV; } +#define CHECK_EXTENSION(name, func) ({ \ + if (!func(name)) { \ + LOG(eGL, Error) << name << " not supported"; \ + return -ENODEV; \ + } \ +}) +#define CHECK_EGL_EXTENSION(name) CHECK_EXTENSION(name, hasEGLExtension); +#define CHECK_GLES_EXTENSION(name) CHECK_EXTENSION(name, hasGLESExtension); + + CHECK_EGL_EXTENSION("EGL_EXT_image_dma_buf_import"); + CHECK_GLES_EXTENSION("GL_OES_EGL_image"); + contextGuard.release(); return 0; From patchwork Fri Dec 4 03:18:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29160 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 145E1C3300 for ; Fri, 4 Dec 2026 03:20:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D1A2D6AB64; Fri, 4 Dec 2026 04:20:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="Du/nC4J7"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="cj6097a/"; 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 340106AB67 for ; Fri, 4 Dec 2026 04:20:12 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=05fYRXbiz7oC20ug+CS8q4W7WZm8RZx7Mxo7KF1EjKs=; b=Du/nC4J7xXQO1KgFbd9cmvKSUR3Ade9+6ZYCYIesyqIIZMDeYpEVpdckZTTEmRpFDKjq0h NIl0REzYJjvdF0S8gtFunaKjuJ+d15A3VW1HwL9YYzAGEXfkCNrTXa/OFjvUBvgLF3JtRQ c7hcWF932uxuM+PjlYdgsbO0BrBtaxGUUQZLXe/LW89pV5k7vJZr9OiJ4Ru8PlWLsWQoxV /9bRyCMNVskoH8Bt0GH/FOOqd/9z5HZbmyNAVarTRf52Gr2sEGNkwxHWtFnI96MbNVcc2p GecY0zp50L9Zm0tZ6r04P5d6pTCvMZwOpAzhBynJN+ud2+NNgRxhBuQg59CGOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=05fYRXbiz7oC20ug+CS8q4W7WZm8RZx7Mxo7KF1EjKs=; b=cj6097a/lEDJie13NY1oZuaIuF9zbuXng6PS3rNslOvjmnwQy7OQkCa7AXsq4Cnu4xcWfl Nv8Bgl89IVFmN/6HSrUZBZxICfY/DWinyv8v3aLvR7blDCxT8IU+HKKH7Fy6BlVbkTAyPs /w2QbWtLKDFK67hXD1UdkjAxn6POSd7nrEN6pJs92UC9ybvlSxIYflLtHC1iaI3THMkNpE AQ2oXbtgbAkYmr7ETp75QFT2yI+wcblR+SjKtld33yjCOPUbwhESFv7b7VNYlktjrNqtVR 9z6+CNz0OnkVkXwagGA5pZ8gJqhlqqOddVW2BOE1+ul4+WAkV8SM5Vj6grZ7wA== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 3/6] libcamera: software_isp: debayer_egl: Check GL_RG support Date: Fri, 4 Dec 2026 16:18:55 +1300 Message-ID: <20261204031914.117401-4-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: Loïc Molinari Unpacked 10 and 12-bit raw input formats require either OpenGL ES 3.0 or the GL_EXT_texture_rg extension. Signed-off-by: Loïc Molinari Reviewed-by: Robert Mader --- src/libcamera/software_isp/debayer_egl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 33933b11..d94a06d1 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -244,6 +244,13 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm break; }; + /* GL_RG textures need GL_EXT_texture_rg before ES 3.0 */ + if (glFormat_ == GL_RG && !egl_.hasGLESVersion(3, 0) && + !egl_.hasGLESExtension("GL_EXT_texture_rg")) { + LOG(Debayer, Error) << "GL_EXT_texture_rg not supported for unpacked input format"; + return -EINVAL; + } + if (egl_.compileVertexShader(vertexShaderId_, vertexShaderData, shaderEnv)) { LOG(Debayer, Error) << "Compile vertex shader fail"; 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 From patchwork Fri Dec 4 03:18:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29162 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 91BFEC3300 for ; Fri, 4 Dec 2026 03:20:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D3086AB60; Fri, 4 Dec 2026 04:20:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="b+8EA77t"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="V3b+Uvj4"; dkim-atps=neutral Received: from mail.coolgi.dev (mail.coolgi.dev [185.193.17.204]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E8D116AB60 for ; Fri, 4 Dec 2026 04:20:20 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354415; 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=p5ptxnSsKGdZxl7d9uNHX5lmkXbxZe6rjbZzvevngBo=; b=b+8EA77t36fBSJTzE1ZP5T/TyD56b+MiDOtO0z/N/SP2uVmaU+CoibLBP5cVDZAG+svl6B TlaaOb0uteJH8krmA2LHw+wZiDrDI1b9fzPEG/ZEXj7dEpeEnewj5OzhLsj2SOzGqWhrrP dthMC5lWAv1batkdjRgNwiUU1rg9r8WNUTgqrvlzFvKMdT+doawWdlycAqtmg4TSWplMim fXbBv9YwbcCKsKe8ANVMCdf/e0j4zD/iFyYhxuUp4NcLKVHh7KtvRLKqm06W6tm6fFr11b rrzmT27C2jkVS3jYBd+adPA2kuTrmXFoy0diA5GZi8RSfnq3Mx27MAoUgvLxYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354415; 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=p5ptxnSsKGdZxl7d9uNHX5lmkXbxZe6rjbZzvevngBo=; b=V3b+Uvj4/N+Ywyjxq3HMeJ7eTl4CQHLi5I2jOIWnCdWGJw5ZRScOeI04LO3JfnO9TAwzEY eXphaN7p/0kLIjthPKUbKlRXUw1xbU4/7a0hJd6ZzlDkHnEka9B6GFfMXsQdzFv6Jh7SQm MBlMVboz7isSI6TtLL2lIfk0y+rCqS7KGJERw/XcOqotzHS0tkuL73+pkzkKRzeQbT7Pqh nVQUXEuhIaDYd0CpNEfvifc2jnXgpvxo9vKqpbfJJC2TSfLd7URkvIljwnMvf+845GPj12 6wSKFvMA4e5yVP6pZVHpgDvpDo4UAfSzHoo+/KWLjUk26cnj5dkAfYHpT9+NCw== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 5/6] software_isp: benchmark: Make benchmark into an abstract class Date: Fri, 4 Dec 2026 16:18:57 +1300 Message-ID: <20261204031914.117401-6-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 Makes the Benchmark class abstract, splitting off the CPU-specific timing code to a separate file to allow for different benchmarking methods to be added in the future. Signed-off-by: Remy Alipoursafari Reviewed-by: Robert Mader --- .../internal/software_isp/benchmark.h | 18 ++- .../internal/software_isp/benchmark_cpu.h | 37 ++++++ .../internal/software_isp/meson.build | 2 +- .../internal/software_isp/swstats_cpu.h | 5 +- src/libcamera/software_isp/benchmark.cpp | 108 ++++++++++++++---- src/libcamera/software_isp/benchmark_cpu.cpp | 74 ++++++++++++ src/libcamera/software_isp/debayer.h | 4 +- src/libcamera/software_isp/debayer_cpu.cpp | 1 + src/libcamera/software_isp/debayer_egl.cpp | 2 + src/libcamera/software_isp/debayer_egl.h | 1 - src/libcamera/software_isp/meson.build | 1 + src/libcamera/software_isp/swstats_cpu.cpp | 1 + 12 files changed, 220 insertions(+), 34 deletions(-) create mode 100644 include/libcamera/internal/software_isp/benchmark_cpu.h create mode 100644 src/libcamera/software_isp/benchmark_cpu.cpp diff --git a/include/libcamera/internal/software_isp/benchmark.h b/include/libcamera/internal/software_isp/benchmark.h index cc7f9d71..be2f6ca5 100644 --- a/include/libcamera/internal/software_isp/benchmark.h +++ b/include/libcamera/internal/software_isp/benchmark.h @@ -1,18 +1,18 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2024, Red Hat Inc. + * Copyright (C) 2026, Collabora Inc. * * Authors: * Hans de Goede + * Remy Alipoursafari * * Simple builtin benchmark to measure software ISP processing times */ #pragma once -#include #include -#include namespace libcamera { @@ -22,18 +22,26 @@ class Benchmark { public: Benchmark(const CameraManager &cm, const std::string &name); - ~Benchmark(); + virtual ~Benchmark(); void startFrame(void); void finishFrame(void); + void queryFrame(void); + +protected: + /* Cumulative time in nanoseconds */ + int64_t frameProcessTime_ = 0; + + virtual bool timeFrameStart(void) = 0; + virtual bool timeFrameEnd(void) = 0; + virtual bool timeFrameQuery(void) = 0; private: std::string name_; - timespec frameStartTime_; + /* Whether to process the current frame */ bool measure_; /* Skip 30 frames for things to stabilize then measure 30 frames */ unsigned int encounteredFrames_ = 0; - int64_t frameProcessTime_ = 0; unsigned int skipBeforeMeasure_ = 30; unsigned int framesToMeasure_ = 30; }; diff --git a/include/libcamera/internal/software_isp/benchmark_cpu.h b/include/libcamera/internal/software_isp/benchmark_cpu.h new file mode 100644 index 00000000..b61737d4 --- /dev/null +++ b/include/libcamera/internal/software_isp/benchmark_cpu.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Red Hat Inc. + * Copyright (C) 2026, Collabora Inc. + * + * Authors: + * Hans de Goede + * Remy Alipoursafari + * + * Simple builtin benchmark to measure software ISP CPU processing times + */ + +#pragma once + +#include +#include + +#include "libcamera/internal/software_isp/benchmark.h" + +namespace libcamera { + +class BenchmarkCpu : public Benchmark +{ +public: + BenchmarkCpu(const CameraManager &cm, const std::string &name); + ~BenchmarkCpu(); + +protected: + bool timeFrameStart(void) override; + bool timeFrameEnd(void) override; + bool timeFrameQuery(void) override; + +private: + timespec frameStartTime_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index df7c3b97..89161600 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -1,7 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_headers += files([ - 'benchmark.h', + 'benchmark_cpu.h', 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index 55187092..e7871e41 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -22,8 +22,7 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/shared_mem_object.h" #include "libcamera/internal/software_isp/swisp_stats.h" - -#include "benchmark.h" +#include "benchmark_cpu.h" namespace libcamera { @@ -123,7 +122,7 @@ private: std::vector stats_; SharedMemObject sharedStats_; - Benchmark bench_; + BenchmarkCpu bench_; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/benchmark.cpp b/src/libcamera/software_isp/benchmark.cpp index 96f0ae00..8f2fa84c 100644 --- a/src/libcamera/software_isp/benchmark.cpp +++ b/src/libcamera/software_isp/benchmark.cpp @@ -1,9 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2024, Red Hat Inc. + * Copyright (C) 2026, Collabora Inc. * * Authors: * Hans de Goede + * Remy Alipoursafari * * Simple builtin benchmark to measure software ISP processing times */ @@ -35,38 +37,74 @@ Benchmark::Benchmark(const CameraManager &cm, const std::string &name) const GlobalConfiguration &configuration = cm._d()->configuration(); skipBeforeMeasure_ = configuration.option( - { "software_isp", "measure", "skip" }) - .value_or(skipBeforeMeasure_); + { "software_isp", "measure", "skip" }) + .value_or(skipBeforeMeasure_); framesToMeasure_ = configuration.option( { "software_isp", "measure", "number" }) - .value_or(framesToMeasure_); + .value_or(framesToMeasure_); } Benchmark::~Benchmark() { } -static inline int64_t timeDiff(timespec &after, timespec &before) -{ - return (after.tv_sec - before.tv_sec) * 1000000000LL + - (int64_t)after.tv_nsec - (int64_t)before.tv_nsec; -} +/** + * \var Benchmark::frameProcessTime_ + * \brief Cumulative time in nanoseconds + */ + +/** + * \fn Benchmark::timeFrameStart() + * \brief Start measuring process time for a single frame + * \return True on success, false on failure. On failure, the rest of the + * pipeline is skipped + * \sa timeFrameEnd() + * \sa timeFrameQuery() + */ + +/** + * \fn Benchmark::timeFrameEnd() + * \brief Finish measuring process time for a single frame + * \return True on success, false on failure. On failure, the rest of the + * pipeline is skipped + * \sa timeFrameStart() + * \sa timeFrameQuery() + */ + +/** + * \fn Benchmark::timeFrameQuery() + * \brief Query the processing time between the timer's start & end + * + * Queries for the time between the timer's start & end, and putting the result + * in Benchmark::frameProcessTime_. + * + * \return True on success, false on failure. On failure, the rest of the + * pipeline is skipped + * \sa timeFrameStart() + * \sa timeFrameEnd() + */ /** * \brief Start measuring process time for a single frame * * Call this function before processing frame data to start measuring * the process time for a frame. + * + * \sa finishFrame() + * \sa queryFrame() */ -void Benchmark::startFrame(void) +void Benchmark::startFrame() { measure_ = framesToMeasure_ > 0 && encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ && ++encounteredFrames_ > skipBeforeMeasure_; if (measure_) { - frameStartTime_ = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime_); + if (!timeFrameStart()) { + LOG(Benchmark, Error) << name_ << " failed starting time benchmark"; + encounteredFrames_--; + measure_ = false; + } } } @@ -76,21 +114,47 @@ void Benchmark::startFrame(void) * Call this function after processing frame data to finish measuring * the process time for a frame. * + * \sa startFrame() + * \sa queryFrame() + */ +void Benchmark::finishFrame() +{ + if (measure_) { + if (!timeFrameEnd()) { + LOG(Benchmark, Error) << name_ << " failed ending time benchmark"; + encounteredFrames_--; + measure_ = false; + } + } +} + +/** + * \brief Query & potentially print the processing time for a single frame + * + * Call this function once Benchmark::startFrame() & Benchmark::finishFrame() + * have been called. + * * This function will log frame processing time information after - * Benchmark::kLastFrameToMeasure frames have been processed. + * (Benchmark::skipBeforeMeasure_ + Benchmark::framesToMeasure_) successful + * frames have been processed. + * + * \sa startFrame() + * \sa finishFrame() */ -void Benchmark::finishFrame(void) +void Benchmark::queryFrame() { if (measure_) { - timespec frameEndTime = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime); - frameProcessTime_ += timeDiff(frameEndTime, frameStartTime_); - if (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) { - LOG(Benchmark, Info) - << name_ << " processed " << framesToMeasure_ - << " frames in " << frameProcessTime_ / 1000 << "us, " - << frameProcessTime_ / (1000 * framesToMeasure_) - << " us/frame"; + if (timeFrameQuery()) { + if (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) { + LOG(Benchmark, Info) + << name_ << " processed " << framesToMeasure_ + << " frames in " << frameProcessTime_ / 1000 << "us, " + << frameProcessTime_ / (1000 * framesToMeasure_) + << " us/frame"; + } + } else { + LOG(Benchmark, Error) << name_ << " failed querying time benchmark"; + encounteredFrames_--; } } } diff --git a/src/libcamera/software_isp/benchmark_cpu.cpp b/src/libcamera/software_isp/benchmark_cpu.cpp new file mode 100644 index 00000000..6994cf23 --- /dev/null +++ b/src/libcamera/software_isp/benchmark_cpu.cpp @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Red Hat Inc. + * Copyright (C) 2026, Collabora Inc. + * + * Authors: + * Hans de Goede + * Remy Alipoursafari + * + * Simple builtin benchmark to measure software ISP CPU processing times + */ + +#include "libcamera/internal/software_isp/benchmark_cpu.h" + +namespace libcamera { + +/** + * \class BenchmarkCpu + * \brief Simple builtin benchmark for mesuring CPU time + * + * Simple builtin benchmark to measure software ISP CPU processing times. + */ + +/** + * \brief Constructs a BenchmarkCpu object + */ +BenchmarkCpu::BenchmarkCpu(const CameraManager &cm, const std::string &name) + : Benchmark(cm, name) +{ +} + +BenchmarkCpu::~BenchmarkCpu() +{ +} + +static inline int64_t timeDiff(timespec &after, timespec &before) +{ + return (after.tv_sec - before.tv_sec) * 1000000000LL + + (int64_t)after.tv_nsec - (int64_t)before.tv_nsec; +} + +/** + * \brief Start measuring process time for a single frame + */ +bool BenchmarkCpu::timeFrameStart() +{ + frameStartTime_ = {}; + return clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime_) == 0; +} + +/** + * \brief Finish measuring process time for a single frame + */ +bool BenchmarkCpu::timeFrameEnd() +{ + timespec frameEndTime = {}; + if (clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime)) + return false; + + frameProcessTime_ += timeDiff(frameEndTime, frameStartTime_); + + return true; +} + +/** + * \brief Query the processing time between the timer's start & end + */ +bool BenchmarkCpu::timeFrameQuery() +{ + // Querying the processing time is done in BenchmarkCpu::timeFrameEnd() + return true; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index e30a0527..c9423263 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -22,7 +22,7 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/dma_buf_allocator.h" -#include "libcamera/internal/software_isp/benchmark.h" +#include "libcamera/internal/software_isp/benchmark_cpu.h" #include "libcamera/internal/software_isp/debayer_params.h" namespace libcamera { @@ -80,7 +80,7 @@ public: PixelFormat inputPixelFormat_; PixelFormat outputPixelFormat_; bool swapRedBlueGains_; - Benchmark bench_; + BenchmarkCpu bench_; private: virtual Size patternSize(PixelFormat inputFormat) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 91867baa..23e519c3 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -1094,6 +1094,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output /* Measure before emitting signals */ bench_.finishFrame(); + bench_.queryFrame(); /* * Buffer ids are currently not used, so pass zeros as its parameter. diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index d94a06d1..ca99bdc2 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -672,6 +672,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output egl_.syncOutput(); bench_.finishFrame(); + bench_.queryFrame(); outputBufferReady.emit(output); inputBufferReady.emit(input); @@ -680,6 +681,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output error: bench_.finishFrame(); + bench_.queryFrame(); metadata.status = FrameMetadata::FrameError; return; } diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index cbbc6a45..4185d32b 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -21,7 +21,6 @@ #include "libcamera/internal/egl.h" #include "libcamera/internal/mapped_framebuffer.h" -#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index 15f9e403..f6ee6700 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -21,6 +21,7 @@ summary({'SoftISP GPU acceleration' : mesa_works}, libcamera_internal_sources += files([ 'benchmark.cpp', + 'benchmark_cpu.cpp', 'debayer.cpp', 'debayer_cpu.cpp', 'software_isp.cpp', diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 74633815..0f08b19e 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -632,6 +632,7 @@ void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuff (this->*processFrame_)(input); finishFrame(frame, bufferId); bench_.finishFrame(); + bench_.queryFrame(); } } /* namespace libcamera */ From patchwork Fri Dec 4 03:18:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Alipoursafari X-Patchwork-Id: 29163 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 74D94C3300 for ; Fri, 4 Dec 2026 03:20:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 127656AB70; Fri, 4 Dec 2026 04:20:25 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="Qz8AGz1p"; dkim=pass (2048-bit key; unprotected) header.d=coolgi.dev header.i=@coolgi.dev header.b="VJxW5Xew"; dkim-atps=neutral Received: from mail.coolgi.dev (mail.coolgi.dev [185.193.17.204]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 65F1E6AB6B for ; Fri, 4 Dec 2026 04:20:23 +0100 (CET) From: Remy Alipoursafari DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-08; t=1796354422; 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=A+Vy81JfPYFKKnAoPnPXkoSkwYLUr/UzYkjdxHkN9/g=; b=Qz8AGz1pWYLqX3QQCCs4gjxr3C5TL2IMB7a/bduGwGgZJh7LT643GvPY6UbOrK+4cW3MGI pCyR/pZGsAITQ9vMBW3lP1Yoaa0xKvFsT4Yu62QLCFOyL51e7a0JwH+YU2xZlzIc+bHImI Ghf5aHHJMhne6/qRSsCKm9Owvz76dxhliXs4sACtbFoYkxxjMKuTRpkTqICxnPPPm8WFw0 0l+KeuTVqIze3Qd54GGEk65Giv/Y3AU02mmZ96w7YG8GMWfmylCLB0H6f6eZ2vGJiFE1J+ f6V9OXxpCLRK7YZTwxTd534OT8JUqEREDuxK0ulumlLcIsM1J1zdM1rOhlt/yw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coolgi.dev; s=rsa-2026-11; t=1796354422; 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=A+Vy81JfPYFKKnAoPnPXkoSkwYLUr/UzYkjdxHkN9/g=; b=VJxW5XewZF9wLCLg7fg7z0RXZga6Xwez/o5oyZpfmHmWOk+aFlbxZtGc0pC64ECqbQsS35 6+k4z15FfYw+U5FdxCQejNSu1whVsWAQqUZtTBkLSpkEROFrxYuOv1k5swk/NJCs7hNMnU d/mHZty1n8471IjeX2+d8dKBja0ZUUwFsZa3xKNtfF3cmGFCCNXfFOBJfIv9Ncg4S+XX+n Yz7ORzn61pGQ+qIk/ra93GSxeN2O18/KbgkLgnKlv8LZjF4hcC1Jmo6Lut76dLuFwjZwfy RtGbrGyz9p+hcFwkT8oSa51velaY94wCyHh4LR7B6WADmn+puSwLnio5Re5FSw== To: libcamera-devel@lists.libcamera.org Cc: Remy Alipoursafari , =?utf-8?q?Lo?= =?utf-8?q?=C3=AFc_Molinari?= , Robert Mader Subject: [PATCH v2 6/6] software_isp: benchmark: Add GPU benchmarking Date: Fri, 4 Dec 2026 16:18:58 +1300 Message-ID: <20261204031914.117401-7-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 Add a method for benchmarking the time taken by GPU in the softisp EGL implementation using the EXT_disjoint_timer_query OpenGL extension. On a Radxa ROCK 5B with Radxa Camera 4K, which uses the imx415 sensor, it results in the following processing time for 30 frames: - Debayer : 45958 us/frame - Debayer EGL : 17556 us/frame - CPU stats : 135974 us/frame Signed-off-by: Remy Alipoursafari Reviewed-by: Robert Mader --- include/libcamera/internal/egl.h | 16 +++ .../internal/software_isp/benchmark_egl.h | 43 +++++++ .../internal/software_isp/meson.build | 1 + src/libcamera/egl.cpp | 105 ++++++++++++++++++ src/libcamera/software_isp/benchmark_egl.cpp | 98 ++++++++++++++++ src/libcamera/software_isp/debayer_egl.cpp | 37 +++++- src/libcamera/software_isp/debayer_egl.h | 3 + src/libcamera/software_isp/meson.build | 1 + 8 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 include/libcamera/internal/software_isp/benchmark_egl.h create mode 100644 src/libcamera/software_isp/benchmark_egl.cpp diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 1d1c530c..dc444139 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -120,6 +120,13 @@ public: void updateTexture2D(eGLImage &eglImage, const void *data); void createOutputTexture2D(eGLImage &eglImage); + bool timerQueryAvailable(); + void createTimerQuery(GLuint *id); + void deleteTimerQuery(GLuint *id); + void beginTimerQuery(GLuint id); + void endTimerQuery(); + int queryTimerQuery(GLuint id, GLuint64 *out); + int attachTextureToFBO(eGLImage &eglImage); void activateBindTexture(eGLImage &eglImage); @@ -159,10 +166,19 @@ private: void makeCurrent(); + bool disjointTimerExtensionAvailable_ = false; + struct VTable { PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + + PFNGLGENQUERIESEXTPROC glGenQueriesEXT; + PFNGLDELETEQUERIESEXTPROC glDeleteQueriesEXT; + PFNGLBEGINQUERYEXTPROC glBeginQueryEXT; + PFNGLENDQUERYEXTPROC glEndQueryEXT; + PFNGLGETQUERYOBJECTIVEXTPROC glGetQueryObjectivEXT; + PFNGLGETQUERYOBJECTUI64VEXTPROC glGetQueryObjectui64vEXT; } vtable_ = {}; void locateProcAddresses(VTable *vtable); diff --git a/include/libcamera/internal/software_isp/benchmark_egl.h b/include/libcamera/internal/software_isp/benchmark_egl.h new file mode 100644 index 00000000..930139fe --- /dev/null +++ b/include/libcamera/internal/software_isp/benchmark_egl.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Collabora Inc. + * + * Authors: + * Remy Alipoursafari + * + * Simple builtin benchmark to measure software ISP GPU processing times + */ + +#pragma once + +#include + +#include "libcamera/internal/egl.h" +#include "libcamera/internal/software_isp/benchmark.h" + +#include + +namespace libcamera { + +class BenchmarkEgl : public Benchmark +{ +public: + BenchmarkEgl(const CameraManager &cm, const std::string &name, eGL &egl); + ~BenchmarkEgl(); + + bool hasTimerQuery(void); + + void initTimer(void); + void deleteTimer(void); + +protected: + bool timeFrameStart(void) override; + bool timeFrameEnd(void) override; + bool timeFrameQuery(void) override; + +private: + eGL &egl_; + GLuint timerQuery_ = 0; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index 89161600..48dcfc5a 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -2,6 +2,7 @@ libcamera_internal_headers += files([ 'benchmark_cpu.h', + 'benchmark_egl.h', 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index df5b542d..eeddb56f 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -363,6 +363,101 @@ void eGL::createOutputTexture2D(eGLImage &eglImage) attachTextureToFBO(eglImage); } +/** + * \brief Checks whether timer queries are available + * + * Checks whether the GL_EXT_disjoint_timer_query extension is available in the + * current OpenGL ES context. + * + * \sa createTimerQuery() + */ +bool eGL::timerQueryAvailable() +{ + return disjointTimerExtensionAvailable_; +} + +/** + * \brief Create a disjoint timer query object + * \param[out] id Location to store the disjoint timer query + * + * Creates a disjoint timer query provided by EXT_disjoint_timer_query for GPU + * timing if the extension is available. + * + * \sa timerQueryAvailble() + * \sa deleteTimerQuery() + */ +void eGL::createTimerQuery(GLuint *id) +{ + if (!timerQueryAvailable()) + return; + + vtable_.glGenQueriesEXT(1, id); +} + +/** + * \brief Deletes a disjoint timer query object + * \param[in,out] id The location of the disjoint timer query + * + * Creates a disjoint timer query provided by EXT_disjoint_timer_query for GPU + * timing. + * + * \sa createTimerQuery() + */ +void eGL::deleteTimerQuery(GLuint *id) +{ + vtable_.glDeleteQueriesEXT(1, id); +} + +/** + * \brief Begins the disjoint timer query + * \param[in] id The ID of the disjoint timer query object + * \sa createTimerQuery() + * \sa endTimerQuery() + * \sa queryTimerQuery() + */ +void eGL::beginTimerQuery(GLuint id) +{ + vtable_.glBeginQueryEXT(GL_TIME_ELAPSED_EXT, id); +} + +/** + * \brief Ends the disjoint timer query + * + * Ends the most recently started non-previously-stopped timer query. + * + * \sa beginTimerQuery() + * \sa queryTimerQuery() + */ +void eGL::endTimerQuery() +{ + vtable_.glEndQueryEXT(GL_TIME_ELAPSED_EXT); +} + +/** + * \brief Gets the result of the timer query + * \param[in] id The ID of the disjoint timer query object + * \param[out] out Time from beginning query in nanoseconds + * + * Once the GPU has finished processing the timer query, this gives the GPU + * processing time between beginning and ending the timer query. + * + * \return 0 on success, -1 on failure (called too early?) + * \sa beginTimerQuery() + * \sa endTimerQuery() + */ +int eGL::queryTimerQuery(GLuint id, GLuint64 *out) +{ + int available = 0; + + vtable_.glGetQueryObjectivEXT(id, GL_QUERY_RESULT_AVAILABLE, &available); + if (!available) + return -1; + + vtable_.glGetQueryObjectui64vEXT(id, GL_QUERY_RESULT, out); + + return 0; +} + /** * \brief Initialise the EGL context * @@ -462,6 +557,7 @@ int eGL::initEGLContext() CHECK_EGL_EXTENSION("EGL_EXT_image_dma_buf_import"); CHECK_GLES_EXTENSION("GL_OES_EGL_image"); + disjointTimerExtensionAvailable_ = hasGLESExtension("GL_EXT_disjoint_timer_query"); contextGuard.release(); @@ -526,6 +622,8 @@ void eGL::resetEGLContext() glesMajor_ = 0; glesMinor_ = 0; + disjointTimerExtensionAvailable_ = false; + tid_ = -1; vtable_ = {}; } @@ -567,6 +665,13 @@ void eGL::locateProcAddresses(VTable *vtable) GET_PROC_ADDRESS(vtable->eglCreateImageKHR, "eglCreateImageKHR"); GET_PROC_ADDRESS(vtable->eglDestroyImageKHR, "eglDestroyImageKHR"); GET_PROC_ADDRESS(vtable->glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES"); + + GET_PROC_ADDRESS(vtable->glGenQueriesEXT, "glGenQueriesEXT"); + GET_PROC_ADDRESS(vtable->glDeleteQueriesEXT, "glDeleteQueriesEXT"); + GET_PROC_ADDRESS(vtable->glBeginQueryEXT, "glBeginQueryEXT"); + GET_PROC_ADDRESS(vtable->glEndQueryEXT, "glEndQueryEXT"); + GET_PROC_ADDRESS(vtable->glGetQueryObjectivEXT, "glGetQueryObjectivEXT"); + GET_PROC_ADDRESS(vtable->glGetQueryObjectui64vEXT, "glGetQueryObjectui64vEXT"); } /** diff --git a/src/libcamera/software_isp/benchmark_egl.cpp b/src/libcamera/software_isp/benchmark_egl.cpp new file mode 100644 index 00000000..bfd78c1d --- /dev/null +++ b/src/libcamera/software_isp/benchmark_egl.cpp @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Collabora Inc. + * + * Authors: + * Remy Alipoursafari + * + * Simple builtin benchmark to measure software ISP GPU processing times + */ + +#include "libcamera/internal/software_isp/benchmark_egl.h" + +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(BenchmarkEgl) + +/** + * \class BenchmarkEgl + * \brief Simple builtin benchmark for mesuring GPU time + * + * Simple builtin benchmark to measure software ISP GPU processing times. + */ + +/** + * \brief Constructs a BenchmarkEgl object + */ +BenchmarkEgl::BenchmarkEgl(const CameraManager &cm, const std::string &name, eGL &egl) + : Benchmark(cm, name), egl_{ egl } +{ +} + +BenchmarkEgl::~BenchmarkEgl() +{ +} + +/** + * \brief Checks if the timer query has been created + */ +bool BenchmarkEgl::hasTimerQuery() +{ + return timerQuery_ != 0; +} + +/** + * \brief Initialises the timer query + * + * Sets up the disjoint timer query for the current OpenGL context. + */ +void BenchmarkEgl::initTimer() +{ + egl_.createTimerQuery(&timerQuery_); +} + +/** + * \brief Deletes the timer query + */ +void BenchmarkEgl::deleteTimer() +{ + egl_.deleteTimerQuery(&timerQuery_); + timerQuery_ = 0; +} + +/** + * \brief Start measuring process time for a single frame + */ +bool BenchmarkEgl::timeFrameStart() +{ + egl_.beginTimerQuery(timerQuery_); + return true; +} + +/** + * \brief Finish measuring process time for a single frame + */ +bool BenchmarkEgl::timeFrameEnd() +{ + egl_.endTimerQuery(); + return true; +} + +/** + * \brief Query the processing time between the timer's start & end + */ +bool BenchmarkEgl::timeFrameQuery() +{ + GLuint64 elapsed = -1; + + if (egl_.queryTimerQuery(timerQuery_, &elapsed)) { + return false; + } + + frameProcessTime_ += elapsed; + return true; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index ca99bdc2..fc75968a 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -43,7 +43,7 @@ namespace libcamera { * \param[in] display The EGL display to use */ DebayerEGL::DebayerEGL(std::unique_ptr stats, const CameraManager &cm, EGLDisplay display) - : Debayer(cm), stats_(std::move(stats)), egl_(display) + : Debayer(cm), benchEgl_(cm, "Debayer EGL", egl_), stats_(std::move(stats)), egl_(display) { } @@ -51,6 +51,14 @@ DebayerEGL::~DebayerEGL() { } +/** + * \var DebayerEGL::benchEgl_ + * \brief Benchmarking utility instance for GPU performance measurements + * + * Used internally to track GPU timing and performance metrics during + * debayer processing. + */ + int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) { BayerFormat bayerFormat = @@ -606,12 +614,21 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye eGLImage *eglImageIn; eGLImage *eglImageOut; + if (benchEgl_.hasTimerQuery()) + benchEgl_.startFrame(); + eglImageIn = getCachedInputFrameBuffer(input, inMapped, inDmaSyncer); - if (!eglImageIn) + if (!eglImageIn) { + if (benchEgl_.hasTimerQuery()) + benchEgl_.finishFrame(); return -ENOMEM; + } eglImageOut = getCachedOutputFrameBuffer(output); - if (!eglImageOut) + if (!eglImageOut) { + if (benchEgl_.hasTimerQuery()) + benchEgl_.finishFrame(); return -ENOMEM; + } egl_.attachTextureToFBO(*eglImageOut); setShaderVariableValues(*eglImageIn, params); @@ -620,6 +637,9 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLE_FAN, 0, DEBAYER_OPENGL_COORDS); + if (benchEgl_.hasTimerQuery()) + benchEgl_.finishFrame(); + GLenum err = glGetError(); if (err != GL_NO_ERROR) { LOG(eGL, Error) << "Drawing scene fail " << err; @@ -674,6 +694,9 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output bench_.finishFrame(); bench_.queryFrame(); + if (benchEgl_.hasTimerQuery()) + benchEgl_.queryFrame(); + outputBufferReady.emit(output); inputBufferReady.emit(input); @@ -682,6 +705,8 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output error: bench_.finishFrame(); bench_.queryFrame(); + if (benchEgl_.hasTimerQuery()) + benchEgl_.queryFrame(); metadata.status = FrameMetadata::FrameError; return; } @@ -700,6 +725,9 @@ int DebayerEGL::start() if (initBayerShaders(inputPixelFormat_, outputPixelFormat_)) return -EINVAL; + if (egl_.timerQueryAvailable()) + benchEgl_.initTimer(); + if (lscEnabled_) { constexpr unsigned int gridSize = DebayerParams::kLscGridSize; constexpr unsigned int stride = gridSize * DebayerParams::kLscBytesPerCell; @@ -723,6 +751,9 @@ void DebayerEGL::stop() eglImageLscLookup_.reset(); lscLutVersion_.reset(); + if (benchEgl_.hasTimerQuery()) + benchEgl_.deleteTimer(); + if (programId_) glDeleteProgram(programId_); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 4185d32b..140d20fa 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -21,6 +21,7 @@ #include "libcamera/internal/egl.h" #include "libcamera/internal/mapped_framebuffer.h" +#include "libcamera/internal/software_isp/benchmark_egl.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include @@ -61,6 +62,8 @@ public: SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) override; + BenchmarkEgl benchEgl_; + private: static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat); diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index f6ee6700..6676db6f 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -32,6 +32,7 @@ if mesa_works config_h.set('HAVE_DEBAYER_EGL', 1) libcamera_internal_sources += files([ '../egl.cpp', + 'benchmark_egl.cpp', 'debayer_egl.cpp', ]) libcamera_deps += [