[{"id":36285,"web_url":"https://patchwork.libcamera.org/comment/36285/","msgid":"<176057102234.635357.15128713905843995860@ping.linuxembedded.co.uk>","date":"2025-10-15T23:30:22","subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Bryan O'Donoghue (2025-10-15 02:22:42)\n> We can easily facilitate swapping R and B on output. Pivot on an\n> environment define for this purpose.\n> \n\nThis looks like wizardry to me. There's not much there and it looks\nreasonable for what is stated - but if I were to put an RB tag here I\nthink I'd feel like I was lying still ... I don't know what is supplying\nthe .bgr magic below.\n\nAnyway - that won't stop me putting this though:\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++\n>  include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 +++++-\n>  2 files changed, 9 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> index 90bd6457..c0632eb1 100644\n> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> @@ -268,5 +268,9 @@ void main(void)\n>         rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;\n>  #endif\n>  \n> +#if defined (SWAP_BLUE)\n> +       gl_FragColor = vec4(rgb.bgr, 1.0);\n> +#else\n>         gl_FragColor = vec4(rgb, 1.0);\n> +#endif\n>  }\n> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> index 5955c2ea..74ce1509 100644\n> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n> @@ -163,5 +163,9 @@ void main(void) {\n>         rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n>  #endif\n>  \n> -    gl_FragColor.rgb = rgb;\n> +#if defined (SWAP_BLUE)\n> +       gl_FragColor = vec4(rgb.bgr, 1.0);\n> +#else\n> +       gl_FragColor = vec4(rgb, 1.0);\n> +#endif\n>  }\n> -- \n> 2.51.0\n>","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 E17EFBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 15 Oct 2025 23:30:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C8586064F;\n\tThu, 16 Oct 2025 01:30:26 +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 2132D60643\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 01:30:25 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 92E851306;\n\tThu, 16 Oct 2025 01:28:45 +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=\"VjFO3iv6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760570925;\n\tbh=98QfKC48vywbCZAEjesILGqvSJ40UTtLabqVbIc9+Q8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=VjFO3iv6SwISAiZbaXewoyUD8tog0eV1cOgbs+0EurPDYZ2slkV5briax+Nfvp9e3\n\t3OY+AeYL2AgmxgSXQuTLU/VQfJi/lPuelmtSvDVYiGd/IJ6xDNa3K3LMkdGVuaiiYC\n\t87H9hEeqnNCDEW1JvbVnXElAEptoezgaP3A/98bc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251015012251.17508-31-bryan.odonoghue@linaro.org>","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-31-bryan.odonoghue@linaro.org>","Subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org,\n\tbod.linux@nxsw.ie","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 16 Oct 2025 00:30:22 +0100","Message-ID":"<176057102234.635357.15128713905843995860@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":36293,"web_url":"https://patchwork.libcamera.org/comment/36293/","msgid":"<55dbe931-fe23-42f6-a492-7ca75e455470@ideasonboard.com>","date":"2025-10-16T07:52:16","subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\n2025. 10. 16. 1:30 keltezéssel, Kieran Bingham írta:\n> Quoting Bryan O'Donoghue (2025-10-15 02:22:42)\n>> We can easily facilitate swapping R and B on output. Pivot on an\n>> environment define for this purpose.\n>>\n> \n> This looks like wizardry to me. There's not much there and it looks\n> reasonable for what is stated - but if I were to put an RB tag here I\n> think I'd feel like I was lying still ... I don't know what is supplying\n> the .bgr magic below.\n\nMaybe I misunderstand, but the `.bgr` part is explained at\nhttps://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html#vector-components\n\n\"\"\"\nThe order of the components can be different to swizzle them, or replicated:\n\nvec4 pos = vec4(1.0, 2.0, 3.0, 4.0);\nvec4 swiz = pos.wzyx;   // swiz = (4.0, 3.0, 2.0, 1.0)\nvec4 dup = pos.xxyy;    // dup = (1.0, 1.0, 2.0, 2.0)\n\"\"\"\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> Anyway - that won't stop me putting this though:\n> \n> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n>> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>> ---\n>>   include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++\n>>   include/libcamera/internal/shaders/bayer_unpacked.frag  | 6 +++++-\n>>   2 files changed, 9 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> index 90bd6457..c0632eb1 100644\n>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> @@ -268,5 +268,9 @@ void main(void)\n>>          rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;\n>>   #endif\n>>\n>> +#if defined (SWAP_BLUE)\n>> +       gl_FragColor = vec4(rgb.bgr, 1.0);\n>> +#else\n>>          gl_FragColor = vec4(rgb, 1.0);\n>> +#endif\n>>   }\n>> diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> index 5955c2ea..74ce1509 100644\n>> --- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag\n>> @@ -163,5 +163,9 @@ void main(void) {\n>>          rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n>>   #endif\n>>\n>> -    gl_FragColor.rgb = rgb;\n>> +#if defined (SWAP_BLUE)\n>> +       gl_FragColor = vec4(rgb.bgr, 1.0);\n>> +#else\n>> +       gl_FragColor = vec4(rgb, 1.0);\n>> +#endif\n>>   }\n>> --\n>> 2.51.0\n>>","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 41B3FBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Oct 2025 07:52:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F0B16065A;\n\tThu, 16 Oct 2025 09:52:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EF95600CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 09:52:20 +0200 (CEST)","from [192.168.33.24] (185.182.214.105.nat.pool.zt.hu\n\t[185.182.214.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 45565C71;\n\tThu, 16 Oct 2025 09:50:40 +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=\"t/ai90Br\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760601040;\n\tbh=+oXLryGdUz+ZVfWos1vHb9kl3zYBZJxTbw3jN0VLDkM=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=t/ai90Br6LH3BQ6thVNRU1Tj7KYIA8oXcRwp+RduOk5wOr9zZ7HXSd4NL++9Gr099\n\tXorF8tUPGwyBQffgSATMnJ1hdf7xEKupePSB2IeF2X77ydx6tWdwfUuSS2KUaIXVCH\n\tCN4ll+3ucTIo1Q3DPqwMv+bvXNIwcHWkBIgldCr8=","Message-ID":"<55dbe931-fe23-42f6-a492-7ca75e455470@ideasonboard.com>","Date":"Thu, 16 Oct 2025 09:52:16 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"hdegoede@redhat.com, mzamazal@redhat.com, bod.linux@nxsw.ie","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-31-bryan.odonoghue@linaro.org>\n\t<LVd5_eC0bMlqQXt_fHBLHOev_hovU3d8J22SRd3o0RI6irzevpZN6BFeQOY0SETc_9vSWoHinUwoEA1V4dqB-g==@protonmail.internalid>\n\t<176057102234.635357.15128713905843995860@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<176057102234.635357.15128713905843995860@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":36297,"web_url":"https://patchwork.libcamera.org/comment/36297/","msgid":"<c1521bfd-e5b6-4a2e-9bc6-339a3e069e76@nxsw.ie>","date":"2025-10-16T08:28:02","subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","submitter":{"id":226,"url":"https://patchwork.libcamera.org/api/people/226/","name":"Bryan O'Donoghue","email":"bod.linux@nxsw.ie"},"content":"On 16/10/2025 08:52, Barnabás Pőcze wrote:\n> Hi\n> \n> \n> 2025. 10. 16. 1:30 keltezéssel, Kieran Bingham írta:\n>> Quoting Bryan O'Donoghue (2025-10-15 02:22:42)\n>>> We can easily facilitate swapping R and B on output. Pivot on an\n>>> environment define for this purpose.\n>>>\n>>\n>> This looks like wizardry to me. There's not much there and it looks\n>> reasonable for what is stated - but if I were to put an RB tag here I\n>> think I'd feel like I was lying still ... I don't know what is supplying\n>> the .bgr magic below.\n> \n> Maybe I misunderstand, but the `.bgr` part is explained at\n> https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html#vector-components\n> \n> \"\"\"\n> The order of the components can be different to swizzle them, or replicated:\n> \n> vec4 pos = vec4(1.0, 2.0, 3.0, 4.0);\n> vec4 swiz = pos.wzyx;   // swiz = (4.0, 3.0, 2.0, 1.0)\n> vec4 dup = pos.xxyy;    // dup = (1.0, 1.0, 2.0, 2.0)\n> \"\"\"\nYeah weirdly I think there is no cost in swizzling at all or no cost you \ncan measure anyway.\n\nI should spell it out in the commit log what the swizzle is and why it \nworks.\n\n---\nbod","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 82B38BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Oct 2025 08:28:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74EAD6066A;\n\tThu, 16 Oct 2025 10:28:10 +0200 (CEST)","from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A26F600CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Oct 2025 10:28:08 +0200 (CEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id B65B86039A;\n\tThu, 16 Oct 2025 08:28:06 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 21FD8C4CEF1;\n\tThu, 16 Oct 2025 08:28:04 +0000 (UTC)"],"Message-ID":"<c1521bfd-e5b6-4a2e-9bc6-339a3e069e76@nxsw.ie>","Date":"Thu, 16 Oct 2025 09:28:02 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to\n\tsupport swapping R and B on output","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>, Bryan O'Donoghue\n\t<bryan.odonoghue@linaro.org>,  libcamera-devel@lists.libcamera.org","Cc":"hdegoede@redhat.com, mzamazal@redhat.com","References":"<20251015012251.17508-1-bryan.odonoghue@linaro.org>\n\t<20251015012251.17508-31-bryan.odonoghue@linaro.org>\n\t<LVd5_eC0bMlqQXt_fHBLHOev_hovU3d8J22SRd3o0RI6irzevpZN6BFeQOY0SETc_9vSWoHinUwoEA1V4dqB-g==@protonmail.internalid>\n\t<176057102234.635357.15128713905843995860@ping.linuxembedded.co.uk>\n\t<RS7X5qeS3LGni-yiGJ-ZvvNz1xf2L5ikzczoj-zOPtCWwkGdf2X_nJ1nOifSqC53E8wcKE8Nu72Buz_cfG8RRw==@protonmail.internalid>\n\t<55dbe931-fe23-42f6-a492-7ca75e455470@ideasonboard.com>","From":"Bryan O'Donoghue <bod.linux@nxsw.ie>","Content-Language":"en-US","In-Reply-To":"<55dbe931-fe23-42f6-a492-7ca75e455470@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}}]