From patchwork Wed Jun 24 08:58:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 27033 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 23AB5C3306 for ; Wed, 24 Jun 2026 08:59:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2873658A4; Wed, 24 Jun 2026 10:59:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xWS2j76z"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E68C65870 for ; Wed, 24 Jun 2026 10:59:05 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4923139e940so4872405e9.3 for ; Wed, 24 Jun 2026 01:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1782291545; x=1782896345; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NUS4ldqtNiG20r3GBYJr0jvyQGDFpx2Gb3eb+pQy1x8=; b=xWS2j76zCZ99iEqddghkKXki0aFa0sedD8ri0mhhlTFnNLw06juhgrZtpfPUSJQWP+ khpjjoNajbDDIQdliSViIQWmpxvHCmbEl6tapguElBOqJandii0aC23myeFFmA15r6uH wWcirIe/l70hHY/JA1mKbpHB5Fq8rh4l6xTQAuBNAfaUHG5g+UX8Dg/4A0DO1M0YHx9N tR63KrNtIM3BtPhL5kzVqWtDT4vZbLgIbAYoUWXZSZ1YhxqYg2kiC03iwU7gPO+Kvgqi s8yDUc5J33E67arsP7+w+vgiKGJy1vMd0JsjrWdpkjC87/sYKlyC8yZbdx8lal9mB073 WWXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782291545; x=1782896345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NUS4ldqtNiG20r3GBYJr0jvyQGDFpx2Gb3eb+pQy1x8=; b=X1u4rNZN5gI9q4hhYBL81nVh7E6btTlqmZ0pn5wAFAiCM1Tb5CRY3y/+bo76j2sEYs pkDZ/Iq5c6aZoI+IPYjlW4LMQEn0nFbQk5DwXhYZ00BLV9LSSORMJ2RVnlLvsQ7b+Wcj ehHijNPXl/FtA1bk+DSdZdvu/HQulO7tT78j8I3FECMFLGsHIcvUJb8yrgGaaDREOqsB 8iMCa2mWp3khBnmnJhBMt4CzvK1skzsBpa/UHb9/X3RCEri91eaXuxTWiCVsswvaxYZK qOtAG3SLAxjxv2kYZqo8wmHSZv9kSaY7Dj+zCGCQ/hNT088XYeirUyQMkj5wJ7CmwCCb pTkQ== X-Gm-Message-State: AOJu0YyQrYgAhP5EzsUOosvnLzs2u2Sj8TcprV3Zqj4dna4CqFsJfC5x ApI/Fzvqm5dtIsPnS/zrwxc/bdnHIITHAgZE2S9SBgYhfWjVhlsSS04IqIacPbTRbb0TPWxOukj HWIz5Ueo= X-Gm-Gg: AfdE7ck2D9Qrk6dMJSHkM0/bvmSb9YRwi/zGXz9K0auOXFbB7+u1fkWvxXuimkdnt9B TqJmvIR9sPXILbXWNFJ6eP/jYH6rbMbUihji6zH1VEKn67ukLUaTnedCqLdjpsbmm2YxyH3oGP1 NKh70wWOOr3XJbh46T1snRqz0h1q2R699rphwVZPH6qcOc8e1b/y5mKpTf2BOTJL5pZqwIhcejB p5uQoO4qz/PvVpiZyUsvY3XI4Z/0n1fa7zIyfvFT13Pmp66vwd+WRc4h8lz4bcvi9TUs2OpM5db XbXS6mkCk96sP120n8vnpwI58MoWwHol/Jr2xqmsR/l4fnHYCGKTYIF1KXuGk58VpMLVeZ4xkkz sQUdrW90Bradn0L7lAukssWrKtVnKvAYbjDI3wWISweWFNaw3YDYtMbhBTvKsQkcIbWEF7KcHfI /8Axo2L6EVJj2BRpsu1LeZgTfyH/tI X-Received: by 2002:a05:600c:3e88:b0:489:5022:39a4 with SMTP id 5b1f17b1804b1-4925b3532ffmr95245295e9.9.1782291545074; Wed, 24 Jun 2026 01:59:05 -0700 (PDT) Received: from inspiron14p-linux ([109.76.100.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49261063d6esm25128375e9.2.2026.06.24.01.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 01:59:04 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz Subject: [PATCH 07/10] libcamera: egl: Add activateBindTexture Date: Wed, 24 Jun 2026 09:58:46 +0100 Message-ID: <20260624085849.873784-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260624085849.873784-1-bryan.odonoghue@linaro.org> References: <20260624085849.873784-1-bryan.odonoghue@linaro.org> 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" When operating from a texture cache on dma-buf inputs we will no longer create new textures nor attach those textures for dma-buf handles we have already encountered. This means we will use the texture id associated with a given texture unit to switch between one texture and another. The pages associated with the texture will have been populated with new data by the CSI2 receiver. All we will do is say to the GPU "reuse this texture id" aka zero-copy. However we must also activate and bind that texture for each loop. This cost is small but necessary for zero-copy. Signed-off-by: Bryan O'Donoghue Reviewed-by: Robert Mader --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index f1fa75d96..59fd52749 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -112,6 +112,7 @@ public: void createOutputTexture2D(eGLImage &eglImage); int attachTextureToFBO(eGLImage &eglImage); + void activateBindTexture(eGLImage &eglImage); void pushEnv(std::vector &shaderEnv, const char *str); void makeCurrent(); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 6134b05f9..f26fe2e53 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -138,6 +138,13 @@ int eGL::attachTextureToFBO(eGLImage &eglImage) return ret; } +void eGL::activateBindTexture(eGLImage &eglImage) +{ + // Bind texture unit and texture + glActiveTexture(eglImage.texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage.texture_); +} + /** * \brief Create a DMA-BUF backed 2D texture * \param[in,out] eglImage EGL image to associate with the DMA-BUF @@ -197,9 +204,7 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) return -ENODEV; } - // Bind texture unit and texture - glActiveTexture(eglImage.texture_unit_); - glBindTexture(GL_TEXTURE_2D, eglImage.texture_); + activateBindTexture(eglImage); // Generate texture with filter semantics glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); @@ -273,8 +278,7 @@ void eGL::createInputTexture2D(eGLImage &eglImage, void *data) ASSERT(tid_ == Thread::currentId()); - glActiveTexture(eglImage.texture_unit_); - glBindTexture(GL_TEXTURE_2D, eglImage.texture_); + activateBindTexture(eglImage); switch (eglImage.format_) { case GL_R16F: