Show a patch.

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

{
    "id": 27147,
    "url": "https://patchwork.libcamera.org/api/patches/27147/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/27147/",
    "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": "<20260630125214.3327516-6-laurent.pinchart@ideasonboard.com>",
    "date": "2026-06-30T12:52:14",
    "name": "[v2,5/5] libcamera: egl: Replace pointer and length with span for shader sources",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "8408e08100ca70acfa5660eae20f76720abadcc2",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/27147/mbox/",
    "series": [
        {
            "id": 6029,
            "url": "https://patchwork.libcamera.org/api/series/6029/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6029",
            "date": "2026-06-30T12:52:09",
            "name": "libcamera: Improve shader header generation",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/6029/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/27147/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/27147/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 0D9AEC3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Jun 2026 12:52:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B51C565F7E;\n\tTue, 30 Jun 2026 14:52:26 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9FD165F8E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Jun 2026 14:52:21 +0200 (CEST)",
            "from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DAB511E8A;\n\tTue, 30 Jun 2026 14:51:37 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ps08ho4r\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782823898;\n\tbh=KHWjspJyNIFBIEH0UtjGouz5PGW3yeXSbCLYzYAoqN8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ps08ho4rr3jmmwK4rIKL29/t7JnPiVteK7E9DQ/Z1xxj3CVblDJm8GrLVUECn87Zr\n\tCZLZvtjRNaoTG1D0MF6+rSlTpeVccA6A3aBOzy8aB5g9OJVRDLD/gmLM1s+jv02o+L\n\tYZM/lo7v78+QYYSGcPzfoUDCPm37unq0HtYpOcM0=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "Subject": "[PATCH v2 5/5] libcamera: egl: Replace pointer and length with span\n\tfor shader sources",
        "Date": "Tue, 30 Jun 2026 15:52:14 +0300",
        "Message-ID": "<20260630125214.3327516-6-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260630125214.3327516-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20260630125214.3327516-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "The compileVertexShader() and compileFragmentShader() functions take a\npointer and length to the shader source code as separate arguments. This\nis an error-prone practice. Replace them with a Span<>.\n\nSuggested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/egl.h           |  9 +++----\n src/libcamera/egl.cpp                      | 29 ++++++++++------------\n src/libcamera/software_isp/debayer_egl.cpp |  8 +++---\n 3 files changed, 20 insertions(+), 26 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\nindex f7bfb28d4e9a..523a62aa89d5 100644\n--- a/include/libcamera/internal/egl.h\n+++ b/include/libcamera/internal/egl.h\n@@ -112,11 +112,9 @@ public:\n \tvoid pushEnv(std::vector<std::string> &shaderEnv, const char *str);\n \tvoid makeCurrent();\n \n-\tint compileVertexShader(GLuint &shaderId, const unsigned char *shaderData,\n-\t\t\t\tunsigned int shaderDataLen,\n+\tint compileVertexShader(GLuint &shaderId, Span<const unsigned char> shaderData,\n \t\t\t\tSpan<const std::string> shaderEnv);\n-\tint compileFragmentShader(GLuint &shaderId, const unsigned char *shaderData,\n-\t\t\t\t  unsigned int shaderDataLen,\n+\tint compileFragmentShader(GLuint &shaderId, Span<const unsigned char> shaderData,\n \t\t\t\t  Span<const std::string> shaderEnv);\n \tint linkProgram(GLuint &programId, GLuint fragmentshaderId, GLuint vertexshaderId);\n \tvoid dumpShaderSource(GLuint shaderId);\n@@ -135,8 +133,7 @@ private:\n \tEGLSurface surface_ = EGL_NO_SURFACE;\n \n \tstatic EGLDisplay probeDisplay();\n-\tint compileShader(int shaderType, GLuint &shaderId, const unsigned char *shaderData,\n-\t\t\t  unsigned int shaderDataLen,\n+\tint compileShader(int shaderType, GLuint &shaderId, Span<const unsigned char> shaderData,\n \t\t\t  Span<const std::string> shaderEnv);\n \n \tint createDMABufTexture2D(eGLImage &eglImage, int fd, bool output);\ndiff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\nindex f03abb8ae07d..b5a5dc60b110 100644\n--- a/src/libcamera/egl.cpp\n+++ b/src/libcamera/egl.cpp\n@@ -463,8 +463,7 @@ void eGL::pushEnv(std::vector<std::string> &shaderEnv, const char *str)\n /**\n  * \\brief Compile a vertex shader\n  * \\param[out] shaderId OpenGL shader object ID\n- * \\param[in] shaderData Pointer to shader source code\n- * \\param[in] shaderDataLen Length of shader source in bytes\n+ * \\param[in] shaderData Shader source code\n  * \\param[in] shaderEnv Span of preprocessor definitions to prepend\n  *\n  * Compiles a vertex shader from source code with optional preprocessor\n@@ -472,18 +471,17 @@ void eGL::pushEnv(std::vector<std::string> &shaderEnv, const char *str)\n  *\n  * \\return 0 on success, or -EINVAL on compilation failure\n  */\n-int eGL::compileVertexShader(GLuint &shaderId, const unsigned char *shaderData,\n-\t\t\t     unsigned int shaderDataLen,\n+int eGL::compileVertexShader(GLuint &shaderId,\n+\t\t\t     Span<const unsigned char> shaderData,\n \t\t\t     Span<const std::string> shaderEnv)\n {\n-\treturn compileShader(GL_VERTEX_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv);\n+\treturn compileShader(GL_VERTEX_SHADER, shaderId, shaderData, shaderEnv);\n }\n \n /**\n  * \\brief Compile a fragment shader\n  * \\param[out] shaderId OpenGL shader object ID\n- * \\param[in] shaderData Pointer to shader source code\n- * \\param[in] shaderDataLen Length of shader source in bytes\n+ * \\param[in] shaderData Shader source code\n  * \\param[in] shaderEnv Span of preprocessor definitions to prepend\n  *\n  * Compiles a fragment shader from source code with optional preprocessor\n@@ -491,19 +489,18 @@ int eGL::compileVertexShader(GLuint &shaderId, const unsigned char *shaderData,\n  *\n  * \\return 0 on success, or -EINVAL on compilation failure\n  */\n-int eGL::compileFragmentShader(GLuint &shaderId, const unsigned char *shaderData,\n-\t\t\t       unsigned int shaderDataLen,\n+int eGL::compileFragmentShader(GLuint &shaderId,\n+\t\t\t       Span<const unsigned char> shaderData,\n \t\t\t       Span<const std::string> shaderEnv)\n {\n-\treturn compileShader(GL_FRAGMENT_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv);\n+\treturn compileShader(GL_FRAGMENT_SHADER, shaderId, shaderData, shaderEnv);\n }\n \n /**\n  * \\brief Compile a shader of specified type\n  * \\param[in] shaderType GL_VERTEX_SHADER or GL_FRAGMENT_SHADER\n  * \\param[out] shaderId OpenGL shader object ID\n- * \\param[in] shaderData Pointer to shader source code\n- * \\param[in] shaderDataLen Length of shader source in bytes\n+ * \\param[in] shaderData Shader source code\n  * \\param[in] shaderEnv Span of preprocessor definitions to prepend\n  *\n  * Internal helper function for shader compilation. Prepends environment\n@@ -511,8 +508,8 @@ int eGL::compileFragmentShader(GLuint &shaderId, const unsigned char *shaderData\n  *\n  * \\return 0 on success, or -EINVAL on compilation failure\n  */\n-int eGL::compileShader(int shaderType, GLuint &shaderId, const unsigned char *shaderData,\n-\t\t       unsigned int shaderDataLen,\n+int eGL::compileShader(int shaderType, GLuint &shaderId,\n+\t\t       Span<const unsigned char> shaderData,\n \t\t       Span<const std::string> shaderEnv)\n {\n \tGLint success;\n@@ -531,8 +528,8 @@ int eGL::compileShader(int shaderType, GLuint &shaderId, const unsigned char *sh\n \t}\n \n \t// Now the main body of the shader program\n-\tshaderSourceData[i] = reinterpret_cast<const GLchar *>(shaderData);\n-\tshaderDataLengths[i] = shaderDataLen;\n+\tshaderSourceData[i] = reinterpret_cast<const GLchar *>(shaderData.data());\n+\tshaderDataLengths[i] = shaderData.size();\n \n \t// And create the shader\n \tshaderId = glCreateShader(shaderType);\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 1f5fc6a4466d..56545816ead5 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -251,15 +251,15 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n \t\tbreak;\n \t};\n \n-\tif (egl_.compileVertexShader(vertexShaderId_, vertexShaderData.data(),\n-\t\t\t\t     vertexShaderData.size(), shaderEnv)) {\n+\tif (egl_.compileVertexShader(vertexShaderId_, vertexShaderData,\n+\t\t\t\t     shaderEnv)) {\n \t\tLOG(Debayer, 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.data(),\n-\t\t\t\t       fragmentShaderData.size(), shaderEnv)) {\n+\tif (egl_.compileFragmentShader(fragmentShaderId_, fragmentShaderData,\n+\t\t\t\t       shaderEnv)) {\n \t\tLOG(Debayer, Error) << \"Compile fragment shader fail\";\n \t\treturn -ENODEV;\n \t}\n",
    "prefixes": [
        "v2",
        "5/5"
    ]
}