From patchwork Sun May 3 11:40:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26598 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 A7712BE173 for ; Sun, 3 May 2026 11:40:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 450BA63022; Sun, 3 May 2026 13:40:47 +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="iKKc2dcH"; 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 75EE962FEA for ; Sun, 3 May 2026 13:40:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1777808440; cv=none; d=zohomail.com; s=zohoarc; b=muarRH+fVgLZpS7FZhJRIMHy96sbFNa9DA39jBKc4aU4RshekDkWO6WKIfsacXOQE+dS+YIPVX2Z88KKKpJRUG6T9xt1AkDckMyJYTBocBx54foTLfeq7vDe3rpFjjYuweB5rrvH+fgZr43/VO+i88HkS4uR5qFIqaSS4MZebJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777808440; 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=fD94TTXq7I1f8t/ltsnbXNfzYny3u/OUNNuzZiiFZVs=; b=lS1HNFJl5TKvbVA8ImgjetxYwQgWd7+1ptr7ywywx4OsZsH6rhjbc0eeXk9g3bxnESqrCcSTYShW5WYZQm4+lILFd5XqJZ6Kx7xU3b5GX+EvF88tO2Pm87wma0uHc4+xljRwkk17HjAjicuw8rdtR5ufqHSrqPKNcKKnGR7Oov0= 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=1777808440; 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=fD94TTXq7I1f8t/ltsnbXNfzYny3u/OUNNuzZiiFZVs=; b=iKKc2dcHF6rERp3qsIVNjOuFE9Nfjjd4HJcyhbVLUNWowzNSs2QUX6IksVEmPNIH OKMoa/y13Mp8/hxHmzbKWT0EVzY39Wkl06kk7hTEAzDMM+jE1qXr6Td5U96VXKbfsob f8UAwivDWlQH30cSigwUiR9qo2UJ3buE/Bv/aQ2M= Received: by mx.zohomail.com with SMTPS id 1777808439095550.941595129288; Sun, 3 May 2026 04:40:39 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH 1/3] egl: Add more parameters to createInputDMABufTexture2D() Date: Sun, 3 May 2026 13:40:00 +0200 Message-ID: <20260503114002.139255-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260503114002.139255-1-robert.mader@collabora.com> References: <20260503114002.139255-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" In order to match createTexture2D(). This will allow us to replace the later with the former going forward. Also demote an error log to debug, avoiding flodding the logs in cases where import failure is an expected result. Signed-off-by: Robert Mader --- include/libcamera/internal/egl.h | 4 ++-- src/libcamera/egl.cpp | 37 +++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 0ad2320b1..bd2f20e33 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -101,7 +101,7 @@ public: int initEGLContext(); - int createInputDMABufTexture2D(eGLImage &eglImage, int fd); + int createInputDMABufTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, void *data); @@ -133,7 +133,7 @@ private: unsigned int shaderDataLen, Span shaderEnv); - int createDMABufTexture2D(eGLImage &eglImage, int fd, bool output); + int createDMABufTexture2D(eGLImage &eglImage, int fd, uint32_t drm_format, uint32_t width, uint32_t height, bool output); PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index f65929470..c30ed95a7 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -19,6 +19,7 @@ #include +#include #include namespace libcamera { @@ -102,6 +103,9 @@ void eGL::syncOutput() * \brief Create a DMA-BUF backed 2D texture * \param[in,out] eglImage EGL image to associate with the DMA-BUF * \param[in] fd DMA-BUF file descriptor + * \param[in] drm_format the DRM fourcc + * \param[in] width the buffer width + * \param[in] height the buffer height * \param[in] output If true, create framebuffer for render target * * Internal implementation for creating DMA-BUF textures. Creates an EGL @@ -110,15 +114,15 @@ void eGL::syncOutput() * * \return 0 on success, or -ENODEV on failure */ -int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) +int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, uint32_t drm_format, uint32_t width, uint32_t height, bool output) { ASSERT(tid_ == Thread::currentId()); // clang-format off EGLint image_attrs[] = { - EGL_WIDTH, (EGLint)eglImage.width_, - EGL_HEIGHT, (EGLint)eglImage.height_, - EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888, + EGL_WIDTH, (EGLint)width, + EGL_HEIGHT, (EGLint)height, + EGL_LINUX_DRM_FOURCC_EXT, (EGLint)drm_format, EGL_DMA_BUF_PLANE0_FD_EXT, fd, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)eglImage.stride_, @@ -133,7 +137,7 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) NULL, image_attrs); if (image == EGL_NO_IMAGE_KHR) { - LOG(eGL, Error) << "eglCreateImageKHR fail"; + LOG(eGL, Debug) << "eglCreateImageKHR fail"; return -ENODEV; } @@ -171,6 +175,9 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) /** * \brief Create an input DMA-BUF backed texture * \param[in,out] eglImage EGL image to associate with the DMA-BUF + * \param[in] format the GL format + * \param[in] width the buffer width + * \param[in] height the buffer height * \param[in] fd DMA-BUF file descriptor * * Creates an EGL image from a DMA-BUF file descriptor and binds it to @@ -179,11 +186,25 @@ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) * * \return 0 on success, or -ENODEV on failure */ -int eGL::createInputDMABufTexture2D(eGLImage &eglImage, int fd) +int eGL::createInputDMABufTexture2D(eGLImage &eglImage, GLint format, uint32_t width, uint32_t height, int fd) { + EGLint drm_format; + ASSERT(tid_ == Thread::currentId()); - return createDMABufTexture2D(eglImage, fd, false); + switch (format) { + case GL_LUMINANCE: + drm_format = DRM_FORMAT_R8; + break; + case GL_RG: + drm_format = DRM_FORMAT_RG88; + break; + default: + LOG(eGL, Error) << "unhandled GL format"; + return -ENODEV; + } + + return createDMABufTexture2D(eglImage, fd, drm_format, width, height, false); } /** @@ -202,7 +223,7 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd) { ASSERT(tid_ == Thread::currentId()); - return createDMABufTexture2D(eglImage, fd, true); + return createDMABufTexture2D(eglImage, fd, DRM_FORMAT_ARGB8888, eglImage.width_, eglImage.height_, true); } /** From patchwork Sun May 3 11:40:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26599 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 39A74BE173 for ; Sun, 3 May 2026 11:40:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E36BF62FD3; Sun, 3 May 2026 13:40:49 +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="ec0w3PpG"; 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 9CC0962FEA for ; Sun, 3 May 2026 13:40:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1777808442; cv=none; d=zohomail.com; s=zohoarc; b=bDj10qVCTkDdj8JA78yKiyCW7ce+jDGgJqNEUFOxxD5Ge3/UPUVD/Qcoc2vNTwuk9K4mHEvP43uPn21FK1U+mDT30ieqsEOFhDKxbfLAanwyOGMYC866PGDBHj4y012tHttBPfZhq26TRdBt7uOGpvsJuP6absvNCss+vGeYq/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777808442; 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=i65c0BUiXvt7qykXzHQOd9vKcclacvakhvD8tLa6N/8=; b=C7iU9Qzw+ejEDCrJvvmVh892T6VvnOQKJej1c/midBOXO8kXwksqZ0QCaESTzgWZwmGmkecFwbe8oG5oCjOADNPMnjnqP7VtInaq58DhXAogRGkadJbjPj/ZGfqIuEjGI51cGthw87K+zw2eb4tu5CC4VB1osn3PfPPO8SOiWm4= 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=1777808442; 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=i65c0BUiXvt7qykXzHQOd9vKcclacvakhvD8tLa6N/8=; b=ec0w3PpGlbRglsup8i1bqKiLVfKg1O4DhvVDRnwa4X2JIShOUuhWqM9MAFTOSqzI TUmt7W0alTLKciL9RWrdcyXqUeZgTWfABmhYJmpBYbk1TbYeTP7QbLeA+L9kAmYz4Aj rIJg7H8WIvck01o7OI6ladFwQY6fJfAojHlh+Euw= Received: by mx.zohomail.com with SMTPS id 1777808440328651.2845930465663; Sun, 3 May 2026 04:40:40 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH 2/3] debayer_egl: Implement dmabuf import for input buffers Date: Sun, 3 May 2026 13:40:01 +0200 Message-ID: <20260503114002.139255-3-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260503114002.139255-1-robert.mader@collabora.com> References: <20260503114002.139255-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" In many cases we can import the GPU-ISP input buffers, dmabufs from v4l2, directly into EGL instead of mapping and uploading - i.e. copying - them. Doing so can have positive effects in multiple areas, including reducing memory bandwidth and CPU usage, as well as avoiding expensive dmabuf syncs and syscalls. The main reason direct imports may not work are the more demanding stride alignment requirements many GPUs have - often 128 or 256 bytes - compared to ISPs - apparently often closer to 32 bytes. Thus we first try to import buffers directly and - if that fails - fall back to the previous upload path. Failing imports should come at low cost as drivers know the limitations and can bail out early, without causing additional IO or context switches. In the future we might be able to request buffers with a matching stride from v4l2 drivers in many cases, making direct import the norm instead of a hit-or-miss. An optional kernel API for that exists, but doesn't seem to be implemented by any driver tested so far. While on it, add some minor code adjustments to make it easier to follow. Signed-off-by: Robert Mader --- src/libcamera/software_isp/debayer_egl.cpp | 28 ++++++++++++---------- src/libcamera/software_isp/debayer_egl.h | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 8f0c229fd..624469947 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -495,16 +495,26 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms) return; } -int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms) +int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, std::vector &dmaSyncers, const DebayerParams ¶ms) { /* eGL context switch */ egl_.makeCurrent(); /* Create a standard texture input */ - egl_.createTexture2D(*eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data()); + if (egl_.createInputDMABufTexture2D(*eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, input->planes()[0].fd.get()) != 0) { + LOG(Debayer, Debug) << "Importing input buffer with DMABuf import failed, falling back to upload"; + + dmaSyncBegin(dmaSyncers, input, nullptr); + MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); + if (!in.isValid()) { + LOG(Debayer, Error) << "mmap-ing buffer(s) failed"; + return -ENODEV; + } + egl_.createTexture2D(*eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data()); + } /* Generate the output render framebuffer as render to texture */ - egl_.createOutputDMABufTexture2D(*eglImageBayerOut_, out_fd); + egl_.createOutputDMABufTexture2D(*eglImageBayerOut_, output->planes()[0].fd.get()); setShaderVariableValues(params); glViewport(0, 0, width_, height_); @@ -528,21 +538,13 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output std::vector dmaSyncers; - dmaSyncBegin(dmaSyncers, input, nullptr); - /* Copy metadata from the input buffer */ FrameMetadata &metadata = output->_d()->metadata(); metadata.status = input->metadata().status; metadata.sequence = input->metadata().sequence; metadata.timestamp = input->metadata().timestamp; - MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); - if (!in.isValid()) { - LOG(Debayer, Error) << "mmap-ing buffer(s) failed"; - goto error; - } - - if (debayerGPU(in, output->planes()[0].fd.get(), params)) { + if (debayerGPU(input, output, dmaSyncers, params)) { LOG(Debayer, Error) << "debayerGPU failed"; goto error; } @@ -552,6 +554,8 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = output->planes()[0].length; /* Calculate stats for the whole frame */ + if (dmaSyncers.empty() && (frame % SwStatsCpu::kStatPerNumFrames) == 0) + dmaSyncBegin(dmaSyncers, input, nullptr); stats_->processFrame(frame, 0, input); dmaSyncers.clear(); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index fcd281f4c..62cb4f7f1 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -66,7 +66,7 @@ private: int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat); int getShaderVariableLocations(); void setShaderVariableValues(const DebayerParams ¶ms); - int debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms); + int debayerGPU(FrameBuffer *input, FrameBuffer *output, std::vector &dmaSyncers, const DebayerParams ¶ms); /* Shader program identifiers */ GLuint vertexShaderId_ = 0; From patchwork Sun May 3 11:40:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26600 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 E1B6CC32F6 for ; Sun, 3 May 2026 11:40:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6AEB463025; Sun, 3 May 2026 13:40:50 +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="KBYDheoR"; 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 BE3A862FEC for ; Sun, 3 May 2026 13:40:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1777808442; cv=none; d=zohomail.com; s=zohoarc; b=Li5DxQq3fHJKK3hjZJEF3VJ6SP57sTY1E27zC+v+AhJv+UaAViIcDeqIwyAK+QT70B8d82qpZn3YixlGdTJE1519ruvzr8wKixV9nigj6Uhf89nglucdJnNbqiiEjGv+ub6L7oIojFr8Fn/xNWXAJi8jigQz5770FreGj3ODvOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777808442; 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=8egq/eZy44hk8/zGT2/aH9nsxoFEncEoCQc2nE+jqp4=; b=frYn3bQIZFALtq3YA0WhmzgX+XSyKoUCU81vner5Noi6+avtfjWZK9Hxu81dH7EzNcjtjScywB8SNn5uvB83MzcJccO6dU1UIkKjaH/wnwqOzGLTDeTR92SEFj6JDPDkPGiqi0Po0RuXvfZYpBkXdQ+g+I2S6q+5uYSKwHijVq4= 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=1777808442; 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=8egq/eZy44hk8/zGT2/aH9nsxoFEncEoCQc2nE+jqp4=; b=KBYDheoRw0y2xT857SvsOUhNv8tO05MK8TJlGy94Det9A2R+DtZayOl1/wCJtmFt bZRbUu94aDkeGekw3eTC2NYmHHCyUb7gUP5RZ0z0PjFDNZ94U1QVutYL9hkzAfauexX Lnm0niIicyv8PWEbaYvTszSGFesczVJL7xBOOH6c= Received: by mx.zohomail.com with SMTPS id 1777808441776849.7051095646871; Sun, 3 May 2026 04:40:41 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH 3/3] debayer_egl: Sync output buffer after processing stats Date: Sun, 3 May 2026 13:40:02 +0200 Message-ID: <20260503114002.139255-4-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260503114002.139255-1-robert.mader@collabora.com> References: <20260503114002.139255-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 the output buffer *before* computing stats, do so afterwards. This allows work to happen in parallel on the GPU and CPU, potentially improving throughput and reducing latency. This, however, requires us to include stats computation into the debayer benchmark data. Signed-off-by: Robert Mader --- src/libcamera/software_isp/debayer_egl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 624469947..7dae52648 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -525,8 +525,6 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, std::vector< if (err != GL_NO_ERROR) { LOG(eGL, Error) << "Drawing scene fail " << err; return -ENODEV; - } else { - egl_.syncOutput(); } return 0; @@ -549,8 +547,6 @@ 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 */ @@ -559,6 +555,9 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output stats_->processFrame(frame, 0, input); dmaSyncers.clear(); + egl_.syncOutput(); + bench_.finishFrame(); + outputBufferReady.emit(output); inputBufferReady.emit(input);