From patchwork Thu May 21 14:10:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26787 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5C958BDCBC for ; Thu, 21 May 2026 14:10:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A793563029; Thu, 21 May 2026 16:10:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="ZBHl1R0A"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D70062FD3 for ; Thu, 21 May 2026 16:10:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1779372627; cv=none; d=zohomail.com; s=zohoarc; b=FRHwQydGWKQsOCjSW+YLxjB1LsjnUPM0y/tYdsJyqRkgHSoPee4anvvJWXao89O6t4yFpghSVVk6EDf8DDK73O4/ghbOod/euTvkhDfDwJnUuxlqvY0A9rCwrIJLZeKUl7DOUjaC5Oj9/1UtmTbdlwk3sokLw4S0QOI7ZcoxbPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372627; h=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; bh=KhircWArfxva8YkhGn2ofnKfqk5O2v7bJnCOmmgPF2s=; b=RC/bD2pKpSYbH0LYx3CDBxWkkVXHQvBxTXR7ded2McSy/wFmxFey8oPBygiR1adW1fQrIHIF9hLqjOKgidcJ66U7rkPUtBAljq8jMj2dqGRQkkTLbKtuZf9M62dEsdrYzlU8g6KxXpFaQqd4Ffavf3WUX5PQH5PuKymHrK57Uv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1779372627; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=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; bh=KhircWArfxva8YkhGn2ofnKfqk5O2v7bJnCOmmgPF2s=; b=ZBHl1R0Av+ARckHcmfiNXf73eCmsRwg1SlJkDfWnUL0+/uAKe491LDDrUNNgZ/WK LCFmU1N9BhRULYIf3zLqjI6xjHPnCzMYyYwsrWoux+9Azi9Ux78/yQtDcucJILtJm5c vmtjvQBD5rBhP5JjbHLZO08YieAgUXbxEXTnqUb4= Received: by mx.zohomail.com with SMTPS id 1779372624757847.8381633735248; Thu, 21 May 2026 07:10:24 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v1 1/3] debayer_egl: Include stats computation into benchmark Date: Thu, 21 May 2026 16:10:04 +0200 Message-ID: <20260521141006.101016-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260521141006.101016-1-robert.mader@collabora.com> References: <20260521141006.101016-1-robert.mader@collabora.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A following commit in this series will allow debayering on the GPU and stats computation on the CPU to happen in parallel, requiring this change. Make the change first in order to make before/after comparisons simpler. Signed-off-by: Robert Mader --- src/libcamera/software_isp/debayer_egl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index eae4c57f4..ed9a68013 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -552,14 +552,14 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output goto error; } - bench_.finishFrame(); - metadata.planes()[0].bytesused = output->planes()[0].length; /* Calculate stats for the whole frame */ stats_->processFrame(frame, 0, input); dmaSyncers.clear(); + bench_.finishFrame(); + outputBufferReady.emit(output); inputBufferReady.emit(input); From patchwork Thu May 21 14:10:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26789 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4C24FC32F4 for ; Thu, 21 May 2026 14:10:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E249363024; Thu, 21 May 2026 16:10:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="HRYz/rUU"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B0EA162FE1 for ; Thu, 21 May 2026 16:10:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1779372627; cv=none; d=zohomail.com; s=zohoarc; b=NTkx9+6ww13vKzMG5b/MTeYp1hL6MVuI7OWw75BMlzhZLTnsZ8WTlBH2/hARZV13q37+TfUxjPUaOlAZvB7pE1MhIuudOJexZW5g3lQK+RpAkL/7YO3lDPiyHUFwIW3DCBO/VW8hS+Vn5oGJXdeze0Dkwm8sfk8iDsMND0dkNHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372627; h=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; bh=TKgp4eFBCV13RWpqr4iN2JjjKqhWVNOT2jg98eLTw6c=; b=GKDI4L/QPEPklh7S/dTk6Vm7MbLTzfppL7kWIsKpnN/VZVXd0yaB/W0BqEoKqj/aSFfhwJRJZFrpc+gS2yOYLUBVn+23di28FOAAzAKU/A/93HUlnzPGAORJby5CenLQmNWxbxJBM8p3rwTe8pTAjbwc8rJOweLXAll7b6+CNLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1779372627; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=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; bh=TKgp4eFBCV13RWpqr4iN2JjjKqhWVNOT2jg98eLTw6c=; b=HRYz/rUUPssLU8FBoGAueK7tbKsNwvb2yGVoHhS+CCWcImPgXvhfa/zUyiaxGM99 UJi6wj1uj/fykX7GBGmzwFdwESex6tWMi1Osm7U48H68bhX7YDCMX/eW9jWNyqhWLw4 rs3LUskYDAkZybapae+D4k74vIfhfxLuhP8rYoQI= Received: by mx.zohomail.com with SMTPS id 1779372626205474.31481325044206; Thu, 21 May 2026 07:10:26 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v1 2/3] egl: Call glFlush before glFinish Date: Thu, 21 May 2026 16:10:05 +0200 Message-ID: <20260521141006.101016-3-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260521141006.101016-1-robert.mader@collabora.com> References: <20260521141006.101016-1-robert.mader@collabora.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Apparently it is not guaranteed that drivers will do so implicitly, which may or may not be a driver bug. The impact on performance has been observed to be significant and it's easy enough, so let's do it explicitly. Below are some benchmark results. All where done using postmarketOS edge with updates from 21th May 2026 (Mesa 26.1.1). The mentioned pipelines where run five times each, with the mean value included here, which should be quite representive as the variance was rather small. All devices where using the powersave governor. cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60 Before: 47986 us/frame After: 33596 us/frame ! cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@1a -s width=1920,height=1080 --capture=60 Before: 30294 us/frame After: 14922 us/frame ! cam -c /base/soc@0/cci@ac4b000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60 Before: 27373 us/frame After: 26106 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@29 -s width=1920,height=1080 --capture=60 Before: 16339 us/frame After: 15897 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60 Before: 26206 us/frame After: 25721 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@10 -s width=1920,height=1080 --capture=60 Before: 43723 us/frame After: 34124 us/frame ! cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60 Before: 23597 us/frame After: 23707 us/frame cam -c /base/soc@0/bus@30800000/i2c@30a40000/camera@20 -s width=1280,height=720 --capture=60 Before: 91200 us/frame After: 91649 us/frame cam -c /base/soc@0/bus@30800000/i2c@30a50000/camera@2d -s width=1280,height=720 --capture=60 Before: 76577 us/frame After: 76956 us/frame cam -c /base/i2c-csi/front-camera@3c -s width=1280,height=720 --capture=60 Before: 188122 us/frame After: 188500 us/frame cam -c /base/i2c-csi/rear-camera@4c -s width=1280,height=720 --capture=60 Before: 193712 us/frame After: 190222 us/frame Signed-off-by: Robert Mader --- src/libcamera/egl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 357918711..d9bc4f555 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -94,6 +94,7 @@ void eGL::syncOutput() { ASSERT(tid_ == Thread::currentId()); + glFlush(); glFinish(); } From patchwork Thu May 21 14:10:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26790 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3CB48BDCBC for ; Thu, 21 May 2026 14:10:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5FA663020; Thu, 21 May 2026 16:10:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="D72usO02"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A96B16302A for ; Thu, 21 May 2026 16:10:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1779372629; cv=none; d=zohomail.com; s=zohoarc; b=Hd8h9LVo/vpqBlV9Tz6FhxFDEKJ3NK29Tn7aCkyQyvBmzYLp4lb16oaLD8ZiAFOcdTGidCrRAGmAC5mZAcLeOWMtuLZEs6UawZeqZI86OkTHiGdpv+U1CFN3picbK2rbBK50cEd5a5kX4LpJDMULKnWGC+Xod3bZ0fVBQs5EcUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779372629; h=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; bh=vNdfs2ygqxRglKSfPeUPEWTNMPx/kX9pm9a4kd4TirQ=; b=Pn32yaFVWw49bap7lxmJh/yXNIOw6KyqHeg/TRXsm8OmnuV+EPEVHfe4xlyx8ZKdUpvkaXI4vWHBCU+nXEtOWIBbEaj9omUknYPVCinQy0AsUEdyguWtENLE5wjkqfZwzzcImZitKzzASIgDrnc03sTL3/1Wdxvu9l/NpJxoSKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1779372629; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=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; bh=vNdfs2ygqxRglKSfPeUPEWTNMPx/kX9pm9a4kd4TirQ=; b=D72usO02TmR95dV08ptWgglQboqyGOxwo9fyTWfER9uTZc7L8kJsMRqyYsqQXKhm SbR5XcVRkUyObaxqfnvb8VETdWZn938HB6bkfXffd98xbJw2XABZXj6sEodJjjPAZl/ rtPyYYpZJa6qrFQdMj+0WwnrqeIvBf5iYhrlDhQk= Received: by mx.zohomail.com with SMTPS id 1779372627967665.2306654464332; Thu, 21 May 2026 07:10:27 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v1 3/3] debayer_egl: Sync output buffers after processing stats Date: Thu, 21 May 2026 16:10:06 +0200 Message-ID: <20260521141006.101016-4-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260521141006.101016-1-robert.mader@collabora.com> References: <20260521141006.101016-1-robert.mader@collabora.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Instead of waiting for the GPU to finish output buffers *before* computing stats, do so afterwards. This allows work to happen in parallel on the GPU and CPU, potentially improving throughput and reducing latency. On order for this to happen efficiently we still need to flush all GL commands to the GPU first, thus split out glFlush into a dedicated function. Below are some benchmark results. All where done using postmarketOS edge with updates from 21th May 2026 (Mesa 26.1.1). The mentioned pipelines where run five times each, with the mean value included here, which should be quite representive as the variance was rather small. All devices where using the powersave governor. Note that we only expect changes for frames where stats get computed, currently every fourth frame (see kStatPerNumFrames) - and the improvements indeed have been observed to increase when computing stats more often. cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60 Before: 33596 us/frame After: 30179 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@1a -s width=1920,height=1080 --capture=60 Before: 14922 us/frame After: 14304 us/frame cam -c /base/soc@0/cci@ac4b000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60 Before: 26106 us/frame After: 23312 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@29 -s width=1920,height=1080 --capture=60 Before: 15897 us/frame After: 14791 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@1/camera@10 -s width=1920,height=1080 --capture=60 Before: 25721 us/frame After: 23625 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@10 -s width=1920,height=1080 --capture=60 Before: 34124 us/frame After: 29471 us/frame cam -c /base/soc@0/cci@ac4a000/i2c-bus@0/camera@1a -s width=1920,height=1080 --capture=60 Before: 23707 us/frame After: 21890 us/frame cam -c /base/soc@0/bus@30800000/i2c@30a40000/camera@20 -s width=1280,height=720 --capture=60 Before: 91649 us/frame After: 83233 us/frame cam -c /base/soc@0/bus@30800000/i2c@30a50000/camera@2d -s width=1280,height=720 --capture=60 Before: 76956 us/frame After: 69569 us/frame cam -c /base/i2c-csi/front-camera@3c -s width=1280,height=720 --capture=60 Before: 188500 us/frame After: 173764 us/frame cam -c /base/i2c-csi/rear-camera@4c -s width=1280,height=720 --capture=60 Before: 190222 us/frame After: 177251 us/frame Signed-off-by: Robert Mader --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 14 +++++++++++++- src/libcamera/software_isp/debayer_egl.cpp | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 0ad2320b1..0ec8ea6ec 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -119,6 +119,7 @@ public: void useProgram(GLuint programId); void deleteProgram(GLuint programId); void syncOutput(); + void flushOutput(); private: LIBCAMERA_DISABLE_COPY_AND_MOVE(eGL) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index d9bc4f555..19ae92305 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -94,10 +94,22 @@ void eGL::syncOutput() { ASSERT(tid_ == Thread::currentId()); - glFlush(); glFinish(); } +/** + * \brief Flush the rendering pipeline + * + * Calls glFlush(). + * + */ +void eGL::flushOutput() +{ + ASSERT(tid_ == Thread::currentId()); + + glFlush(); +} + /** * \brief Create a DMA-BUF backed 2D texture * \param[in,out] eglImage EGL image to associate with the DMA-BUF diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index ed9a68013..7b9e02d90 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -521,7 +521,7 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParam LOG(eGL, Error) << "Drawing scene fail " << err; return -ENODEV; } else { - egl_.syncOutput(); + egl_.flushOutput(); } return 0; @@ -558,6 +558,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output stats_->processFrame(frame, 0, input); dmaSyncers.clear(); + egl_.syncOutput(); bench_.finishFrame(); outputBufferReady.emit(output);