[{"id":36318,"web_url":"https://patchwork.libcamera.org/comment/36318/","msgid":"<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-10-16T15:17:27","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Bryan,\n\nBryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n> to application of colour correction data.\n\nI may be missing something but I think white balance is already applied\nin lut.cpp to both the CCM and the R/G/B lookup tables.\n\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++\n>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 ++++++\n>  2 files changed, 12 insertions(+)\n>\n> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> index c0632eb1..8b35dd63 100644\n> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> @@ -69,6 +69,7 @@ uniform sampler2D red_param;\n>  uniform sampler2D green_param;\n>  uniform sampler2D blue_param;\n>  uniform mat3 ccm;\n> +uniform vec3 awb;\n>  \n>  void main(void)\n>  {\n> @@ -216,6 +217,11 @@ void main(void)\n>  \t\t\tvec3(patterns.y, C, patterns.x) :\n>  \t\t\tvec3(patterns.wz, C));\n>  \n> +\t/* Apply white balance before colour correction matrix */\n> +\trgb.r = rgb.r * awb.r;\n> +\trgb.g = rgb.g * awb.g;\n> +\trgb.b = rgb.b * awb.b;\n> +\n>  #if defined(APPLY_CCM_PARAMETERS)\n>  \t/*\n>  \t *   CCM is a 3x3 in the format\n> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> index 74ce1509..37bd4812 100644\n> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> @@ -28,6 +28,7 @@ varying vec4            center;\n>  varying vec4            yCoord;\n>  varying vec4            xCoord;\n>  uniform mat3\t\tccm;\n> +uniform vec3\t\tawb;\n>  \n>  void main(void) {\n>      vec3 rgb;\n> @@ -111,6 +112,11 @@ void main(void) {\n>              vec3(PATTERN.w, C, PATTERN.z) :\n>              vec3(PATTERN.yx, C));\n>  \n> +\t/* Apply white balance before colour correction matrix */\n> +\trgb.r = rgb.r * awb.r;\n> +\trgb.g = rgb.g * awb.g;\n> +\trgb.b = rgb.b * awb.b;\n> +\n>  #if defined(APPLY_CCM_PARAMETERS)\n>  \t/*\n>  \t *   CCM is a 3x3 in the format","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 ACACFBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Oct 2025 15:17:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE42360685;\n\tThu, 16 Oct 2025 17:17:33 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 078F0605D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 17:17:32 +0200 (CEST)","from mail-ej1-f72.google.com (mail-ej1-f72.google.com\n\t[209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-582-oNG-In5qP3K22P1tNY5QVA-1; Thu, 16 Oct 2025 11:17:30 -0400","by mail-ej1-f72.google.com with SMTP id\n\ta640c23a62f3a-b548c516b79so140502566b.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 08:17:30 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b5cb965dac0sm552123866b.13.2025.10.16.08.17.27\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 16 Oct 2025 08:17:28 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"hHtedb9m\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1760627851;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=qZSxRAmPILhQh55xVbqMT4CErx/AhAp7Lm5DoYqaiV4=;\n\tb=hHtedb9mqEtg8O7GGnT0gGSzLkkqhep44L7QOknaYn75DBjUW/Mui3F8GpkBUO0g2Rtk6l\n\t0XYr14nsGM1AUWosd2dsW3NaDnAgtsegw9OgSmEA3/0LqeK1RzCsy2xPpJJ2LpdiwtPMGO\n\tPTxm3HCWu9Bdkkwq8+y1QGrN5H7e3pQ=","X-MC-Unique":"oNG-In5qP3K22P1tNY5QVA-1","X-Mimecast-MFC-AGG-ID":"oNG-In5qP3K22P1tNY5QVA_1760627849","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760627849; x=1761232649;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=qZSxRAmPILhQh55xVbqMT4CErx/AhAp7Lm5DoYqaiV4=;\n\tb=gJpjFs9extNffFLI6laV9XHLOXQjQ74w4w2tTo0LY87quXVpt4BNDMqOcCqb+OsdkJ\n\t+bCFjpWDB9qKbs/7lTEyV+uQ3FllOsbHwGmULmnAZ+ngTph3etFOwceS1vZCAT5CEUD3\n\tTr3KEHflen/tj5JH8VMwj1YvcoSbFZjsUmhJP7t6w9xTu8TqxKngfJvC+InXtqYq6Ynr\n\t2YGpA4//ACkUaZZPsfvJ5w64uKGsRIVq0VgcXwnhAYkyAtAebV+l9pCEO5DZq6PGwC4B\n\tT5MDwJmpPfBBm++6FnXGLfPJZhZ4zldWFuEHSFZST2SSmQdMlO/SqcomSQQtxYgog2XL\n\tUSxg==","X-Gm-Message-State":"AOJu0YyT6Ki3VElo5jp/rYjMPSvfW7AWwbwFT3rRaqoLmHZy3qZ5bot2\n\tLFWuiJ2BVQJcAqVHVRbUWKLriVoWyGwNAA186ezxxjCDJFGPNbQaKZofxSqTdeS07CZHAtHxzge\n\tUlKyhJTtPQhxU8HgSUEagF7CNahI099ltyv6eM76wfwd4mNQ9ugxoXSU4y61t1gpnibDBFjpJTj\n\tY=","X-Gm-Gg":"ASbGnctk9P8H0/wHAen2NqpLcRjXD5xHGqHW6q7ks8xWsatpfHX0zAFUZZ9XmoZ0Yg5\n\t983idSEqGiut80mhSurEDd3Nxm9KGtxTiHyQ5L7KPhg3HB6hlnOl5Gm+I3JiH3HndLOsq5S+PUS\n\tU/Fn3ieB00U35OccOoX3akEMiDgIqLe53ERGj+x2iEDsGbWIBQcNF3q3Irj6R9HfS3s1GJx6otj\n\tfmg0FV/uprrNm00aSWTmo7wyC7F1f+BOGhohtlgy12znNroFrPq/GhjBNb2PtqD5TfsJL/YXbYw\n\tNjhWtqBKSstMFyNpX6Z7fkvH5s9Ni404MVJp23Frw+1wv/b2Ja7huQ2DXA54vrpreQ+TaPt2SPB\n\thEPx1Rc5uF60KHmQMrFRPfnpmxnAePSx9oGJ4J4LAO854kj4yQNOd","X-Received":["by 2002:a17:907:bb49:b0:b50:697e:ba3 with SMTP id\n\ta640c23a62f3a-b647570ad13mr31230766b.63.1760627849297; \n\tThu, 16 Oct 2025 08:17:29 -0700 (PDT)","by 2002:a17:907:bb49:b0:b50:697e:ba3 with SMTP id\n\ta640c23a62f3a-b647570ad13mr31227366b.63.1760627848879; \n\tThu, 16 Oct 2025 08:17:28 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IFw10TlCYZlkOcC7TM+PE9v7yJS40bmNVsoqN8w/pWkBlwakm1fHu0i6+gmZ6bUB/CAEaz8PQ==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  hdegoede@redhat.com,\n\tbod.linux@nxsw.ie","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","In-Reply-To":"<20251015012251.17508-33-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 15 Oct 2025 02:22:44 +0100\")","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>","Date":"Thu, 16 Oct 2025 17:17:27 +0200","Message-ID":"<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"SJ4Pt95ruuz1YqpTkc_U0QALD9jNYBmSTGU1Pa9UVnw_1760627849","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":36325,"web_url":"https://patchwork.libcamera.org/comment/36325/","msgid":"<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-10-16T16:50:16","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Milan Zamazal <mzamazal@redhat.com> writes:\n\n> Hi Bryan,\n>\n> Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n>\n>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n>> to application of colour correction data.\n>\n> I may be missing something but I think white balance is already applied\n> in lut.cpp to both the CCM and the R/G/B lookup tables.\n\nI must be something missing, I get a colour cast without this, at least\nwhen CCM is not used.\n\n>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>> ---\n>>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++\n>>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 ++++++\n>>  2 files changed, 12 insertions(+)\n>>\n>> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> index c0632eb1..8b35dd63 100644\n>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> @@ -69,6 +69,7 @@ uniform sampler2D red_param;\n>>  uniform sampler2D green_param;\n>>  uniform sampler2D blue_param;\n>>  uniform mat3 ccm;\n>> +uniform vec3 awb;\n>>  \n>>  void main(void)\n>>  {\n>> @@ -216,6 +217,11 @@ void main(void)\n>>  \t\t\tvec3(patterns.y, C, patterns.x) :\n>>  \t\t\tvec3(patterns.wz, C));\n>>  \n>> +\t/* Apply white balance before colour correction matrix */\n>> +\trgb.r = rgb.r * awb.r;\n>> +\trgb.g = rgb.g * awb.g;\n>> +\trgb.b = rgb.b * awb.b;\n>> +\n>>  #if defined(APPLY_CCM_PARAMETERS)\n>>  \t/*\n>>  \t *   CCM is a 3x3 in the format\n>> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> index 74ce1509..37bd4812 100644\n>> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> @@ -28,6 +28,7 @@ varying vec4            center;\n>>  varying vec4            yCoord;\n>>  varying vec4            xCoord;\n>>  uniform mat3\t\tccm;\n>> +uniform vec3\t\tawb;\n>>  \n>>  void main(void) {\n>>      vec3 rgb;\n>> @@ -111,6 +112,11 @@ void main(void) {\n>>              vec3(PATTERN.w, C, PATTERN.z) :\n>>              vec3(PATTERN.yx, C));\n>>  \n>> +\t/* Apply white balance before colour correction matrix */\n>> +\trgb.r = rgb.r * awb.r;\n>> +\trgb.g = rgb.g * awb.g;\n>> +\trgb.b = rgb.b * awb.b;\n>> +\n>>  #if defined(APPLY_CCM_PARAMETERS)\n>>  \t/*\n>>  \t *   CCM is a 3x3 in the format","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 2BE63BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Oct 2025 16:50:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 668BB6068E;\n\tThu, 16 Oct 2025 18:50:26 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2AAB0605D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 18:50:24 +0200 (CEST)","from mail-ed1-f70.google.com (mail-ed1-f70.google.com\n\t[209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-670-X7HwDXJJMbefLjvNnyOiZA-1; Thu, 16 Oct 2025 12:50:21 -0400","by mail-ed1-f70.google.com with SMTP id\n\t4fb4d7f45d1cf-63c13b3f23dso657740a12.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 09:50:21 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b5cb9e7ebbfsm554586766b.24.2025.10.16.09.50.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 16 Oct 2025 09:50:17 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"aU3RQb9n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1760633423;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=yfq+OPVS2QBVtmFUPzPLQ/wUdpZZv30zbQ4eijP3gds=;\n\tb=aU3RQb9njwVGg7qwIpT+q+MXKTIc1LcT7m+FYjf9kbbThedy/3Vr9meoyv5rfOal6ocMyQ\n\tiGlyV6yEvnn6oHY2IXQuvSDR/+cxwH+6fxZUkLcGGaLbMueXsAS0El0Cl2PeesS339srOm\n\txjQq0TFQmY46etmXgOBJlmJ7drbwp2E=","X-MC-Unique":"X7HwDXJJMbefLjvNnyOiZA-1","X-Mimecast-MFC-AGG-ID":"X7HwDXJJMbefLjvNnyOiZA_1760633421","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760633421; x=1761238221;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=yfq+OPVS2QBVtmFUPzPLQ/wUdpZZv30zbQ4eijP3gds=;\n\tb=vHaraGEQc2C9Yul1qHB057lwb7IcgvVSWJtUDipAnJ8ZTX6fl4uWQ2wr/TrrfHTonI\n\t/pcSAONBBzNG9cLWgaV83qgs35mfKPctKw668vd8CY8WgRGhO/sNs7JFQBdF5FxgasIp\n\t/XE6DEr2VFiFvZ2kqh1+RnuKMGRPX8cw67h3PLdj/ttuRlALYUES/gdX7cYosJRapIiE\n\tuL5OrkY4cOLmXJvhtHAuQDTby08ar7erqfH/jArClepPx/JChDbPuhQvm2D9I7hQatVn\n\tBUAb51bbfgQgbN869oA/TSkKDdgZzXwiECE6LocUguMmN+p/eRZiFlDmfKqosggpls1k\n\tqgTg==","X-Gm-Message-State":"AOJu0Yz5SYHlhGPAXvywIzh7WQxV1zO/a5xLKxs1qSwXnczxIjC3mAyK\n\tHE5AUkzRya9zrzUh3XjA2XWQk3ypvEbWnObAP4J6p8i7Ka1oQYqKIG2uQMOMBjiO77e+inKmfF5\n\tLQZgY5xDoW6qL+AECL+1bWLyqa+f+6Q2WulUJw/eRZCUwLSDlUlU3v/xCgB2TT5hT8rFugLzfOE\n\tk=","X-Gm-Gg":"ASbGnctrOLzZPFZOaZaoESoT/nh015BXMazBIm8T720AXjrYI5JnFlvpA5rtcdUMzTe\n\t21iIT7o8/htbW2okmk28/uCYyM+7mQYk7XZSgj6iPAcsnpgijFVGto7W99kGux+d5/PNMVcskLF\n\tUpbq03qLSg9zIpwn5T6dwoPI7hCqXUdKzGlzELzoVEAn8ppSe+Rit21ppPvgtwuMHv2LkrZkMEi\n\tcMXQ2ypoxzW2MVq4Qt1Ah3HqNeZ37+T/4J1opbw5BP4XjVU3s8BtfZfhqbrgu/Iyhzl7MXDgpFi\n\tVvqeRjDboXBA5Cs9kVgYhAEQXNiL5ysLihdBa/pPapsk3bWlKIos5ueVrK1W4k4wxG8RdlWAu1T\n\tB24F1RN9MvDJId7st4VZxGlA71bH1EVpR5GIFSg1efHao6z76yJ4i","X-Received":["by 2002:a17:907:1c03:b0:b4f:e12e:aa24 with SMTP id\n\ta640c23a62f3a-b6472b5e482mr63058866b.22.1760633420608; \n\tThu, 16 Oct 2025 09:50:20 -0700 (PDT)","by 2002:a17:907:1c03:b0:b4f:e12e:aa24 with SMTP id\n\ta640c23a62f3a-b6472b5e482mr63044766b.22.1760633417607; \n\tThu, 16 Oct 2025 09:50:17 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IHaitugMqIoQwe/NhKC1Oot6Oc3KvALQg/zlW5kJaqCv3Hm8fIEOeLlL7ymcFZGL96HpWBVPw==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  hdegoede@redhat.com,\n\tbod.linux@nxsw.ie","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","In-Reply-To":"<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb> (Milan\n\tZamazal's message of \"Thu, 16 Oct 2025 17:17:27 +0200\")","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Date":"Thu, 16 Oct 2025 18:50:16 +0200","Message-ID":"<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"yRlvWzLE1q5HKhU1tlcqILrKKZGkdIWvU-hWFTtlKeQ_1760633421","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":36336,"web_url":"https://patchwork.libcamera.org/comment/36336/","msgid":"<85tszxnywr.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-10-17T18:52:52","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n> to application of colour correction data.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++\n>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 ++++++\n>  2 files changed, 12 insertions(+)\n>\n> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> index c0632eb1..8b35dd63 100644\n> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> @@ -69,6 +69,7 @@ uniform sampler2D red_param;\n>  uniform sampler2D green_param;\n>  uniform sampler2D blue_param;\n>  uniform mat3 ccm;\n> +uniform vec3 awb;\n>  \n>  void main(void)\n>  {\n> @@ -216,6 +217,11 @@ void main(void)\n>  \t\t\tvec3(patterns.y, C, patterns.x) :\n>  \t\t\tvec3(patterns.wz, C));\n>  \n> +\t/* Apply white balance before colour correction matrix */\n> +\trgb.r = rgb.r * awb.r;\n> +\trgb.g = rgb.g * awb.g;\n> +\trgb.b = rgb.b * awb.b;\n\nThis block is misaligned, should be indented by 4 spaces rather than a\ntab.  And I think it can be simplified as:\n\n  rgb = rgb * awb;\n\nAnd it should be applied only if APPLY_RGB_PARAMETERS.  For CCM, it's\napplied to the CCM in lut.cpp:\n\n  Matrix<float, 3, 3> gainCcm = { { gains.r(), 0, 0,\n  \t\t\t\t  0, gains.g(), 0,\n  \t\t\t\t  0, 0, gains.b() } };\n  auto ccm = context.activeState.ccm.ccm * gainCcm;\n\nThe same for the other shader.\n\n> +\n>  #if defined(APPLY_CCM_PARAMETERS)\n>  \t/*\n>  \t *   CCM is a 3x3 in the format\n> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> index 74ce1509..37bd4812 100644\n> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> @@ -28,6 +28,7 @@ varying vec4            center;\n>  varying vec4            yCoord;\n>  varying vec4            xCoord;\n>  uniform mat3\t\tccm;\n> +uniform vec3\t\tawb;\n>  \n>  void main(void) {\n>      vec3 rgb;\n> @@ -111,6 +112,11 @@ void main(void) {\n>              vec3(PATTERN.w, C, PATTERN.z) :\n>              vec3(PATTERN.yx, C));\n>\n> +\t/* Apply white balance before colour correction matrix */\n> +\trgb.r = rgb.r * awb.r;\n> +\trgb.g = rgb.g * awb.g;\n> +\trgb.b = rgb.b * awb.b;\n> +\n>  #if defined(APPLY_CCM_PARAMETERS)\n>  \t/*\n>  \t *   CCM is a 3x3 in the format","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 B5946C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Oct 2025 18:53:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 966BB606BF;\n\tFri, 17 Oct 2025 20:53:00 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36F68606B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 20:52:59 +0200 (CEST)","from mail-wr1-f72.google.com (mail-wr1-f72.google.com\n\t[209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-80-BgWgnOPbPH6o6k25LxFhMg-1; Fri, 17 Oct 2025 14:52:56 -0400","by mail-wr1-f72.google.com with SMTP id\n\tffacd0b85a97d-4270848ceffso2071511f8f.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 11:52:55 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-427ea5a0f19sm715068f8f.9.2025.10.17.11.52.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Oct 2025 11:52:53 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"aKMKumuX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1760727178;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=O4fkcH08LcEImM6LoWPMDltxIo4dDH/j0IvHFCPRrjE=;\n\tb=aKMKumuXS7f+zqZYGvdsfKgjOc5WTCN++ctRzxNcnbbxpwopZ61hm3grXDXMM+wA8t4EWo\n\tObUWznieJBPJlSKGLsHbqF8mK7EmhvHRDtUJYgQlghgqXnKQYI7VohRMbcNMkW+xSmF1Sn\n\tAETTMulMms/Ms7YGhEpHwRcTXLe+LJc=","X-MC-Unique":"BgWgnOPbPH6o6k25LxFhMg-1","X-Mimecast-MFC-AGG-ID":"BgWgnOPbPH6o6k25LxFhMg_1760727175","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760727175; x=1761331975;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=O4fkcH08LcEImM6LoWPMDltxIo4dDH/j0IvHFCPRrjE=;\n\tb=b8jCkwGobwT2R2iBsHGRnHn2LZmmJsO9vRMV3Kn7f09pLobsAGX2ZvcqQAoXLaFECP\n\t8Ida7G9Wkh48lHt0C/e7CgqPm1HZSG82joqd7bROD7aSGkacBg26OvIzEI16TYQV9ao5\n\tldEl5zPfcplZ1ozoMh/o0Xro8ni+I5sB12Ca4IbvIvy/8l7G1U4OLKnmbUOHcw0ygOI3\n\tYnmdxL1J3hwhEN3eU3KUo/L6nN4YuEVBi1TE1chydKBqDzwTwhyfvz1SF7lAxNFMvFcs\n\tX9fGB7sdS3r0LGHzm85Sfu/kFcegwRQRTWCic2FnOBgCmXgEy5NWcZCFClN+OgHWXfuz\n\t1uDw==","X-Gm-Message-State":"AOJu0YznzBlQNEdtMzepAy82hr6b0LImuqIFV6Jk/O5bYQOKv/u1si2D\n\tPW5ktLYXcCJ9mqQr93HdTgRfDrVD2qKXjL9qBbsD7HWhOaqIuFv3KsyQCp+TyebVYTpbYmOC0D7\n\tLkR9pSO4oqM9eXJa1SnRrE6khyUwDL7obfK20v/9X+LIaX5LFuDlGfuWQkP3g5NYUyj2wueX2ga\n\tg=","X-Gm-Gg":"ASbGncvmq0WUum7mFmdK5A/w3OTZwvWKWZE1UyBZr+2YTN6mhTnw3vPLcd4EhUp+Lfc\n\tUHN0IsMinzK0too+OuykaQA6MtXB3/ByX3HVOPI0MuWgxmXM3NvEjKoli1lpIHOEsYSPJVguBMb\n\tLVv7zPff3bOtKuxZeWLv9hu+SlHSMMzryG/hVF9cJ+QndBKVlti/0LkCEV//JYXtVeDTrk/E4Y8\n\ty3MSvxD5C7k8A5zEjPMXIIj5OzgFLrNEBqhLEjmXnAeTbFtQ20SagbPYgw6HP7tmX8q8yflEYy2\n\tcDuAILxOhcuaMy5sO00oej0mY1k1LLHGvehYPZ13aMDAnu9iUX8nBBBR9ncG6K4Rwd8urpwT/ed\n\t2Gz2jPdpOtMqxTnfOFtkkeN/Y3C44U0g8vz++95tXNN8X2IUKtmhJ","X-Received":["by 2002:a05:6000:2c0e:b0:405:3028:1bce with SMTP id\n\tffacd0b85a97d-42704daed0fmr3377586f8f.32.1760727174815; \n\tFri, 17 Oct 2025 11:52:54 -0700 (PDT)","by 2002:a05:6000:2c0e:b0:405:3028:1bce with SMTP id\n\tffacd0b85a97d-42704daed0fmr3377570f8f.32.1760727174400; \n\tFri, 17 Oct 2025 11:52:54 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IF6DzEv9rTQDkqJSQShDKRIC9yygc6AJD1lLvv7xCIfkneCf6eTe2qnxPTrCByflaXGCzO3zA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  hdegoede@redhat.com,\n\tbod.linux@nxsw.ie","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","In-Reply-To":"<20251015012251.17508-33-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 15 Oct 2025 02:22:44 +0100\")","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>","Date":"Fri, 17 Oct 2025 20:52:52 +0200","Message-ID":"<85tszxnywr.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"fpisdOCmpWoT0r4Rr4KM_xcy0tVEbk7Lkm8MBgS9HZA_1760727175","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":36340,"web_url":"https://patchwork.libcamera.org/comment/36340/","msgid":"<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-10-18T11:03:48","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Milan Zamazal <mzamazal@redhat.com> writes:\n\n> Milan Zamazal <mzamazal@redhat.com> writes:\n>\n>> Hi Bryan,\n>>\n>> Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n>>\n>>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n>>> to application of colour correction data.\n>>\n>> I may be missing something but I think white balance is already applied\n>> in lut.cpp to both the CCM and the R/G/B lookup tables.\n>\n> I must be something missing, I get a colour cast without this, at least\n> when CCM is not used.\n\nThe problem was that the shader looks up all the RGB channels in\nred_param by mistake, as reported on the corresponding patch.\n\nAWB shouldn't be handled in the shaders at all, it's already\nincorporated in the lookup tables or CCM.\n\nWith the fixes I reported yesterday and today, I get the same output\nwith and without CCM. \\o/\n\n>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>>> ---\n>>>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++\n>>>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 ++++++\n>>>  2 files changed, 12 insertions(+)\n>>>\n>>> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>>> index c0632eb1..8b35dd63 100644\n>>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>>> @@ -69,6 +69,7 @@ uniform sampler2D red_param;\n>>>  uniform sampler2D green_param;\n>>>  uniform sampler2D blue_param;\n>>>  uniform mat3 ccm;\n>>> +uniform vec3 awb;\n>>>  \n>>>  void main(void)\n>>>  {\n>>> @@ -216,6 +217,11 @@ void main(void)\n>>>  \t\t\tvec3(patterns.y, C, patterns.x) :\n>>>  \t\t\tvec3(patterns.wz, C));\n>>>  \n>>> +\t/* Apply white balance before colour correction matrix */\n>>> +\trgb.r = rgb.r * awb.r;\n>>> +\trgb.g = rgb.g * awb.g;\n>>> +\trgb.b = rgb.b * awb.b;\n>>> +\n>>>  #if defined(APPLY_CCM_PARAMETERS)\n>>>  \t/*\n>>>  \t *   CCM is a 3x3 in the format\n>>> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>>> index 74ce1509..37bd4812 100644\n>>> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n>>> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>>> @@ -28,6 +28,7 @@ varying vec4            center;\n>>>  varying vec4            yCoord;\n>>>  varying vec4            xCoord;\n>>>  uniform mat3\t\tccm;\n>>> +uniform vec3\t\tawb;\n>>>  \n>>>  void main(void) {\n>>>      vec3 rgb;\n>>> @@ -111,6 +112,11 @@ void main(void) {\n>>>              vec3(PATTERN.w, C, PATTERN.z) :\n>>>              vec3(PATTERN.yx, C));\n>>>  \n>>> +\t/* Apply white balance before colour correction matrix */\n>>> +\trgb.r = rgb.r * awb.r;\n>>> +\trgb.g = rgb.g * awb.g;\n>>> +\trgb.b = rgb.b * awb.b;\n>>> +\n>>>  #if defined(APPLY_CCM_PARAMETERS)\n>>>  \t/*\n>>>  \t *   CCM is a 3x3 in the format","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 38291C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 18 Oct 2025 11:03:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 804E9606D4;\n\tSat, 18 Oct 2025 13:03:55 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CED41606BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Oct 2025 13:03:53 +0200 (CEST)","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n\t[209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-67-QPJpqud5Oba3IpedrXBtFw-1; Sat, 18 Oct 2025 07:03:51 -0400","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-47113dcc1e0so23875385e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Oct 2025 04:03:51 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4714fb1b668sm49680555e9.0.2025.10.18.04.03.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 18 Oct 2025 04:03:48 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"eHKLk2To\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1760785432;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=d95BhoSM/FSpTtDzFEJqB1gXCy0Tr/54UvqErzmhE7s=;\n\tb=eHKLk2Tod1GQWZk8escPFlNKl/BonwDXqqezp6YQ2D8tGZm8hNhjwMR+BV3PZrdDDXM5IH\n\t0smQIUIULkllS6V82jvp5IqQsxxNY5EUGSpRkhw0tRQd/3bQ9R6luMHY+oRHxMC/SUYQt3\n\tstQ4wqPrlt+rmegVw73tjBoVxOtDRcI=","X-MC-Unique":"QPJpqud5Oba3IpedrXBtFw-1","X-Mimecast-MFC-AGG-ID":"QPJpqud5Oba3IpedrXBtFw_1760785430","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760785430; x=1761390230;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=d95BhoSM/FSpTtDzFEJqB1gXCy0Tr/54UvqErzmhE7s=;\n\tb=feQEJNG9MxV+FMnymVMngxZ0caaG4CM6pXc94tm3Vh2wxU08nZn46z+lgkl/B20n83\n\t0YR3IPJAwDDC2J/TukhxOXuHrFQFPoFr1jYweKR9MdEaB9ACl4wzijkTJ8Pb2+Xq6vRK\n\tqJWWhkSXHoP2X/jtVO3vre8jXynyEPDLrS1mfEWWevr5L+LhnsOx7291cDTO3q3m1MU8\n\tc0ipI5sItLJKKTZ8aNxrrkSJVKixYIbcbmquVNPXf8FOR5/5wuwVgrcNbx6JQ6ZkIjY1\n\tdcLfmsDKDo4v0KxumsqV+rtxNRqxBRFzKz7vIJ5+hh8+P4ZnY/oJp0vP35NmxX+WrMmo\n\tW9ug==","X-Gm-Message-State":"AOJu0YxKCrB1PFcDoUOt5UP6IkUIZGlDHHY/yp/gbQJLZGUgatNKWKmt\n\t5vJWgLpR7w47eZGfu5quroSOZDudThY3AH3jza8CjAioDyiJkizgDFuOhsHqep4DeuRz81FNwpS\n\tS1mILgAJZFS6k2edlbJ82f+fWgRZKwbFlOeAhSHw3uSbmoo0uDAHKSr91CJGPo/wW4HRnRlU/hl\n\tQ4zDJDM6s=","X-Gm-Gg":"ASbGnctK49gngo0AKt75e7gttlr3g6WLhDXhxkrCRnLBpB29hT7HBRPOFcfh7RucDmJ\n\t9XeQF7gR1lxqJNAijqi7LicrWu40I+ATF6Jd4b5FYNsFqi+2+s/1ZqJ4wby/ZX08KP4UrrXi2T8\n\tpQfFIQLyemfczVpxIgJgcS944UTYSebj/5avirRLanGcQBhLOJn2RJG7Jkdxi8ybd46FqRRcADF\n\tDXeXLrCbQ9yHbgcZRuTFY0h9I/SePQV4hd5pR3r8BDGBTcxu5BBgfVAFE3k7HBuYlEexfIxZQ4d\n\thmIl2Xg0ng33gxOd/kwf3P9vQ1xDsMxesKLO+XjgnhelxAYTV+X+2uqT+3FRB5QXCA/Ubho8DqN\n\t5sQVDTZ697k9CE5EyfysE+gBWPcLHINwwWKb5rvy5MrxviJrJfcLD","X-Received":["by 2002:a05:600c:3b8d:b0:471:60c:1501 with SMTP id\n\t5b1f17b1804b1-47117918c0cmr59775695e9.28.1760785429830; \n\tSat, 18 Oct 2025 04:03:49 -0700 (PDT)","by 2002:a05:600c:3b8d:b0:471:60c:1501 with SMTP id\n\t5b1f17b1804b1-47117918c0cmr59775505e9.28.1760785429380; \n\tSat, 18 Oct 2025 04:03:49 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IFv2SONpg1DF+H+36h/GWGzDqLbK5s5ab9B41+A7uELAfxP0ZxORblMDIeahpZyCVZZA8CZXg==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  hdegoede@redhat.com,\n\tbod.linux@nxsw.ie","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","In-Reply-To":"<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb> (Milan\n\tZamazal's message of \"Thu, 16 Oct 2025 18:50:16 +0200\")","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Date":"Sat, 18 Oct 2025 13:03:48 +0200","Message-ID":"<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"sqtsva5So3nYlTi1NBtYzX2Tew_UNy-eG0j5DRpTwcY_1760785430","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":36341,"web_url":"https://patchwork.libcamera.org/comment/36341/","msgid":"<85qzv0sc1p.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-10-18T11:07:46","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Milan Zamazal <mzamazal@redhat.com> writes:\n\n> Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n>\n>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n>> to application of colour correction data.\n>>\n>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>> ---\n>>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++\n>>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 ++++++\n>>  2 files changed, 12 insertions(+)\n>>\n>> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> index c0632eb1..8b35dd63 100644\n>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> @@ -69,6 +69,7 @@ uniform sampler2D red_param;\n>>  uniform sampler2D green_param;\n>>  uniform sampler2D blue_param;\n>>  uniform mat3 ccm;\n>> +uniform vec3 awb;\n>>  \n>>  void main(void)\n>>  {\n>> @@ -216,6 +217,11 @@ void main(void)\n>>  \t\t\tvec3(patterns.y, C, patterns.x) :\n>>  \t\t\tvec3(patterns.wz, C));\n>>  \n>> +\t/* Apply white balance before colour correction matrix */\n>> +\trgb.r = rgb.r * awb.r;\n>> +\trgb.g = rgb.g * awb.g;\n>> +\trgb.b = rgb.b * awb.b;\n>\n> This block is misaligned, should be indented by 4 spaces rather than a\n> tab.  And I think it can be simplified as:\n>\n>   rgb = rgb * awb;\n>\n> And it should be applied only if APPLY_RGB_PARAMETERS.\n\nIt shouldn't be applied anywhere.  AWB is already part of the lookup\ntables created in lut.cpp:\n\n  auto &gains = context.activeState.awb.gains;\n  ...  \n  if (!context.ccmEnabled) {\n  \tfor (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {\n  \t\t/* Apply gamma after gain! */\n  \t\tconst RGB<float> lutGains = (gains * i / div).min(gammaTableSize - 1);\n  \t\tparams->red[i] = gammaTable[static_cast<unsigned int>(lutGains.r())];\n  \t\tparams->green[i] = gammaTable[static_cast<unsigned int>(lutGains.g())];\n  \t\tparams->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n\nAn unrelated bug in the shader confused me when testing this.\n\nSorry for the incremental reviews.  I think I'm done with v3 review and\ntesting now.\n\n> For CCM, it's applied to the CCM in lut.cpp:\n>\n>   Matrix<float, 3, 3> gainCcm = { { gains.r(), 0, 0,\n>   \t\t\t\t  0, gains.g(), 0,\n>   \t\t\t\t  0, 0, gains.b() } };\n>   auto ccm = context.activeState.ccm.ccm * gainCcm;\n>\n> The same for the other shader.\n>\n>> +\n>>  #if defined(APPLY_CCM_PARAMETERS)\n>>  \t/*\n>>  \t *   CCM is a 3x3 in the format\n>> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> index 74ce1509..37bd4812 100644\n>> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> @@ -28,6 +28,7 @@ varying vec4            center;\n>>  varying vec4            yCoord;\n>>  varying vec4            xCoord;\n>>  uniform mat3\t\tccm;\n>> +uniform vec3\t\tawb;\n>>  \n>>  void main(void) {\n>>      vec3 rgb;\n>> @@ -111,6 +112,11 @@ void main(void) {\n>>              vec3(PATTERN.w, C, PATTERN.z) :\n>>              vec3(PATTERN.yx, C));\n>>\n>> +\t/* Apply white balance before colour correction matrix */\n>> +\trgb.r = rgb.r * awb.r;\n>> +\trgb.g = rgb.g * awb.g;\n>> +\trgb.b = rgb.b * awb.b;\n>> +\n>>  #if defined(APPLY_CCM_PARAMETERS)\n>>  \t/*\n>>  \t *   CCM is a 3x3 in the format","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 2B3B4BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 18 Oct 2025 11:07:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 52421606DA;\n\tSat, 18 Oct 2025 13:07:53 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FC3E606CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Oct 2025 13:07:52 +0200 (CEST)","from mail-wm1-f71.google.com (mail-wm1-f71.google.com\n\t[209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-664-6eKfwA3hMQqtDn2SW4Ozjg-1; Sat, 18 Oct 2025 07:07:49 -0400","by mail-wm1-f71.google.com with SMTP id\n\t5b1f17b1804b1-471001b980eso17989535e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Oct 2025 04:07:49 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-427f00ce3e2sm4326086f8f.47.2025.10.18.04.07.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 18 Oct 2025 04:07:46 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"LAPkFZtP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1760785671;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=AC1qSjSZjWpoZyJMX3spuZHUAzNAjGgl9fAyt6FTxE8=;\n\tb=LAPkFZtPT3Afd5DZ4RuWMVp3Rg9rB3VMNAimPsq6iGsHPhSbf0Vace0zK0iL6L6jCO8dG5\n\tYLCqjzvD29xlUwoTQq2LCWd78fuqJ39Pww0zleGyC9HyV6aqZYTkHxE7iSEa2p5rXg348V\n\tXs71U0MQE8y6GpJX/Al+E1cB5qoPYjw=","X-MC-Unique":"6eKfwA3hMQqtDn2SW4Ozjg-1","X-Mimecast-MFC-AGG-ID":"6eKfwA3hMQqtDn2SW4Ozjg_1760785669","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760785668; x=1761390468;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=AC1qSjSZjWpoZyJMX3spuZHUAzNAjGgl9fAyt6FTxE8=;\n\tb=cxn3BMR2JmSmXTFruhlhl14H6TrUmxjq3Rh3mfCbA+m4FkbtbGs1apCO7F/MPwaAeY\n\thEOWkhyhXFwaszWlA99pKo0yLkBhuJ2BJjXwgOHTNYerC53GDAMetfjdswSGw7ws3RtB\n\tIkEJNyUHIsQyoEo6Iq/zlJGBkkrEr2pz92uetJR99mNXdCAUMIGMgdNvLuEObTdlqPHi\n\tma5+B6oQvN38zdnFerL5MTqa03qw4jJXqb3W/bZ7UL+ncAlTSwggDhzWTnbk8C3RWZTZ\n\tvCibjeT0UxPC0+AJezlZmaGl9z+nCliXzxkUTaGaYHIyf1AFKZ0wGuHAJ/dPl5cUVfH8\n\tOjwA==","X-Gm-Message-State":"AOJu0YypH7WvycrHCxtFaGdmjneMctRsswpk0hP4IKtbG7nkTeCNNkTS\n\t0X79tRofUt0vQPsyBArD8z5tPpCsIu6uzaMJUbKXnXxjI1UQ2BWKzCr3ly5gnMHMXavuLoW2HEt\n\t8md0zrp3JglrhQ3rT3hnblel3UFu+teEki+W77ZL+J50NZIBZPv+OXetrU5wuhc616pdjxO3M8s\n\t8=","X-Gm-Gg":"ASbGncsU/80Jzom07vxhofu1Qnt/CrvlLKZ++AzokQpy7qW+RvWbOTxHCTZKwbDHttc\n\tGwVcpAoTXnuFaIyFii0FM5twrZQiy7kxopdlzYV5qBP/V7uqlMqsokk3bwEBW7hlTRfscr39PQg\n\tkMCAoZ7bhM1xcUwFzWKoZVfkN9DNcxKlQWnQo3L4dkYBZPJYLXmyirEYicV6mtjTY2GQWDKyVrp\n\tgvQz9MINABMPy7CxHmQ4GatOose7j7os6GeogLo0LgcphcH54COLWIbVzmhAJXif/1t9LhmNb6d\n\t8U4AtYd8HTfPEiDBhbl/7W73vvS/D7snf/Mk1RX7B36BAJlSs6D8Ixht75cR6d6elF3m83Yc2Fs\n\t3vUNcA/6G/Rj3vjFoaNoat49aZWi+ilRMPOhL/eemzWw3LmX+6K82","X-Received":["by 2002:a05:600c:518f:b0:46e:4a60:ea2c with SMTP id\n\t5b1f17b1804b1-47117925e1dmr52694485e9.37.1760785668512; \n\tSat, 18 Oct 2025 04:07:48 -0700 (PDT)","by 2002:a05:600c:518f:b0:46e:4a60:ea2c with SMTP id\n\t5b1f17b1804b1-47117925e1dmr52694345e9.37.1760785668124; \n\tSat, 18 Oct 2025 04:07:48 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IH1EmKm4Packtwn9GAyBYrsyDnPkuHyQQO8tmBXnT+AH5HeSSFGLAQSl7yen/QqEQNeA27YKA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  hdegoede@redhat.com,\n\tbod.linux@nxsw.ie","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","In-Reply-To":"<85tszxnywr.fsf@mzamazal-thinkpadp1gen7.tpbc.csb> (Milan\n\tZamazal's message of \"Fri, 17 Oct 2025 20:52:52 +0200\")","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszxnywr.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Date":"Sat, 18 Oct 2025 13:07:46 +0200","Message-ID":"<85qzv0sc1p.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"gUuecwouQpS4nW-rh22JFj9TJQ8z6zudjXJsMkIQdqo_1760785669","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":36812,"web_url":"https://patchwork.libcamera.org/comment/36812/","msgid":"<aRcd8RCbsEF+FZhh@duo.ucw.cz>","date":"2025-11-14T12:17:53","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> >> Hi Bryan,\n> >>\n> >> Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:\n> >>\n> >>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n> >>> to application of colour correction data.\n> >>\n> >> I may be missing something but I think white balance is already applied\n> >> in lut.cpp to both the CCM and the R/G/B lookup tables.\n> >\n> > I must be something missing, I get a colour cast without this, at least\n> > when CCM is not used.\n> \n> The problem was that the shader looks up all the RGB channels in\n> red_param by mistake, as reported on the corresponding patch.\n> \n> AWB shouldn't be handled in the shaders at all, it's already\n> incorporated in the lookup tables or CCM.\n> \n> With the fixes I reported yesterday and today, I get the same output\n> with and without CCM. \\o/\n\nI'm still going through the code but...\n\nYou really, really, really want to handle this in shaders on arm64.\n\nTouching the framebuffer data from CPU on the arm64 is very expensive\ndue to cache issues. But you can do everything on the GPU, and then\nyou don't have to pay the cost.\n\nv4l (4MP)-> cpu -> gpu (1MP)-> cpu === slow\nv4l (4MP)-> gpu (1MP)-> cpu === better\n\n(Second case is even better if you can scale down while debayering and\nto YUY2. Then you can actually record 0.8MPix, 30fps videos on slow\nhardware such as Librem 5).\n\nBest regards,\n\t\t\t\t\t\t\t\tPavel","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 5A02CC3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 12:17:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 945FE60A81;\n\tFri, 14 Nov 2025 13:17:55 +0100 (CET)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DCB5606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 13:17:54 +0100 (CET)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid 1AC671C01B7; Fri, 14 Nov 2025 13:17:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"c2PLGvNf\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1763122674;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=rBkpdlpDIm1hRQEjAaFo0GSoG59BOZeJMSydtd004ts=;\n\tb=c2PLGvNfgddcFH2ggNIQELR9A2j/v1j5EHpPFT3WxaKxBCiMfMnA6Wf13pwghifw7APdXT\n\to+ZRzVqrXoA6+8qnGvHZBPQo+wNQBv6EzjFIdnOq0KDNCLLIQxGvzrr/4vSnXmZQ675npJ\n\tsVrchwdyYEbN7E5V1OxpmhrYFt7BsaQ=","Date":"Fri, 14 Nov 2025 13:17:53 +0100","From":"Pavel Machek <pavel@ucw.cz>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","Message-ID":"<aRcd8RCbsEF+FZhh@duo.ucw.cz>","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"EYCsFrIEky4rMfWM\"","Content-Disposition":"inline","In-Reply-To":"<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","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>"}},{"id":36813,"web_url":"https://patchwork.libcamera.org/comment/36813/","msgid":"<aRcis1r2PU7OaIoy@duo.ucw.cz>","date":"2025-11-14T12:38:11","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"On Fri 2025-11-14 13:17:54, Pavel Machek wrote:\n> Hi!\n> \n> > >> Hi Bryan,\n> > >>\n> > >> Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:\n> > >>\n> > >>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n> > >>> to application of colour correction data.\n> > >>\n> > >> I may be missing something but I think white balance is already applied\n> > >> in lut.cpp to both the CCM and the R/G/B lookup tables.\n> > >\n> > > I must be something missing, I get a colour cast without this, at least\n> > > when CCM is not used.\n> > \n> > The problem was that the shader looks up all the RGB channels in\n> > red_param by mistake, as reported on the corresponding patch.\n> > \n> > AWB shouldn't be handled in the shaders at all, it's already\n> > incorporated in the lookup tables or CCM.\n> > \n> > With the fixes I reported yesterday and today, I get the same output\n> > with and without CCM. \\o/\n> \n> I'm still going through the code but...\n> \n> You really, really, really want to handle this in shaders on arm64.\n> \n> Touching the framebuffer data from CPU on the arm64 is very expensive\n> due to cache issues. But you can do everything on the GPU, and then\n> you don't have to pay the cost.\n\nI misunderstood how this works, I did not expect code to use lookup\ntables on GPU.\n\n> v4l (4MP)-> cpu -> gpu (1MP)-> cpu === slow\n> v4l (4MP)-> gpu (1MP)-> cpu === better\n> \n> (Second case is even better if you can scale down while debayering and\n> to YUY2. Then you can actually record 0.8MPix, 30fps videos on slow\n> hardware such as Librem 5).\n\nAnd no, I don't believe current code can do debayer+scale or YUY2. I\nguess I should take a look after this is merged... or maybe I should\nlook at AF, first.\n\nBest regards,\n\n\t\t\t\t\t\t\t\tPavel","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 F2431C3263\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 12:38:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C217760A8B;\n\tFri, 14 Nov 2025 13:38:13 +0100 (CET)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4215D606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 13:38:12 +0100 (CET)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid C9E311C00AB; Fri, 14 Nov 2025 13:38:11 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"CDIBKLIM\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1763123891;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=HadP8UOZrsbr8F4odNRiUw67vACXdTLpSLBX+iZcYKk=;\n\tb=CDIBKLIMvrPAKhLYLT1yMMFZNf0GW7SGulp+4fVoKZTj0Xz9i23ra1xOTut1XtgHpj+BJT\n\tKTFIQ/MvOATbv/7jh0HVdb6td5R65sB697RACUQ24IrJtOpaP8UtGwsbzi/ON6fliCMrlz\n\tsafSupE6pwxXWthdzoxj3wwnIilPrKI=","Date":"Fri, 14 Nov 2025 13:38:11 +0100","From":"Pavel Machek <pavel@ucw.cz>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","Message-ID":"<aRcis1r2PU7OaIoy@duo.ucw.cz>","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<aRcd8RCbsEF+FZhh@duo.ucw.cz>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"MpYVQEF5SRWffC+v\"","Content-Disposition":"inline","In-Reply-To":"<aRcd8RCbsEF+FZhh@duo.ucw.cz>","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>"}},{"id":36814,"web_url":"https://patchwork.libcamera.org/comment/36814/","msgid":"<0fdfe82f-6ace-4612-b0db-c54916b4c048@collabora.com>","date":"2025-11-14T12:49:35","subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","submitter":{"id":140,"url":"https://patchwork.libcamera.org/api/people/140/","name":"Robert Mader","email":"robert.mader@collabora.com"},"content":"Hi Pavel!\n\nOn 14.11.25 13:38, Pavel Machek wrote:\n> On Fri 2025-11-14 13:17:54, Pavel Machek wrote:\n>> Hi!\n>>\n>>>>> Hi Bryan,\n>>>>>\n>>>>> Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:\n>>>>>\n>>>>>> Add the ability to apply a vec3 AWB array against the demosaiced data prior\n>>>>>> to application of colour correction data.\n>>>>> I may be missing something but I think white balance is already applied\n>>>>> in lut.cpp to both the CCM and the R/G/B lookup tables.\n>>>> I must be something missing, I get a colour cast without this, at least\n>>>> when CCM is not used.\n>>> The problem was that the shader looks up all the RGB channels in\n>>> red_param by mistake, as reported on the corresponding patch.\n>>>\n>>> AWB shouldn't be handled in the shaders at all, it's already\n>>> incorporated in the lookup tables or CCM.\n>>>\n>>> With the fixes I reported yesterday and today, I get the same output\n>>> with and without CCM. \\o/\n>> I'm still going through the code but...\n>>\n>> You really, really, really want to handle this in shaders on arm64.\n>>\n>> Touching the framebuffer data from CPU on the arm64 is very expensive\n>> due to cache issues. But you can do everything on the GPU, and then\n>> you don't have to pay the cost.\n> I misunderstood how this works, I did not expect code to use lookup\n> tables on GPU.\n>\n>> v4l (4MP)-> cpu -> gpu (1MP)-> cpu === slow\n>> v4l (4MP)-> gpu (1MP)-> cpu === better\n>>\n>> (Second case is even better if you can scale down while debayering and\n>> to YUY2. Then you can actually record 0.8MPix, 30fps videos on slow\n>> hardware such as Librem 5).\n> And no, I don't believe current code can do debayer+scale or YUY2. I\n> guess I should take a look after this is merged... or maybe I should\n> look at AF, first.\n\nThe current series does implement debayering on the GPU (see \ndebayer_egl), however it takes a round-trip to CPU before uploading, i.e.\n\nv4l2 -> CPU -> GPU (debayer / conversion to RGB) -> client (which may \nuse it with GPU or CPU)\n\nThere is a WIP patch to implement direct GPU import when possible (not \nplanned to get picked before the merge / planned as follow-up)\n\nhttps://gitlab.freedesktop.org/rmader/libcamera/-/commit/1f5c2764c4d42c916e52f9c06c44f4ae52519a78\n\nas well as a patch to implement scaling on the GPU (planned to get \npicked for v4 IIUC)\n\nhttps://gitlab.freedesktop.org/rmader/libcamera/-/commit/048cc02e295fd82f6ecfb1d5c6280a21709cd0d5\n\n>\n> Best regards,\n>\n> \t\t\t\t\t\t\t\tPavel\nBest regards","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 0BC71C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 12:49:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BA1A860A80;\n\tFri, 14 Nov 2025 13:49:47 +0100 (CET)","from sender4-op-o12.zoho.com (sender4-op-o12.zoho.com\n\t[136.143.188.12])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B9A37606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 13:49:45 +0100 (CET)","by mx.zohomail.com with SMTPS id 1763124579531502.1629694540958;\n\tFri, 14 Nov 2025 04:49:39 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"OH5gVai3\"; \n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1763124582; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=fCSfbsaog1X6ChqILzYkjebniIFoxP8Y9+LaP7O+4MbtwoC4PoK65VE9pUo8A1JYptp2N9ZgGEH8M7FosA7oV/W5DeefkLUr/jw1jVxuLAUgxWte4xk81mLnCmNF9JrWXzzHdyV0CZ9bCaynxZLIGZcCWP1xCxWUmB39JLHQEwU=","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1763124582;\n\th=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc;\n\tbh=fluAAuR6etUjyRslOXp3y9riWOw74imp7lUtVykn/Po=; \n\tb=Parqt7d01W7YmaWqb0fyjNszztGJkFmcXQCekgJ/g+28OtqNIkNNsgZ3uZZAfHR/FGmbZ83ilR9YfxsR3ySw2lgtpx7ijE+4eznanT+I+R5QeY1T7fbwq0I4ocjhTGXNEsZWeKe/Sm+LL4cf79aMMMc1arUFoA+Bb7C7pqiGl7Q=","ARC-Authentication-Results":"i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763124582;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc;\n\tbh=fluAAuR6etUjyRslOXp3y9riWOw74imp7lUtVykn/Po=;\n\tb=OH5gVai31XfhVqw//ebMOX/1DaJPFCPEco9/KcVYG1FVvJ0Q/L5BgZQ39WHn1cSR\n\tc8TkNY2bUDFyoiDacrkrlzY9GeRjjqOOwI+qXaP/Tk/Dhqcfl3fCsXR3ODW1xl/aF2F\n\tICP/iWDcVFXMGIQJHJ8uk86wI9Z4vhLKLdUzf8b0=","Message-ID":"<0fdfe82f-6ace-4612-b0db-c54916b4c048@collabora.com>","Date":"Fri, 14 Nov 2025 13:49:35 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White\n\tBalance gains","To":"libcamera-devel@lists.libcamera.org","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-33-bryan.odonoghue@linaro.org>\n\t<85tszydgfs.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<855xcebxkn.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<85v7kcsc8b.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<aRcd8RCbsEF+FZhh@duo.ucw.cz> <aRcis1r2PU7OaIoy@duo.ucw.cz>","Content-Language":"en-US, de-DE","From":"Robert Mader <robert.mader@collabora.com>","In-Reply-To":"<aRcis1r2PU7OaIoy@duo.ucw.cz>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}}]