[{"id":39463,"web_url":"https://patchwork.libcamera.org/comment/39463/","msgid":"<85wlvljxk8.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-06-26T12:28:07","subject":"Re: [PATCH v3 6/8] 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> Reviewed-by: Robert Mader <robert.mader@collabora.com>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  include/libcamera/internal/egl.h |  1 +\n>  src/libcamera/egl.cpp            | 24 +++++++++++++++++++-----\n>  2 files changed, 20 insertions(+), 5 deletions(-)\n>\n> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\n> index 9b679332c..e4d366abd 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 22f46e92a..4eabddcc7 100644\n> --- a/src/libcamera/egl.cpp\n> +++ b/src/libcamera/egl.cpp\n> @@ -138,6 +138,23 @@ int eGL::attachTextureToFBO(eGLImage &eglImage)\n>  \treturn ret;\n>  }\n>  \n> +/**\n> + * \\brief Activate a texture unit and bind a texture to that unit\n> + * \\param[in,out] eglImage EGL image containing data related to unit and texture id\n> + *\n> + * When we create a texture we will bind a texture unit and texture id so\n> + * we can set filters. For the case where a texture already exists thought\n\ns/thought/though/\n\nWith the typo fixed:\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> + * we need to activate and bind an existing texture. This helper function\n> + * facilitates both cases.\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 +214,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> @@ -270,8 +285,7 @@ void eGL::createTexture2D(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>  \t// Generate texture, bind, associate image to texture, configure, unbind\n>  \tglTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, eglImage.format_, GL_UNSIGNED_BYTE, data);","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 B5AA0C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Jun 2026 12:28:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD07365ED9;\n\tFri, 26 Jun 2026 14:28:14 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 82BA3658FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 14:28:13 +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-265-WsEi3CDtOMCDRCadhqfv-Q-1; Fri, 26 Jun 2026 08:28:10 -0400","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-49244130073so6929515e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 05:28:10 -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-49268fc0f32sm76946575e9.3.2026.06.26.05.28.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Jun 2026 05:28:07 -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=\"hAG7ts5w\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1782476892;\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=nppr5LSLU8dcIbt+BELwwLEI1ObxEzsLDcbg0YZ8H40=;\n\tb=hAG7ts5wlAWSSWo34jqDQRldMt6LMy7OrRIlAHETLgxjuYLBi98asBmoxv4ucIbGU5tSBB\n\tZL86zGsZ+MZK9w5SeeAvLqtw461H2WIsfwuXs+R9aSCTojtsVRaGzRcMIqw66E9JzKM1ws\n\tX2hp5+Hdf+PgDm0iX6fkMjTYFshdLFk=","X-MC-Unique":"WsEi3CDtOMCDRCadhqfv-Q-1","X-Mimecast-MFC-AGG-ID":"WsEi3CDtOMCDRCadhqfv-Q_1782476890","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782476890; x=1783081690;\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=nppr5LSLU8dcIbt+BELwwLEI1ObxEzsLDcbg0YZ8H40=;\n\tb=WnUjLaxHji93O7Dk0RDrcFtNfKShwmH4a9G6xdzNFv0w8uinJgAY976XSoOhyIwW2a\n\tA3zeY3j01WkbBRc3vo2jN0aTZV2Hz/glIeRZxUucRZR3NWDbQfpa7elrz2SC+7RZpmEG\n\tk++6bbFRVqvnqYfuNY1YVIE1aNcBSsENCmSnQWsNmz3BdDb/JKZtsP1RxCI2NHVfQKdn\n\tl1x2oH63RRBolqXlfKgE9kIj7gJZ8fjNCIRby6hUuGxsDay68ca7W/G8jn/kluGr45c8\n\tjaISX57BgX11jVNwGySayq4maI+jhnn3GCSGV2pqHD3YuhVWqhSEGK/JDIGl7pTx862p\n\toSqA==","X-Gm-Message-State":"AOJu0Yxhd0cbHs45u+s5bmI72Suvng20Bms12Yty0GMqSlLWLv+G8bxc\n\tjxOqvJbH116epb3qMCXSWhJD2RH3q6HWXRQwBNkz6Du5kkvcvwEwYq7+yI/zK0ipwK5VTW2DuBq\n\tJ04Ejuzs9qYtKGInULEuaAAQC4HKavO5a50Fey921hESUIqcF4gTnQvBApjDWFSGUktNWD16vQ2\n\tM=","X-Gm-Gg":"AfdE7cnL03bFLludZ2148KaJuEXkfp8Rm0p1oCE4tb6Q/+e+KIdrJt+/JwzuexSyoXw\n\ttzhHQ2Ed0YS03RRaC7JUCGdELh90Mw0AG830+zX4sgyPvE9kE0QAumM6vbv4sF+BGxqYLyDgfkQ\n\tZtKqd3ISROka6VfXOCu9jj1vOEjT/brXQUs9aF6pLVHjMXInbedwwunp7Hm43sa4UWNv9ZBKc5+\n\tz91aVp7BleJJPGD2PgTFNhsR0nxD6cCI1uQJ4Hp6B9BZ/3mCgb9t3iCJtMC9BdZYqDLHPxEvA2S\n\th7cz9dj8zr0Ds/rjp8j1b9xb4ls4yYRiQQyfYLSK8WNIZ49gmfyVIEQROIUdNpszNOjP5kAV0Nz\n\txh4bahw2VzQofA6JSAJIeZG8lblQZkDZ939YqwH4okBx0laIcBqNGdxd/AHlRo7Yb","X-Received":["by 2002:a05:600c:5486:b0:490:601f:d776 with SMTP id\n\t5b1f17b1804b1-492668628admr94565655e9.3.1782476889622; \n\tFri, 26 Jun 2026 05:28:09 -0700 (PDT)","by 2002:a05:600c:5486:b0:490:601f:d776 with SMTP id\n\t5b1f17b1804b1-492668628admr94565295e9.3.1782476889234; \n\tFri, 26 Jun 2026 05:28:09 -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,  Robert Mader\n\t<robert.mader@collabora.com>","Subject":"Re: [PATCH v3 6/8] libcamera: egl: Add activateBindTexture","In-Reply-To":"<20260626113325.3218045-7-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Fri, 26 Jun 2026 12:33:23 +0100\")","References":"<20260626113325.3218045-1-bryan.odonoghue@linaro.org>\n\t<20260626113325.3218045-7-bryan.odonoghue@linaro.org>","Date":"Fri, 26 Jun 2026 14:28:07 +0200","Message-ID":"<85wlvljxk8.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":"AuLSursCSU2FXWtAdBTssq0AS7ZPDJJYjrMlM7nm30E_1782476890","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>"}}]