[{"id":38931,"web_url":"https://patchwork.libcamera.org/comment/38931/","msgid":"<3544399f-6427-4986-94e1-0fb1a05e3345@ideasonboard.com>","date":"2026-05-19T20:39:48","subject":"Re: [PATCH v3 3/5] debayer_egl: Implement dmabuf import for input\n\tbuffers","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2026. 05. 19. 21:39 keltezéssel, Robert Mader írta:\n> In many cases we can import the GPU-ISP input buffers, dmabufs from v4l2,\n> directly into EGL instead of mapping and uploading - i.e. copying - them.\n> \n> Doing so can have positive effects in multiple areas, including reducing\n> memory bandwidth and CPU usage, as well as avoiding expensive dmabuf syncs\n> and syscalls.\n> \n> The main reason direct imports may not work are the more demanding stride\n> alignment requirements many GPUs have - often 128 or 256 bytes - compared\n> to ISPs - apparently often closer to 32 bytes.\n> \n> Thus we first try to import buffers directly and - if that fails - fall back\n> to the previous upload path. Failing imports should come at low cost as\n> drivers know the limitations and can bail out early, without causing\n> additional IO or context switches.\n> \n> In the future we might be able to request buffers with a matching stride\n> from v4l2 drivers in many cases, making direct import the norm instead\n> of a hit-or-miss. An optional kernel API for that exists, but doesn't\n> seem to be implemented by any driver tested so far.\n> \n> While on it, add some minor code adjustments to make it easier to\n> follow.\n> \n> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n> ---\n>   src/libcamera/software_isp/debayer_egl.cpp | 40 ++++++++++++++--------\n>   src/libcamera/software_isp/debayer_egl.h   |  4 ++-\n>   2 files changed, 28 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index a217e3798..750895d10 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -500,16 +500,32 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams &params)\n> [...]\n> @@ -557,8 +565,10 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>   \tmetadata.planes()[0].bytesused = output->planes()[0].length;\n>   \n>   \t/* Calculate stats for the whole frame */\n> +\tif (!inputBufferDmaSyncer && (frame % SwStatsCpu::kStatPerNumFrames) == 0)\n> +\t\tinputBufferDmaSyncer.emplace(input->planes()[0].fd, DmaSyncer::SyncType::Read);\n>   \tstats_->processFrame(frame, 0, input);\n> -\tdmaSyncers.clear();\n> +\tinputBufferDmaSyncer.reset();\n>   \n>   \toutputBufferReady.emit(output);\n>   \tinputBufferReady.emit(input);\n> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\n> index 141fb288f..fd8c577d3 100644\n> --- a/src/libcamera/software_isp/debayer_egl.h\n> +++ b/src/libcamera/software_isp/debayer_egl.h\n> @@ -65,7 +65,7 @@ private:\n>   \tint initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat);\n>   \tint getShaderVariableLocations();\n>   \tvoid setShaderVariableValues(const DebayerParams &params);\n> -\tint debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams &params);\n> +\tint debayerGPU(FrameBuffer *input, std::optional<DmaSyncer> *inputBufferDmaSyncer, FrameBuffer *output, const DebayerParams &params);\n>   \n>   \t/* Shader program identifiers */\n>   \tGLuint vertexShaderId_ = 0;\n> @@ -109,6 +109,8 @@ private:\n>   \tGLint glFormat_;\n>   \tunsigned int bytesPerPixel_;\n>   \tuint32_t shaderStridePixels_;\n> +\n> +\tbool dmabuf_import_failed_;\n\n  = false;\n\nand probably reset it in `configure()` or such.\n\n\n>   };\n>   \n>   } /* namespace libcamera */","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 AF08EBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 May 2026 20:39:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA12C6303E;\n\tTue, 19 May 2026 22:39:54 +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 12AB963024\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2026 22:39:53 +0200 (CEST)","from [IPV6:2a01:cb1d:8f2:800:9eb6:570e:4fb2:add3] (unknown\n\t[IPv6:2a01:cb1d:8f2:800:9eb6:570e:4fb2:add3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E2B8312BB;\n\tTue, 19 May 2026 22:39:39 +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=\"Yra6HTQh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1779223180;\n\tbh=Yy2nBdVqkw4/X+pVAHGtl6peswjPeH4Ec5H6WdFxVjc=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=Yra6HTQhcCx21Y7jyn79eRfi/nSWxb5o6Mdok5vNEizEG26ORGI28F4j/ZzEbLTqj\n\tJ+HDIirJdBJ5vyzNsl/v4Z9lNioK7jPinz8G1MYR5nQICDsylpgWeHQ/eGIJNvD+4H\n\tK/YK96dQmjxSvwi8zzWf3kZAMXEW2SkRbu0rvZuY=","Message-ID":"<3544399f-6427-4986-94e1-0fb1a05e3345@ideasonboard.com>","Date":"Tue, 19 May 2026 22:39:48 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 3/5] debayer_egl: Implement dmabuf import for input\n\tbuffers","To":"Robert Mader <robert.mader@collabora.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260519193907.86812-1-robert.mader@collabora.com>\n\t<20260519193907.86812-4-robert.mader@collabora.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260519193907.86812-4-robert.mader@collabora.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":38933,"web_url":"https://patchwork.libcamera.org/comment/38933/","msgid":"<cc130d30-bac9-4f34-afdc-fb852cbcc04b@collabora.com>","date":"2026-05-20T07:45:44","subject":"Re: [PATCH v3 3/5] debayer_egl: Implement dmabuf import for input\n\tbuffers","submitter":{"id":140,"url":"https://patchwork.libcamera.org/api/people/140/","name":"Robert Mader","email":"robert.mader@collabora.com"},"content":"On 19.05.26 22:39, Barnabás Pőcze wrote:\n> Hi\n>\n> 2026. 05. 19. 21:39 keltezéssel, Robert Mader írta:\n>> ...\n>>       unsigned int bytesPerPixel_;\n>>       uint32_t shaderStridePixels_;\n>> +\n>> +    bool dmabuf_import_failed_;\n>\n>  = false;\n>\n> and probably reset it in `configure()` or such. \nOuch, good point. Alternatively the flag could be made a member of \neGLImage, ensuring it always gets reset accordingly. Will look into that \nfor v4.","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 3D41EBDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 May 2026 07:45:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2467862FE8;\n\tWed, 20 May 2026 09:45:55 +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 9B44D6175A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2026 09:45:53 +0200 (CEST)","by mx.zohomail.com with SMTPS id 1779263149260107.83048108838466; \n\tWed, 20 May 2026 00:45:49 -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=\"Ndof6l4u\"; \n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1779263150; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=hdcrOevFoUjK/yjpcChxSZB6m81fre4A396W+nTavP4Wqt+kd9NF79nUN26LzvHK0MxET5lpodb9npfYcJ1TsCPnbsnxCY0zDr6nzz0JGugnzqAAm1ZU4KLbT3lxsxBmcFARBMIF0RBPYHWGMp/Zv0Q7fR4V09ltiLwa0tz2u5k=","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1779263150;\n\th=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc;\n\tbh=P0ugHK2ZL1lvngjR7kwJ8TD7ogfaSrBWANVgnCFsqLk=; \n\tb=QRRMDM50thp5M0sfelagiMhJawSLvXhfOt4E/cqnrOT3gerQxgLMl/cQ3DVaytBxKs0LHGssLtCV23Tg1vWQaZpAIRmvzE2MlW72RE36g8kqsenFmF9tKUO6whLYhyT7XYqU9KFa1J51KmmWAnhM/B4KfM7wf4CKC6+XOpEdbGI=","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=1779263150;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc;\n\tbh=P0ugHK2ZL1lvngjR7kwJ8TD7ogfaSrBWANVgnCFsqLk=;\n\tb=Ndof6l4uLh9YpUgygCcTHghjGPHUpgEx5k6vX1PJWoQOfTDXmAw6ks3a7Kn3gSbg\n\tbxpPs3zSOH2Kr5pdYUZ3/TX8P7RgeRj/XnUu8G8OiE/RkYHQwYFivicQuLGw6MMq1W+\n\tBTraMCvQ7iCPNgIdJE2zxHymP96V2sKgqnc2cUMs=","Message-ID":"<cc130d30-bac9-4f34-afdc-fb852cbcc04b@collabora.com>","Date":"Wed, 20 May 2026 09:45:44 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 3/5] debayer_egl: Implement dmabuf import for input\n\tbuffers","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260519193907.86812-1-robert.mader@collabora.com>\n\t<20260519193907.86812-4-robert.mader@collabora.com>\n\t<3544399f-6427-4986-94e1-0fb1a05e3345@ideasonboard.com>","Content-Language":"en-US, de-DE","From":"Robert Mader <robert.mader@collabora.com>","In-Reply-To":"<3544399f-6427-4986-94e1-0fb1a05e3345@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]