From patchwork Wed Nov 18 09:57:10 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: 28965 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 6E9CBBDE17 for ; Wed, 18 Nov 2026 09:57:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 17B826A8C4; Wed, 18 Nov 2026 10:57:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bKQab0mt"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB7266A8B0 for ; Wed, 18 Nov 2026 10:57:52 +0100 (CET) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so598147f8f.1 for ; Wed, 18 Nov 2026 01:57:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794995872; x=1795600672; 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=OYuqmQtv68YLL5Eezwz3DHdGo3X9/WrrF5vKFay5Mg4=; b=bKQab0mtyv1N4UzNvJVxaO3S09AmuVhiFyCbvdJeGMOMgIYc1CxcQbg3q/D0NvAamo j9Gw/qt5c5rnM/FfU3mx4ljyIPix4mQozXd6hyqUIIWmhNUAcUoM9CJ/WAKZYOwhcBEn IDy2Pac5hXzHRD3xnOJ/VfvuCkZvm+fGqOqwj5/sqC461OILy+DTTJDjGR9gO9b1TXJo yoiImBymqWxAHGMjXyngAMKDoLln3VrHCCwmXpmoV4cGL+lDALpUburw1+Bz7fqyucMq vPXfbEaToyalP0PmvsPmTQT4ptgs9V6b3h81joyK9mnbLXEnGtoFnhtassV8UvApZ1X0 xNfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794995872; x=1795600672; 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=OYuqmQtv68YLL5Eezwz3DHdGo3X9/WrrF5vKFay5Mg4=; b=X4tyGUKYLUhvDLp8fbsvvtVDzJwtj8yygH3XNZbOxM1s+EIoOu9A27ZZyfWY3YyrMt tJAMTamAdu76AyT6v+EYKndGdz5gQ+8sx5xwSShXT1jWfUgvpC7KLauGFChMbjAix0F8 tJfNiJws8i2qA/TM0dRf/v1QDeBkF7nsOW9pFkGzi6w46+Mbnk/jvU4pSmXS9+flURpi 3AZM6+FK/GtHqZ1539RDQbw+E2bqQXfcERg+Dva51rZpz08M2YcO/kyYZhv9RgM9+rNi v00sVDCjMFZF64iS//FWpEHhyo5ZQcvQGjL/5HE+puQBnnl/Wy9Zz44GArV4QemhT4gp yaUw== X-Gm-Message-State: APuU4Z9exENk/AEzvWqK30pz9T+b9E7usdfoVVcYT64XLse82oxix1aV gIxE85JbVFxCc/t41MmID5mgXwhAZLvLGc4EOucNGJFmvREJo6bm080knz4FWWmVdOQva1ClAWZ 2cX6w834= X-Gm-Gg: AZFdTZfl9pqn6Y93/CF5ZpGJSWZAgL9QpiOD2z4xcPrlrzKlVJ9Z1YdKLRyn1Oiex2T 5+IVHJmgIx3wQ7mzDPVLYIU/0kJiMwO/SzuUxvMORAulkQlGq1ZdJkCVGb6VEBAgIZXSOTD+f08 QC3w1aCGUws6NTSo96MuTXVwEaz4fVNfGZK71lSnIO5QWWFmTFXCfZl88OPhSHTOAMGdS+/LIVq +oEOt+19c8lP1nkQhCVukYpaOhjfG0ciz8USVp6yWqZ7RnFzxCJovBVRhEwzGJ6dV9HEgnIPvIz PQpiSyWtu2ep1M+g0wWi69zoS8Nz4n/n+JqTwgmWrR8wZclqQD1vx24To2v51Ca8mBh3HuFjdS/ iuz3Sq60G/RNPh0wP66irFHTVRGvm7X91QeGU2SIpH48NUSUmygj6eNXEtA9M7hJNcuU2zECSXz /Rm/acZFsdzgDmrJlCwSZ7w6yWEBYgK+pgMf9/iZyd9yZsWymEYGmHnDKQ9kvBhTJDL+uIM0XlN gorE05EHOXOH+44DtVNHWNwV2rDniFcpW/pJUKjEfimuT0l99d1tBNOaDYxdS0fywdJ6fpvywks DCcX2OI9SUgv3U/j4qxn6LmkqiRErtVjCIlUOJZeUIoNJQ== X-Received: by 2002:a05:6000:4703:b0:4a6:4f35:31fa with SMTP id ffacd0b85a97d-4a64f35323dmr3951871f8f.3.1794995871254; Wed, 18 Nov 2026 01:57:51 -0800 (PST) Received: from inspiron14p-linux ([109.76.187.112]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a655f9f4a7sm3940871f8f.34.2026.11.18.01.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 01:57:50 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: rstrode@redhat.com, robert.mader@collabora.com, barnabas.pocze@ideasonboard.com, Bryan O'Donoghue Subject: [RFC PATCH v2 03/26] libcamera: software_isp: gpu_pipeline_shader_pass: Add base class GpuPipelineShaderPass Date: Wed, 18 Nov 2026 10:57:10 +0100 Message-ID: <20261118095735.170587-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261118095735.170587-1-bryan.odonoghue@linaro.org> References: <20261118095735.170587-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" Signed-off-by: Bryan O'Donoghue --- .../software_isp/gpu_pipeline_shader_pass.cpp | 79 +++++++++++++++++ .../software_isp/gpu_pipeline_shader_pass.h | 85 +++++++++++++++++++ src/libcamera/software_isp/meson.build | 1 + 3 files changed, 165 insertions(+) create mode 100644 src/libcamera/software_isp/gpu_pipeline_shader_pass.cpp create mode 100644 src/libcamera/software_isp/gpu_pipeline_shader_pass.h diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass.cpp b/src/libcamera/software_isp/gpu_pipeline_shader_pass.cpp new file mode 100644 index 000000000..241ea5d8d --- /dev/null +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass.cpp @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Linaro Ltd + * + * GPU ISP shader pass implementation + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/software_isp/debayer_params.h" + +#include "gpu_pipeline_shader_pass.h" + +/** + * \file gpu_pipeline_shader_pass.cpp + * \brief GPU ISP shader pass implementation + */ + +namespace libcamera { + +LOG_DEFINE_CATEGORY(GpuShaderPass) + +int GpuIspShaderPass::process(eGLImage &eglImageIn, eGLImage &eglImageOut, uint32_t width, uint32_t height, const DebayerParams ¶ms) +{ + /* Use the program associated with this pass */ + glUseProgram(programId_); + + /* Switch to the output framebuffer */ + egl_.attachTextureToFBO(eglImageOut); + + setShaderVariableValues(eglImageIn, params); + + glViewport(0, 0, width, height); + glClear(GL_COLOR_BUFFER_BIT); + glDrawArrays(GL_TRIANGLE_FAN, 0, DEBAYER_OPENGL_COORDS); + + GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + LOG(GpuShaderPass, Error) << "Drawing scene fail " << err; + return -EIO; + } else { + egl_.flushOutput(); + } + + return 0; +} + +int GpuIspShaderPass::start() +{ + return 0; +} + +void GpuIspShaderPass::stop() +{ + if (programId_) + glDeleteProgram(programId_); +} + +void GpuIspShaderPass::configure(const struct PassConfig &passInputCfg, const struct PassConfig &passOutputCfg) +{ + passInputCfg_ = passInputCfg; + passOutputCfg_ = passOutputCfg; +} + +} diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass.h b/src/libcamera/software_isp/gpu_pipeline_shader_pass.h new file mode 100644 index 000000000..5e3748621 --- /dev/null +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Linaro Ltd + * + * Authors: + * Bryan O'Donoghue + * + * GpuIspShaderPass base class + */ + +#pragma once + +#include + +#include +#include +#include + +#include +#include + +#include "libcamera/internal/egl.h" +#include "libcamera/internal/software_isp/debayer_params.h" + +#include +#include +#include + +#include "../shaders/glsl_shaders.h" + +namespace libcamera { + +#define DEBAYER_OPENGL_COORDS 4 + +class FrameBuffer; + +struct PassConfig { + Size size; + unsigned int stride; + PixelFormat format; + Rectangle window; +}; + +class GpuIspShaderPass : public Object +{ +public: + GpuIspShaderPass(eGL& egl) : egl_(egl) {} + virtual ~GpuIspShaderPass() = default; + + virtual int process(eGLImage &eglImageIn, eGLImage &eglImageOut, uint32_t width, uint32_t height, const DebayerParams ¶ms); + virtual int start(); + virtual void stop(); + virtual void configure(const struct PassConfig &passInputCfg, const struct PassConfig &passOutputCfg); + virtual int initShaders(PixelFormat inputFormat, PixelFormat outputFormat) = 0; + virtual int getShaderVariableLocations(void) = 0; + virtual void setShaderVariableValues(eGLImage &eglImageIn, const DebayerParams ¶ms) = 0; + virtual const char *name() const { return "GpuIspShaderPass"; } + + unsigned int getBytesPerPixel() { return bytesPerPixel_; }; + + /* glFormat_ is a special case we are moving to one shader which will use GL_R + * so rather than do a hack make glFormat_ available to the upper level class. + * This variabile will be dropped at the end of the series anyway. + */ + GLint glFormat_; + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(GpuIspShaderPass) + +protected: + eGL& egl_; + + /* Shader calculates this getter provides ability to interrogate if needed */ + unsigned int bytesPerPixel_; + + /* Shader program identifiers */ + GLuint vertexShaderId_ = 0; + GLuint fragmentShaderId_ = 0; + GLuint programId_ = 0; + + struct PassConfig passInputCfg_; + struct PassConfig passOutputCfg_; +}; + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index f241e4489..91274e968 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -32,6 +32,7 @@ if mesa_works libcamera_internal_sources += files([ '../egl.cpp', 'software_isp_instance_gpu.cpp', + 'gpu_pipeline_shader_pass.cpp', ]) libcamera_deps += [ libegl,