Patch Detail
Show a patch.
GET /api/1.1/patches/26485/?format=api
{ "id": 26485, "url": "https://patchwork.libcamera.org/api/1.1/patches/26485/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26485/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260407-kbingham-awb-split-v1-2-a39af3f4dc20@ideasonboard.com>", "date": "2026-04-07T22:01:05", "name": "[02/13] softisp: Split AWB from Combined Matrix", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "be2e080703bbc658e18bccdfa7ced23c0268ac03", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26485/mbox/", "series": [ { "id": 5874, "url": "https://patchwork.libcamera.org/api/1.1/series/5874/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5874", "date": "2026-04-07T22:01:03", "name": "ipa: simple: Convert to libipa AWB implementation", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5874/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26485/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26485/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1294FBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 7 Apr 2026 22:02:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 17EE762DB3;\n\tWed, 8 Apr 2026 00:02:46 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D4EA62D4E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 Apr 2026 00:02:41 +0200 (CEST)", "from [192.168.0.204] (ams.linuxembedded.co.uk [209.38.108.23])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A63E78E;\n\tWed, 8 Apr 2026 00:01:13 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"plrZJoD3\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775599273;\n\tbh=GZHQq9+jIh6UviRqwn4nW5G/p4P5DRND9QKZt5BZ/+w=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=plrZJoD3fsPnL6VSAjRJ/jqAUpDrjA/OHhNNZy5gipzjydCo6cBqqSGss80TzWRIH\n\tBjijU0c9Q8mOtICc/ddHpKOokjm/QAfAFSXSKWOy5xz1G7A2dqu0Hm64L4wjMFc755\n\tHQvZF5F1bPK+a9fXyoUcjSTTFY6xyz55/NU/Mlw0=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Date": "Tue, 07 Apr 2026 23:01:05 +0100", "Subject": "[PATCH 02/13] softisp: Split AWB from Combined Matrix", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260407-kbingham-awb-split-v1-2-a39af3f4dc20@ideasonboard.com>", "References": "<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>", "In-Reply-To": "<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "X-Mailer": "b4 0.14.2", "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1775599359; l=6147;\n\ti=kieran.bingham@ideasonboard.com; s=20260204;\n\th=from:subject:message-id; \n\tbh=GZHQq9+jIh6UviRqwn4nW5G/p4P5DRND9QKZt5BZ/+w=;\n\tb=0JrTVKw8nf+CrHPNW0JzPARMPLZ6C5HvVQY/TiOndT0yJgS38Y07ySr6l8gRrL88Or+iWG2CS\n\ttT+9pZSN0wxA0X6FG6qt6DYpSqMG7KYn1FGp7U0ZdGaXk55f0Jq5g4M", "X-Developer-Key": "i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY=", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Move the AWB gains out of the combined matrix and pass\nthem directly to the EGL shaders.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/simple/algorithms/awb.cpp | 16 +++-------------\n src/ipa/simple/ipa_context.h | 5 +----\n src/libcamera/shaders/bayer_1x_packed.frag | 4 ++++\n src/libcamera/shaders/bayer_unpacked.frag | 4 ++++\n src/libcamera/software_isp/debayer_egl.cpp | 5 +++++\n src/libcamera/software_isp/debayer_egl.h | 3 +++\n 6 files changed, 20 insertions(+), 17 deletions(-)", "diff": "diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\nindex f5c88ea6f896ff8a7ffdc328e09a4d4aa99df5e4..05155c83d172d64609053ba940a4c12a2248bb04 100644\n--- a/src/ipa/simple/algorithms/awb.cpp\n+++ b/src/ipa/simple/algorithms/awb.cpp\n@@ -38,15 +38,8 @@ void Awb::prepare(IPAContext &context,\n \t\t DebayerParams *params)\n {\n \tauto &gains = context.activeState.awb.gains;\n-\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n-\t\t\t\t\t 0, gains.g(), 0,\n-\t\t\t\t\t 0, 0, gains.b() } };\n-\tcontext.activeState.combinedMatrix =\n-\t\tgainMatrix * context.activeState.combinedMatrix;\n-\n-\tframeContext.gains.red = gains.r();\n-\tframeContext.gains.blue = gains.b();\n \n+\tframeContext.gains = gains;\n \tparams->gains = gains;\n }\n \n@@ -59,11 +52,8 @@ void Awb::process(IPAContext &context,\n \tconst SwIspStats::Histogram &histogram = stats->yHistogram;\n \tconst uint8_t blackLevel = context.activeState.blc.level;\n \n-\tconst float mdGains[] = {\n-\t\tstatic_cast<float>(frameContext.gains.red),\n-\t\tstatic_cast<float>(frameContext.gains.blue)\n-\t};\n-\tmetadata.set(controls::ColourGains, mdGains);\n+\tmetadata.set(controls::ColourGains, { frameContext.gains.r(),\n+\t\t\t\t\t frameContext.gains.b() });\n \n \tif (!stats->valid)\n \t\treturn;\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 34f7403a41d690cb3f0c271827ae2e915b6ea49d..8ccfacb46a59cedb5a0ad051d67f7c1f40af4b52 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -71,10 +71,7 @@ struct IPAFrameContext : public FrameContext {\n \t\tdouble gain;\n \t} sensor;\n \n-\tstruct {\n-\t\tdouble red;\n-\t\tdouble blue;\n-\t} gains;\n+\tRGB<float> gains;\n \n \tfloat gamma;\n \tstd::optional<float> contrast;\ndiff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag\nindex 23747f78a6313503a46b61ed5bae6e7c178c5745..9a1992e219dd066945b3f46ec509f47a31590385 100644\n--- a/src/libcamera/shaders/bayer_1x_packed.frag\n+++ b/src/libcamera/shaders/bayer_1x_packed.frag\n@@ -65,6 +65,7 @@ uniform vec2 tex_step;\n uniform vec2 tex_bayer_first_red;\n \n uniform sampler2D tex_y;\n+uniform vec3 awb;\n uniform mat3 ccm;\n uniform vec3 blacklevel;\n uniform float gamma;\n@@ -227,6 +228,9 @@ void main(void)\n \n \trgb = rgb - blacklevel;\n \n+\t/* Apply AWB gains, and saturate each channel at sensor range */\n+\trgb = clamp(rgb * awb, vec3(0.0), vec3(1.0) - blacklevel);\n+\n \t/*\n \t * CCM is a 3x3 in the format\n \t *\ndiff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag\nindex 76ffc47a8a29f242c1fba88f32bd8db731edeee0..87e4e4915fe19679943fdcc3d213a0224b89065e 100644\n--- a/src/libcamera/shaders/bayer_unpacked.frag\n+++ b/src/libcamera/shaders/bayer_unpacked.frag\n@@ -24,6 +24,7 @@ uniform sampler2D tex_y;\n varying vec4 center;\n varying vec4 yCoord;\n varying vec4 xCoord;\n+uniform vec3 awb;\n uniform mat3 ccm;\n uniform vec3 blacklevel;\n uniform float gamma;\n@@ -130,6 +131,9 @@ void main(void) {\n \n \trgb = rgb - blacklevel;\n \n+\t/* Apply AWB gains, and saturate each channel at sensor range */\n+\trgb = clamp(rgb * awb, vec3(0.0), vec3(1.0) - blacklevel);\n+\n \t/*\n \t * CCM is a 3x3 in the format\n \t *\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 2ad258bca69fb8dff19e35d9239ebd7d350590ae..738036e649224f370bdf9a0cc59b399f8b1066de 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -100,6 +100,7 @@ int DebayerEGL::getShaderVariableLocations(void)\n \tattributeTexture_ = glGetAttribLocation(programId_, \"textureIn\");\n \n \ttextureUniformBayerDataIn_ = glGetUniformLocation(programId_, \"tex_y\");\n+\tawbUniformDataIn_ = glGetUniformLocation(programId_, \"awb\");\n \tccmUniformDataIn_ = glGetUniformLocation(programId_, \"ccm\");\n \tblackLevelUniformDataIn_ = glGetUniformLocation(programId_, \"blacklevel\");\n \tgammaUniformDataIn_ = glGetUniformLocation(programId_, \"gamma\");\n@@ -113,6 +114,7 @@ int DebayerEGL::getShaderVariableLocations(void)\n \n \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n \t\t\t << \" tex_y \" << textureUniformBayerDataIn_\n+\t\t\t << \" awb \" << awbUniformDataIn_\n \t\t\t << \" ccm \" << ccmUniformDataIn_\n \t\t\t << \" blacklevel \" << blackLevelUniformDataIn_\n \t\t\t << \" gamma \" << gammaUniformDataIn_\n@@ -481,6 +483,9 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms)\n \tglUniform3f(blackLevelUniformDataIn_, params.blackLevel[0], params.blackLevel[1], params.blackLevel[2]);\n \tLOG(Debayer, Debug) << \" blackLevelUniformDataIn_ \" << blackLevelUniformDataIn_ << \" data \" << params.blackLevel;\n \n+\tglUniform3f(awbUniformDataIn_, params.gains[0], params.gains[1], params.gains[2]);\n+\tLOG(Debayer, Debug) << \" awbUniformDataIn_ \" << awbUniformDataIn_ << \" data \" << params.gains;\n+\n \t/*\n \t * Gamma\n \t */\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex bdde676f2394e7298006c88bbec75917800af4ad..23ef99117fbd209246ae565141a2365c6a7b0a63 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -97,6 +97,9 @@ private:\n \n \tGLint textureUniformBayerDataIn_;\n \n+\t/* Per-frame AWB gains */\n+\tGLint awbUniformDataIn_;\n+\n \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n \tGLint ccmUniformDataIn_;\n \n", "prefixes": [ "02/13" ] }