[{"id":39466,"web_url":"https://patchwork.libcamera.org/comment/39466/","msgid":"<85o6gxjxft.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-06-26T12:30:46","subject":"Re: [PATCH v3 3/8] libcamera: egl: Add new helper attachTextureToFBO","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> This method does what it says on the tin. It attaches a texture to a\n> framebuffer object, splitting existing code into a helper function which we\n> will use in subsequent patches.\n>\n> Reviewed-by: Robert Mader <robert.mader@collabora.com>\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 |  2 ++\n>  src/libcamera/egl.cpp            | 42 +++++++++++++++++++++++---------\n>  2 files changed, 32 insertions(+), 12 deletions(-)\n>\n> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\n> index f7bfb28d4..4b0757afd 100644\n> --- a/include/libcamera/internal/egl.h\n> +++ b/include/libcamera/internal/egl.h\n> @@ -109,6 +109,8 @@ public:\n>  \tint createOutputDMABufTexture2D(eGLImage &eglImage, int fd);\n>  \tvoid createTexture2D(eGLImage &eglImage, void *data);\n>  \n> +\tint attachTextureToFBO(eGLImage &eglImage);\n> +\n>  \tvoid pushEnv(std::vector<std::string> &shaderEnv, const char *str);\n>  \tvoid makeCurrent();\n>  \n> diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\n> index f03abb8ae..e83e24606 100644\n> --- a/src/libcamera/egl.cpp\n> +++ b/src/libcamera/egl.cpp\n> @@ -112,6 +112,32 @@ void eGL::flushOutput()\n>  \tglFlush();\n>  }\n>  \n> +/**\n> + * \\brief Attach a texture to a frame-buffer-object\n> + *\n> + * \\param[in,out] eglImage EGL image containing texture to attach to FBO\n> + *\n> + * Helper function to make attachment of texture to FBO easy to reuse.\n> + *\n> + * \\return 0 on success, or -ENODEV on failure\n> + */\n> +int eGL::attachTextureToFBO(eGLImage &eglImage)\n> +{\n> +\tint ret = 0;\n> +\n> +\t// Generate a framebuffer from our texture direct to dma-buf handle buffer\n> +\tglBindFramebuffer(GL_FRAMEBUFFER, eglImage.fbo_);\n> +\tglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eglImage.texture_, 0);\n> +\n> +\tGLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n> +\tif (err != GL_FRAMEBUFFER_COMPLETE) {\n> +\t\tLOG(eGL, Error) << \"glFrameBufferTexture2D error \" << err;\n> +\t\tret = -ENODEV;\n> +\t}\n> +\n> +\treturn ret;\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> @@ -127,6 +153,7 @@ void eGL::flushOutput()\n>  int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n>  {\n>  \tEGLint drm_format;\n> +\tint ret = 0;\n>  \n>  \tASSERT(tid_ == Thread::currentId());\n>  \n> @@ -186,19 +213,10 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output)\n>  \tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n>  \tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n>  \n> -\tif (output) {\n> -\t\t// Generate a framebuffer from our texture direct to dma-buf handle buffer\n> -\t\tglBindFramebuffer(GL_FRAMEBUFFER, eglImage.fbo_);\n> -\t\tglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eglImage.texture_, 0);\n> +\tif (output)\n> +\t\tret = attachTextureToFBO(eglImage);\n>  \n> -\t\tGLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n> -\t\tif (err != GL_FRAMEBUFFER_COMPLETE) {\n> -\t\t\tLOG(eGL, Error) << \"glFrameBufferTexture2D error \" << err;\n> -\t\t\treturn -ENODEV;\n> -\t\t}\n> -\t}\n> -\n> -\treturn 0;\n> +\treturn ret;\n>  }\n>  \n>  /**","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 EB1D0BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Jun 2026 12:30:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C5A865ED9;\n\tFri, 26 Jun 2026 14:30:53 +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 3392C658FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 14:30:52 +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-88-UgTpJ0XEP7KbUhiXxhOqtg-1; Fri, 26 Jun 2026 08:30:48 -0400","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-4923d2f0dedso5128255e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 05:30:48 -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-49268fce5a8sm74226505e9.3.2026.06.26.05.30.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Jun 2026 05:30:46 -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=\"i2Un3f/s\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1782477051;\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=yeit9UUCgHkFPzod1P9xe9BO1sX6JjA6kmMJjcAQqgw=;\n\tb=i2Un3f/sfj+SOZLWgMqmU01syMh2bkczd/BaBLVDdqK473kCdOCujgFKrrzj9UXnFYPPL2\n\tCOhvlbY4DKh0rA454V2r4llTyGmngGxcRi+O6HOemfKSBWYbpcNKwGrCBcSyHh2mx7WX9o\n\tk6ri3sdbDkbHRT9fiFbmdR3m9lINlnU=","X-MC-Unique":"UgTpJ0XEP7KbUhiXxhOqtg-1","X-Mimecast-MFC-AGG-ID":"UgTpJ0XEP7KbUhiXxhOqtg_1782477048","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782477048; x=1783081848;\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=yeit9UUCgHkFPzod1P9xe9BO1sX6JjA6kmMJjcAQqgw=;\n\tb=bkievnH0XGXJS8KBRjCm0eqq3b66ubYCQ03XStWR/jqOAU1CjWTNGnenDI1Tb54aSh\n\t0N1zlFP1HHppMAbLUBZQt0rK8eNJ16TP5Kb/emDh1Ffo05aJEfkgMOfyWSlcxhnV8aka\n\tSrj3q08MVJqog+T999tZiFwJZFk8sEmzZSXUD9iYRovG/Kw+O+QSYSOWa0lKqSMQC8sa\n\t11ja25NKTVm1TQCOyNhGSo6wRZf9CBuicGMcIAnWKli6UycHoUWA9EgNyLIA+31Q574X\n\tgsMmXtaS3nTFymZbRjRG0cg8EpK6ePEQu/W5Ya2TxawXvbkuxYGV0L4oJJoF9Bbx43ur\n\tTJQg==","X-Gm-Message-State":"AOJu0YxtYIbtqApS5wHzRCSOPrK9lMigPS66R9Ey1YoQntWZgm19R557\n\tiQYuC37zmSHJYhhR4txZ4NZLvJHD5OSppYwNyT4QRITqDRmsMWv1hFkUFkyRCoYIQhl0XnvTJKz\n\tEbTas8Xz5PYt5//Epe3VjuGNDQPdi7oi+4bEXquZFf3qBNZJI/ax4tWLJga6S4pfZUuuv91nF2h\n\tI=","X-Gm-Gg":"AfdE7cnnpaCRRVA3L8xABey8TR+nOmn9fXS57gp5DcXTkJg2TD31Ya3dI7ZG+dn22eU\n\tbZ+NP32wpMXFrGKKy59vRGOE+vV9DtWM3oVks8JaStkoxGyQGbwkz/6WrK4bSl7qUkTyoW2Oa39\n\tjI9b0xHJOpbvh/FHY/DzbJ3yPACaEU1PPU9w6U+mIRnT0uixOJUz/DbrM7zpGeZS4MEf4ZLrmS8\n\tA+uD7CA9faI5c/tCw+36b9ApsNOXvHNPj7S7kzUZ1N/gF9ApS2K8NZNfm6E7By8vX+oCiKKo5dU\n\tj4SQ9xbmGzSjsENIl7FJwEhQ8Y9vD4YGalb0iAT4RPVBJU44UBCPxmFyDrxaH8Ide/7cVftfKqq\n\tKFGiUHU3KiHXBOToEiHYIgE8YjxQUS4u2fC/50URbj118QIfyQLQq3urULGTjhbLd","X-Received":["by 2002:a05:600c:5486:b0:490:601f:d776 with SMTP id\n\t5b1f17b1804b1-492668628admr94702135e9.3.1782477047687; \n\tFri, 26 Jun 2026 05:30:47 -0700 (PDT)","by 2002:a05:600c:5486:b0:490:601f:d776 with SMTP id\n\t5b1f17b1804b1-492668628admr94701645e9.3.1782477047257; \n\tFri, 26 Jun 2026 05:30:47 -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 3/8] libcamera: egl: Add new helper attachTextureToFBO","In-Reply-To":"<20260626113325.3218045-4-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Fri, 26 Jun 2026 12:33:20 +0100\")","References":"<20260626113325.3218045-1-bryan.odonoghue@linaro.org>\n\t<20260626113325.3218045-4-bryan.odonoghue@linaro.org>","Date":"Fri, 26 Jun 2026 14:30:46 +0200","Message-ID":"<85o6gxjxft.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":"U8DfzhduOY0JtHipnQQWQCSqeOSLwCPUBu2pv678azM_1782477048","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>"}}]