[{"id":39386,"web_url":"https://patchwork.libcamera.org/comment/39386/","msgid":"<8655c7ad-ded5-4b59-bd93-0e6f93c974fe@collabora.com>","date":"2026-06-24T12:15:47","subject":"Re: [PATCH 07/10] libcamera: egl: Add activateBindTexture","submitter":{"id":140,"url":"https://patchwork.libcamera.org/api/people/140/","name":"Robert Mader","email":"robert.mader@collabora.com"},"content":"On 24.06.26 10:58, Bryan O'Donoghue wrote:\n> When operating from a texture cache on dma-buf inputs we will no longer\n> create new textures nor attach those textures for dma-buf handles we have\n> already encountered.\n>\n> This means we will use the texture id associated with a given texture unit\n> to switch between one texture and another. The pages associated with the\n> texture will have been populated with new data by the CSI2 receiver. All we\n> will do is say to the GPU \"reuse this texture id\" aka zero-copy.\n>\n> However we must also activate and bind that texture for each loop. This\n> cost is small but necessary for zero-copy.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>   include/libcamera/internal/egl.h |  1 +\n>   src/libcamera/egl.cpp            | 14 +++++++++-----\n>   2 files changed, 10 insertions(+), 5 deletions(-)\n>\n> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\n> index f1fa75d96..59fd52749 100644\n> --- a/include/libcamera/internal/egl.h\n> +++ b/include/libcamera/internal/egl.h\n> @@ -112,6 +112,7 @@ public:\n>   \tvoid createOutputTexture2D(eGLImage &eglImage);\n>   \n>   \tint attachTextureToFBO(eGLImage &eglImage);\n> +\tvoid activateBindTexture(eGLImage &eglImage);\n>   \n>   \tvoid pushEnv(std::vector<std::string> &shaderEnv, const char *str);\n>   \tvoid makeCurrent();\n> diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\n> index 6134b05f9..f26fe2e53 100644\n> --- a/src/libcamera/egl.cpp\n> +++ b/src/libcamera/egl.cpp\n> @@ -138,6 +138,13 @@ int eGL::attachTextureToFBO(eGLImage &eglImage)\n>   \treturn ret;\n>   }\n>   \n> +void eGL::activateBindTexture(eGLImage &eglImage)\n> +{\n> +\t// Bind texture unit and texture\n> +\tglActiveTexture(eglImage.texture_unit_);\n> +\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +}\n> +\n>   /**\n>    * \\brief Create a DMA-BUF backed 2D texture\n>    * \\param[in,out] eglImage EGL image to associate with the DMA-BUF\n> @@ -197,9 +204,7 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n>   \t\treturn -ENODEV;\n>   \t}\n>   \n> -\t// Bind texture unit and texture\n> -\tglActiveTexture(eglImage.texture_unit_);\n> -\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +\tactivateBindTexture(eglImage);\n>   \n>   \t// Generate texture with filter semantics\n>   \tglEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);\n> @@ -273,8 +278,7 @@ void eGL::createInputTexture2D(eGLImage &eglImage, void *data)\n>   \n>   \tASSERT(tid_ == Thread::currentId());\n>   \n> -\tglActiveTexture(eglImage.texture_unit_);\n> -\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +\tactivateBindTexture(eglImage);\n>   \n>   \tswitch (eglImage.format_) {\n>   \tcase GL_R16F:\n\nAs noted on the previous commit, this is missing updateInputTexture2D(). \nI suggest to switch those commits around.\n\nApart from that:\n\nReviewed-by: Robert Mader <robert.mader@collabora.com>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2C14EC3306\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jun 2026 12:15:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CA4D7658A6;\n\tWed, 24 Jun 2026 14:15:54 +0200 (CEST)","from sender4-op-o12.zoho.com (sender4-op-o12.zoho.com\n\t[136.143.188.12])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7303B65718\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2026 14:15:53 +0200 (CEST)","by mx.zohomail.com with SMTPS id 1782303349209848.1119145686093;\n\tWed, 24 Jun 2026 05:15:49 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"S01dtk4U\"; \n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1782303350; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=GTOJSaCh0jP7pg0e4KGk5G3od6rWbdMZvhxZAJxibbBMtMekqYQGfG6RRK282Zt6wuPQwnr4ztnu0f1CqKytTDcXrwu44TNM75BSm5mtEBY1A7J0Wu39CFqqgPh7RUpGgckTnN5Zg1DWpUBWE2nYfi9qst32iUhEWBk1y5hhVs4=","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1782303350;\n\th=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc;\n\tbh=n/8SBjZNXzC8ucg7O1+47XX+1OmeCFAwIjh4MExtwkE=; \n\tb=O0rZ2+Km6PzhVQDoAMkDATPnnZdE/fKBab4rk7UXiQUpxMqI/vTK4ejyucnpS03wSMdsWs3mqDkhiBvYnWzevuGT+6i+CrCWIiQw3dZuUWTnJzj4SnnlHZJjGPvQZtSLju+B8h5JlDKhxofZKQUsHdPmccejqrf/taJl2TCh0Qg=","ARC-Authentication-Results":"i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1782303350;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc;\n\tbh=n/8SBjZNXzC8ucg7O1+47XX+1OmeCFAwIjh4MExtwkE=;\n\tb=S01dtk4UQaLOefEFFrsPQOZsCELYymYAKdnTRDvTvj5zyNiqj2mTekdgtdcX1d+X\n\tECgLgPg5ny8jJPNX/ePp3EREVpeGcLKn11EllVG6B2Un0ES9Y696Oz5E+etSR/90neu\n\trUQ6WYRxtZmammhWs3Z12k36LK1535D04v3uIHw8=","Message-ID":"<8655c7ad-ded5-4b59-bd93-0e6f93c974fe@collabora.com>","Date":"Wed, 24 Jun 2026 14:15:47 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 07/10] libcamera: egl: Add activateBindTexture","To":"libcamera-devel@lists.libcamera.org","References":"<20260624085849.873784-1-bryan.odonoghue@linaro.org>\n\t<20260624085849.873784-8-bryan.odonoghue@linaro.org>","Content-Language":"en-US, de-DE, en-GB","From":"Robert Mader <robert.mader@collabora.com>","In-Reply-To":"<20260624085849.873784-8-bryan.odonoghue@linaro.org>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":39448,"web_url":"https://patchwork.libcamera.org/comment/39448/","msgid":"<85echtlfjp.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-06-26T11:14:18","subject":"Re: [PATCH 07/10] libcamera: egl: Add activateBindTexture","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> When operating from a texture cache on dma-buf inputs we will no longer\n> create new textures nor attach those textures for dma-buf handles we have\n> already encountered.\n>\n> This means we will use the texture id associated with a given texture unit\n> to switch between one texture and another. The pages associated with the\n> texture will have been populated with new data by the CSI2 receiver. All we\n> will do is say to the GPU \"reuse this texture id\" aka zero-copy.\n>\n> However we must also activate and bind that texture for each loop. This\n> cost is small but necessary for zero-copy.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> ---\n>  include/libcamera/internal/egl.h |  1 +\n>  src/libcamera/egl.cpp            | 14 +++++++++-----\n>  2 files changed, 10 insertions(+), 5 deletions(-)\n>\n> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\n> index f1fa75d96..59fd52749 100644\n> --- a/include/libcamera/internal/egl.h\n> +++ b/include/libcamera/internal/egl.h\n> @@ -112,6 +112,7 @@ public:\n>  \tvoid createOutputTexture2D(eGLImage &eglImage);\n>  \n>  \tint attachTextureToFBO(eGLImage &eglImage);\n> +\tvoid activateBindTexture(eGLImage &eglImage);\n>  \n>  \tvoid pushEnv(std::vector<std::string> &shaderEnv, const char *str);\n>  \tvoid makeCurrent();\n> diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\n> index 6134b05f9..f26fe2e53 100644\n> --- a/src/libcamera/egl.cpp\n> +++ b/src/libcamera/egl.cpp\n> @@ -138,6 +138,13 @@ int eGL::attachTextureToFBO(eGLImage &eglImage)\n>  \treturn ret;\n>  }\n>  \n> +void eGL::activateBindTexture(eGLImage &eglImage)\n> +{\n> +\t// Bind texture unit and texture\n> +\tglActiveTexture(eglImage.texture_unit_);\n> +\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +}\n> +\n>  /**\n>   * \\brief Create a DMA-BUF backed 2D texture\n>   * \\param[in,out] eglImage EGL image to associate with the DMA-BUF\n> @@ -197,9 +204,7 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n>  \t\treturn -ENODEV;\n>  \t}\n>  \n> -\t// Bind texture unit and texture\n> -\tglActiveTexture(eglImage.texture_unit_);\n> -\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +\tactivateBindTexture(eglImage);\n>  \n>  \t// Generate texture with filter semantics\n>  \tglEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);\n> @@ -273,8 +278,7 @@ void eGL::createInputTexture2D(eGLImage &eglImage, void *data)\n>  \n>  \tASSERT(tid_ == Thread::currentId());\n>  \n> -\tglActiveTexture(eglImage.texture_unit_);\n> -\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n> +\tactivateBindTexture(eglImage);\n>  \n>  \tswitch (eglImage.format_) {\n>  \tcase GL_R16F:","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BC380BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Jun 2026 11:14:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 067DF658F2;\n\tFri, 26 Jun 2026 13:14:26 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42A1965878\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 13:14:24 +0200 (CEST)","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n\t[209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-202-xLF7ras3Muq1SHw4YkIrVw-1; Fri, 26 Jun 2026 07:14:22 -0400","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-4924725bec9so5181785e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 04:14:21 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-4.net.vodafone.cz. [77.48.47.4])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-49269071d05sm76602945e9.11.2026.06.26.04.14.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Jun 2026 04:14:19 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"dYJIf5zW\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1782472463;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=R10WL69cXs+74Ep4RwKicEtOBVb7tmhWsZ9CD9s+mU4=;\n\tb=dYJIf5zWqzrgCAMRtklAekhCbTP0ocx2EzJeccSK6jQ+cT2B8etnMQbc7m7qEYnFclgn4K\n\td++DKNRMb5uPNM3q3RgZlNMD3jUqiVljGRTvcxcmIsrlt5gY/52djKSi5tLZ0N9nHEs9N7\n\tkcV1bMXsYUMmtQIZq1jvOcmR5Ly7ZtA=","X-MC-Unique":"xLF7ras3Muq1SHw4YkIrVw-1","X-Mimecast-MFC-AGG-ID":"xLF7ras3Muq1SHw4YkIrVw_1782472461","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782472461; x=1783077261;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=R10WL69cXs+74Ep4RwKicEtOBVb7tmhWsZ9CD9s+mU4=;\n\tb=em0/VhNjmQBdPPMBJZFY/txBR+C5E0SjcLzFnxRDNs2ck25Zw9DRekN5xKK8KmyHpw\n\t5C6QNNeFXSfUA0f15byxWx9e/N0/6UWKdEEgBD3tjrcj3f+jSYGyRTPr8ePrg0oSaVYJ\n\tPFYPBdHcpoGzmkuKA/dWZvDMW2ra5ruoyA/7X230VKRdT9bpjSVqN5ccdMB7TDCm3+Xp\n\tSV5brkTl4EojB2M6o1WlP1y9p5FrGnszN1W1XgDYMCfZ41NFJ7wkb8Y+rfI11aJcGY+L\n\tTULXXrlkRfrOO0vHuB/SunaNo4A2UFB8kutoAm1eFMd/b8MTdCB6kDw+8DFH7i43tUhf\n\tI5Gw==","X-Gm-Message-State":"AOJu0Yw7FTzK4JGnc3u0BNUFsfsl3ZecdtI1/cfL10O5yooXyArwBPgK\n\tlLI0/RmeLPrFYwWK9YDeAeysFMJVZEy8iNBbfczOXHqqCjqX3O1C5uK10OayllWZVQ5f/LCMvoo\n\tXZZ3iO66LZYhOVJQD6hFWXHt9SDE7YM8vhDPoe8rrdbR/jDYf0PX9E6E3UoRykwWA55XYJGb1zt\n\t0=","X-Gm-Gg":"AfdE7clO7QIDTCjr1l6jD5cPdeJeE2QoUuX4eT0EJSkJWdC4sTV8sZRShPr3Qwvs0KB\n\t78ivG7etkKuCPlpKR+l7feEIpxhFvMP+scHoftopH42Ogr/3H+vMSTQZORsjJbnmyfwfGG/Xv9y\n\t1kMeluWeJmUVveRx9529vPOT7pNym8fcXSUIbzPb9Q66x02gvBkdH5oTDvID9HtI3Q2eUh2rL4m\n\t+Ix8kN1pf/zVcxIhepNp9A7VD9rnNaXp3pDGDm8X8lmgkAR4LyKXv+R68gbLC5vKhTzNDquhyJH\n\tu10v55twaHFFn3qZlsPwW5/0IqQFPatxr18JWQxk53u+0nZ3l083hz/xZ1QKePFa0shEZjLP+Cw\n\tGkWR2woxyQ0w+1h60StBeGSpf4eqs3WE8w2jcImn3Zr+LFc2sc4IbEiCOfHO0M7Zx","X-Received":["by 2002:a05:600c:41c1:b0:492:324d:e93f with SMTP id\n\t5b1f17b1804b1-4926fcac16cmr3388055e9.36.1782472460806; \n\tFri, 26 Jun 2026 04:14:20 -0700 (PDT)","by 2002:a05:600c:41c1:b0:492:324d:e93f with SMTP id\n\t5b1f17b1804b1-4926fcac16cmr3387775e9.36.1782472460327; \n\tFri, 26 Jun 2026 04:14:20 -0700 (PDT)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  pavel@ucw.cz","Subject":"Re: [PATCH 07/10] libcamera: egl: Add activateBindTexture","In-Reply-To":"<20260624085849.873784-8-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 24 Jun 2026 09:58:46 +0100\")","References":"<20260624085849.873784-1-bryan.odonoghue@linaro.org>\n\t<20260624085849.873784-8-bryan.odonoghue@linaro.org>","Date":"Fri, 26 Jun 2026 13:14:18 +0200","Message-ID":"<85echtlfjp.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"zBAmujoYSYWylsSUVB8I01RwwrlrXVUVyoqBxPlfAGU_1782472461","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]