Patch Detail
Show a patch.
GET /api/patches/24674/?format=api
{ "id": 24674, "url": "https://patchwork.libcamera.org/api/patches/24674/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24674/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20251015012251.17508-30-bryan.odonoghue@linaro.org>", "date": "2025-10-15T01:22:41", "name": "[v3,29/39] libcamera: shaders: Extend debayer shaders to apply RGB gain values on output", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "272bfe15991baaf4707b918b0f059ea591c539fb", "submitter": { "id": 175, "url": "https://patchwork.libcamera.org/api/people/175/?format=api", "name": "Bryan O'Donoghue", "email": "bryan.odonoghue@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24674/mbox/", "series": [ { "id": 5503, "url": "https://patchwork.libcamera.org/api/series/5503/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5503", "date": "2025-10-15T01:22:12", "name": "Add GLES 2.0 GPUISP to libcamera", "version": 3, "mbox": "https://patchwork.libcamera.org/series/5503/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24674/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24674/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 33674C3334\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 15 Oct 2025 01:23:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 932D960686;\n\tWed, 15 Oct 2025 03:23:39 +0200 (CEST)", "from mail-ej1-x635.google.com (mail-ej1-x635.google.com\n\t[IPv6:2a00:1450:4864:20::635])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D611560626\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Oct 2025 03:23:24 +0200 (CEST)", "by mail-ej1-x635.google.com with SMTP id\n\ta640c23a62f3a-b4aed12cea3so947566766b.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Oct 2025 18:23:24 -0700 (PDT)", "from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie.\n\t[188.141.3.146]) by smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.23\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Oct 2025 18:23:23 -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=\"OZ2d4EmQ\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1760491404; x=1761096204;\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=3sraFz/ECz/08gX1UxD7qCQLpBOGxyxdQpxiRp03TY8=;\n\tb=OZ2d4EmQIeZUTnxdSmZc0bpalXJvXMjGMWVsx2DvAqf2ic5Ee8pbJ8/NLMzY0J3H5C\n\thJVWQbWDgySNNf7m8uTHbp/OfOWCH/eJ71S4l8+Q4c6UmS17SOGA6isZ8M2lbbqBWbTX\n\tM3Ifl3SA1a3MkKpKZ9BjzxWKsGqI9MbIQyi6B0fz7ZAVuk6oRdt3mJJmEUxQkX2MGkvT\n\tgXlR3v7pOUf2hcH5BTpXKe4fcLDz4Ba3lr0VvQoANDehUWcpJHWfYGntHsgQgcSVXXxP\n\t6TjeBJHWP8dRlsN0rlUCe3GgMh2IfGpHYfuTLuHZRuwFx5xYfEHG5jdht1bftIaZ1mRm\n\t5yww==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760491404; x=1761096204;\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=3sraFz/ECz/08gX1UxD7qCQLpBOGxyxdQpxiRp03TY8=;\n\tb=Sh5recVQss2rUpA8pqQYbd5VhbUwO/i7MwFJALAU38EtgSkZSnj9GmKSka29IUmuve\n\tUMnIKDVGcxOQHAcdJ6NcioWx2k/gDGLhhmXiE8/M2UIECPAY8FOpvYScPeoDg6tNObz5\n\twDDpqTMhLa2P5sDXNAiWwinkLuUUkOAt87zwSSr04OVgxY6SdKpcCUceqycjjWcACheh\n\t6A2ErW/9V4udTHZmxhuVATH8JNt5X4flKoNbTeY/waLivHIXHAYnGHkvgluZ2f9KBHPy\n\toFnTgDVuKeTHtFYUbJHjE+6scPZkoM0IBt052Y4VmsXKzJoyk96wKm+7AS98tK8NB3vo\n\tAxnQ==", "X-Gm-Message-State": "AOJu0Yz6JnPe+bVH8wU93RtJLRFfGrGhfk/4/Cq0apNhG94rxosncWcu\n\tatnw0cVVhsv+GFy4GEzx9pQDWWDWv4Yg57wzHrr9xI7RyWXTqnCn4wJFFJImh+KaQv2L0FKJGYF\n\tnsBEx", "X-Gm-Gg": "ASbGncu/n+rtZEkQMbRJUUF6YefQrjh4MroaKadkOE4Y5JBiyr8xqxjPABGfQ+IHsam\n\t8YSH/0DWOgUW1vMwrGA7eEWwMwEuSqvCy15mTmYK0552xiV34reuJNTsPusq1dJrkmFytDO+FP9\n\tGnRFxArFeZbVLxlKMPGBv3JsoY6ZKOcvsh2TRee7sHz3hcPSLny3F9Ru1IMahsCqzk5FoEWpT5k\n\txABbmtPg7cIoPL5/FIKTZGAfzv59OMQjl7nDr20m71nDt7J4r3lKrzvAOJ7JkQaiIY40wII2FDI\n\tu4jkzobhx4thPDzVrB4ngDjpnhnjUeWDcpRhG+Vfpg99X2vbKr5kly3r9f0sK0Av4QcKvDBStkd\n\th0os8AOhOeZ9abXFi0cCg4rLKlMsZiIKDYc3U2yGxz5+Vw0MFkFkAqy5YbHXS+BHfFe1CTBMfWG\n\tJPnq7wOueY5Jt0r57ffy4/CszpKQeomdeCRQ+DeVQN", "X-Google-Smtp-Source": "AGHT+IGKEo/LXzvl1qrZ5I8z5+saAM5ZJ/Yjlnw0Ds112IFVoUeE20d9QlJrzLNmjBZiiew/0TIeFg==", "X-Received": "by 2002:a17:907:da2:b0:b3c:de0e:7091 with SMTP id\n\ta640c23a62f3a-b50aa28f291mr2863547266b.8.1760491404045; \n\tTue, 14 Oct 2025 18:23:24 -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 v3 29/39] libcamera: shaders: Extend debayer shaders to apply\n\tRGB gain values on output", "Date": "Wed, 15 Oct 2025 02:22:41 +0100", "Message-ID": "<20251015012251.17508-30-bryan.odonoghue@linaro.org>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20251015012251.17508-1-bryan.odonoghue@linaro.org>", "References": "<20251015012251.17508-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\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 19b13ad0..90bd6457 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 aa7a1b00..5955c2ea 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(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": [ "v3", "29/39" ] }