From patchwork Thu Jun 18 12:22:40 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: 26959 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 98E03C3332 for ; Thu, 18 Jun 2026 12:23:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 09F3E656DD; Thu, 18 Jun 2026 14:23:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="W0rbTAmm"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9649262C75 for ; Thu, 18 Jun 2026 14:23:18 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-490b12270b3so4543205e9.1 for ; Thu, 18 Jun 2026 05:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781785398; x=1782390198; 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=jk6VjmJB52VBfryw+VvVOx5GPW7iwAzDIFqNQWEf2q0=; b=W0rbTAmmlkNMdDRYN7Slug0qb4gfL51I5Ib1Tv+RuBWfPxtfrWbHi5GaWkn4wg2AYj d2QcVEyk2tRmaCp23qktEhBEtJEb/nHh29PyAbkcxLVXNwvunsZsfiXu6uW7NAZTZFP3 4CZfQlXaWhmRHoYyQF6MghjG0UKHTNcWVkb/GYfILsH1YGOFqyGHQGRszYtCilsRgLDc QbTkvw3OtIs0o9MaPF4Eb53Mrp1/TaQRjbYb4dEP8jEhkVO59fgEQPvrWctQ5KO6+Uxz dvnuCvKaPTIaRbRMrSD5y3yihhUd0oFYMpb8RL9xwLTNqcgZHcz89cALHZNfbfWQQbbz Y+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781785398; x=1782390198; 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=jk6VjmJB52VBfryw+VvVOx5GPW7iwAzDIFqNQWEf2q0=; b=rs5x4ajLI6Cc66BAleirndx0AYcu9fBlH6UfAu9i5wmgfq1uNrkUcOmblyUkTTBWK/ 0aTpft6jONJLrWYI+y+vvIqGw2mTVvXsJHJEd72UBuT00fmhHuWOdXlrirfDlCeaSCAa JxeJSY5qqaHcxNNRzGu6+dnyoCkMsZBNtlrBQYQtRBTkG/sZJxCreByh0URTCWZTTcdi Oee0LBG7gv0bZwqs8nOovrmAmfe9ws2cJnkSZSMUTw3wlHE7Cd4Z3En5WihSJMqx7GtG WcjM+StIiBrferGwbDcf6mBEabHrwO0kguP6knyjGcDFEmgHiSgi1OGibnbXLbQGz2pw 9m3A== X-Gm-Message-State: AOJu0YxxEj2vTLtZ5/a8MMxQGt91vTaTxzrpnjbW7NEcsBuzeZ9JLy9V s4nqADHc5cM4CxXUYjWwruXzGy6W/F7AhkygeVZRcoIaIkafFhSM+qXp/f1SOUWn0KcweLUUnl8 sO9ZVcD0= X-Gm-Gg: AfdE7cmdV9BJTVOXz+gs09PEh7DXmzqUo1IDHP8XBsgErFYeJEMjYacc6KUs1K2eV/4 2mfMAbE4gyjFKjswAwDxj4VZe/6i8sKb+6y7jQP4g0ISrXwy7cj2dsx4P7FuOZ4UoSfOzoNMDmF 5Xfxezu0kAFvtpWd3rwMdYeuL4lcHHOTZH6nsg5jahOVYlAhjAk6s0Sov+LitkO2eH7cv1yeHjK v4+OiEW+FQlhQB0Uh9Y3vANf7e7/66qgpYyMwdfua8ueby7hHLCVL2S9e3BAnZqcwsDvs6kr0hm 0COoADtAlbGrneUzWw/nf0Tn3hMLfpspdIjxxoj0Gi7gWNigIFoA2Bd+KQ2yvWRBSI74rcUoPaV y9cQWCpGohXZnKlfXqPupfOnn9oHr1t/hnL01kr+XmeFCmFL8v80FmqffXluX0+n2d5f9DaTvIE s3W/jXNUM02zC1nNHxXWCFopEHtD+5 X-Received: by 2002:a05:600c:4e54:b0:492:328f:8623 with SMTP id 5b1f17b1804b1-49234139d57mr135580655e9.31.1781785398158; Thu, 18 Jun 2026 05:23:18 -0700 (PDT) Received: from inspiron14p-linux ([109.76.144.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a4easm275198015e9.3.2026.06.18.05.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 05:23:17 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz Subject: [PATCH 27/30] libcamera: software_isp: egl: Add updateInputTexture2D Date: Thu, 18 Jun 2026 13:22:40 +0100 Message-ID: <20260618122245.946138-28-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618122245.946138-1-bryan.odonoghue@linaro.org> References: <20260618122245.946138-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. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 8f905416a..c9b3a4e81 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -107,6 +107,7 @@ public: int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createInputTexture2D(eGLImage &eglImage, void *data); + void updateInputTexture2D(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 2fc10b800..fc1516634 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -297,6 +297,33 @@ void eGL::createInputTexture2D(eGLImage &eglImage, void *data) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } +void eGL::updateInputTexture2D(eGLImage &eglImage, void *data) +{ + GLenum format; + GLenum type = GL_UNSIGNED_BYTE; + + ASSERT(tid_ == Thread::currentId()); + + glActiveTexture(eglImage.texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage.texture_); + + switch (eglImage.format_) { + case GL_R16F: + format = GL_RED; + type = GL_HALF_FLOAT; + break; + case GL_RG8: + format = GL_RG; + break; + case GL_LUMINANCE: + format = GL_LUMINANCE; + break; + } + + // Update an already exsiting texture + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, eglImage.width_, eglImage.height_, format, type, 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