From patchwork Fri Dec 12 00:29:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25515 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 1A70BBD1F1 for ; Fri, 12 Dec 2025 00:33:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 00B2061623; Fri, 12 Dec 2025 01:33:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Gg/6KmFH"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC7A261613 for ; Fri, 12 Dec 2025 01:33:21 +0100 (CET) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-7b89c1ce9easo809725b3a.2 for ; Thu, 11 Dec 2025 16:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765499600; x=1766104400; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hJu2llA1senP4OwRJgGlYcIRb2InkqWEJeerRSzdne8=; b=Gg/6KmFHqRbjAoFzmCQskJqLuWIsoto7ebJF8khiRmo5UXWGet7fGYwGgOgyqtDoVg 5oi7+pK+hLxo5axaopLJNXoSue/H/PYdnQk+eNxUg3yQXU0BqAB/dlNraA4l9qAsKIvz CbEcejR+x8DfeiRXFvIZAnMhnSDB/zgF10QKX+QxZLmtF77IZkupS/NEoVapSgx/zwmV Gm6z7a5wUwu2VZSRXyFf2oZzxyghvYimo8lHtyc3GKOYpE7bhJvhNZqPNwiA7PXlFzBs j6FQr1fmoS0bK1bRnlS9AHbENrWlk8k2zzdajyYicMcSo1bOuTYUlx2axsfkQ2YBQN60 IX8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765499600; x=1766104400; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hJu2llA1senP4OwRJgGlYcIRb2InkqWEJeerRSzdne8=; b=viq69G0kfrmkgMOQqnmkIC580eELEjU2Y7Jqwe5BEJhWVCTxjxngn24dCuJOR9dcPJ yr4ooHIgFJ90ODMt95L7Gi0WP0F/PiIt7fJjKmaXpEDhwCAz6i67xnLiYfDhZr6BdQmc PeweYuSZQd39zvLIQghK4qr+lvi+tdFJn4XsQ35tPlhZ/TDuZh3L5z3j2pt/GcX06Pxi djDj0g1Hf83vFbxiL6opSLWIiJjGakpiKtlQ63Bw2DXWyPDaNOdvPnkWp09M3VkZUQ5w IZ4Cnrh1DlnMxuuqdrNHqsZorVNHA5ipLJp8Xt6ZC55XM9APn1fZ5z8VHvywUDZZ7ELv w8OA== X-Gm-Message-State: AOJu0YyosZr8CuWlqsbZBs4+fyvAonb/KIojBtZK3fpfnZpDuBaEbdjq ppoT7EEPB7OqMwOtef2MkC5dFtzXIB4bEFaJoUYAsFiozpaua28UwoDFXMZ4o4PWC22XAvEafYi /nud/ X-Gm-Gg: AY/fxX5B8hXwT5yB+o2qIk2Xa34gDWIfHYJSvTrt0Dwwjek9tEzZFyA+IwtJQuehH5I sPWsjzJ4B4BNuvr7CZygWHnuH5jn+XCnJkTKUQuj27sM9npsTxD3csFEchMhQEtcZum6bCPekVq 3J3z5VGYLVewmeZdAxG1AI5DfoSs9jvO9cGkXHSz1LTDRhWev9yiM8UphhOql+ew92C7Yjr1FSj XMumgQ9urBlSd+xCnI9WUVwjGG6T9IFfjLUc6UhUAjkxGIwo3kkbcRJr2pb2aPcKIoUpR+YnOKh MbLtyLu0NCfuLbASTi5DUZKkBjh/kLAGL3DIFj7S/+HHp0+ntCn4XmmWiGar/VP6AefyWKntpXl o0xXXF7fFIGy85Eib1E6oYcNB2lHf8Vck+k+VDIV+DsaEEQtWtCCiuy+fQRJGuJjRYMATT6NIE/ pVJq2p8nIVuJ0K8YdYLmfQ++w/mFq46S9Y7LDcliSc5VWnf+jddpWisP0pfphRzVzITA5OTg== X-Google-Smtp-Source: AGHT+IHwAFEqZJTAozc17HOhGLb+68/NYR+2kwBiOTLuwTifKwtKxY3L4Pp2a3OBsATe4i/CVuRejA== X-Received: by 2002:a05:6a21:99a7:b0:364:31e:2cac with SMTP id adf61e73a8af0-369afa02a4emr313748637.46.1765499599830; Thu, 11 Dec 2025 16:33:19 -0800 (PST) Received: from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp. [153.246.134.249]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 16:33:19 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v8 00/26] Add GLES 2.0 GPUISP to libcamera Date: Fri, 12 Dec 2025 00:29:11 +0000 Message-ID: <20251212002937.3118-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 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" v8: A small number of updates. I'll copy and paste my change notes directly. - gbm patch - \todo, nullptr comments addressed - Milan - Left fail - meant fail - Changed cleanup flow - // namespace libcamera -> /* namespace libcamera */ - Dropped HAVE_GBM - Contrast patch Passed contrastExp as argument to apply_contrast() - Milan - Dropped "invalid." for "invalid" Left "it makes sense" not sure of "let's try" was a suggested commit log comment but - "it makes sense" to me :) - Milan - Changes CCM init to Matrix identityMatrix = Matrix::identity(); Amends commit log - Milan - Fixes the identity CCM commit log Old commit log not updated on review changes - Milan - Changed selfEnumerating to use common code Milan left a comment on not having copied code so I created a helper function and moved a much as I thought I could - Milan - todo - rewriging -> rewiring. onomatopoeic error ! - manging -> managing v7: - Takes Laurent's question on doing egl init in start() instead of configure() and implements it. Tested with repeated start()/stop() from qcam. - A few supporting patches to get data we require in configure() into start() has been added as a result. - Bayer object now has a start() and a stop() - introduced in the precursor series. - Dropped overloaded algorith init() function as Milan seemed to prefer a flag in context_ over an overloaded init(). - Small tidy up on the use of TEXTURE1 instead of TEXTURE4 now that the RGB lookup tables have been dropped too. - Updates the todo list - The one thing not done is passing the complex contrast into the fragment shader per frame, instead of having it calculated per-pixel. I'd rather get the current series out/merged than add this extra bit right now. v6: - Rebases on 0.6.0 - Removes conditional compilation for lookup-table v CCM. The conditional compile to switch the ordering of blue is kept. - Laurent - Removes Bayer lookup table code from shaders and debayer_egl logic Disussed with Laurent and agree it can be dropped now - Adds a patch to pass no-op values to the debayer shaders when running those shaders in qcam. Confirmed this works by switching the true/false flag in simple.cpp and recompiling. Once the raw-streams stuff gets merged changing simple.cpp shouldn't be required. This lets us continue to support the original behaviour of the debayer shaders in Qcam while also reusing those shaders with our extensions in softisp. - Re-orders the patches a bit to group changes a bit more logically especially on more recently added patches. CI is still happy with building as progressive changes. - Drops the patch to make isStandardBayerOrder static as this logic has been squashed into the precursor series. Barnabas v5: - Takes in a fix from Hans for the unpacked center bytes. I opted to have separate stride values passed to the shaders to maintain consistency with qcam - Implements the unique_ptr change Barnabas suggested - Changes to glFinish instead of eglWaitSyncKHR - Milan/Robert - Fixes interface to pass gpuIspEnabled as a parameter - Barnabas - Makes it an error if you request GPUISP but object instantiation fails - Barnabas - Fixes indentation splat in unpacked shader - I love whitespace :( - Laurent - Leaves the upload tables in place - I thought we noted to do this in weekly meeting I'm open/happy to drop this code though its not really necessary now. - Leaves conditional compilation in shaders. The reason being with conditional compilation we can still run the original unmodifed shaders - which gives a nice base to mess with the demosiac phase in isolation. v4: - Drops AWB since the CCM contains it already - Includes Gamma - Includes Contrast - testable via camshark - Includes Saturation - testable via camshark - Includes a scaler from Robert - Includes synch changes from Robert - Includes all feedback incorporated from Pavel - Generates a default 65k CCM if none is supplied - Various Doxygen torments fixed along the way - And is the "top half" of the precursor series as the GPUISP series becomes 44 patches long this is an unreasonable number to merge in one go. - Full testable branch Link: https://gitlab.freedesktop.org/camera/libcamera-softisp/-/tree/v0.5.2-gpuisp-v4e?ref_type=heads - The first part of the series is in the precurso here Link: https://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/v0.5.2-gpuisp-v4e-split That precursor is just a tag about half way through the integrated series. Bryan O'Donoghue (23): libcamera: software_isp: gbm: Add a GBM helper class for GPU surface access libcamera: software_isp: egl: Add a eGL base helper class qcam: viewfinder_gl: Set no-op Bayer shader values libcamera: shaders: Use highp not mediump for float precision libcamera: shaders: Extend debayer shaders to apply CCM gains libcamera: shaders: Extend bayer shaders to support swapping R and B on output libcamera: shaders: Add support for black level compensation libcamera: shaders: Add support for Gamma libcamera: shaders: Add support for contrast libcamera: software_isp: Add member variables to track selected input/output pixelFormat libcamera: software_isp: Add a Size_ member variable to pass to eGL later libcamera: software_isp: debayer_egl: Add an eGL Debayer class libcamera: software_isp: debayer_cpu: Make getInputConfig and getOutputConfig static libcamera: software_isp: debayer_egl: Make DebayerEGL an environment option libcamera: software_isp: debayer_egl: Make gpuisp default softisp mode ipa: software_isp: Add a selfInitialising flag to IPAContext libcamera: software_isp: ccm: Add self-initialising identity CCM to Ccm::init ipa: libipa: module: Add createSelfEnumeratingAlgorithm ipa: simple: Add a flag to indicate gpuIspEnabled ipa: software_isp: Call createSelfEnumeratingAlgorithm() to statically instantiate CCM algo libcamera: software_isp: lut: Skip calculation lookup tables if gpuIspEnabled is true libcamera: software_isp: lut: Change default Gamma to 1.0/2.2 libcamera: software_isp: Add a gpuisp todo list Hans de Goede (1): libcamera: shaders: Fix input sampling when width != stride Milan Zamazal (2): libcamera: shaders: Rename bayer_8 to bayer_unpacked libcamera: software_isp: GPU support for unpacked 10/12-bit formats include/libcamera/internal/egl.h | 186 +++++ include/libcamera/internal/gbm.h | 39 ++ include/libcamera/internal/meson.build | 1 + include/libcamera/ipa/soft.mojom | 3 +- src/apps/qcam/assets/shader/shaders.qrc | 4 +- src/apps/qcam/viewfinder_gl.cpp | 41 +- src/apps/qcam/viewfinder_gl.h | 12 + src/ipa/libipa/module.cpp | 34 + src/ipa/libipa/module.h | 47 +- src/ipa/simple/algorithms/ccm.cpp | 22 +- src/ipa/simple/algorithms/lut.cpp | 72 +- src/ipa/simple/ipa_context.h | 2 + src/ipa/simple/soft_simple.cpp | 9 + src/libcamera/egl.cpp | 619 +++++++++++++++++ src/libcamera/gbm.cpp | 130 ++++ src/libcamera/meson.build | 33 + src/libcamera/shaders/RGB.frag | 2 +- src/libcamera/shaders/YUV_2_planes.frag | 2 +- src/libcamera/shaders/YUV_3_planes.frag | 2 +- src/libcamera/shaders/YUV_packed.frag | 2 +- src/libcamera/shaders/bayer_1x_packed.frag | 79 ++- .../{bayer_8.frag => bayer_unpacked.frag} | 95 ++- .../{bayer_8.vert => bayer_unpacked.vert} | 6 +- src/libcamera/shaders/meson.build | 4 +- src/libcamera/software_isp/debayer.cpp | 15 + src/libcamera/software_isp/debayer.h | 3 + src/libcamera/software_isp/debayer_cpu.h | 4 +- src/libcamera/software_isp/debayer_egl.cpp | 641 ++++++++++++++++++ src/libcamera/software_isp/debayer_egl.h | 142 ++++ src/libcamera/software_isp/gpuisp-todo.txt | 40 ++ src/libcamera/software_isp/meson.build | 8 + src/libcamera/software_isp/software_isp.cpp | 37 +- 32 files changed, 2258 insertions(+), 78 deletions(-) create mode 100644 include/libcamera/internal/egl.h create mode 100644 include/libcamera/internal/gbm.h create mode 100644 src/libcamera/egl.cpp create mode 100644 src/libcamera/gbm.cpp rename src/libcamera/shaders/{bayer_8.frag => bayer_unpacked.frag} (51%) rename src/libcamera/shaders/{bayer_8.vert => bayer_unpacked.vert} (90%) create mode 100644 src/libcamera/software_isp/debayer_egl.cpp create mode 100644 src/libcamera/software_isp/debayer_egl.h create mode 100644 src/libcamera/software_isp/gpuisp-todo.txt