Show a patch.

GET /api/patches/25579/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 25579,
    "url": "https://patchwork.libcamera.org/api/patches/25579/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25579/",
    "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": "<20251217100138.82525-7-bryan.odonoghue@linaro.org>",
    "date": "2025-12-17T10:01:18",
    "name": "[v9,06/26] libcamera: shaders: Extend debayer shaders to apply CCM gains",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3e8894e04ddf9a4e61feb6000701fa9f7c2bb1d3",
    "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/25579/mbox/",
    "series": [
        {
            "id": 5669,
            "url": "https://patchwork.libcamera.org/api/series/5669/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5669",
            "date": "2025-12-17T10:01:12",
            "name": "Add GLES 2.0 GPUISP to libcamera",
            "version": 9,
            "mbox": "https://patchwork.libcamera.org/series/5669/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25579/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25579/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 4EE38C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 17 Dec 2025 10:02:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE18861ABD;\n\tWed, 17 Dec 2025 11:02:00 +0100 (CET)",
            "from mail-wm1-x344.google.com (mail-wm1-x344.google.com\n\t[IPv6:2a00:1450:4864:20::344])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72EBA61A5C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Dec 2025 11:01:50 +0100 (CET)",
            "by mail-wm1-x344.google.com with SMTP id\n\t5b1f17b1804b1-47775fb6cb4so39071675e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Dec 2025 02:01:50 -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\t5b1f17b1804b1-47bdc1583fbsm32292585e9.0.2025.12.17.02.01.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 17 Dec 2025 02:01:49 -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=\"VzOeDH5k\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765965710; x=1766570510;\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=Zkzu0tqbzAOlMWvnkw6w2p9R2Nid+3zoTkR/m4lKMgE=;\n\tb=VzOeDH5kBINuxbv/4m1l48PCe9GYJ0bnuyQUB/YQhUoYmagPK/tHDI0+/EHvpiUAQv\n\tcQhQgyGABxKkHPRaZppwbCDtHKAQSfhSeMUcJdqm18brntUAcmjIv5agAFDJZa6aR76r\n\tMCgpoSk333ETTiA13RjIqDLVFUpN//9U0r2FGSyr7Zf553oW7TQYufrfFsv7CI/seUus\n\tvbpf5WDzJzosTkY/afbw93URA+sXdnA5n8rPoDd19BH9vEPODWNDM6eIX4gTpvlvF1y+\n\t9iq+fog9iOVy9cseolHuqIhu4QsMGpIfUq6/53ADxKA6SdspI3BN6XnPbr5M98XDsIkB\n\tWgJQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765965710; x=1766570510;\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=Zkzu0tqbzAOlMWvnkw6w2p9R2Nid+3zoTkR/m4lKMgE=;\n\tb=Dc6SGo/hXFi6MMJMtEDNa37d1Nkfu2XK1t5QeKx0XpsW3EzD0MhQ3ICbV3yfM9eknW\n\t91cYj0ezv8pybEL1HG3sWW9U7sgD7QIi+8mOvUdDCrXVxts9M+eBXrgJwqMoLvELgPm8\n\tiEbf4ImPBdfcPEnYncKYMfnqc6l+CjCYByfFi3e5t2oa7oNqxsuZ9wTUM4w1inKAfGSR\n\tMM4pL49eH1A40ukREwtNfwRnCYv61uHlj4lCT444dE+TEsNe5QY9bLPSW2n5SJjPBXG7\n\tLQTGKz2x4CTPLNqEK+rcoNMpU1h/l0lGTZKpO97MfbUlFWnP9RAvVKwyX0tsnSdJUCAO\n\tjwdg==",
        "X-Gm-Message-State": "AOJu0YxUQ4jFpiLaeE0MemQzoSz276sdfecuQuHQShIBP1BuyqGCNhy+\n\tOOHgbGIJ4cOBIRJ57b0ipHfdnp74HZFD5pqEIBNCeDQT3pMfQcSWd8dbIaplzkkxfa+1yeteBRu\n\ti0IjZC28=",
        "X-Gm-Gg": "AY/fxX5d1YoiNJawUcdvVBzfuE8UqZS0fAm0llb241mLrmiin5rxW7/FRXgnZmAuEXA\n\t0pQmSWg6m+Fho12x3B5vbz8Xu+YWV16V+B36lrvSXEG5DHgTG6BGHUxH5q0S1EuTgH2HA3fGDDW\n\tQO5K37EXXwHt1sRFBceN71nJXr6MoGbytQDl453rPd9NjxqFafm1LmgDeqeHglaFb/lWDnlepZ6\n\tZIGUkGzqj4ubSIs6xrgS9MmVNbroAykg8YNFihaQpjL7w/jsZpb0AH75gaq5MqPgfhOjH4WLhmC\n\tQn2AFXS+1QGyz0j1mwMbjWwIb88h+Pf69xImrZ40FcEC4IMhQVYZsNF0YLCT1JSdxh5YGhmok44\n\ttKeC6/QXC7N6CukFK2Ffm6Xc5ViPhoYb+gqRkEUxVUh0S6I60T5HbcmOgaWnKar/OH1t1UmD757\n\tAu7rt9KW1EuensJMS+TFVVsZYdtMNy5TzBUCQ5TxmNL7Pza4FUp6q6MxY2Qg1D0tUGY6Ou+BUk0\n\tZ9tBQ==",
        "X-Google-Smtp-Source": "AGHT+IF03kRrjPlt40PtVFkP72T6S43oPtDLssb2CttrBH9TpI8EvOpY2X5eIDWFkqDfXQVWAF0Jpw==",
        "X-Received": "by 2002:a05:600c:19c6:b0:45c:4470:271c with SMTP id\n\t5b1f17b1804b1-47a8f90598emr172228595e9.18.1765965709648; \n\tWed, 17 Dec 2025 02:01:49 -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 v9 06/26] libcamera: shaders: Extend debayer shaders to apply\n\tCCM gains",
        "Date": "Wed, 17 Dec 2025 10:01:18 +0000",
        "Message-ID": "<20251217100138.82525-7-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20251217100138.82525-1-bryan.odonoghue@linaro.org>",
        "References": "<20251217100138.82525-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 Bayer shaders to support application of a passed CCM table.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n src/libcamera/shaders/bayer_1x_packed.frag | 45 +++++++++++++++++++\n src/libcamera/shaders/bayer_unpacked.frag  | 51 +++++++++++++++++++++-\n 2 files changed, 95 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag\nindex 19b13ad08..171a928c2 100644\n--- a/src/libcamera/shaders/bayer_1x_packed.frag\n+++ b/src/libcamera/shaders/bayer_1x_packed.frag\n@@ -65,6 +65,7 @@ uniform vec2 tex_step;\n uniform vec2 tex_bayer_first_red;\n \n uniform sampler2D tex_y;\n+uniform mat3 ccm;\n \n void main(void)\n {\n@@ -212,5 +213,49 @@ void main(void)\n \t\t\tvec3(patterns.y, C, patterns.x) :\n \t\t\tvec3(patterns.wz, C));\n \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 \tgl_FragColor = vec4(rgb, 1.0);\n }\ndiff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag\nindex aa7a1b004..c41d72f4f 100644\n--- a/src/libcamera/shaders/bayer_unpacked.frag\n+++ b/src/libcamera/shaders/bayer_unpacked.frag\n@@ -24,8 +24,11 @@ uniform sampler2D       tex_y;\n varying vec4            center;\n varying vec4            yCoord;\n varying vec4            xCoord;\n+uniform mat3            ccm;\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 +100,57 @@ 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+    /*\n+     *   CCM is a 3x3 in the format\n+     *\n+     *   +--------------+----------------+---------------+\n+     *   | RedRedGain   | RedGreenGain   | RedBlueGain   |\n+     *   +--------------+----------------+---------------+\n+     *   | GreenRedGain | GreenGreenGain | GreenBlueGain |\n+     *   +--------------+----------------+---------------+\n+     *   | BlueRedGain  |  BlueGreenGain | BlueBlueGain  |\n+     *   +--------------+----------------+---------------+\n+     *\n+     *   Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin\n+     *   Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin\n+     *   Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin\n+     *\n+     *   We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm);\n+     *\n+     *   CPU\n+     *   float ccm [] = {\n+     *             RedRedGain,   RedGreenGain,   RedBlueGain,\n+     *             GreenRedGain, GreenGreenGain, GreenBlueGain,\n+     *             BlueRedGain,  BlueGreenGain,  BlueBlueGain,\n+     *   };\n+     *\n+     *   GPU\n+     *   ccm = {\n+     *             RedRedGain,   GreenRedGain,   BlueRedGain,\n+     *             RedGreenGain, GreenGreenGain, BlueGreenGain,\n+     *             RedBlueGain,  GreenBlueGain,  BlueBlueGain,\n+     *   }\n+     *\n+     *   However the indexing for the mat data-type is column major hence\n+     *   ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain\n+     *\n+     */\n+    float rin, gin, bin;\n+    rin = rgb.r;\n+    gin = rgb.g;\n+    bin = rgb.b;\n+\n+    rgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]);\n+    rgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]);\n+    rgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]);\n+\n+    gl_FragColor.rgb = rgb;\n }\n",
    "prefixes": [
        "v9",
        "06/26"
    ]
}