From patchwork Mon Jul 6 11:01: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: 27241 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 830A6C3318 for ; Mon, 6 Jul 2026 11:01:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA4666602B; Mon, 6 Jul 2026 13:01:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EtouIF7O"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A09AD66007 for ; Mon, 6 Jul 2026 13:01:34 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-475881b9a4bso2493008f8f.3 for ; Mon, 06 Jul 2026 04:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783335694; x=1783940494; 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:content-type; bh=jm28t3W8seSh/4fiCoMetv0uEp/689cCMRBSitfqhw4=; b=EtouIF7O87jh5QNQGt+CYjmDdcWrUDmeHaWz/ajnZjcj4lenawcA/WS7/3T/ifw32U KEuI6Vo+GR3R5tyHjHuTZv5tsZbqwtNUYZJJY9xncrrpy9D7yySJMIJ+1Mmd3MdpBBPO X5UVth0oAqrtmEZOdBiIoMzQGz8Rog1nuouluR4SZx1snhCtlMm9qvIVIcRD1TfxOKb1 Mdk0gN2Zb6jOLPqtONpXGFUOiDHlmVTxhEizfETvewAwWhZ6iFgQwOL8b7zHf/ih5NDe wLKS8vpS8TnBN0R7cfcAEzwj4gYUBA/JFenIbB8UjXuUsen+WSku8vs8bCP9g+qKPZwY ottg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783335694; x=1783940494; 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:content-type; bh=jm28t3W8seSh/4fiCoMetv0uEp/689cCMRBSitfqhw4=; b=p9qIzDsV/dz4Lvk58b78tjPgUB78+SDJs2izZrbT0XL+/R237JWYE4VSC2kuBwMIas j+a77mj9pSF8JiPLvaL2A5Z+Cki2beZjMYiVfNTHzANYumHlabul2Kkyx1678OzuBRdp pk8zWItB8wtbw9DD+Zqkzwj2xfWL9ik5aEqUz6A3N1OEY3H7oLUValqfYVc1Ay04fhgm kqCnpmUM3edXGcSvGRvh16xuX4LUoDCb/I+4l8FPAkqkGfWf34Rw55D72i6KorYi1VGd /CSJEo8oY+OjHKH9/qIfZBo0MfNPB4e4nFftW/9IOfiHRmYKrVBbl7lW6QiHZTrPwntY rghw== X-Gm-Message-State: AOJu0YzdSj6B4ajs9s3EPFA7BMoMRTr4IVWzGJEqJJQSPkSx52XbjQuK r+xCvFZWhkq/Yc/0Ie9CcM7Ic+dhBULSRAJYOHL1sKQaHL8abn4LSA242zLcLxj0/+p8cnXQW/s 6zQHZ X-Gm-Gg: AfdE7cnSin8wDkyM1x8Lu9WtUBwcvaXUylFAsCKh7kqutlnLp1PzYY/9OQC/7YFBvOM uKmIGs3eIhLqJd8/6vr7VmllbyupqRkdbtBmLG1Bb1plu9Y9rW7lSKdTlpADxIxSUhnEo82VBYw Aw3frNtH6AZz2SQ5/aURWnlvEbHuw5neXWmG5QdOEL+p9nn8332Jq5tVwGHuFhO6MKb5NZ5e02c NBUIH8rBx7mSyXxPOR+Q9tny46Ps171WUocyM7BKBpRgghSJP5Ng68hsyoqnhXtT6cYTa8cNmxw IY3pceNr9yjgYqwz0DYwUl1u3Rp27bV2UKJ5HqoPiz5cwJWS4T+U0PFsPkzMHwkvE/430fuhcTN hruYdQjHlw3Hdw+ubhvY+xPtQ+0jQ1ZXToc9dyW8mwcN7gIINhZ56VLXstDRS9mMd0kiWoabXKT VpfW+eGbe7svnscqgmPFmbskfRu2fq X-Received: by 2002:adf:f3c6:0:b0:460:1301:dec6 with SMTP id ffacd0b85a97d-47aab57d2d8mr7214883f8f.10.1783335694131; Mon, 06 Jul 2026 04:01:34 -0700 (PDT) Received: from inspiron14p-linux ([109.77.44.220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47aa0960634sm25190846f8f.26.2026.07.06.04.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 04:01:33 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz, Robert Mader , Milan Zamazal Subject: [PATCH v4 4/7] libcamera: egl: Add updateTexture2D Date: Mon, 6 Jul 2026 12:01:17 +0100 Message-ID: <20260706110120.2509826-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260706110120.2509826-1-bryan.odonoghue@linaro.org> References: <20260706110120.2509826-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. Reviewed-by: Robert Mader Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 1955d09c5..9b4261c55 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 createTexture2D(eGLImage &eglImage, void *data); + void updateTexture2D(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 c1b5514b6..b91f9096a 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -329,6 +329,24 @@ 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::updateTexture2D(eGLImage &eglImage, void *data) +{ + ASSERT(tid_ == Thread::currentId()); + + glActiveTexture(eglImage.texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage.texture_); + + // Update an already existing texture + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, eglImage.width_, eglImage.height_, eglImage.format_, GL_UNSIGNED_BYTE, 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