From patchwork Wed Jun 24 08:58:45 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: 27032 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 22562C3308 for ; Wed, 24 Jun 2026 08:59:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E4CB26588B; Wed, 24 Jun 2026 10:59:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IS69L03Z"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D29336587B for ; Wed, 24 Jun 2026 10:59:04 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-490ace40f4bso7840405e9.3 for ; Wed, 24 Jun 2026 01:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1782291544; x=1782896344; 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=flfSSfWZJxE4D8DY7Vyt/cuEj4PNcIobfHtmpG3tyRc=; b=IS69L03ZQmXDEUDs19Xt6b5Qq3KENt6XWeagSqXzIe4ZDuduPT6UZBa/P3XpsLI/Af LwtwQCFTQSAZdMApG5UYR55sJPDOBTA04EW452IsRNE5TW5cZarDHZZX5GztOJfaw8EA nkufge060HXnzZlbyUrM73sZ5n8aksm7bF808bhvXl42GK5LANYUTM1eJf4fXcyETLsr 8lC1lLUjQi5UJ00iIeEU/ZPNLf+YY8L53cZ3Ul+qv7OrKSNZPiMwcELuS/CExQ4YT95N maXo+ygr0LRxt5Ezf3d9ZJY/1ceK1SqyizJ5fY6gfOhyMlrWq4XhX2zy2Umx6QENEDHI gcog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782291544; x=1782896344; 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=flfSSfWZJxE4D8DY7Vyt/cuEj4PNcIobfHtmpG3tyRc=; b=apTUoEmpIPXiQABx3jeAsF1YYbNBqDyE3RNPGcAtBHIT26jQghYq0zG53Nwk2DVeD0 CSWG2G/XuRHtfl8/lOgBJG2xNbCtjoL5Obo3j/8346gfLWQxZXn947BG7Ya+x+BojR5C ++xmRrHtC7x1XhDYuDswXExV5LG2Pqx5LdHFN9LyvSLeAblCJ0btaQhqU6+WqxtrmmEe j1LHZmWvnppB12IGoKQ8ZNLejSmONcI4MwjUhNPQ/CGEPNAziAzI3LBSzT7yupa6KP0R lFNTgRmE4iR/7M4cmRpqC+f3uJV1dKKiW9TWm7f7G5ebTUXvu3rZk2se3Ld3XNtUUISu PFOQ== X-Gm-Message-State: AOJu0YzSUflvEz1d7xKUyWU0jZ2h/DB6G+UBZZ5nyD1oODOKcgom9dqu UQevEiiIKtkQ+QapkDZP5P9HNIptjhIKxjNfF86DW+KHO2/17n04j6Gquerc3AK80Ogkqm3uCME Uj+qEaz8= X-Gm-Gg: AfdE7ckmaL6Dhfa+Af0W7e75gSXtnaRKnUy9TSDFoMQ8yS+CkkT5iaBlVxYY0L7nPzp w3pq0jWc/mlYyyaPzB3pi/QK5pU1suv8hhU/nijnY22KgzS5T3WedV6PT1BRoiNSd64WWrCyAop I2ol4LJ9H7nfWKKNXE785ziL7kf1gLdYsmRlaJH2jD3hB6GSP/Nil2wZyOkkk6WkVQQCyycy9WK 7YsPsPDJ3/iuuNJpRRu8MMsQbfnjcoINo0O1GDd26EK4AEK0ySghxGbna/7vm2D2GPCsBLE76Km VF9oIK5NFZSacXcARqEvdtJAAPqiLSUPrqwUARgi/N/6mWpB90ymF7y7txWmOX93HizJz5nHEhc WndwHI6cHTUb8Pf6M2YKaXkNux1aPrlxQASVrWfBmASoA8Rnm2pTOFLuTRLiAxHbHDNXVcfI3Ea STqdWt9EY6PQbO4X/el0n8ui9JwFD1 X-Received: by 2002:a05:600d:8486:20b0:490:3c15:7146 with SMTP id 5b1f17b1804b1-49260872a09mr23749255e9.19.1782291544372; Wed, 24 Jun 2026 01:59:04 -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.03 (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 06/10] libcamera: egl: Add updateInputTexture2D Date: Wed, 24 Jun 2026 09:58:45 +0100 Message-ID: <20260624085849.873784-7-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" The internet box tells me that glTextSubImage2D lets us update a texture's data only, instead of recreating the texture and uploading data. This is a smallish optimisation but we are hunting for every possible cycle and watt so add the routine as precursor to using it in-place of createTexture2D on every upload cycle. Signed-off-by: Bryan O'Donoghue Reviewed-by: Robert Mader --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 34 ++++++++++++++++++++++ src/libcamera/software_isp/debayer_egl.cpp | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index b992baf25..f1fa75d96 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -108,6 +108,7 @@ public: int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createInputTexture2D(eGLImage &eglImage, void *data); + void updateInputTexture2D(eGLImage &eglImage, void *data); void createOutputTexture2D(eGLImage &eglImage); int attachTextureToFBO(eGLImage &eglImage); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 123653b58..6134b05f9 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -345,6 +345,40 @@ bool eGL::isAvailable() return true; } +/** + * \brief Update a 2D texture already created + * \param[in,out] eglImage EGL image to associate with the texture + * \param[data] Data to update the texture with + * + * Updates a 2D texture in VRAM. + */ +void eGL::updateInputTexture2D(eGLImage &eglImage, void *data) +{ + GLenum format; + GLenum type = GL_UNSIGNED_BYTE; + + ASSERT(tid_ == Thread::currentId()); + + glActiveTexture(eglImage.texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage.texture_); + + switch (eglImage.format_) { + case GL_R16F: + format = GL_RED; + type = GL_HALF_FLOAT; + break; + case GL_RG8: + format = GL_RG; + break; + case GL_LUMINANCE: + format = GL_LUMINANCE; + break; + } + + // Update an already exsiting texture + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, eglImage.width_, eglImage.height_, format, type, data); +} + /** * \brief Create a 2D texture attached to an FBO for render-to-texture * \param[in,out] eglImage EGL image to associate with the texture diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 0ec2a98cf..cdceacf96 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -536,7 +536,7 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye LOG(Debayer, Error) << "mmap-ing buffer(s) failed"; return -ENODEV; } - egl_.createTexture2D(*eglImageBayerIn_, inMapped->value().planes()[0].data()); + egl_.createInputTexture2D(*eglImageBayerIn_, inMapped->value().planes()[0].data()); } /* Generate the output render framebuffer as render to texture */