Show a patch.

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

{
    "id": 26801,
    "url": "https://patchwork.libcamera.org/api/patches/26801/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26801/",
    "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": "<20260526080639.70173-3-robert.mader@collabora.com>",
    "date": "2026-05-26T08:06:39",
    "name": "[v2,2/2] debayer_egl: Sync output buffers after processing stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "99dbb3c0918c4407426f26e6ac3a94ee4052224c",
    "submitter": {
        "id": 140,
        "url": "https://patchwork.libcamera.org/api/people/140/?format=api",
        "name": "Robert Mader",
        "email": "robert.mader@collabora.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26801/mbox/",
    "series": [
        {
            "id": 5963,
            "url": "https://patchwork.libcamera.org/api/series/5963/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5963",
            "date": "2026-05-26T08:06:37",
            "name": "debayer_egl: Sync output buffers after processing stats",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5963/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26801/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26801/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 A39CDBDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 May 2026 08:07:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B0D06175A;\n\tTue, 26 May 2026 10:07:07 +0200 (CEST)",
            "from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com\n\t[136.143.188.112])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A370D62FE8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 May 2026 10:07:01 +0200 (CEST)",
            "by mx.zohomail.com with SMTPS id 1779782817125866.728989903609;\n\tTue, 26 May 2026 01:06:57 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"KJozV3Zx\"; \n\tdkim-atps=neutral",
        "ARC-Seal": "i=1; a=rsa-sha256; t=1779782818; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=FFS/GCugBQ3/UsjdgIab2DAByovjgzPP3W2XSFVkTMoYy/NfMO66yRPaDm9dric8FqHM4aXXO54N8R3vsGt9xd8+sdHJpeJsX8r08X9w+iqLDvhXU06kiFAAuLhaXrlNNquAS1MxtCOSrE7GIzteFoAK84HIAyJtC0pqDK9qzXA=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1779782818;\n\th=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To;\n\tbh=K5kcKpaFplODiMO6UlgBFWqCeukHA2z/tDC8Oje4cx0=; \n\tb=MzjyInr3knogtYfOJgJTaskb3kXFtpl3JHcGMi5nGi1VS4zgLTRZUt6idiI0LGntiNA+wPsm9Wiphv+ikPWTWAg/ocZyIHgV4DVNHTpDzMIYbGsycyjyIn/ChC0JFFJdvOrZF0qZaolcKraK+5ljKNEUPNjr1J6uo2naspg8kqI=",
        "ARC-Authentication-Results": "i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>",
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1779782818;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To;\n\tbh=K5kcKpaFplODiMO6UlgBFWqCeukHA2z/tDC8Oje4cx0=;\n\tb=KJozV3ZxYdcGzozXZT7DFedpYPntIS7d0wii22rpOvWjMqlj0Df+w6gT4/gQHTip\n\t+ZLBicqdDKZH9Kr0Uzfzs5mAi248nWYQ7uW29wBhDu2qUGwHh+D6twvos5lhVGxAZMT\n\teMP3pBoDpgk1AIn4I+EQd8dIhYMOF2ruSulFSGuk=",
        "From": "Robert Mader <robert.mader@collabora.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Robert Mader <robert.mader@collabora.com>",
        "Subject": "[PATCH v2 2/2] debayer_egl: Sync output buffers after processing\n\tstats",
        "Date": "Tue, 26 May 2026 10:06:39 +0200",
        "Message-ID": "<20260526080639.70173-3-robert.mader@collabora.com>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260526080639.70173-1-robert.mader@collabora.com>",
        "References": "<20260526080639.70173-1-robert.mader@collabora.com>",
        "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": "Instead of waiting for the GPU to finish output buffers *before* computing\nstats, do so afterwards. This allows work to happen in parallel on the GPU\nand CPU, improving throughput and reducing latency on various devices as\nshown below.\n\nOn order for this to work well we need to flush all GL commands to the\nGPU before doing heavy CPU work - thus add a corresponding function.\n\nBelow are some benchmark results. All where done using postmarketOS edge\nwith updates from 21th May 2026 (Mesa 26.1.1). The mentioned pipelines\nwhere run five times each, with the mean value included here, which should\nbe quite representive as the variance was rather small. All devices\nwhere using the powersave governor.\n\nNotes:\n1. We only expect changes for frames where stats get computed, currently\n   every fourth frame (see kStatPerNumFrames) - and the improvements indeed\n   have been observed to increase when computing stats more often.\n2. At least the qcom/freedreno devices have been found to be affected by a\n   performance issue *without* this patch. This issue can be worked\n   around by calling `glFlush()` directly before `glFinish()` - as done\n   in v1 of this series - or by running with `GALLIUM_THREAD=0`. The\n   benchmarks below show the performance gains *with* those workarounds\n   applied in order to not inflate the impact of this patch. See\n   https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15516 for more\n   context.\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60\nBefore: 33596 us/frame\nAfter: 30179 us/frame\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@1a -s width=1920,height=1080 --capture=60\nBefore: 14922 us/frame\nAfter: 14304 us/frame\n\ncam -c /base/soc@0/cci@ac4b000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60\nBefore: 26106 us/frame\nAfter: 23312 us/frame\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@29 -s width=1920,height=1080 --capture=60\nBefore: 15897 us/frame\nAfter: 14791 us/frame\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60\nBefore: 25721 us/frame\nAfter: 23625 us/frame\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@10 -s width=1920,height=1080 --capture=60\nBefore: 34124 us/frame\nAfter: 29471 us/frame\n\ncam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60\nBefore: 23707 us/frame\nAfter: 21890 us/frame\n\ncam -c /base/soc@0/bus@30800000/i2c@30a40000/camera@20 -s width=1280,height=720 --capture=60\nBefore: 91649 us/frame\nAfter: 83233 us/frame\n\ncam -c /base/soc@0/bus@30800000/i2c@30a50000/camera@2d -s width=1280,height=720 --capture=60\nBefore: 76956 us/frame\nAfter: 69569 us/frame\n\ncam -c /base/i2c-csi/front-camera@3c -s width=1280,height=720 --capture=60\nBefore: 188500 us/frame\nAfter: 173764 us/frame\n\ncam -c /base/i2c-csi/rear-camera@4c -s width=1280,height=720 --capture=60\nBefore: 190222 us/frame\nAfter: 177251 us/frame\n\nSigned-off-by: Robert Mader <robert.mader@collabora.com>\n---\n include/libcamera/internal/egl.h           |  1 +\n src/libcamera/egl.cpp                      | 13 +++++++++++++\n src/libcamera/software_isp/debayer_egl.cpp |  3 ++-\n 3 files changed, 16 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h\nindex 0ad2320b1..0ec8ea6ec 100644\n--- a/include/libcamera/internal/egl.h\n+++ b/include/libcamera/internal/egl.h\n@@ -119,6 +119,7 @@ public:\n \tvoid useProgram(GLuint programId);\n \tvoid deleteProgram(GLuint programId);\n \tvoid syncOutput();\n+\tvoid flushOutput();\n \n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(eGL)\ndiff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp\nindex 357918711..19ae92305 100644\n--- a/src/libcamera/egl.cpp\n+++ b/src/libcamera/egl.cpp\n@@ -97,6 +97,19 @@ void eGL::syncOutput()\n \tglFinish();\n }\n \n+/**\n+ * \\brief Flush the rendering pipeline\n+ *\n+ * Calls glFlush().\n+ *\n+ */\n+void eGL::flushOutput()\n+{\n+\tASSERT(tid_ == Thread::currentId());\n+\n+\tglFlush();\n+}\n+\n /**\n  * \\brief Create a DMA-BUF backed 2D texture\n  * \\param[in,out] eglImage EGL image to associate with the DMA-BUF\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex ed9a68013..7b9e02d90 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -521,7 +521,7 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParam\n \t\tLOG(eGL, Error) << \"Drawing scene fail \" << err;\n \t\treturn -ENODEV;\n \t} else {\n-\t\tegl_.syncOutput();\n+\t\tegl_.flushOutput();\n \t}\n \n \treturn 0;\n@@ -558,6 +558,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n \tstats_->processFrame(frame, 0, input);\n \tdmaSyncers.clear();\n \n+\tegl_.syncOutput();\n \tbench_.finishFrame();\n \n \toutputBufferReady.emit(output);\n",
    "prefixes": [
        "v2",
        "2/2"
    ]
}