From patchwork Tue May 19 19:39:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26781 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 AF16BC32F4 for ; Tue, 19 May 2026 19:39:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34A1F6302A; Tue, 19 May 2026 21:39:41 +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="Jsq2oUpe"; 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 C419462FE8 for ; Tue, 19 May 2026 21:39:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1779219574; cv=none; d=zohomail.com; s=zohoarc; b=HNtqadN2Ogb18lXqACs5WAsIiu9A2sI7KWFBD+6CBZ7n1KyXm90bSB7p1NhHbnqTgoxmf7wMFcOPDJD/WPaq4tEBgt9OMfZglHW0UN2yRyOQaEjkV45fkXEvpgq6rKHqgkZyA+hVd9CPUFJ/QI+gCIWj17Ea9lTTYKGyocekV54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779219574; 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=8EFLgFlwCAVbk5DhsdGh5G5uLW1flfwkpQlBHsT+ZQI=; b=KCHgcq+4KmlvR2ud/50zzEiNcFPOXpL7k4LtHlYbV9jd6f0zpFwc4IzgMvRdG6wH54Z18iVkOGOaNUGDKD54+KXasbweCWknCyrIPtZuJvXO+i0MTt3yXQpd5oe/4/F3EzXaF6dLmciHo8FeusesQGKz48rDWdpF9bkf5XY8930= 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=1779219574; 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=8EFLgFlwCAVbk5DhsdGh5G5uLW1flfwkpQlBHsT+ZQI=; b=Jsq2oUpeGwywznnkBj362K7WdaEgIeAM3gNHTDc9XTFJKYlOiCagoVcx+C9V173z WkZZ308peROaHaqRrACSxse8rKPN2oXXRlG0fJHCy8jsHWgG+pOaXhpzgkOntbrP808 BG0NKjEPBvHy/E1dCQgk6nUtPR6cPjom36LkFBBw= Received: by mx.zohomail.com with SMTPS id 1779219572897860.9292318309206; Tue, 19 May 2026 12:39:32 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v3 1/5] egl: Add GL format parameter to eGLImage constructor Date: Tue, 19 May 2026 21:39:03 +0200 Message-ID: <20260519193907.86812-2-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260519193907.86812-1-robert.mader@collabora.com> References: <20260519193907.86812-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 preparation for the following commits. This requires a minor reordering in DebayerEGL::start() as the value for the input texture is only known after initBayerShaders(). Signed-off-by: Robert Mader --- include/libcamera/internal/egl.h | 6 ++++-- src/libcamera/egl.cpp | 22 +++++++++++++++++++++- src/libcamera/software_isp/debayer_egl.cpp | 10 +++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 0ad2320b1..eb340eb58 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -51,14 +51,15 @@ class eGLImage public: /** * \brief Construct an eGLImage with explicit stride + * \param[in] format Image GL format * \param[in] width Image width in pixels * \param[in] height Image height in pixels * \param[in] stride Row stride in bytes * \param[in] texture_unit OpenGL texture unit * \param[in] texture_unit_uniform_id Shader uniform ID */ - eGLImage(uint32_t width, uint32_t height, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id) - : width_(width), height_(height), stride_(stride), + eGLImage(GLint format, uint32_t width, uint32_t height, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id) + : format_(format), width_(width), height_(height), stride_(stride), framesize_(stride * height), texture_unit_uniform_id_(texture_unit_uniform_id), texture_unit_(texture_unit) @@ -79,6 +80,7 @@ public: glDeleteTextures(1, &texture_); } + GLint format_; /**< Image GL format */ uint32_t width_; /**< Image width in pixels */ uint32_t height_; /**< Image height in pixels */ uint32_t stride_; /**< Row stride in bytes */ diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 357918711..e02e3edc3 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -20,6 +20,8 @@ #include +#include + namespace libcamera { LOG_DEFINE_CATEGORY(eGL) @@ -111,13 +113,31 @@ void eGL::syncOutput() */ int eGL::createDMABufTexture2D(eGLImage &eglImage, int fd, bool output) { + EGLint drm_format; + ASSERT(tid_ == Thread::currentId()); + switch (eglImage.format_) { + case GL_RED: + case GL_LUMINANCE: + drm_format = DRM_FORMAT_R8; + break; + case GL_RG: + drm_format = DRM_FORMAT_RG88; + break; + case GL_RGBA: + drm_format = DRM_FORMAT_ARGB8888; + break; + default: + LOG(eGL, Error) << "unhandled GL format"; + return -ENODEV; + } + // 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_LINUX_DRM_FOURCC_EXT, 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_, diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index eae4c57f4..4e4e375c5 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -582,14 +582,14 @@ int DebayerEGL::start() LOG(Debayer, Debug) << "Available fragment shader texture units " << maxTextureImageUnits; + if (initBayerShaders(inputPixelFormat_, outputPixelFormat_)) + return -EINVAL; + /* Raw bayer input as texture */ - eglImageBayerIn_ = std::make_unique(width_, height_, inputConfig_.stride, GL_TEXTURE0, 0); + eglImageBayerIn_ = std::make_unique(glFormat_, width_, height_, inputConfig_.stride, GL_TEXTURE0, 0); /* Texture we will render to */ - eglImageBayerOut_ = std::make_unique(outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE1, 1); - - if (initBayerShaders(inputPixelFormat_, outputPixelFormat_)) - return -EINVAL; + eglImageBayerOut_ = std::make_unique(GL_RGBA, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE1, 1); return 0; }