From patchwork Mon Jul 6 22:22:44 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: 27258 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 328CAC3308 for ; Mon, 6 Jul 2026 22:23:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB83F6605B; Tue, 7 Jul 2026 00:23:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KttMJ/q5"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8278F6604F for ; Tue, 7 Jul 2026 00:23:02 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so22524115e9.1 for ; Mon, 06 Jul 2026 15:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783376582; x=1783981382; 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=/B6GIAyW48ah9/xcsZgbpJ85k5AYURJJX6RMJWKLdbo=; b=KttMJ/q54CQS+UqWtZ3729Cuc74I1UkdmwqUz6yvdvOqFDjJ0biZ8PfWNfbGo8Zf2O lOOgi6wYtFznRUAjSxK7T4RV6lxXdmAak143t47pjeVzNk2ysHsXWkQtEv6xfwLa+C9n 4+QTXhroia7kTWs6bJzhh7vHtkMAyykYOEYuinXt+38Ks0SaRVgcsiQbfbSmuU7VbREu Zk5Gd+RO//qNNjPQFlj/I8a6BZ66bWcroJ3KfZxwaaXWBtuf+qOxKYtx9CUd0IS4h5Lo OSREU3c1ALAaYjKIROJlTGeVSA2ZmkOOw7AYuHz/v8pYSdgBCKZ3OAJRcz30qt1xufP+ TqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783376582; x=1783981382; 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=/B6GIAyW48ah9/xcsZgbpJ85k5AYURJJX6RMJWKLdbo=; b=N7fQpVHgMP86lWhFAGXgXY4PrYrHWOVA5i+BbPolYj/RdERcrEsN3qvYwdZbYAIdek KTX68a5XcrdTXY/zQ9fZ1ZWSatVvDiE+D9PjHviZ8uxI9R7cPjsQEgykG5oJpKpIPHMB UIR7o8tw0h6Y1C5blXErVqJme1Wdll5/Kzp48ir2/FqnsKqZ6VGkvCaeTNAJE4kJ9ULt FywULVDNaflVxHJ4d8sJZXwK1uzIyng/d+t3+s+3G1Oq+FHYUx/9U9Y13krP9vdCf/fW ei+C3xVIYfrEuV2+aqOzsXh0skV4GJQvg9W2lUEz9uxlMIvMJNkE2ozBjEPe/z1F4P1v zuzg== X-Gm-Message-State: AOJu0Yyw4h8KJl7UMsIKA/M9jipribJKNJROomiat0I75oLbS+PtcZVn sw2CCz4Ur0eUtE1+A70kCVzNAkEVQ1JKpfWdVIsf2wvyIygyEsRVN1soKO10N81CARv96lkRHAr FxoY8 X-Gm-Gg: AfdE7clL9F4kAcpmpwFxDYDZESikNuLRRSvtBYvZMOHHK8X34W96XIELs9xkhoUG6VF jqRixKoa2DuQg6yHaeZic60E5zMovIwjUyNE/xC1VEbvPAZvTQza4tD844l2U1b3STXzkcgjdDZ IYiOUaMjuT7icIB967qQunO+dsWSR+yCP7yo+n/QmX/T5sgGlYEBkavnQ8tJnCvGtYorOYIor3D S+M1QbeUaroxd9voKwCTYim5fXVTnK3/QmBrwP6NCq6ECD7XUSS/ocw5yyhiP68Kf8dEZqZSLBl PCfkOKqv2wP2HuN0JFVtrZBf7PHphbPOM1uddY6MdjDDq044PaklRGRtwefGvPXuZMMcujkwSIP j5RVEepQPiM+op5wCrcY3aABWM81IzKne37F/BEtd37ZJms7z7YxZMCq6CCOCXPgygSjsnbdPqV BhK+wmiYqfevXCNLBCxLJU9sz8225+ X-Received: by 2002:a05:600c:8283:b0:493:b8cd:2555 with SMTP id 5b1f17b1804b1-493df066947mr24762605e9.3.1783376582063; Mon, 06 Jul 2026 15:23:02 -0700 (PDT) Received: from inspiron14p-linux ([109.77.44.220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47aa039ad21sm27916413f8f.20.2026.07.06.15.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 15:23:01 -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 v6 5/6] libcamera: egl: Add updateTexture2D Date: Mon, 6 Jul 2026 23:22:44 +0100 Message-ID: <20260706222245.247396-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260706222245.247396-1-bryan.odonoghue@linaro.org> References: <20260706222245.247396-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