From patchwork Thu Jun 18 12:22:18 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: 26938 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 E5ABBC3303 for ; Thu, 18 Jun 2026 12:23:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA52C62B40; Thu, 18 Jun 2026 14:23:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LDM7INbL"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62AF3629E3 for ; Thu, 18 Jun 2026 14:23:01 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso6312135e9.1 for ; Thu, 18 Jun 2026 05:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1781785381; x=1782390181; 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=oDBiA8HS3JX8yt0LRD4gcwtMzbFmINhfLsRnr0WONfg=; b=LDM7INbLkyCzNtMJbULJ64T5NHnvBS5P5Ew801Zv8eTQZHsIjWTl4vDj070Ups0NR9 Sr/QPpz3/bM+1yVwN/XEQpvfL3JL/m37l/nNWsdMY9YNuM++Sf+C1WMbMnLctOK8KPHv Gftxdzh0s2optc/Q0O6tpiWfPk98P7uN2qXZ6PLvsjZVNbmQRfE82OHGZqn9YxAZZjyn VCkZLoWxlYjPWPEnzZiBvGUO0GHMlQX+q09vFIVY1/FfRpHhPgDe06nXxVOYMlenxE2C MFsflgzbQg45V80zoupl+MhOLXcSOxzMyS4A57VP85gZrUWVs6SPrm1+mmw6hrykLCXk oj6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781785381; x=1782390181; 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=oDBiA8HS3JX8yt0LRD4gcwtMzbFmINhfLsRnr0WONfg=; b=efdnOrxdaXUT+3qWtgmPf/lr334AFCQ9pWerw8W/7nYzzK3CFXwcbP54xuObDmz+7t t11vj9+AxfiQo43Oech/IsvXOu2g0pxIruj96zSW6gRa5TS/20U7y26wgcyx4peK9idH MzbJPiQU/M2ULEkXZwOaBXm1E1WYzH5fzaJdRVl75DJYCXsj1rZa1liWtIhRCq6hoRNR q2eg/Jfmsg0zR9b12Rd97gZUMa2FzOT2uCtgMXPFJMVXfXT8ljTqtLPosk7/ZtwsbP+v UltPP3Io2xReKKVNmR2DxpxXMZsDemGclczqItfD22P0H4FBBGudIQkSFciN/njw9HEI vSDQ== X-Gm-Message-State: AOJu0Yx0F2JXc8ieArI0+uLixi99CNRTjHVyEs8vX/TjsT/k3sHkBjX9 hoe2yJ0FvaW/rU1jWgG7WSG0z5OeF2PoeCIH8urETznFovMqCQ6lbqH12wXohzkX5TrUPmWBSml i/XzDUBg= X-Gm-Gg: AfdE7ckaOBUYvvV+VbrUuuHqWQzySqIuOg2JUAkB9L8XcwxwhqywQIj/tGzeRI8pWY3 g/k8z/jzKcLNZOoZayHnf1drIkNpJEpXvsoKBiwNOaGieZEeMqAtXiYQ4diQwX5TVchulEtGE9u Yq6O2/oamHs4wNAu/nGQKxFmFYnrTITGeVRq53GqiRSw3pBYiWlm3fzONDPY4KN0paebVDrLJWs ShFMcvD5zW728apVoj8aD6HQHvm00Xa29GGyBV1mleqoGU4dgl+Qh068sPNexVnWYRb/7cDVAK8 LT/BrUZXx19z6EAyZ3pbA4JyX5NzQcq8Y7WsgIYgTAPVdv+KsEDySSrxpSTMvZPIm4RVP5j0I7u 7ILqhpf7lWQvz51HL1w1OeWxREwzzfKwArkkHUZHDlQlKQINECn/UyIwFl3kPcZdPZS2yLRjsy6 9H3nrt1Z9l8Rpcuzaw0xzfE6AMFix/ X-Received: by 2002:a05:600d:8486:10b0:490:6e12:542d with SMTP id 5b1f17b1804b1-4923821b94emr41777835e9.19.1781785380904; Thu, 18 Jun 2026 05:23:00 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 05:23:00 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: bryan.odonoghue@linaro.org, pavel@ucw.cz Subject: [PATCH 05/30] libcamera: software_isp: gpu_pipeline_shader_pass: Add base class GpuPipelineShaderPass Date: Thu, 18 Jun 2026 13:22:18 +0100 Message-ID: <20260618122245.946138-6-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" Signed-off-by: Bryan O'Donoghue --- .../software_isp/gpu_pipeline_shader_pass.cpp | 74 +++++++++++++++++ .../software_isp/gpu_pipeline_shader_pass.h | 83 +++++++++++++++++++ src/libcamera/software_isp/meson.build | 1 + 3 files changed, 158 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..669a1c1b6 --- /dev/null +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass.cpp @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Linaro Ltd + * + * Simple software ISP 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 software_isp.cpp + * \brief Simple software ISP implementation + */ + +namespace libcamera { + +LOG_DEFINE_CATEGORY(GpuShaderPass) + +int GpuIspShaderPass::process(eGLImage &eglImageIn, eGLImage &eglImageOut, uint32_t width, uint32_t height, const DebayerParams ¶ms) +{ + /* Switch to the output framebuffer */ + egl_.useProgram(programId_); + egl_.attachTextureToFBO(eglImageOut); + + setShaderVariableValues(params, eglImageIn); + 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 -ENODEV; + } + + 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..d4d4cf34d --- /dev/null +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Linaro Ltd + * + * Authors: + * Bryan O'Donoghue + * + * GpuIspIspShaderPass 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 "../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) {} + ~GpuIspShaderPass() {} + + 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(const DebayerParams ¶ms, eGLImage &eglImageIn) = 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 ShaderPasses do the Textrue allocation and thus have + * access to glFormat_. Make glFormat_ available to the upper level class. + * This variabile will be dropped at the end of the series anyway. + */ + GLint glFormat_; + +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 51cc6ac3e..f8bce5203 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_pipeline_gpu.cpp', + 'gpu_pipeline_shader_pass.cpp', ]) libcamera_deps += [ libegl,