Show a patch.

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

{
    "id": 26940,
    "url": "https://patchwork.libcamera.org/api/patches/26940/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26940/",
    "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": "<20260618122245.946138-7-bryan.odonoghue@linaro.org>",
    "date": "2026-06-18T12:22:19",
    "name": "[06/30] libcamera: software_isp: gpu_pipeline_shader_pass: Add GpuPipelineShaderPassDemosiac",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "b33a083ba401a8656f41720222444363640611fa",
    "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/26940/mbox/",
    "series": [
        {
            "id": 6005,
            "url": "https://patchwork.libcamera.org/api/series/6005/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6005",
            "date": "2026-06-18T12:22:13",
            "name": "RFC/RFT: gpuisp: Multipass with speed optimisations on top",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/6005/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26940/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26940/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 34029C3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Jun 2026 12:23:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 34FDE62C7B;\n\tThu, 18 Jun 2026 14:23:15 +0200 (CEST)",
            "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6459D62987\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 14:23:03 +0200 (CEST)",
            "by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-4908b92904fso11839545e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 05:23:03 -0700 (PDT)",
            "from inspiron14p-linux ([109.76.144.236])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4922fa3a4easm275198015e9.3.2026.06.18.05.23.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 18 Jun 2026 05:23:01 -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=\"xfbELInR\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1781785383; x=1782390183;\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=2KNw94Q/s6NvGxjf3HPcINyW9wFENRp5rFz7Yc/uVaI=;\n\tb=xfbELInREjxuHpoktCuVVRGFKJ/hM3egk521oXOakuWiEiyE+d2nlkyqrWXY2q3qh4\n\tMJ1c8h0YlFKoVV7PbGe9mN/BYpUvyOPX9iq8ZM7SD2845YraG6pu1NPLOoSU3ytvfoKu\n\tpnqdOkbHOAUS0K4MqixFrTZX1r/Q9eSQftL9NOZWG3iRv0OIqpNmdjhwvAakZz6c4Icm\n\td7BZ1bWciESCxvg0p1kmS4mfwQkVDkcHhSrM89+VNxsLho0LStD41+09S2J8gPnwUZ/+\n\tdASrMzi+k8CFswEA10kqGayrWJqOpe+wrZHFPEsHEqHE16jbKMkDZraGCReJZsh+LVpP\n\tb0nQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1781785383; x=1782390183;\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=2KNw94Q/s6NvGxjf3HPcINyW9wFENRp5rFz7Yc/uVaI=;\n\tb=BUmP9CNntAlroNsZr4M0BBaWN/HBGHOvcvfMhLNnKaKuDTLqwSZFNQzebdN3YoWn4i\n\tuJWRSVQzNfr+Hu4+/kpuRvBe9BYwhA7dop6RkU66g8wy1S7LTBqvoQGTYe5svvydHU70\n\tVhYqNegWgdDarIungO4b7V0vystrpljrvh+17gRpb+0Txvv9t+5onnoOdwBdph1sFomf\n\tiVe/XMW355ux+9VwzCB7h9+YJOeM6H1vOzftYts3N82Fi7WnrlGcNX1Ah41zRVm8DMAj\n\tfVXN70xU4nH8zdueAQR394EECHXZYjIRTNVLCnkUKBeorEcIbN3/CK2TgycaWZeBpg3D\n\tkkng==",
        "X-Gm-Message-State": "AOJu0YxBKUevHWz6SEffmHiMm/zv5cQWlQQo0TeCoTbes3r6qbDDQ4bD\n\tIlrnWbYR17d7pwrFOmT2eELFo7UBeg56V2pgm5fX6WDHKl51jFBrFbHYS7zH6l8fcZGJqSNFkm1\n\t6k0jVmqI=",
        "X-Gm-Gg": "AfdE7cm9UsnqQuE/+cpGLGKVNebujjCICrym2lO4lLk620+aaxw5kc4MRPbaGEDu7/0\n\t9lZta9qoLbxb5rnPHc2u6myuR6fLmHYSDinAII6dQqC0rA9gX1N7RHMf/tO0D6tmtfygeqmy+2u\n\tj/PlRGLWvA0CfqOfnxEsfNJRU8M2CW9wdaWfW0UTtQ/Z1sFwi6dgPvMD48Nfcwk1NnpanSm6O16\n\t6iB3jWuVYHW9qjF9dz7MPk6CidKxLqWYP6OshvLitXmTBU4Mavfxixf+W1nXc2japb9rvh6A6vv\n\tPJc90aq3/Po9drW6AC2FG1WqGhdDnQhGWprpOO8pyN2PIKhy7JSwIdTBU/T8tIYQl/KDom2s+6G\n\tSEhRCblswzR6vtICQcbME3cLP163O1t2gvbDi9gUrAUO33m/XhblGdE07lk/hGXDFGSr5YbXwCa\n\tebYZ3buSDl3yt1357uiI81NO9iB0Jw",
        "X-Received": "by 2002:a05:600c:1389:b0:490:d3ef:fa4a with SMTP id\n\t5b1f17b1804b1-49234105541mr113887085e9.14.1781785381717; \n\tThu, 18 Jun 2026 05:23:01 -0700 (PDT)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "bryan.odonoghue@linaro.org,\n\tpavel@ucw.cz",
        "Subject": "[PATCH 06/30] libcamera: software_isp: gpu_pipeline_shader_pass: Add\n\tGpuPipelineShaderPassDemosiac",
        "Date": "Thu, 18 Jun 2026 13:22:19 +0100",
        "Message-ID": "<20260618122245.946138-7-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260618122245.946138-1-bryan.odonoghue@linaro.org>",
        "References": "<20260618122245.946138-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 .../gpu_pipeline_shader_pass_demosiac.cpp     | 357 ++++++++++++++++++\n .../gpu_pipeline_shader_pass_demosiac.h       |  72 ++++\n src/libcamera/software_isp/meson.build        |   1 +\n 3 files changed, 430 insertions(+)\n create mode 100644 src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp\n create mode 100644 src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h",
    "diff": "diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp\nnew file mode 100644\nindex 000000000..02d9da2f0\n--- /dev/null\n+++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp\n@@ -0,0 +1,357 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2026, Linaro Ltd\n+ *\n+ * GPU ISP Demosiac pass\n+ */\n+\n+#include <cmath>\n+#include <stdint.h>\n+#include <sys/mman.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/thread.h>\n+#include <libcamera/base/utils.h>\n+\n+#include <libcamera/controls.h>\n+#include <libcamera/formats.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/framebuffer.h\"\n+#include \"libcamera/internal/ipa_manager.h\"\n+#include \"libcamera/internal/software_isp/debayer_params.h\"\n+\n+#include \"gpu_pipeline_shader_pass_demosiac.h\"\n+\n+/**\n+ * \\file software_isp.cpp\n+ * \\brief Simple software ISP implementation\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(GpuShaderDemosiac)\n+\n+int GpuIspShaderPassDemosiac::start()\n+{\n+\treturn 0;\n+}\n+\n+void GpuIspShaderPassDemosiac::stop()\n+{\n+}\n+\n+int GpuIspShaderPassDemosiac::initShaders(PixelFormat inputFormat, PixelFormat outputFormat)\n+{\n+\tstd::vector<std::string> shaderEnv;\n+\tunsigned int fragmentShaderDataLen = 0;\n+\tconst unsigned char *fragmentShaderData = 0;\n+\tunsigned int vertexShaderDataLen = 0;\n+\tconst unsigned char *vertexShaderData = 0;\n+\tGLenum err;\n+\n+\t/* Target gles 100 glsl requires \"#version x\" as first directive in shader */\n+\tegl_.pushEnv(shaderEnv, \"#version 100\");\n+\n+\t/* Specify GL_OES_EGL_image_external */\n+\tegl_.pushEnv(shaderEnv, \"#extension GL_OES_EGL_image_external: enable\");\n+\n+\t/*\n+\t * Tell shaders how to re-order output taking account of how the pixels\n+\t * are actually stored by EGL.\n+\t */\n+\tswitch (outputFormat) {\n+\tcase formats::ARGB8888:\n+\tcase formats::XRGB8888:\n+\t\tbreak;\n+\tcase formats::ABGR8888:\n+\tcase formats::XBGR8888:\n+\t\tegl_.pushEnv(shaderEnv, \"#define SWAP_BLUE\");\n+\t\tbreak;\n+\tdefault:\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Unsupported output format\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Pixel location parameters */\n+\tglFormat_ = GL_LUMINANCE;\n+\tbytesPerPixel_ = 1;\n+\tshaderStridePixels_ = passInputCfg_.stride;\n+\n+\tswitch (inputFormat) {\n+\tcase libcamera::formats::SBGGR8:\n+\tcase libcamera::formats::SBGGR10_CSI2P:\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\t\tfirstRed_x_ = 1.0;\n+\t\tfirstRed_y_ = 1.0;\n+\t\tbreak;\n+\tcase libcamera::formats::SGBRG8:\n+\tcase libcamera::formats::SGBRG10_CSI2P:\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\t\tfirstRed_x_ = 0.0;\n+\t\tfirstRed_y_ = 1.0;\n+\t\tbreak;\n+\tcase libcamera::formats::SGRBG8:\n+\tcase libcamera::formats::SGRBG10_CSI2P:\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\t\tfirstRed_x_ = 1.0;\n+\t\tfirstRed_y_ = 0.0;\n+\t\tbreak;\n+\tcase libcamera::formats::SRGGB8:\n+\tcase libcamera::formats::SRGGB10_CSI2P:\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tfirstRed_x_ = 0.0;\n+\t\tfirstRed_y_ = 0.0;\n+\t\tbreak;\n+\tdefault:\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Unsupported input format\";\n+\t\treturn -EINVAL;\n+\t};\n+\n+\t/* Shader selection */\n+\tswitch (inputFormat) {\n+\tcase libcamera::formats::SBGGR8:\n+\tcase libcamera::formats::SGBRG8:\n+\tcase libcamera::formats::SGRBG8:\n+\tcase libcamera::formats::SRGGB8:\n+\t\tfragmentShaderData = bayer_unpacked_frag;\n+\t\tfragmentShaderDataLen = bayer_unpacked_frag_len;\n+\t\tvertexShaderData = bayer_unpacked_vert;\n+\t\tvertexShaderDataLen = bayer_unpacked_vert_len;\n+\t\tbreak;\n+\tcase libcamera::formats::SBGGR10_CSI2P:\n+\tcase libcamera::formats::SGBRG10_CSI2P:\n+\tcase libcamera::formats::SGRBG10_CSI2P:\n+\tcase libcamera::formats::SRGGB10_CSI2P:\n+\t\tegl_.pushEnv(shaderEnv, \"#define RAW10P\");\n+\t\tif (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) {\n+\t\t\tfragmentShaderData = bayer_unpacked_frag;\n+\t\t\tfragmentShaderDataLen = bayer_unpacked_frag_len;\n+\t\t\tvertexShaderData = bayer_unpacked_vert;\n+\t\t\tvertexShaderDataLen = bayer_unpacked_vert_len;\n+\t\t\tglFormat_ = GL_RG;\n+\t\t\tbytesPerPixel_ = 2;\n+\t\t} else {\n+\t\t\tfragmentShaderData = bayer_1x_packed_frag;\n+\t\t\tfragmentShaderDataLen = bayer_1x_packed_frag_len;\n+\t\t\tvertexShaderData = identity_vert;\n+\t\t\tvertexShaderDataLen = identity_vert_len;\n+\t\t\tshaderStridePixels_ = passInputCfg_.size.width;\n+\t\t}\n+\t\tbreak;\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tegl_.pushEnv(shaderEnv, \"#define RAW12P\");\n+\t\tif (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) {\n+\t\t\tfragmentShaderData = bayer_unpacked_frag;\n+\t\t\tfragmentShaderDataLen = bayer_unpacked_frag_len;\n+\t\t\tvertexShaderData = bayer_unpacked_vert;\n+\t\t\tvertexShaderDataLen = bayer_unpacked_vert_len;\n+\t\t\tglFormat_ = GL_RG;\n+\t\t\tbytesPerPixel_ = 2;\n+\t\t} else {\n+\t\t\tfragmentShaderData = bayer_1x_packed_frag;\n+\t\t\tfragmentShaderDataLen = bayer_1x_packed_frag_len;\n+\t\t\tvertexShaderData = identity_vert;\n+\t\t\tvertexShaderDataLen = identity_vert_len;\n+\t\t\tshaderStridePixels_ = passInputCfg_.size.width;\n+\t\t}\n+\t\tbreak;\n+\t};\n+\n+\t/* TODO: move from here to the end of the method into a helper function in the base class\n+\t *       this logic will be common to all pipeline instances\n+\t */\n+\tif (egl_.compileVertexShader(vertexShaderId_, vertexShaderData, vertexShaderDataLen, shaderEnv)) {\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Compile vertex shader fail\";\n+\t\treturn -ENODEV;\n+\t}\n+\tutils::scope_exit vShaderGuard([&] { glDeleteShader(vertexShaderId_); });\n+\n+\tif (egl_.compileFragmentShader(fragmentShaderId_, fragmentShaderData, fragmentShaderDataLen, shaderEnv)) {\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Compile fragment shader fail\";\n+\t\treturn -ENODEV;\n+\t}\n+\tutils::scope_exit fShaderGuard([&] { glDeleteShader(fragmentShaderId_); });\n+\n+\tif (egl_.linkProgram(programId_, vertexShaderId_, fragmentShaderId_)) {\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Linking program fail\";\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tegl_.dumpShaderSource(vertexShaderId_);\n+\tegl_.dumpShaderSource(fragmentShaderId_);\n+\n+\t/* Ensure we set the programId_ */\n+\tegl_.useProgram(programId_);\n+\terr = glGetError();\n+\tif (err != GL_NO_ERROR) {\n+\t\tLOG(GpuShaderDemosiac, Error) << \"Use program error \" << err;\n+\t\treturn -ENODEV;\n+\t}\n+\n+\treturn getShaderVariableLocations();\n+}\n+\n+int GpuIspShaderPassDemosiac::getShaderVariableLocations(void)\n+{\n+\tattributeVertex_ = glGetAttribLocation(programId_, \"vertexIn\");\n+\tattributeTexture_ = glGetAttribLocation(programId_, \"textureIn\");\n+\n+\ttextureUniformBayerDataIn_ = glGetUniformLocation(programId_, \"tex_y\");\n+\tccmUniformDataIn_ = glGetUniformLocation(programId_, \"ccm\");\n+\tblackLevelUniformDataIn_ = glGetUniformLocation(programId_, \"blacklevel\");\n+\tgammaUniformDataIn_ = glGetUniformLocation(programId_, \"gamma\");\n+\tcontrastExpUniformDataIn_ = glGetUniformLocation(programId_, \"contrastExp\");\n+\n+\ttextureUniformStep_ = glGetUniformLocation(programId_, \"tex_step\");\n+\ttextureUniformSize_ = glGetUniformLocation(programId_, \"tex_size\");\n+\ttextureUniformStrideFactor_ = glGetUniformLocation(programId_, \"stride_factor\");\n+\ttextureUniformBayerFirstRed_ = glGetUniformLocation(programId_, \"tex_bayer_first_red\");\n+\ttextureUniformProjMatrix_ = glGetUniformLocation(programId_, \"proj_matrix\");\n+\n+\tLOG(GpuShaderDemosiac, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n+\t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n+\t\t\t    << \" ccm \" << ccmUniformDataIn_\n+\t\t\t    << \" blacklevel \" << blackLevelUniformDataIn_\n+\t\t\t    << \" gamma \" << gammaUniformDataIn_\n+\t\t\t    << \" contrastExp \" << contrastExpUniformDataIn_\n+\t\t\t    << \" tex_step \" << textureUniformStep_\n+\t\t\t    << \" tex_size \" << textureUniformSize_\n+\t\t\t    << \" stride_factor \" << textureUniformStrideFactor_\n+\t\t\t    << \" tex_bayer_first_red \" << textureUniformBayerFirstRed_\n+\t\t\t    << \" proj_matrix \" << textureUniformProjMatrix_;\n+\n+\t/* TODO: trap errors */\n+\treturn 0;\n+}\n+\n+void GpuIspShaderPassDemosiac::setShaderVariableValues(const DebayerParams &params, eGLImage &eglImageIn)\n+{\n+\t/*\n+\t * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats\n+\t * are stored in a GL_LUMINANCE texture. The texture width is\n+\t * equal to the stride.\n+\t */\n+\tGLfloat firstRed[] = { firstRed_x_, firstRed_y_ };\n+\tGLfloat imgSize[] = { (GLfloat)passInputCfg_.size.width,\n+\t\t\t      (GLfloat)passInputCfg_.size.height };\n+\tGLfloat Step[] = { static_cast<float>(bytesPerPixel_) / (passInputCfg_.stride - 1),\n+\t\t\t   1.0f / (passInputCfg_.size.height - 1) };\n+\tGLfloat Stride = (GLfloat)passInputCfg_.size.width / (shaderStridePixels_ / bytesPerPixel_);\n+\t/*\n+\t * Scale input to output size, keeping the aspect ratio and preferring\n+\t * cropping over black bars.\n+\t */\n+\tGLfloat scale = std::max((GLfloat)passInputCfg_.window.width / passInputCfg_.size.width,\n+\t\t\t\t (GLfloat)passInputCfg_.window.height / passInputCfg_.size.height);\n+\tGLfloat trans = -(1.0f - scale);\n+\tGLfloat projMatrix[] = {\n+\t\tscale, 0, 0, 0,\n+\t\t0, scale, 0, 0,\n+\t\t0, 0, 1, 0,\n+\t\ttrans, trans, 0, 1\n+\t};\n+\t/* Static const coordinates */\n+\tstatic const GLfloat vcoordinates[4][2] = {\n+\t\t{ -1.0f, -1.0f },\n+\t\t{ -1.0f, +1.0f },\n+\t\t{ +1.0f, +1.0f },\n+\t\t{ +1.0f, -1.0f },\n+\t};\n+\tstatic const GLfloat tcoordinates[4][2] = {\n+\t\t{ 0.0f, 0.0f },\n+\t\t{ 0.0f, 1.0f },\n+\t\t{ 1.0f, 1.0f },\n+\t\t{ 1.0f, 0.0f },\n+\t};\n+\n+\t/* vertexIn - bayer_8.vert */\n+\tglEnableVertexAttribArray(attributeVertex_);\n+\tglVertexAttribPointer(attributeVertex_, 2, GL_FLOAT, GL_TRUE,\n+\t\t\t      2 * sizeof(GLfloat), vcoordinates);\n+\n+\t/* textureIn - bayer_8.vert */\n+\tglEnableVertexAttribArray(attributeTexture_);\n+\tglVertexAttribPointer(attributeTexture_, 2, GL_FLOAT, GL_TRUE,\n+\t\t\t      2 * sizeof(GLfloat), tcoordinates);\n+\n+\t/*\n+\t * Set the sampler2D to the respective texture unit for each texutre\n+\t * To simultaneously sample multiple textures we need to use multiple\n+\t * texture units\n+\t */\n+\tglUniform1i(textureUniformBayerDataIn_, eglImageIn.texture_unit_uniform_id_);\n+\n+\t/*\n+\t * These values are:\n+\t * firstRed = tex_bayer_first_red - bayer_8.vert\n+\t * imgSize = tex_size - bayer_8.vert\n+\t * step = tex_step - bayer_8.vert\n+\t * Stride = stride_factor identity.vert\n+\t * textureUniformProjMatri = No scaling\n+\t */\n+\tglUniform2fv(textureUniformBayerFirstRed_, 1, firstRed);\n+\tglUniform2fv(textureUniformSize_, 1, imgSize);\n+\tglUniform2fv(textureUniformStep_, 1, Step);\n+\tglUniform1f(textureUniformStrideFactor_, Stride);\n+\tglUniformMatrix4fv(textureUniformProjMatrix_, 1, GL_FALSE, projMatrix);\n+\n+\tLOG(GpuShaderDemosiac, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n+\t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n+\t\t\t    << \" tex_step \" << textureUniformStep_\n+\t\t\t    << \" tex_size \" << textureUniformSize_\n+\t\t\t    << \" stride_factor \" << textureUniformStrideFactor_\n+\t\t\t    << \" tex_bayer_first_red \" << textureUniformBayerFirstRed_;\n+\n+\tLOG(GpuShaderDemosiac, Debug) << \"textureUniformY_ = 0 \"\n+\t\t\t    << \" firstRed.x \" << firstRed[0]\n+\t\t\t    << \" firstRed.y \" << firstRed[1]\n+\t\t\t    << \" textureUniformSize_.width \" << imgSize[0]\n+\t\t\t    << \" textureUniformSize_.height \" << imgSize[1]\n+\t\t\t    << \" textureUniformStep_.x \" << Step[0]\n+\t\t\t    << \" textureUniformStep_.y \" << Step[1]\n+\t\t\t    << \" textureUniformStrideFactor_ \" << Stride\n+\t\t\t    << \" textureUniformProjMatrix_ \" << textureUniformProjMatrix_;\n+\n+\tGLfloat ccm[9] = {\n+\t\tparams.combinedMatrix[0][0],\n+\t\tparams.combinedMatrix[0][1],\n+\t\tparams.combinedMatrix[0][2],\n+\t\tparams.combinedMatrix[1][0],\n+\t\tparams.combinedMatrix[1][1],\n+\t\tparams.combinedMatrix[1][2],\n+\t\tparams.combinedMatrix[2][0],\n+\t\tparams.combinedMatrix[2][1],\n+\t\tparams.combinedMatrix[2][2],\n+\t};\n+\tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n+\tLOG(GpuShaderDemosiac, Debug) << \" ccmUniformDataIn_ \" << ccmUniformDataIn_ << \" data \" << params.combinedMatrix;\n+\n+\t/*\n+\t * 0 = Red, 1 = Green, 2 = Blue\n+\t */\n+\tglUniform3f(blackLevelUniformDataIn_, params.blackLevel[0], params.blackLevel[1], params.blackLevel[2]);\n+\tLOG(GpuShaderDemosiac, Debug) << \" blackLevelUniformDataIn_ \" << blackLevelUniformDataIn_ << \" data \" << params.blackLevel;\n+\n+\t/*\n+\t * Gamma\n+\t */\n+\tglUniform1f(gammaUniformDataIn_, params.gamma);\n+\tLOG(GpuShaderDemosiac, Debug) << \" gammaUniformDataIn_ \" << gammaUniformDataIn_ << \" data \" << params.gamma;\n+\n+\t/*\n+\t * Contrast\n+\t */\n+\tglUniform1f(contrastExpUniformDataIn_, params.contrastExp);\n+\tLOG(GpuShaderDemosiac, Debug) << \" contrastExpUniformDataIn_ \" << contrastExpUniformDataIn_ << \" data \" << params.contrastExp;\n+\n+\treturn;\n+}\n+\n+}\ndiff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h\nnew file mode 100644\nindex 000000000..11bb04c30\n--- /dev/null\n+++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h\n@@ -0,0 +1,72 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2026, Linaro Ltd\n+ *\n+ * Authors:\n+ * Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n+ *\n+ * GpuIspIspShaderPass base class\n+ */\n+\n+#pragma once\n+\n+#include <stdint.h>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/object.h>\n+#include <libcamera/base/signal.h>\n+\n+#include <libcamera/geometry.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/egl.h\"\n+#include \"libcamera/internal/software_isp/debayer_params.h\"\n+\n+#include \"gpu_pipeline_shader_pass.h\"\n+\n+namespace libcamera {\n+\n+class FrameBuffer;\n+\n+class GpuIspShaderPassDemosiac : public GpuIspShaderPass\n+{\n+public:\n+\tGpuIspShaderPassDemosiac(eGL& egl) : GpuIspShaderPass(egl) {};\n+\n+\tint start();\n+\tvoid stop();\n+\n+\t/* Things that every ISP pipeline pass will need to do */\n+\tint initShaders(PixelFormat inputFormat, PixelFormat outputFormat);\n+\tint getShaderVariableLocations(void);\n+\tvoid setShaderVariableValues(const DebayerParams &params, eGLImage &eglImageIn);\n+\tconst char *name() const override { return \"GpuIspShaderPassDemosiac\"; }\n+private:\n+\t/* Shader parameters */\n+\tfloat firstRed_x_;\n+\tfloat firstRed_y_;\n+\tGLint attributeVertex_;\n+\tGLint attributeTexture_;\n+\tGLint textureUniformStep_;\n+\tGLint textureUniformSize_;\n+\tGLint textureUniformStrideFactor_;\n+\tGLint textureUniformBayerFirstRed_;\n+\tGLint textureUniformProjMatrix_;\n+\tGLint textureUniformBayerDataIn_;\n+\n+\tuint32_t shaderStridePixels_;\n+\n+\t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n+\tGLint ccmUniformDataIn_;\n+\n+\t/* Black Level compensation */\n+\tGLint blackLevelUniformDataIn_;\n+\n+\t/* Gamma */\n+\tGLint gammaUniformDataIn_;\n+\n+\t/* Contrast */\n+\tGLint contrastExpUniformDataIn_;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build\nindex f8bce5203..3e7d21318 100644\n--- a/src/libcamera/software_isp/meson.build\n+++ b/src/libcamera/software_isp/meson.build\n@@ -33,6 +33,7 @@ if mesa_works\n         '../egl.cpp',\n         'software_isp_pipeline_gpu.cpp',\n         'gpu_pipeline_shader_pass.cpp',\n+        'gpu_pipeline_shader_pass_demosiac.cpp',\n     ])\n     libcamera_deps += [\n         libegl,\n",
    "prefixes": [
        "06/30"
    ]
}