Show a patch.

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

{
    "id": 23539,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/23539/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23539/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250611013245.133785-34-bryan.odonoghue@linaro.org>",
    "date": "2025-06-11T01:32:43",
    "name": "[33/35] libcamera: software_isp: GPU support for unpacked 10/12-bit formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "35fe146487aae273843dabbb807a02c2855f80bf",
    "submitter": {
        "id": 175,
        "url": "https://patchwork.libcamera.org/api/1.1/people/175/?format=api",
        "name": "Bryan O'Donoghue",
        "email": "bryan.odonoghue@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23539/mbox/",
    "series": [
        {
            "id": 5212,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5212/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5212",
            "date": "2025-06-11T01:32:10",
            "name": "Add GLES 2.0 GPUISP to libcamera",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5212/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23539/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23539/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 5024FC3329\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 11 Jun 2025 01:34:40 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7EDAD68DFE;\n\tWed, 11 Jun 2025 03:34:39 +0200 (CEST)",
            "from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D6DFE68DFB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 11 Jun 2025 03:34:36 +0200 (CEST)",
            "by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-441ab63a415so63502735e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Jun 2025 18:34:36 -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-4532514138asm5680625e9.3.2025.06.10.18.34.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Jun 2025 18:34:34 -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=\"oXancp/e\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1749605676; x=1750210476;\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=IhTu7mdgMev/e/IpYBpbMZAEkHJmFS1pXA/lABpS35g=;\n\tb=oXancp/eIq3LVsk85GUQUNwhGeg6A+eTwAn/3BhwD9a8QvuCZZ6C83Q6BPgcAfELyb\n\tVHBVA6vtU8MXP92Nw/0DNC3bbIpNVwn5Dn7u+XSd6ruhUKmTdtspuXA1aN3fzL/gRand\n\tbsF5XhsH4V13WgMHld/fDBjtaazMp1axZAylPKVkH03kh4Q/dja6/StD1g3bppPFwldM\n\tLW19Y/tsA9ClY79abFH/cSmQK50QRyEuqOVa40ithixEPY+H4lg5FNDqO35mQhXgW4QE\n\tW5u6nyHYVyOJ/Be0d0ZlTSSbOipPei/Mbgf+bhN6zq2NWwOH3RiQZ/3htdUXTfTCod/A\n\tTZbw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1749605676; x=1750210476;\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=IhTu7mdgMev/e/IpYBpbMZAEkHJmFS1pXA/lABpS35g=;\n\tb=HBLCkbZrZNPwu8xJqVwaQMuVmOuduCmUqYxHqbXE/ZPNBdKH3e5bxaILBpt4GP3w4a\n\t73wexi3Ebrkn+OLRdqrKAmWzid5Ci/bdfRwGDCxepJUYINc+iDZYYjLRun6ZdurCydOw\n\tFSHAwr8LHK/hySxwjKGh6JGkCwJTQQARFJp05Q0A/ejGmqrkBortt7rwfsVCUd9257sq\n\t7k9X3idm4NJ+E6OtFY4Ofmp32kvwtXejG94U/5tkdTUCbiLDBcLLPtLDCAQ4KmP0DTbY\n\t9Jh/zDmOz5pTGBZRRz8rxT824hdloCru2bXhk2r2a3b6MSTZKbeKcibHtXgDtRuBToI4\n\tyfEQ==",
        "X-Gm-Message-State": "AOJu0YymvOE1TSHCKUiiy8cms4e/AhMi90+5L5To0EAc27NktA7r1irL\n\tXGOYww55dHZAXWSKoxzVodurMS1yyofD5OVxXzd4CZ7iBmO8Cmud2fBbL04Ih0rYvXOHwp0wB8W\n\tJsBJOhQs=",
        "X-Gm-Gg": "ASbGncvLafIx7nnEJyG90qNxS9lCS6MUgcG3QToflQl6f8KUS6kmX82e9ceD3lskMDS\n\tTN2x+W4X5IgjCSY4X8Zr9R6O/sFCxnlBDbg1SY7U879klcaBrCZnQfe5cn2ADW1vv61/z/1Jfwi\n\tuDczqQCkpX3fkt9AcUI7MCUjJCtGBJ2P8Lf6H4p2pny0LWcU83a0Pe6BEeGSM5hgPdXT12mf/2u\n\tteMX6c9DS6rc2549kKw36g7ZmfT6g0OxjVWWq0QEUVrpDUg5y5+QcmcKq1oclg9j2yXBHRm5Yyc\n\t6Tr4FL9HHyDhigqNhMk094sDiQYZW3CuUXiMYFRWj5wjBkyTelFxBKRJx7BnCnsiLur6GDNWFUq\n\tRcolht1nkbo3orLbY/XmHK2hBJxwFU1fCfwDgkF+gaA==",
        "X-Google-Smtp-Source": "AGHT+IHlnsui8rdDPd5HazGwud6/iw05I3aHfIw4O7HRFeHrsxjaBJDVHt8KdXT8ycyFSdNq/dG4nw==",
        "X-Received": "by 2002:a05:600c:64c5:b0:450:cff7:62f9 with SMTP id\n\t5b1f17b1804b1-453248c3bdamr7902115e9.22.1749605676007; \n\tTue, 10 Jun 2025 18:34:36 -0700 (PDT)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "Subject": "[PATCH 33/35] libcamera: software_isp: GPU support for unpacked\n\t10/12-bit formats",
        "Date": "Wed, 11 Jun 2025 02:32:43 +0100",
        "Message-ID": "<20250611013245.133785-34-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250611013245.133785-1-bryan.odonoghue@linaro.org>",
        "References": "<20250611013245.133785-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": "From: Milan Zamazal <mzamazal@redhat.com>\n\nThe GPU processing supports 8-bit sensor formats and 10/12-bit packed\nformats.  Support for 10/12-bit unpacked formats is missing, let's add\nit.\n\n10/12-bit unpacked formats use two adjacent bytes to store the value.\nThis means the 8-bit shaders can be used if we can modify them for\nadditional support of 16-bit addressing.  This requires the following\nmodifications:\n\n- Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte\n  per pixel) as the texture format for the given input formats.\n\n- Setting the texture width to the number of pixels rather than the\n  number of bytes.\n\n- Making the definition of `fetch' macro variable, according to the\n  pixel format.\n\n- Using only `fetch' for accessing the texture.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../libcamera/internal/shaders/bayer_8.frag   | 10 +++-\n src/libcamera/software_isp/debayer_egl.cpp    | 46 +++++++++++++------\n src/libcamera/software_isp/debayer_egl.h      |  2 +\n 3 files changed, 44 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag\nindex 74ce1509..78c2609c 100644\n--- a/include/libcamera/internal/shaders/bayer_8.frag\n+++ b/include/libcamera/internal/shaders/bayer_8.frag\n@@ -32,9 +32,17 @@ uniform mat3\t\tccm;\n void main(void) {\n     vec3 rgb;\n \n+    #if defined(RAW10P)\n+    #define pixel(p) p.r / 4.0 + p.g * 64.0\n+    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))\n+    #elif defined(RAW12P)\n+    #define pixel(p) p.r / 16.0 + p.g * 16.0\n+    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))\n+    #else\n     #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n+    #endif\n \n-    float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n+    float C = fetch(center.x, center.y); // ( 0, 0)\n     const vec4 kC = vec4( 4.0,  6.0,  5.0,  5.0) / 8.0;\n \n     // Determine which of four types of pixels we are on.\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex b30d2107..71742d84 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -151,6 +151,8 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n \t}\n \n \t// Pixel location parameters\n+\tglFormat_ = GL_LUMINANCE;\n+\tbytesPerPixel_ = 1;\n \tswitch (inputFormat) {\n \tcase libcamera::formats::SBGGR8:\n \tcase libcamera::formats::SBGGR10_CSI2P:\n@@ -197,20 +199,38 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n \tcase libcamera::formats::SGRBG10_CSI2P:\n \tcase libcamera::formats::SRGGB10_CSI2P:\n \t\tegl_.pushEnv(shaderEnv, \"#define RAW10P\");\n-\t\tfragmentShaderData = bayer_1x_packed_frag;\n-\t\tfragmentShaderDataLen = bayer_1x_packed_frag_len;\n-\t\tvertexShaderData = identity_vert;\n-\t\tvertexShaderDataLen = identity_vert_len;\n+\t\tif (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) {\n+\t\t\tfragmentShaderData = bayer_8_frag;\n+\t\t\tfragmentShaderDataLen = bayer_8_frag_len;\n+\t\t\tvertexShaderData = bayer_8_vert;\n+\t\t\tvertexShaderDataLen = bayer_8_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}\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\tfragmentShaderData = bayer_1x_packed_frag;\n-\t\tfragmentShaderDataLen = bayer_1x_packed_frag_len;\n-\t\tvertexShaderData = identity_vert;\n-\t\tvertexShaderDataLen = identity_vert_len;\n+\t\tif (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) {\n+\t\t\tfragmentShaderData = bayer_8_frag;\n+\t\t\tfragmentShaderDataLen = bayer_8_frag_len;\n+\t\t\tvertexShaderData = bayer_8_vert;\n+\t\t\tvertexShaderDataLen = bayer_8_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}\n \t\tbreak;\n \tdefault:\n \t\tgoto invalid_fmt;\n@@ -430,7 +450,7 @@ void DebayerEGL::setShaderVariableValues(void)\n \tGLfloat firstRed[] = { firstRed_x_, firstRed_y_ };\n \tGLfloat imgSize[] = { (GLfloat)width_,\n \t\t\t      (GLfloat)height_ };\n-\tGLfloat Step[] = { 1.0f / (inputConfig_.stride - 1),\n+\tGLfloat Step[] = { static_cast<float>(bytesPerPixel_) / (inputConfig_.stride - 1),\n \t\t\t   1.0f / (height_ - 1) };\n \tGLfloat Stride = 1.0f;\n \tGLfloat projIdentityMatrix[] = {\n@@ -507,7 +527,7 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay\n \n \t// Greate a standard texture\n \t// we will replace this with the DMA version at some point\n-\tegl_.createTexture2D(eglImageBayerIn_, inputConfig_.stride, height_, in.planes()[0].data());\n+\tegl_.createTexture2D(eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data());\n \n \t// Populate bayer parameters\n \tif (ccmEnabled_) {\n@@ -518,9 +538,9 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay\n \t\t};\n \t\tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n \t} else {\n-\t\tegl_.createTexture2D(eglImageRedLookup_, DebayerParams::kRGBLookupSize, 1, &params.red);\n-\t\tegl_.createTexture2D(eglImageGreenLookup_, DebayerParams::kRGBLookupSize, 1, &params.green);\n-\t\tegl_.createTexture2D(eglImageBlueLookup_, DebayerParams::kRGBLookupSize, 1, &params.blue);\n+\t\tegl_.createTexture2D(eglImageRedLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, &params.red);\n+\t\tegl_.createTexture2D(eglImageGreenLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, &params.green);\n+\t\tegl_.createTexture2D(eglImageBlueLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, &params.blue);\n \t}\n \n \t// Setup the scene\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex 94bc6fc4..56f5434a 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -150,6 +150,8 @@ private:\n \tGBM gbmSurface_;\n \tuint32_t width_;\n \tuint32_t height_;\n+\tGLint glFormat_;\n+\tunsigned int bytesPerPixel_;\n \n \tGLfloat vcoordinates[DEBAYER_OPENGL_COORDS][2] = {\n \t\t{ -1.0f, -1.0f },\n",
    "prefixes": [
        "33/35"
    ]
}