[{"id":35988,"web_url":"https://patchwork.libcamera.org/comment/35988/","msgid":"<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>","date":"2025-09-25T15:10:46","subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values 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. 08. 24. 2:48 keltezéssel, Bryan O'Donoghue írta:\n> Extend out the bayer fragment shaders to take 3 x 256 byte inputs as\n> textures from the CPU.\n> \n> We then use an index to the table to recover the colour-corrected values\n> provided by the SoftIPA thread.\n> \n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>   .../internal/shaders/bayer_1x_packed.frag          | 56 +++++++++++++++++++\n>   include/libcamera/internal/shaders/bayer_8.frag    | 62 +++++++++++++++++++++-\n>   2 files changed, 117 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 19b13ad08b3a71e408774dbb8e75ca4e22d9ba8e..90bd645709e02d8cf9bee112b25cbb26c681db0a 100644\n> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n> @@ -65,6 +65,10 @@ uniform vec2 tex_step;\n>   uniform vec2 tex_bayer_first_red;\n>   \n>   uniform sampler2D tex_y;\n> +uniform sampler2D red_param;\n> +uniform sampler2D green_param;\n> +uniform sampler2D blue_param;\n> +uniform mat3 ccm;\n>   \n>   void main(void)\n>   {\n> @@ -212,5 +216,57 @@ void main(void)\n>   \t\t\tvec3(patterns.y, C, patterns.x) :\n>   \t\t\tvec3(patterns.wz, C));\n>   \n> +#if defined(APPLY_CCM_PARAMETERS)\n> +\t/*\n> +\t *   CCM is a 3x3 in the format\n> +\t *\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n> +\t *   +--------------+----------------+---------------+\n> +\t *\n> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n> +\t *\n> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n> +\t *\n> +\t *   CPU\n> +\t *   float ccm [] = {\n> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n> +\t *   };\n> +\t *\n> +\t *   GPU\n> +\t *   ccm = {\n> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n> +\t *   }\n> +\t *\n> +\t *   However the indexing for the mat data-type is column major hence\n> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n> +\t *\n> +\t */\n> +\tfloat rin, gin, bin;\n> +\trin = rgb.r;\n> +\tgin = rgb.g;\n> +\tbin = rgb.b;\n> +\n> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n> +\n> +#elif defined(APPLY_RGB_PARAMETERS)\n> +\t/* Apply bayer params */\n> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n> +\trgb.g = texture2D(green_param, vec2(rgb.g, 0.5)).g;\n> +\trgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;\n> +#endif\n> +\n>   \tgl_FragColor = vec4(rgb, 1.0);\n>   }\n> diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\n> index aa7a1b00436ae15d2ed6af7d666441d20db6bb0b..5955c2eafbe03678158b240740e18c7f00e58057 100644\n> --- a/include/libcamera/internal/shaders/bayer_8.frag\n> +++ b/include/libcamera/internal/shaders/bayer_8.frag\n> @@ -21,11 +21,17 @@ precision highp float;\n>   \n>   /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n>   uniform sampler2D       tex_y;\n> +uniform sampler2D\tred_param;\n> +uniform sampler2D\tgreen_param;\n> +uniform sampler2D\tblue_param;\n>   varying vec4            center;\n>   varying vec4            yCoord;\n>   varying vec4            xCoord;\n> +uniform mat3\t\tccm;\n>   \n>   void main(void) {\n> +    vec3 rgb;\n> +\n>       #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n>   \n>       float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n> @@ -97,11 +103,65 @@ void main(void) {\n>       PATTERN.xw  += kB.xw * B;\n>       PATTERN.xz  += kF.xz * F;\n>   \n> -    gl_FragColor.rgb = (alternate.y == 0.0) ?\n> +    rgb =  (alternate.y == 0.0) ?\n>           ((alternate.x == 0.0) ?\n>               vec3(C, PATTERN.xy) :\n>               vec3(PATTERN.z, C, PATTERN.w)) :\n>           ((alternate.x == 0.0) ?\n>               vec3(PATTERN.w, C, PATTERN.z) :\n>               vec3(PATTERN.yx, C));\n> +\n> +#if defined(APPLY_CCM_PARAMETERS)\n> +\t/*\n> +\t *   CCM is a 3x3 in the format\n> +\t *\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n> +\t *   +--------------+----------------+---------------+\n> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n> +\t *   +--------------+----------------+---------------+\n> +\t *\n> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n> +\t *\n> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n> +\t *\n> +\t *   CPU\n> +\t *   float ccm [] = {\n> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n> +\t *   };\n> +\t *\n> +\t *   GPU\n> +\t *   ccm = {\n> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n> +\t *   }\n> +\t *\n> +\t *   However the indexing for the mat data-type is column major hence\n> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n> +\t *\n> +\t */\n> +\tfloat rin, gin, bin;\n> +\trin = rgb.r;\n> +\tgin = rgb.g;\n> +\tbin = rgb.b;\n> +\n> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n\nIs there any downside to making `rgb = rgb * ccm` or similar work instead\nof manual multiplication?\n\n\n> +\n> +#elif defined(APPLY_RGB_PARAMETERS)\n> +\t/* Apply bayer params */\n> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n> +\trgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g;\n\ngreen_param ?\n\n> +\trgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n\nblue_param ?\n\n\nRegards,\nBarnabás Pőcze\n\n\n> +#endif\n> +\n> +    gl_FragColor.rgb = rgb;\n>   }\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 6EEC8BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Sep 2025 15:10:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1294C6B5F3;\n\tThu, 25 Sep 2025 17:10:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 731E869318\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Sep 2025 17:10:49 +0200 (CEST)","from [192.168.33.22] (185.221.140.70.nat.pool.zt.hu\n\t[185.221.140.70])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B077C4AD;\n\tThu, 25 Sep 2025 17:09:24 +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=\"qTr6R/vf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758812964;\n\tbh=BJWU4Qv3ujjEFEXoIQUD4VtAw+dHzF2KwX9wwJcPMxk=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=qTr6R/vfn0XlcNqgwnDGX4QIch/pUKn5V1wNuY+qiqtwDOb/o+upGkDauIkrQveXM\n\t4XWw60q5hlTBkiTPFUzJ4Zl49bD5yL5G2Jd41seh1LJ8Bmh6M1KBtYmriKH7YalEK5\n\ts82A2oOeeRTIb+4iwNOgXZf/3g/xEKPaSoiB+FCI=","Message-ID":"<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>","Date":"Thu, 25 Sep 2025 17:10:46 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org>\n\t<20250824-b4-v0-5-2-gpuisp-v2-a-v2-28-96f4576c814e@linaro.org>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250824-b4-v0-5-2-gpuisp-v2-a-v2-28-96f4576c814e@linaro.org>","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":35989,"web_url":"https://patchwork.libcamera.org/comment/35989/","msgid":"<019605ba-8235-44ab-8f67-9833afe47e1e@nxsw.ie>","date":"2025-09-25T15:14:43","subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","submitter":{"id":226,"url":"https://patchwork.libcamera.org/api/people/226/","name":"Bryan O'Donoghue","email":"bod.linux@nxsw.ie"},"content":"On 25/09/2025 16:10, Barnabás Pőcze wrote:\n> Hi\n> \n> \n> 2025. 08. 24. 2:48 keltezéssel, Bryan O'Donoghue írta:\n>> Extend out the bayer fragment shaders to take 3 x 256 byte inputs as\n>> textures from the CPU.\n>>\n>> We then use an index to the table to recover the colour-corrected values\n>> provided by the SoftIPA thread.\n>>\n>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>> ---\n>>    .../internal/shaders/bayer_1x_packed.frag          | 56 +++++++++++++++++++\n>>    include/libcamera/internal/shaders/bayer_8.frag    | 62 +++++++++++++++++++++-\n>>    2 files changed, 117 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 19b13ad08b3a71e408774dbb8e75ca4e22d9ba8e..90bd645709e02d8cf9bee112b25cbb26c681db0a 100644\n>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> @@ -65,6 +65,10 @@ uniform vec2 tex_step;\n>>    uniform vec2 tex_bayer_first_red;\n>>\n>>    uniform sampler2D tex_y;\n>> +uniform sampler2D red_param;\n>> +uniform sampler2D green_param;\n>> +uniform sampler2D blue_param;\n>> +uniform mat3 ccm;\n>>\n>>    void main(void)\n>>    {\n>> @@ -212,5 +216,57 @@ void main(void)\n>>    \t\t\tvec3(patterns.y, C, patterns.x) :\n>>    \t\t\tvec3(patterns.wz, C));\n>>\n>> +#if defined(APPLY_CCM_PARAMETERS)\n>> +\t/*\n>> +\t *   CCM is a 3x3 in the format\n>> +\t *\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *\n>> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n>> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n>> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n>> +\t *\n>> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n>> +\t *\n>> +\t *   CPU\n>> +\t *   float ccm [] = {\n>> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n>> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n>> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n>> +\t *   };\n>> +\t *\n>> +\t *   GPU\n>> +\t *   ccm = {\n>> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n>> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n>> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n>> +\t *   }\n>> +\t *\n>> +\t *   However the indexing for the mat data-type is column major hence\n>> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n>> +\t *\n>> +\t */\n>> +\tfloat rin, gin, bin;\n>> +\trin = rgb.r;\n>> +\tgin = rgb.g;\n>> +\tbin = rgb.b;\n>> +\n>> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n>> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n>> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n>> +\n>> +#elif defined(APPLY_RGB_PARAMETERS)\n>> +\t/* Apply bayer params */\n>> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n>> +\trgb.g = texture2D(green_param, vec2(rgb.g, 0.5)).g;\n>> +\trgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;\n>> +#endif\n>> +\n>>    \tgl_FragColor = vec4(rgb, 1.0);\n>>    }\n>> diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\n>> index aa7a1b00436ae15d2ed6af7d666441d20db6bb0b..5955c2eafbe03678158b240740e18c7f00e58057 100644\n>> --- a/include/libcamera/internal/shaders/bayer_8.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_8.frag\n>> @@ -21,11 +21,17 @@ precision highp float;\n>>\n>>    /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n>>    uniform sampler2D       tex_y;\n>> +uniform sampler2D\tred_param;\n>> +uniform sampler2D\tgreen_param;\n>> +uniform sampler2D\tblue_param;\n>>    varying vec4            center;\n>>    varying vec4            yCoord;\n>>    varying vec4            xCoord;\n>> +uniform mat3\t\tccm;\n>>\n>>    void main(void) {\n>> +    vec3 rgb;\n>> +\n>>        #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n>>\n>>        float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n>> @@ -97,11 +103,65 @@ void main(void) {\n>>        PATTERN.xw  += kB.xw * B;\n>>        PATTERN.xz  += kF.xz * F;\n>>\n>> -    gl_FragColor.rgb = (alternate.y == 0.0) ?\n>> +    rgb =  (alternate.y == 0.0) ?\n>>            ((alternate.x == 0.0) ?\n>>                vec3(C, PATTERN.xy) :\n>>                vec3(PATTERN.z, C, PATTERN.w)) :\n>>            ((alternate.x == 0.0) ?\n>>                vec3(PATTERN.w, C, PATTERN.z) :\n>>                vec3(PATTERN.yx, C));\n>> +\n>> +#if defined(APPLY_CCM_PARAMETERS)\n>> +\t/*\n>> +\t *   CCM is a 3x3 in the format\n>> +\t *\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *\n>> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n>> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n>> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n>> +\t *\n>> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n>> +\t *\n>> +\t *   CPU\n>> +\t *   float ccm [] = {\n>> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n>> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n>> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n>> +\t *   };\n>> +\t *\n>> +\t *   GPU\n>> +\t *   ccm = {\n>> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n>> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n>> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n>> +\t *   }\n>> +\t *\n>> +\t *   However the indexing for the mat data-type is column major hence\n>> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n>> +\t *\n>> +\t */\n>> +\tfloat rin, gin, bin;\n>> +\trin = rgb.r;\n>> +\tgin = rgb.g;\n>> +\tbin = rgb.b;\n>> +\n>> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n>> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n>> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n> \n> Is there any downside to making `rgb = rgb * ccm` or similar work instead\n> of manual multiplication?\n\n... No I think that will work just as well.\n\n> \n> \n>> +\n>> +#elif defined(APPLY_RGB_PARAMETERS)\n>> +\t/* Apply bayer params */\n>> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n>> +\trgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g;\n> \n> green_param ?\n> \n>> +\trgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n> \n> blue_param ?\n\nYep already noticed this thx:\n\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/blob/v0.5.2-gpuisp-v2-a+kbingham-agc/include/libcamera/internal/shaders/bayer_1x_packed.frag?ref_type=heads#L264> \n\n> \n> Regards,\n> Barnabás Pőcze\n> \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 23E5BC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Sep 2025 15:14:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 08BC16B5F3;\n\tThu, 25 Sep 2025 17:14:49 +0200 (CEST)","from sea.source.kernel.org (sea.source.kernel.org\n\t[IPv6:2600:3c0a:e001:78e:0:1991:8:25])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 871B969318\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Sep 2025 17:14:47 +0200 (CEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 9E10F43235\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Sep 2025 15:14:45 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 2CA73C4CEF0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Sep 2025 15:14:44 +0000 (UTC)"],"Message-ID":"<019605ba-8235-44ab-8f67-9833afe47e1e@nxsw.ie>","Date":"Thu, 25 Sep 2025 16:14:43 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","To":"libcamera-devel@lists.libcamera.org","References":"<20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org>\n\t<20250824-b4-v0-5-2-gpuisp-v2-a-v2-28-96f4576c814e@linaro.org>\n\t<1_Dh0VhvbDBtsV445ZJuIgaw_8nWBAgXJSr7gqZ80Xpp0h79gB16W0CKN09eUSEGk_fBfpaGGrshpGD3LK10bw==@protonmail.internalid>\n\t<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>","From":"Bryan O'Donoghue <bod.linux@nxsw.ie>","Content-Language":"en-US","In-Reply-To":"<26ab76ee-f353-44d8-b830-db2dd9b2eea9@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>"}},{"id":36156,"web_url":"https://patchwork.libcamera.org/comment/36156/","msgid":"<a551fd23-2a7c-47af-9619-bdd5499550fe@nxsw.ie>","date":"2025-10-06T21:13:13","subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","submitter":{"id":226,"url":"https://patchwork.libcamera.org/api/people/226/","name":"Bryan O'Donoghue","email":"bod.linux@nxsw.ie"},"content":"On 25/09/2025 16:10, Barnabás Pőcze wrote:\n> Hi\n> \n> \n> 2025. 08. 24. 2:48 keltezéssel, Bryan O'Donoghue írta:\n>> Extend out the bayer fragment shaders to take 3 x 256 byte inputs as\n>> textures from the CPU.\n>>\n>> We then use an index to the table to recover the colour-corrected values\n>> provided by the SoftIPA thread.\n>>\n>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>> ---\n>>    .../internal/shaders/bayer_1x_packed.frag          | 56 +++++++++++++++++++\n>>    include/libcamera/internal/shaders/bayer_8.frag    | 62 +++++++++++++++++++++-\n>>    2 files changed, 117 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 19b13ad08b3a71e408774dbb8e75ca4e22d9ba8e..90bd645709e02d8cf9bee112b25cbb26c681db0a 100644\n>> --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag\n>> @@ -65,6 +65,10 @@ uniform vec2 tex_step;\n>>    uniform vec2 tex_bayer_first_red;\n>>\n>>    uniform sampler2D tex_y;\n>> +uniform sampler2D red_param;\n>> +uniform sampler2D green_param;\n>> +uniform sampler2D blue_param;\n>> +uniform mat3 ccm;\n>>\n>>    void main(void)\n>>    {\n>> @@ -212,5 +216,57 @@ void main(void)\n>>    \t\t\tvec3(patterns.y, C, patterns.x) :\n>>    \t\t\tvec3(patterns.wz, C));\n>>\n>> +#if defined(APPLY_CCM_PARAMETERS)\n>> +\t/*\n>> +\t *   CCM is a 3x3 in the format\n>> +\t *\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *\n>> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n>> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n>> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n>> +\t *\n>> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n>> +\t *\n>> +\t *   CPU\n>> +\t *   float ccm [] = {\n>> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n>> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n>> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n>> +\t *   };\n>> +\t *\n>> +\t *   GPU\n>> +\t *   ccm = {\n>> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n>> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n>> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n>> +\t *   }\n>> +\t *\n>> +\t *   However the indexing for the mat data-type is column major hence\n>> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n>> +\t *\n>> +\t */\n>> +\tfloat rin, gin, bin;\n>> +\trin = rgb.r;\n>> +\tgin = rgb.g;\n>> +\tbin = rgb.b;\n>> +\n>> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n>> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n>> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n>> +\n>> +#elif defined(APPLY_RGB_PARAMETERS)\n>> +\t/* Apply bayer params */\n>> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n>> +\trgb.g = texture2D(green_param, vec2(rgb.g, 0.5)).g;\n>> +\trgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b;\n>> +#endif\n>> +\n>>    \tgl_FragColor = vec4(rgb, 1.0);\n>>    }\n>> diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\n>> index aa7a1b00436ae15d2ed6af7d666441d20db6bb0b..5955c2eafbe03678158b240740e18c7f00e58057 100644\n>> --- a/include/libcamera/internal/shaders/bayer_8.frag\n>> +++ b/include/libcamera/internal/shaders/bayer_8.frag\n>> @@ -21,11 +21,17 @@ precision highp float;\n>>\n>>    /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n>>    uniform sampler2D       tex_y;\n>> +uniform sampler2D\tred_param;\n>> +uniform sampler2D\tgreen_param;\n>> +uniform sampler2D\tblue_param;\n>>    varying vec4            center;\n>>    varying vec4            yCoord;\n>>    varying vec4            xCoord;\n>> +uniform mat3\t\tccm;\n>>\n>>    void main(void) {\n>> +    vec3 rgb;\n>> +\n>>        #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n>>\n>>        float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n>> @@ -97,11 +103,65 @@ void main(void) {\n>>        PATTERN.xw  += kB.xw * B;\n>>        PATTERN.xz  += kF.xz * F;\n>>\n>> -    gl_FragColor.rgb = (alternate.y == 0.0) ?\n>> +    rgb =  (alternate.y == 0.0) ?\n>>            ((alternate.x == 0.0) ?\n>>                vec3(C, PATTERN.xy) :\n>>                vec3(PATTERN.z, C, PATTERN.w)) :\n>>            ((alternate.x == 0.0) ?\n>>                vec3(PATTERN.w, C, PATTERN.z) :\n>>                vec3(PATTERN.yx, C));\n>> +\n>> +#if defined(APPLY_CCM_PARAMETERS)\n>> +\t/*\n>> +\t *   CCM is a 3x3 in the format\n>> +\t *\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n>> +\t *   +--------------+----------------+---------------+\n>> +\t *\n>> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n>> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n>> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n>> +\t *\n>> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n>> +\t *\n>> +\t *   CPU\n>> +\t *   float ccm [] = {\n>> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n>> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n>> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n>> +\t *   };\n>> +\t *\n>> +\t *   GPU\n>> +\t *   ccm = {\n>> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n>> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n>> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n>> +\t *   }\n>> +\t *\n>> +\t *   However the indexing for the mat data-type is column major hence\n>> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n>> +\t *\n>> +\t */\n>> +\tfloat rin, gin, bin;\n>> +\trin = rgb.r;\n>> +\tgin = rgb.g;\n>> +\tbin = rgb.b;\n>> +\n>> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n>> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n>> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n> \n> Is there any downside to making `rgb = rgb * ccm` or similar work instead\n> of manual multiplication?\n\nI didn't do this because the code is I think easier to understand this \nway without loosing any performance.\n\n>> +\n>> +#elif defined(APPLY_RGB_PARAMETERS)\n>> +\t/* Apply bayer params */\n>> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n>> +\trgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g;\n> \n> green_param ?\n> \n>> +\trgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n> \n> blue_param ?\n\nI very much did this though :)\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 302B0C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Oct 2025 21:13:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 22BEB6B5F8;\n\tMon,  6 Oct 2025 23:13:20 +0200 (CEST)","from mail-24420.protonmail.ch (mail-24420.protonmail.ch\n\t[109.224.244.20])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D1E8F6936E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Oct 2025 23:13:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=nxsw.ie header.i=@nxsw.ie header.b=\"qaM/9sI6\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxsw.ie;\n\ts=protonmail3; t=1759785196; x=1760044396;\n\tbh=36hXNBfXiMTEAhtK7paq9USd7VNuv6tig/QlaPtmIFU=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector;\n\tb=qaM/9sI6YubaSvfN9N4iwZqTuzCpvKbdy1E7SLJdTyrdHL8XUa/r7Aao58dA9vI/0\n\tQCPWYsCo6ND6rFewZ7YzaA788KXFUhj71RM4jX4zcbrwIu9s5JP8Q38skBx9b6EHrd\n\ttI+EH29/1umA3jC5wgHy4fHG1DbsKiO4/pE3UbTwBLxINfVMap+bQswpIkiOphBrKn\n\t63Mrje/iMzcOquz/RDzgLbwoLy7DUnxgy2R15zq4d0iPPCTYZYOJxAD8P3Ej+9n/Yg\n\t12qiBdAN0GelBYZTd2sVM8yeHrNrGTp1elpHG/jyL4BbipJz7BNU/ytr++rcqvgCC/\n\tA2Ok59O0VxziA==","Date":"Mon, 06 Oct 2025 21:13:13 +0000","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>, \n\tlibcamera-devel@lists.libcamera.org","From":"Bryan O'Donoghue <bod.linux@nxsw.ie>","Subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","Message-ID":"<a551fd23-2a7c-47af-9619-bdd5499550fe@nxsw.ie>","In-Reply-To":"<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>","References":"<20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org>\n\t<20250824-b4-v0-5-2-gpuisp-v2-a-v2-28-96f4576c814e@linaro.org>\n\t<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>","Feedback-ID":"136405006:user:proton","X-Pm-Message-ID":"0b9a44cf926a4d668034fd386d1a1ebcbb434ed8","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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":36166,"web_url":"https://patchwork.libcamera.org/comment/36166/","msgid":"<cb397496-b253-476c-971e-0d60032e0dad@ideasonboard.com>","date":"2025-10-07T11:23:29","subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 10. 06. 23:13 keltezéssel, Bryan O'Donoghue írta:\n> On 25/09/2025 16:10, Barnabás Pőcze wrote:\n>> Hi\n>>\n>>\n>> 2025. 08. 24. 2:48 keltezéssel, Bryan O'Donoghue írta:\n>>> Extend out the bayer fragment shaders to take 3 x 256 byte inputs as\n>>> textures from the CPU.\n>>>\n>>> We then use an index to the table to recover the colour-corrected values\n>>> provided by the SoftIPA thread.\n>>>\n>>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n>>> ---\n>>>     .../internal/shaders/bayer_1x_packed.frag          | 56 +++++++++++++++++++\n>>>     include/libcamera/internal/shaders/bayer_8.frag    | 62 +++++++++++++++++++++-\n>>>     2 files changed, 117 insertions(+), 1 deletion(-)\n>>>\n> [...]\n>>> diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\n>>> index aa7a1b00436ae15d2ed6af7d666441d20db6bb0b..5955c2eafbe03678158b240740e18c7f00e58057 100644\n>>> --- a/include/libcamera/internal/shaders/bayer_8.frag\n>>> +++ b/include/libcamera/internal/shaders/bayer_8.frag\n>>> @@ -21,11 +21,17 @@ precision highp float;\n>>>\n>>>     /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n>>>     uniform sampler2D       tex_y;\n>>> +uniform sampler2D\tred_param;\n>>> +uniform sampler2D\tgreen_param;\n>>> +uniform sampler2D\tblue_param;\n>>>     varying vec4            center;\n>>>     varying vec4            yCoord;\n>>>     varying vec4            xCoord;\n>>> +uniform mat3\t\tccm;\n>>>\n>>>     void main(void) {\n>>> +    vec3 rgb;\n>>> +\n>>>         #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n>>>\n>>>         float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n>>> @@ -97,11 +103,65 @@ void main(void) {\n>>>         PATTERN.xw  += kB.xw * B;\n>>>         PATTERN.xz  += kF.xz * F;\n>>>\n>>> -    gl_FragColor.rgb = (alternate.y == 0.0) ?\n>>> +    rgb =  (alternate.y == 0.0) ?\n>>>             ((alternate.x == 0.0) ?\n>>>                 vec3(C, PATTERN.xy) :\n>>>                 vec3(PATTERN.z, C, PATTERN.w)) :\n>>>             ((alternate.x == 0.0) ?\n>>>                 vec3(PATTERN.w, C, PATTERN.z) :\n>>>                 vec3(PATTERN.yx, C));\n>>> +\n>>> +#if defined(APPLY_CCM_PARAMETERS)\n>>> +\t/*\n>>> +\t *   CCM is a 3x3 in the format\n>>> +\t *\n>>> +\t *   +--------------+----------------+---------------+\n>>> +\t *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n>>> +\t *   +--------------+----------------+---------------+\n>>> +\t *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n>>> +\t *   +--------------+----------------+---------------+\n>>> +\t *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n>>> +\t *   +--------------+----------------+---------------+\n>>> +\t *\n>>> +\t *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n>>> +\t *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n>>> +\t *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n>>> +\t *\n>>> +\t *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n>>> +\t *\n>>> +\t *   CPU\n>>> +\t *   float ccm [] = {\n>>> +\t *             RedRedGain,   RedGreenGain,   RedBlueGain,\n>>> +\t *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n>>> +\t *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n>>> +\t *   };\n>>> +\t *\n>>> +\t *   GPU\n>>> +\t *   ccm = {\n>>> +\t *             RedRedGain,   GreenRedGain,   BlueRedGain,\n>>> +\t *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n>>> +\t *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n>>> +\t *   }\n>>> +\t *\n>>> +\t *   However the indexing for the mat data-type is column major hence\n>>> +\t *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n>>> +\t *\n>>> +\t */\n>>> +\tfloat rin, gin, bin;\n>>> +\trin = rgb.r;\n>>> +\tgin = rgb.g;\n>>> +\tbin = rgb.b;\n>>> +\n>>> +\trgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n>>> +\trgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n>>> +\trgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n>>\n>> Is there any downside to making `rgb = rgb * ccm` or similar work instead\n>> of manual multiplication?\n> \n> I didn't do this because the code is I think easier to understand this\n> way without loosing any performance.\n\nI see, in my mind there wasn't any doubt that `rgb * ccm` is easier\nto read, well, at least to me.\n\n\nRegards,\nBarnabás Pőcze\n\n> \n>>> +\n>>> +#elif defined(APPLY_RGB_PARAMETERS)\n>>> +\t/* Apply bayer params */\n>>> +\trgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r;\n>>> +\trgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g;\n>>\n>> green_param ?\n>>\n>>> +\trgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n>>\n>> blue_param ?\n> \n> I very much did this though :)\n> \n> ---\n> bod\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 63EC3C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Oct 2025 11:23:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5212B6B5F9;\n\tTue,  7 Oct 2025 13:23:36 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 47EF569367\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Oct 2025 13:23:34 +0200 (CEST)","from [192.168.33.24] (185.182.214.142.nat.pool.zt.hu\n\t[185.182.214.142])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 818F0EB5;\n\tTue,  7 Oct 2025 13:22:00 +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=\"rgqpkRSb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759836120;\n\tbh=Qr+foMT8Fyx2j9l7vDOx1phRR89f6Z7mZQ0cNl18btA=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=rgqpkRSbHfE8qv3rOk28VvaAOny4/B81eP756kbjYAKBfZyCzXCOIgAAamyBg2wSu\n\ty9r3T1sQEMqLdDj87YHrfqwfBlTfeiCjzIEi2piZ8ojmWpPKrzD6zimYxI2AQttxup\n\tLLtFnImjYiOsl273xlAlvBG4PypIrK3ia47G1QEg=","Message-ID":"<cb397496-b253-476c-971e-0d60032e0dad@ideasonboard.com>","Date":"Tue, 7 Oct 2025 13:23:29 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 28/37] libcamera: shaders: Extend debayer shaders to\n\tapply RGB gain values on output","To":"Bryan O'Donoghue <bod.linux@nxsw.ie>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org>\n\t<20250824-b4-v0-5-2-gpuisp-v2-a-v2-28-96f4576c814e@linaro.org>\n\t<26ab76ee-f353-44d8-b830-db2dd9b2eea9@ideasonboard.com>\n\t<a551fd23-2a7c-47af-9619-bdd5499550fe@nxsw.ie>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<a551fd23-2a7c-47af-9619-bdd5499550fe@nxsw.ie>","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>"}}]