{"id":25130,"url":"https://patchwork.libcamera.org/api/patches/25130/?format=json","web_url":"https://patchwork.libcamera.org/patch/25130/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251120233347.5046-7-bryan.odonoghue@linaro.org>","date":"2025-11-20T23:33:30","name":"[v4,06/23] libcamera: shaders: Extend debayer shaders to apply RGB gain values on output","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"034a21c9938df5a8f94cecfef7232a6f5e7555dd","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/people/175/?format=json","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25130/mbox/","series":[{"id":5600,"url":"https://patchwork.libcamera.org/api/series/5600/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5600","date":"2025-11-20T23:33:24","name":"Add GLES 2.0 GPUISP to libcamera","version":4,"mbox":"https://patchwork.libcamera.org/series/5600/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25130/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25130/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B784CBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Nov 2025 23:34:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 17D5460A8A;\n\tFri, 21 Nov 2025 00:34:06 +0100 (CET)","from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E04960AAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Nov 2025 00:34:03 +0100 (CET)","by mail-wm1-x330.google.com with SMTP id\n\t5b1f17b1804b1-477a2ab455fso15608005e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Nov 2025 15:34:03 -0800 (PST)","from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie.\n\t[188.141.3.146]) by smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-42cb7fa3a81sm7984139f8f.26.2025.11.20.15.34.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 20 Nov 2025 15:34:02 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"H6Vggu0u\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1763681643; x=1764286443;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=8LAYBbEVeoy2BI04tnQYlfHshsWQZXR3yj5shjq0yvA=;\n\tb=H6Vggu0uQdHILCsCLzBEk8q2CDb71nuKpJPiwey3bcdmpisJeLawO17K5ffo4aD6Ic\n\td7Kdxilut3/J4oxXQXth8RGv7JyzpdB3lqSxmuJk4S5NmVzOLuT3puFTDmZLcR1bmhSF\n\tnU/EGxdVeM7xMqlYnSNbilhE3AFAmmc4rzK74CUEsSveOiGPzHq2FpQctVVpZB0xfh40\n\tIl/gQcl1zbX25FqpVNaAFSMH7VbapM6HNYynS0O7l6I6Bn4E6Qb8r0f/QyhCY5wMayRL\n\t6cxvZZtunVZncnMdLb3r+VezG5/LvCXVL4JpGFKRMLOJrgIZZ9kmiRp4zfx1F066/JEc\n\tYbQg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1763681643; x=1764286443;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=8LAYBbEVeoy2BI04tnQYlfHshsWQZXR3yj5shjq0yvA=;\n\tb=UOvPHNw7UIAG1WbxwMcYQDLK43t24EOJ+RFN80arzD2/nShtFt6CuVOzXbZ//H5znM\n\tEsxmr1OGhtZIVF4ILZBSHkSrysmwQ8ASRSoASP3GGnWMIEu+1VmpGpFvrmfNKKWbKs07\n\tOlJG2Lc0fq8cG7V9yojha5su1ZuYA8/9hnRHT3KUblaR0XjJnN05Kv5CGMIyC0xbQp9O\n\t/+MnZy+E42IxbKLQotKxMZxdWzZJBOgPFZkpdwscX/tSln7R1GKoq0uesed0TC8HIO3k\n\tlQRWTqilBmHbDXhTdX9RnyNFznhx9DVVbHO3x8mG19vMMNf3+YLBWgnXph48WzYiPS7+\n\tyGpQ==","X-Gm-Message-State":"AOJu0YxkveaF43UFBOY4vzlj0ky9lZCdLp8/DvrUeS78NOm94kAtf8mg\n\tjkLIQzLkdU7BjOLMaCFpOFCWOxBP45AoTi70R+XgBDpXHCtCECw196IEDxY5OzgJqOEpRqW8XJa\n\tRhLgo6uA=","X-Gm-Gg":"ASbGnct9RZe7rlAKdMLuyloi01yh4eb9JZQhtDeujtUOvkqW44Ay2Fyqgz8wMQ88Sp1\n\t7yRk/5V5+nVQShQY7HRv2Ln/eSwgXe/j7uY8qK60jIbOArtjcqTAS3xHxKjrDL+d44snLNc0/2/\n\tVBjEyiS/y1pGQmcXdd/6HX1bwH2iumgAGs+Cl4gkVn/Bthw/nK+VpgQmGmde3dLyIBVxEg7uuxi\n\t8hME0VcmlaJLKmbpu+kTbjv5JlKNoveuibdCzia8FPkd7pR0HxbPHaJBKid61Q6+j7ULWmmYJvz\n\tSwSzkqdJ/YXgnhTLax0d4epth/NNh0fevPit1BcUpqORY6MTGrgepHVkeOphWCKe4mvh78acoAU\n\tVvTYhbMnWNvJGBcfJifns9qYjSECDhLvW6R9wajYWqNpMWx0RnDFnTJCzUFAN0kLDmu8FoEOGUT\n\tUbTIamyRtxB/sRzhDo7cUfITeV83Ns3iOIb45Uu1uL7CVB2W62rg/2N9uN6lrFbmeKy2Y=","X-Google-Smtp-Source":"AGHT+IHx3vrcZuLGdHapd7L/UfdiMYhJs6hSH1/M882yAfd978/ekZ8pen5Amxg+/I4LOrceD2ZUFw==","X-Received":"by 2002:a05:600c:1f94:b0:477:af07:dd21 with SMTP id\n\t5b1f17b1804b1-477c1123edfmr591855e9.25.1763681642758; \n\tThu, 20 Nov 2025 15:34:02 -0800 (PST)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMilan Zamazal <mzamazal@redhat.com>","Subject":"[PATCH v4 06/23] libcamera: shaders: Extend debayer shaders to apply\n\tRGB gain values on output","Date":"Thu, 20 Nov 2025 23:33:30 +0000","Message-ID":"<20251120233347.5046-7-bryan.odonoghue@linaro.org>","X-Mailer":"git-send-email 2.51.2","In-Reply-To":"<20251120233347.5046-1-bryan.odonoghue@linaro.org>","References":"<20251120233347.5046-1-bryan.odonoghue@linaro.org>","MIME-Version":"1.0","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>"},"content":"Extend out the bayer fragment shaders to take 3 x 256 byte inputs as\ntextures from the CPU.\n\nWe then use an index to the table to recover the colour-corrected values\nprovided by the SoftIPA thread.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../internal/shaders/bayer_1x_packed.frag     | 56 +++++++++++++++++\n .../internal/shaders/bayer_unpacked.frag      | 62 ++++++++++++++++++-\n 2 files changed, 117 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag\nindex 19b13ad08..90bd64570 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 }\ndiff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag\nindex aa7a1b004..7c3d12b03 100644\n--- a/include/libcamera/internal/shaders/bayer_unpacked.frag\n+++ b/include/libcamera/internal/shaders/bayer_unpacked.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+#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+    gl_FragColor.rgb = rgb;\n }\n","prefixes":["v4","06/23"]}