{"id":23240,"url":"https://patchwork.libcamera.org/api/patches/23240/?format=json","web_url":"https://patchwork.libcamera.org/patch/23240/","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":"<20250422215920.4297-28-bryan.odonoghue@linaro.org>","date":"2025-04-22T21:59:20","name":"[27/27] shaders: Extend debayer shaders to apply RGB gain values on output","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"c8b364bd180dc0c9442bcb2870532246900cca9c","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/23240/mbox/","series":[{"id":5142,"url":"https://patchwork.libcamera.org/api/series/5142/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5142","date":"2025-04-22T21:58:53","name":"RFC: Add in a eGL based GPUISP in libcamera","version":1,"mbox":"https://patchwork.libcamera.org/series/5142/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23240/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23240/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 820BDC331E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Apr 2025 22:00:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 09F0568B54;\n\tWed, 23 Apr 2025 00:00:18 +0200 (CEST)","from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com\n\t[IPv6:2a00:1450:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 644F668B49\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Apr 2025 23:59:49 +0200 (CEST)","by mail-wr1-x42c.google.com with SMTP id\n\tffacd0b85a97d-39c14016868so5711679f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Apr 2025 14:59:49 -0700 (PDT)","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\t5b1f17b1804b1-44092d2eccesm2726615e9.20.2025.04.22.14.59.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Apr 2025 14:59:48 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"Q4238P8T\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1745359189; x=1745963989;\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=wmRwDLedsnMO6yr9mFqNtiEcjM/t9yyved9O22mAiPA=;\n\tb=Q4238P8TMxnfadUIOweUFGr14ijCjBr6yXWfZyi9ZhJ4RfQpnT+Ke745Lv344PkoS8\n\tIqn6O/xxUDiO8WLwhU6ntiBL3UsEUQpPLuus/+uodURchTCZBKC2wcERu+DQ9AL9qxW3\n\t89jNS5ssuYE09ANzHxhzO2UpjksJqMzEW+VW5b5F8MlVqrwc8zIXUmkbKd0NKr9MSeKh\n\tXFzenQIpZMUk/FvQKiaaNKa7NpW4b2mn1z5s/I8ryc7JFGw05jdt0zyV9dAprV6oFvTu\n\t2pvRwwJHaAlJxO2kecCTin3X6a2A7dl0tWRPvO5ObgEzIEGmGWDdspeIeCMYrLylJA9r\n\teyhA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1745359189; x=1745963989;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=wmRwDLedsnMO6yr9mFqNtiEcjM/t9yyved9O22mAiPA=;\n\tb=osINqGDxUx2UHP+QkpWoBcV+ehN6VL0mT708dlaLCyMVXfT8IklfOe0aeUWgCsh2cU\n\txRexF16rrapIqi6H3fn/QcWVbwYdOW8Q8HlgImG75ExLqaqhSMg2julJSqVVqoHMnIKt\n\t8afWq3tfOM53DPVGRlGEBXq6+88YE7MZKnw5CFpDQpZ4oQRqQghjsNK7iOVHnvvg2PgS\n\toXh6+v04R4c7UJBnwC/oxYgNt0riL34k+JMVv26YwExVNjUqlyLtySWR00NGrM7VgPVi\n\t+vcXY/lmSS+Jx0bbjmsSsq9e2SOgTNR7iiQMIVnIcNr3uFZDCojM8x+mNi4m0jlz+ypV\n\tG+3g==","X-Gm-Message-State":"AOJu0Yw+dxw+NCoj5pvChqVxKZWNsP/c4XNBcnar5bZM4CqJC9ASqrcV\n\tf8lo1KIb8+OhZK6lFEsgcxeotltnnGA8A72bHsn/wZB7p0VMYOGJV2tbYAZhSyaUfYavp+9K/su\n\t935Q=","X-Gm-Gg":"ASbGncsVOjCO9v3/EaKsZ1o6vCIhvQi7DwyRqDbNf4sLeRAYbBBfcMhTUzunsfigRXb\n\tLwFu6MN+tGWsTbgeOdQDDLlJQjexxcjG98X81IW/stBSwBcdOEG/xbnc+ZN9T9lHmtpQ4Z2iRvf\n\tA/0pVf7G/pZNesL8oW0C3VykU7Oy9pWzEpV6YxnS9gM2lXFXFTMnX+o/iZXC1k0XbijEWMnA+BG\n\tJnu8zqKpeGQIgZ2t+GGdyvC2dtDPAjy7YvYS7DC2lAAjdFTi6/+BSJ0bKB1Yh3A1rVAq7mvDUEw\n\tzD1WUbJGiZxmgPG62seWGR4FAUna80lD+2NXdb9Qa6T0WzF0i1BoYLbNIBPkBoWS81pO8M0blwM\n\tcyQTjD86qXGUQtS95FBNdMH0/YvLU7n0=","X-Google-Smtp-Source":"AGHT+IErHHN8UwkVL/aHJiMvcryGHUWcDvKLh32XQZ2hNYUDCi6fuRiBZZxDJ9pu6EIeo3+hjc4BhA==","X-Received":"by 2002:a05:6000:40cf:b0:39c:12f2:2f86 with SMTP id\n\tffacd0b85a97d-39efba2ab5amr13237543f8f.8.1745359188758; \n\tTue, 22 Apr 2025 14:59:48 -0700 (PDT)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org,\n\tbod.linux@nxsw.ie","Subject":"[PATCH 27/27] shaders: Extend debayer shaders to apply RGB gain\n\tvalues on output","Date":"Tue, 22 Apr 2025 22:59:20 +0100","Message-ID":"<20250422215920.4297-28-bryan.odonoghue@linaro.org>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250422215920.4297-1-bryan.odonoghue@linaro.org>","References":"<20250422215920.4297-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":"Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../internal/shaders/bayer_1x_packed.frag        | 10 ++++++++++\n include/libcamera/internal/shaders/bayer_8.frag  | 16 +++++++++++++++-\n 2 files changed, 25 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 19b13ad0..9a2389f7 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,9 @@ 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 \n void main(void)\n {\n@@ -212,5 +215,12 @@ void main(void)\n \t\t\tvec3(patterns.y, C, patterns.x) :\n \t\t\tvec3(patterns.wz, C));\n \n+#if defined(APPLY_BAYER_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+\trgb.b = texture2D(red_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_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\nindex aa7a1b00..a7ed75c8 100644\n--- a/include/libcamera/internal/shaders/bayer_8.frag\n+++ b/include/libcamera/internal/shaders/bayer_8.frag\n@@ -21,11 +21,16 @@ 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 \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 +102,20 @@ 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_BAYER_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+\trgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b;\n+#endif\n+\n+    gl_FragColor.rgb = rgb;\n }\n","prefixes":["27/27"]}