{"id":27032,"url":"https://patchwork.libcamera.org/api/patches/27032/?format=json","web_url":"https://patchwork.libcamera.org/patch/27032/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260624085849.873784-7-bryan.odonoghue@linaro.org>","date":"2026-06-24T08:58:45","name":"[06/10] libcamera: egl: Add updateInputTexture2D","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"12706a20c3922523b09e95b68d2a454983f11d8f","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/people/175/?format=json","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27032/mbox/","series":[{"id":6015,"url":"https://patchwork.libcamera.org/api/series/6015/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6015","date":"2026-06-24T08:58:39","name":"libcamera: software_isp: gpu: Add go faster stripes","version":1,"mbox":"https://patchwork.libcamera.org/series/6015/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27032/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27032/checks/","tags":{},"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 22562C3308\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jun 2026 08:59:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E4CB26588B;\n\tWed, 24 Jun 2026 10:59:15 +0200 (CEST)","from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D29336587B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2026 10:59:04 +0200 (CEST)","by mail-wm1-x32f.google.com with SMTP id\n\t5b1f17b1804b1-490ace40f4bso7840405e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2026 01:59:04 -0700 (PDT)","from inspiron14p-linux ([109.76.100.231])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-49261063d6esm25128375e9.2.2026.06.24.01.59.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 24 Jun 2026 01:59:04 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"IS69L03Z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1782291544; x=1782896344;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=flfSSfWZJxE4D8DY7Vyt/cuEj4PNcIobfHtmpG3tyRc=;\n\tb=IS69L03ZQmXDEUDs19Xt6b5Qq3KENt6XWeagSqXzIe4ZDuduPT6UZBa/P3XpsLI/Af\n\tLwtwQCFTQSAZdMApG5UYR55sJPDOBTA04EW452IsRNE5TW5cZarDHZZX5GztOJfaw8EA\n\tnkufge060HXnzZlbyUrM73sZ5n8aksm7bF808bhvXl42GK5LANYUTM1eJf4fXcyETLsr\n\t8lC1lLUjQi5UJ00iIeEU/ZPNLf+YY8L53cZ3Ul+qv7OrKSNZPiMwcELuS/CExQ4YT95N\n\tmaXo+ygr0LRxt5Ezf3d9ZJY/1ceK1SqyizJ5fY6gfOhyMlrWq4XhX2zy2Umx6QENEDHI\n\tgcog==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782291544; x=1782896344;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=flfSSfWZJxE4D8DY7Vyt/cuEj4PNcIobfHtmpG3tyRc=;\n\tb=apTUoEmpIPXiQABx3jeAsF1YYbNBqDyE3RNPGcAtBHIT26jQghYq0zG53Nwk2DVeD0\n\tCSWG2G/XuRHtfl8/lOgBJG2xNbCtjoL5Obo3j/8346gfLWQxZXn947BG7Ya+x+BojR5C\n\t++xmRrHtC7x1XhDYuDswXExV5LG2Pqx5LdHFN9LyvSLeAblCJ0btaQhqU6+WqxtrmmEe\n\tj1LHZmWvnppB12IGoKQ8ZNLejSmONcI4MwjUhNPQ/CGEPNAziAzI3LBSzT7yupa6KP0R\n\tlFNTgRmE4iR/7M4cmRpqC+f3uJV1dKKiW9TWm7f7G5ebTUXvu3rZk2se3Ld3XNtUUISu\n\tPFOQ==","X-Gm-Message-State":"AOJu0YzSUflvEz1d7xKUyWU0jZ2h/DB6G+UBZZ5nyD1oODOKcgom9dqu\n\tUQevEiiIKtkQ+QapkDZP5P9HNIptjhIKxjNfF86DW+KHO2/17n04j6Gquerc3AK80Ogkqm3uCME\n\tUj+qEaz8=","X-Gm-Gg":"AfdE7ckmaL6Dhfa+Af0W7e75gSXtnaRKnUy9TSDFoMQ8yS+CkkT5iaBlVxYY0L7nPzp\n\tw3pq0jWc/mlYyyaPzB3pi/QK5pU1suv8hhU/nijnY22KgzS5T3WedV6PT1BRoiNSd64WWrCyAop\n\tI2ol4LJ9H7nfWKKNXE785ziL7kf1gLdYsmRlaJH2jD3hB6GSP/Nil2wZyOkkk6WkVQQCyycy9WK\n\t7YsPsPDJ3/iuuNJpRRu8MMsQbfnjcoINo0O1GDd26EK4AEK0ySghxGbna/7vm2D2GPCsBLE76Km\n\tVF9oIK5NFZSacXcARqEvdtJAAPqiLSUPrqwUARgi/N/6mWpB90ymF7y7txWmOX93HizJz5nHEhc\n\tWndwHI6cHTUb8Pf6M2YKaXkNux1aPrlxQASVrWfBmASoA8Rnm2pTOFLuTRLiAxHbHDNXVcfI3Ea\n\tSTqdWt9EY6PQbO4X/el0n8ui9JwFD1","X-Received":"by 2002:a05:600d:8486:20b0:490:3c15:7146 with SMTP id\n\t5b1f17b1804b1-49260872a09mr23749255e9.19.1782291544372; \n\tWed, 24 Jun 2026 01:59:04 -0700 (PDT)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"bryan.odonoghue@linaro.org,\n\tpavel@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","Content-Transfer-Encoding":"8bit","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>"},"content":"The internet box tells me that glTextSubImage2D lets us update a texture's\ndata only, instead of recreating the texture and uploading data.\n\nThis is a smallish optimisation but we are hunting for every possible cycle\nand watt so add the routine as precursor to using it in-place of\ncreateTexture2D on every upload cycle.\n\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n include/libcamera/internal/egl.h           |  1 +\n src/libcamera/egl.cpp                      | 34 ++++++++++++++++++++++\n src/libcamera/software_isp/debayer_egl.cpp |  2 +-\n 3 files changed, 36 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\nindex b992baf25..f1fa75d96 100644\n--- a/include/libcamera/internal/egl.h\n+++ b/include/libcamera/internal/egl.h\n@@ -108,6 +108,7 @@ public:\n \tint createInputDMABufTexture2D(eGLImage &eglImage, int fd);\n \tint createOutputDMABufTexture2D(eGLImage &eglImage, int fd);\n \tvoid createInputTexture2D(eGLImage &eglImage, void *data);\n+\tvoid updateInputTexture2D(eGLImage &eglImage, void *data);\n \tvoid createOutputTexture2D(eGLImage &eglImage);\n \n \tint attachTextureToFBO(eGLImage &eglImage);\ndiff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\nindex 123653b58..6134b05f9 100644\n--- a/src/libcamera/egl.cpp\n+++ b/src/libcamera/egl.cpp\n@@ -345,6 +345,40 @@ bool eGL::isAvailable()\n \treturn true;\n }\n \n+/**\n+ * \\brief Update a 2D texture already created\n+ * \\param[in,out] eglImage EGL image to associate with the texture\n+ * \\param[data] Data to update the texture with\n+ *\n+ * Updates a 2D texture in VRAM.\n+ */\n+void eGL::updateInputTexture2D(eGLImage &eglImage, void *data)\n+{\n+\tGLenum format;\n+\tGLenum type = GL_UNSIGNED_BYTE;\n+\n+\tASSERT(tid_ == Thread::currentId());\n+\n+\tglActiveTexture(eglImage.texture_unit_);\n+\tglBindTexture(GL_TEXTURE_2D, eglImage.texture_);\n+\n+\tswitch (eglImage.format_) {\n+\tcase GL_R16F:\n+\t\tformat = GL_RED;\n+\t\ttype = GL_HALF_FLOAT;\n+\t\tbreak;\n+\tcase GL_RG8:\n+\t\tformat = GL_RG;\n+\t\tbreak;\n+\tcase GL_LUMINANCE:\n+\t\tformat = GL_LUMINANCE;\n+\t\tbreak;\n+\t}\n+\n+\t// Update an already exsiting texture\n+\tglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, eglImage.width_, eglImage.height_, format, type, data);\n+}\n+\n /**\n  * \\brief Create a 2D texture attached to an FBO for render-to-texture\n  * \\param[in,out] eglImage EGL image to associate with the texture\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 0ec2a98cf..cdceacf96 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -536,7 +536,7 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye\n \t\t\tLOG(Debayer, Error) << \"mmap-ing buffer(s) failed\";\n \t\t\treturn -ENODEV;\n \t\t}\n-\t\tegl_.createTexture2D(*eglImageBayerIn_, inMapped->value().planes()[0].data());\n+\t\tegl_.createInputTexture2D(*eglImageBayerIn_, inMapped->value().planes()[0].data());\n \t}\n \n \t/* Generate the output render framebuffer as render to texture */\n","prefixes":["06/10"]}