{"id":27052,"url":"https://patchwork.libcamera.org/api/patches/27052/?format=json","web_url":"https://patchwork.libcamera.org/patch/27052/","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":"<20260626113325.3218045-6-bryan.odonoghue@linaro.org>","date":"2026-06-26T11:33:22","name":"[v3,5/8] libcamera: egl: Add updateTexture2D","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4de234f1f0e37a9844c3c303b7302756ff8eb884","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/27052/mbox/","series":[{"id":6020,"url":"https://patchwork.libcamera.org/api/series/6020/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6020","date":"2026-06-26T11:33:17","name":"libcamera: software_isp: gpu: Add go faster stripes","version":3,"mbox":"https://patchwork.libcamera.org/series/6020/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27052/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27052/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 D2C6BC3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Jun 2026 11:33:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D5A065EE0;\n\tFri, 26 Jun 2026 13:33:47 +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 88F08658FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 13:33:43 +0200 (CEST)","by mail-wm1-x32f.google.com with SMTP id\n\t5b1f17b1804b1-490cf3000f0so8768165e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2026 04:33:43 -0700 (PDT)","from inspiron14p-linux ([109.76.78.98])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-49268fe31b0sm79265985e9.4.2026.06.26.04.33.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Jun 2026 04:33:42 -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=\"Ax9NxrNd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1782473623; x=1783078423;\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=oKZ71QaBtM6ROt/Onecsm43QmMC4gfI0FGbAVT9Ibl4=;\n\tb=Ax9NxrNdFqHSFAoeZ4lz5J1I5KM211xOLkB0bf9nNDtlxGXqsSP5SYEEjYBqgyuY8X\n\ttH0Scn4FFHMFIyfvFnvqYDVwLIYoaH6sL3GB5yG6h52I9sfzuLlLG7bK1Eef4N/Nk8U2\n\t4/9EN5IlP45TtnsxxUNUr7ebw1fnmF+UpHWAM6gJWtzF8aF4duIe2VqiZAxBakTdXgaM\n\tyxYVh9bO0bGQkattzT6cCnSVfJjmTquINF3p0JHGHzFTqZgHjQiDJraTaZ0dkcArObSz\n\t197vzF8og40n2691Tyqk2wvbu2OjH7Fh7H/RwJHeK7cRv1uN1klAo7vx9kHZ/hBV3oEy\n\tqRAQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782473623; x=1783078423;\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=oKZ71QaBtM6ROt/Onecsm43QmMC4gfI0FGbAVT9Ibl4=;\n\tb=aNy2Ybth2NtiBrZawTGKMJCYu9UYYscIUpomKQk55pgjLU2S9rFAs7mqOipIYAGNq+\n\tY6wKs9UhNEOVUx0yHqGuL4AyQye770nMFSbJNpuo5KszQfKF/pARn+4tmfx0pVpu906h\n\tlJAxdL0F7AkxVOgIu8jC0podbRGFfL5LK3TBnHHOyehbwQkUk3SEFW6djNPlFStEZU1n\n\txCUpxvNnK7KMDGkhw0dksMFNOWXCUCD8gwkebbryu0O3/mCC4QfZjWVpfpzMGptFIG15\n\tz1XUWqWJuTUPPEK5VUoHvqES0RyYdIRycAtZmB1469eybp5ScrWsGHcn6xlwo1szndDf\n\tObAw==","X-Gm-Message-State":"AOJu0YwKtEwGWz//1Pot9KrsX2S+6w9g5I2SbgbDxm/XMOBgS+kucfXO\n\tMU32x2AznD6qCzZnohmpisG0DFO9XoZdYqHigU3Kx0PowNrBEJ8mdVOjHyy/xj/hjxNoQi4PaUi\n\tAMlmz1HM=","X-Gm-Gg":"AfdE7ckNAsMNlSAI/nq3AxhTRs5goabZ+7GhMzaXqBbd10PznrI0YU4gOM410itk3iu\n\t6ICU/QPveVqfBFLqLX1SpXMPYpoMlzztru9SIK30MXJe13r8Vc/OZwYO+dp4b9yK6w+580n4Ly+\n\toipHUR9wTNtspXexqa9ja0XKpNcVjLeAJxb+LPVuYdErA35Lr17fyR9nhT1hMojYnSAKPbQdpyv\n\tcdMaA1Mk8j5XOTZu6NvLV0Ehci19kYX4+1SOGm9brGDnNbA/a59MCXjn+1WSPneS2xNXWKoc2HO\n\tBxl+LgfRLGSPd058qsj1Akdf3LjIB6Jkp8Wr93vVvQHa5iQMdT7xG1sOx7nv4em15BV9FojABSE\n\tpaS4wwP8V1YL3a1q6ALp1+8grrUrusm7xgYaxGoOB08Wq4D/4B90YjntRCg8FpKOkHurcrQmdD0\n\tQjiLhAwBiNw63ao9JY1nK6ZIoqazN7jlQ1Hjkg","X-Received":"by 2002:a05:600c:1d0e:b0:492:63ff:d577 with SMTP id\n\t5b1f17b1804b1-49266899cf0mr97714435e9.27.1782473623005; \n\tFri, 26 Jun 2026 04:33:43 -0700 (PDT)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"bryan.odonoghue@linaro.org, pavel@ucw.cz,\n\tRobert Mader <robert.mader@collabora.com>","Subject":"[PATCH v3 5/8] libcamera: egl: Add updateTexture2D","Date":"Fri, 26 Jun 2026 12:33:22 +0100","Message-ID":"<20260626113325.3218045-6-bryan.odonoghue@linaro.org>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260626113325.3218045-1-bryan.odonoghue@linaro.org>","References":"<20260626113325.3218045-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\nReviewed-by: Robert Mader <robert.mader@collabora.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n include/libcamera/internal/egl.h |  1 +\n src/libcamera/egl.cpp            | 35 ++++++++++++++++++++++++++++++++\n 2 files changed, 36 insertions(+)","diff":"diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\nindex e24a726dc..9b679332c 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 createTexture2D(eGLImage &eglImage, void *data);\n+\tvoid updateTexture2D(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 8e8d61813..22f46e92a 100644\n--- a/src/libcamera/egl.cpp\n+++ b/src/libcamera/egl.cpp\n@@ -329,6 +329,41 @@ 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::updateTexture2D(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+\tdefault:\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\n","prefixes":["v3","5/8"]}