From patchwork Tue Aug 4 10:19:48 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: 27611 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 D7C64C3336 for ; Tue, 4 Aug 2026 10:20:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 48CE96808A; Tue, 4 Aug 2026 12:20:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L+rKbkEh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CCC267F9E for ; Tue, 4 Aug 2026 12:19:54 +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 9D42FDA8 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=sm8eRvBcgM+v78i9vMsRX7Ix/YevzdQ9LiDLdV4PPyI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L+rKbkEh63WR+m8YkIHcStMI+YVXHc/IH+QigRfkD4HIVKJO3FsfmKtqKqnneLSEI 6Ggz4tfh/c5ao9GCZ3MD3M0bC7n6tA47YyrtxVVvuLSY46iWg84I++5bsBp5NRgluc 9IuzFv78zHWd4E0RMSPCVjXdv4MrJLlxOE/BZznk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 09/10] libcamera: egl: Make it possible to unmake the context Date: Tue, 4 Aug 2026 12:19:48 +0200 Message-ID: <20260804101949.353266-10-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-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" Add a parameter to `makeCurrent()` to make it possible to remove the currently bound context. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/egl.h | 2 +- src/libcamera/egl.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index e18bb91f4d..a3218af9ef 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -116,7 +116,7 @@ public: void activateBindTexture(eGLImage &eglImage); void pushEnv(std::vector &shaderEnv, const char *str); - void makeCurrent(); + void makeCurrent(bool make); int compileVertexShader(GLuint &shaderId, Span shaderData, Span shaderEnv); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 5e75c3a6d2..f351bcf52c 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -427,7 +427,7 @@ int eGL::initEGLContext() tid_ = Thread::currentId(); vtable_ = vtable; - makeCurrent(); + makeCurrent(true); LOG(eGL, Info) << "EGL: GL_RENDERER: " << glGetString(GL_RENDERER); LOG(eGL, Info) << "EGL: GL_VERSION: " << glGetString(GL_VERSION); @@ -454,16 +454,17 @@ void eGL::resetEGLContext() /** * \brief Make the EGL context current for the calling thread + * \param[in] make Whether to make/unmake the EGL context * * Binds the EGL context to the current thread, allowing OpenGL ES * operations to be performed. Must be called from the thread that * will perform rendering operations. */ -void eGL::makeCurrent() +void eGL::makeCurrent(bool make) { ASSERT(tid_ == Thread::currentId()); - if (eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, context_) != EGL_TRUE) { + if (eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, make ? context_ : EGL_NO_CONTEXT) != EGL_TRUE) { LOG(eGL, Error) << "eglMakeCurrent fail"; } }