From patchwork Thu Jun 18 12:22:17 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: 26937 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 D31FFC3302 for ; Thu, 18 Jun 2026 12:23:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1B7D62B41; Thu, 18 Jun 2026 14:23:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ko3rLRBk"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A0C65629AB for ; Thu, 18 Jun 2026 14:23:00 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49230a567a9so4339415e9.0 for ; Thu, 18 Jun 2026 05:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781785380; x=1782390180; 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=vRWhBE/nddyiuyjIUBDoioByaHPkqc4AcaoqAb/P8s0=; b=Ko3rLRBkLH2LospBm+bTfOQ4pCyPMgz5ZES2WRbTUY5Yuklc9TmttFEEkuhUVY+wBm bVBDtqyJl12nu55JnaZzIXo/DvLioRwIIUnaWtlv5bo9fUj8+D57vaAVYZYH7IOb6onw O6j7atuCjTJ2R6InFC8JFIiiZsH0laeCd5fcWO57BFIZAGp2JVRz4Awjkj5oC8790yFI 1KKNgsMnhUlOr1WjwBVLoeiUjfD5SiZARsGe+zcwABr2t7jogaRuJF1cNI6IdC8F7Bvv 54l9L86OZ9peZ4Czyrp7f9R8DzRPMYeDxeATV16f2tfwTzPz2AeJlo9nGtiqjSb4VAhC 36bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781785380; x=1782390180; 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=vRWhBE/nddyiuyjIUBDoioByaHPkqc4AcaoqAb/P8s0=; b=fRzYRGJb8OomdLKa5OWlfANVj3Xzks/5Rq1OTTm+F4Yij+wAPFsxuuecXm8tQSXLm4 UrBhoSrLsk5NNS3mxZgwkw7VKElMIn1HhH/K8zYLoq/0z2RB311u3cmZfOUk31R+fUA4 h9FMXdPsUtW+7KJsGMSN+AIa5yhbwEsGO0IoBpgnVUZxbCrnYIIAMB+FkZw3g30Fuf8t grnIPPqWW1xji7h+hUovmG0E9GtfY9RQnXaYVsKA9YGKCQ7HG+ft2BqCGXEa4ItSyAdq ddQ9ygGQQY6BDtpVOgrpnl69lhMalrdqN6wJTM40UFsIyPPw6pxiEvtL38jaCeEOZ8uB W/Wg== X-Gm-Message-State: AOJu0YwSCLzmZqkLMnoYaYa2qenpk+5Mvt+AHUKbfWkfNiYySre43sux hFXLgeQKeBPWE34Fjka4xKoptTTIlzm1H1E3mPtjsvca3c3RLtl/3B0TvpHEd4AHBWflDTKWh1n EVK8kvqA= X-Gm-Gg: AfdE7cmp55t0OXLGbk7NIZhXkj9meR7AUmDzy5WbWpGFre/r+RKvkJI+UFtxvecruKb w1DzQEOQR1O8Z26FZ40vdqrfqhlo7i9tMIBBwMZjendvtsUypMdyDUoHJd6TpzNxYl3leO4a8YB EmfOGw0qRClHHQ+g/kM4r0qhmIrW3tNfR9yo6AWMn4bclWUFZhFsviAGK3FcCqUIZNY0bEwrbCP CSA+nLCqMelVcpTNGdZRr45S5OcdsbFK7VQhbP/2aPtVRGWWPPAIgt/AKAQHANQ2zdB4Obre2wo qkNc0SbjtVrwCu8syOGe6oMjyv2149TaDKmLBz9G5SjMlDMjGsPFUiyamNlr/HyKrRlEKND69P7 SEfjIwWh+RqI+cAPN75SgybcTG2ouOo8Owj0lMvZH444VRsKZ2Hc816oTndO2587r8veUPMXfOG kZ6iEBaVEhx7P2jxoG90ehqMEWCbc2 X-Received: by 2002:a05:600c:8217:b0:492:3754:15f2 with SMTP id 5b1f17b1804b1-4923754161dmr77053665e9.32.1781785380068; Thu, 18 Jun 2026 05:23:00 -0700 (PDT) Received: from inspiron14p-linux ([109.76.144.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a4easm275198015e9.3.2026.06.18.05.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 05:22:59 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz Subject: [PATCH 04/30] libcamera: software_isp: egl: Add new helper attachTextureToFBO Date: Thu, 18 Jun 2026 13:22:17 +0100 Message-ID: <20260618122245.946138-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618122245.946138-1-bryan.odonoghue@linaro.org> References: <20260618122245.946138-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" This method does what it says on the tin. It attaches a texture to a framebuffer object, splitting existing code into a helper function which we will use in subsequent patches. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/egl.h | 2 ++ src/libcamera/egl.cpp | 42 +++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 57f90d93f..d88617afa 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -108,6 +108,8 @@ public: int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createTexture2D(eGLImage &eglImage, void *data); + int attachTextureToFBO(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 c185bb7ad..3ea694d7c 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -112,6 +112,32 @@ void eGL::flushOutput() glFlush(); } +/** + * \brief Attach a texture to a frame-buffer-object + * + * \param[in,out] eglImage EGL image containing texture to attach to FBO + * + * Helper function to make attachment of texture to FBO easy to reuse. + * + * \return 0 on success, or -ENODEV on failure + */ +int eGL::attachTextureToFBO(eGLImage &eglImage) +{ + int ret = 0; + + // Generate a framebuffer from our texture direct to dma-buf handle buffer + glBindFramebuffer(GL_FRAMEBUFFER, eglImage.fbo_); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eglImage.texture_, 0); + + GLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (err != GL_FRAMEBUFFER_COMPLETE) { + LOG(eGL, Error) << "glFrameBufferTexture2D error " << err; + ret = -ENODEV; + } + + return ret; +} + /** * \brief Create a DMA-BUF backed 2D texture * \param[in,out] eglImage EGL image to associate with the DMA-BUF @@ -127,6 +153,7 @@ void eGL::flushOutput() int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) { EGLint drm_format; + int ret; ASSERT(tid_ == Thread::currentId()); @@ -186,19 +213,10 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (output) { - // Generate a framebuffer from our texture direct to dma-buf handle buffer - glBindFramebuffer(GL_FRAMEBUFFER, eglImage.fbo_); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eglImage.texture_, 0); + if (output) + ret = attachTextureToFBO(eglImage); - GLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER); - if (err != GL_FRAMEBUFFER_COMPLETE) { - LOG(eGL, Error) << "glFrameBufferTexture2D error " << err; - return -ENODEV; - } - } - - return 0; + return ret; } /**