From patchwork Mon Jul 6 11:38:58 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: 27250 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 CB512C330A for ; Mon, 6 Jul 2026 11:39:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91E9966030; Mon, 6 Jul 2026 13:39:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Mnreu3TL"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CFBA6600A for ; Mon, 6 Jul 2026 13:39:15 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-4720f3bf164so1931706f8f.1 for ; Mon, 06 Jul 2026 04:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783337955; x=1783942755; 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=/B6GIAyW48ah9/xcsZgbpJ85k5AYURJJX6RMJWKLdbo=; b=Mnreu3TLiDs8ZvIuEMr6OSDGSkTCkLGdpQ3IIQUtPpuhCrFyxgok0DzMma9wVhy8Vs JBaeieSx1cjeKeW42dYqZ96xILBraSjGV9sRrRSOosADd4A4f2GRbfVVXrKRWHUzV+XD N3Fwzv5nGfbbWDoIT3Hy0ODjdZj16l26S2qUX2xOCxke2dxdsOE6wcshMZt1ODf4T7BC r4YfZhRVbD836t4yMFXtigcrgbAZTDAIkI1/11eGc0gAkiAFa3f22LqBlnBUKi9GTBV0 c6d/FasqvDLV9YEoq/WRGYdUxoN3iwvjB0YZ3EE4oOrZOYZfkSB+0yPI+xCpY9OjlJAi rzug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783337955; x=1783942755; 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=/B6GIAyW48ah9/xcsZgbpJ85k5AYURJJX6RMJWKLdbo=; b=N/TFLUAMX1Qc0HtYWR/1tnnNuAPojaxLRzuVgVEFv6Q0NFYgNDk3ED7vVKgsDfmZm/ ed3zKu3Y0FBey3GU50pZur+DFnfjTZO0dCIehUJwjvb3Zogc99Hzic/ylvqGV3hzEX4f P40nuedEvmvRnwzSr7ldeZ8nGETFDrDalLzxYciKlv1iC+RA0Fi7XtPPhOp1VC54j97/ fEr7/XI2eaWTy8uvQM9iCXGepISW5QE4C3vOxKVAFoheEZFAXi2CwKrMOrePO2KnLtO2 T//8sn/2AuMxS68wwbc8/tmyQj21XiV3Viep+a7NozONlkdyO6tS69VWdp7adkwl3gyE 0IOw== X-Gm-Message-State: AOJu0Yzyr83SCbmaAdBlkIMz3cbtuS2Cw39TkIPwb8vaQSdAPMFD5zbW kjS2zD8TgdUMimjnK3pNy01O4erwQIqpJs0PPaVuUr8SJp03zGg4yda00tMi0w29tiBLtLbQBJa M+Gk0 X-Gm-Gg: AfdE7cnsInnuJLHWdmekGQxXuxJBp3EWwQEciYJK+KfYAtjM2qSUpkDrA8xuQSXEYof RDYQkxqpy8zb92+2V165Sx3PnXj6fy5SWv/5IDyKzrS9R/SVk/12xDcVurlpUQUqAUq2H1DfWVz ELbxDEEbctCmhS+eJbYzfpd0e44tgUyAxFryZroGFqdGMmqya5Q7PKzjJ4zzhyg6xNx5pjcy5kd tkl3z4JyyLH4O+jt3gkFCNXBz4vp1ybNRlPpiavsqH+H4cy4Hlff3QaY0poixibiXvN0KnhntOF irR0Vv4CKzOin0YzlX8PkRLHZ++LSOoJj1F+3qySPU3QDbbJWP9LrMAB1qOY3/mMjJFfNYiQsfp slP4DJVr4HGzzcRapxv17ziv34TbRUSx8EHCuZkWudrDZ0sOYXf7EfgE57O3X5vU6+5KJMq/iho +p6WPhCXrmzlKpBXLrQ2vzozSL4YSd X-Received: by 2002:adf:f84e:0:b0:474:a0a3:df0c with SMTP id ffacd0b85a97d-47de6173bb0mr369642f8f.10.1783337955185; Mon, 06 Jul 2026 04:39:15 -0700 (PDT) Received: from inspiron14p-linux ([109.77.44.220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9de1e6ccsm24796084f8f.5.2026.07.06.04.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 04:39:14 -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 v5 5/7] libcamera: egl: Add updateTexture2D Date: Mon, 6 Jul 2026 12:38:58 +0100 Message-ID: <20260706113900.2530549-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260706113900.2530549-1-bryan.odonoghue@linaro.org> References: <20260706113900.2530549-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 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 64196213a..1e31d490b 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 0726b63f2..7ec7a654d 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -343,6 +343,23 @@ 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()); + + activateBindTexture(eglImage); + + // 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