[{"id":37941,"web_url":"https://patchwork.libcamera.org/comment/37941/","msgid":"<ccbb9e66-aa01-4f7c-86c9-59018e70c000@ideasonboard.com>","date":"2026-01-26T11:30:39","subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","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. 01. 26. 11:42 keltezéssel, Rick ten Wolde írta:\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n> \n> Add support for passing the LSC tables from debayerParams to\n> the shaders.\n> \n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>   src/libcamera/software_isp/debayer_egl.cpp | 21 +++++++++++++++++++++\n>   src/libcamera/software_isp/debayer_egl.h   |  9 +++++++++\n>   2 files changed, 30 insertions(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index 8e089032..0f36b149 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -111,6 +111,10 @@ int DebayerEGL::getShaderVariableLocations(void)\n>   \ttextureUniformBayerFirstRed_ = glGetUniformLocation(programId_, \"tex_bayer_first_red\");\n>   \ttextureUniformProjMatrix_ = glGetUniformLocation(programId_, \"proj_matrix\");\n>   \n> +\ttextureUniformLSCRed_ = glGetUniformLocation(programId_, \"lsc_tex_red\");\n> +\ttextureUniformLSCGreen_ = glGetUniformLocation(programId_, \"lsc_tex_green\");\n> +\ttextureUniformLSCBlue_ = glGetUniformLocation(programId_, \"lsc_tex_blue\");\n> +\n>   \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n>   \t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n>   \t\t\t    << \" ccm \" << ccmUniformDataIn_\n> @@ -140,6 +144,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n>   \t/* Specify GL_OES_EGL_image_external */\n>   \tegl_.pushEnv(shaderEnv, \"#extension GL_OES_EGL_image_external: enable\");\n>   \n> +\t/* Always use LSC */\n> +\tegl_.pushEnv(shaderEnv, \"#define DO_LSC\");\n> +\n>   \t/*\n>   \t * Tell shaders how to re-order output taking account of how the\n>   \t * pixels are actually stored by GBM\n> @@ -349,6 +356,12 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n>   \t */\n>   \tstats_->setWindow(Rectangle(window_.size()));\n>   \n> +\teglImageLSCLookupRed_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupGreen_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupBlue_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\tif (!eglImageLSCLookupRed_ || !eglImageLSCLookupGreen_ || !eglImageLSCLookupBlue_)\n\nThese operator new calls never return nullptr. But see below.\n\n\n> +\t\treturn -ENOMEM;\n> +\n>   \treturn 0;\n>   }\n>   \n> @@ -488,6 +501,14 @@ void DebayerEGL::setShaderVariableValues(DebayerParams &params)\n>   \tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n>   \tLOG(Debayer, Debug) << \" ccmUniformDataIn_ \" << ccmUniformDataIn_ << \" data \" << params.ccm;\n>   \n> +\tegl_.createTexture2D(*eglImageLSCLookupRed_, GL_LUMINANCE, 16, 16, &params.LSC_red, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupBlue_, GL_LUMINANCE, 16, 16, &params.LSC_green, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupGreen_, GL_LUMINANCE, 16, 16, &params.LSC_blue, GL_LINEAR);\n> +\n> +\tglUniform1i(textureUniformLSCRed_, eglImageLSCLookupRed_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCGreen_, eglImageLSCLookupGreen_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCBlue_, eglImageLSCLookupBlue_->texture_unit_uniform_id_);\n> +\n>   \t/*\n>   \t * 0 = Red, 1 = Green, 2 = Blue\n>   \t */\n> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\n> index a5033bc6..61feadab 100644\n> --- a/src/libcamera/software_isp/debayer_egl.h\n> +++ b/src/libcamera/software_isp/debayer_egl.h\n> @@ -85,6 +85,11 @@ private:\n>   \tstd::unique_ptr<eGLImage> eglImageBayerIn_;\n>   \tstd::unique_ptr<eGLImage> eglImageBayerOut_;\n>   \n> +\t/* Pointer to object representing input texture */\n> +\teGLImage *eglImageLSCLookupRed_;\n> +\teGLImage *eglImageLSCLookupBlue_;\n> +\teGLImage *eglImageLSCLookupGreen_;\n\nThese need to become `std::optional<eGLImage>` or `std::unique_ptr<>` at least.\nPlease no raw owning raw pointers.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> +\n>   \t/* Shader parameters */\n>   \tfloat firstRed_x_;\n>   \tfloat firstRed_y_;\n> @@ -98,6 +103,10 @@ private:\n>   \n>   \tGLint textureUniformBayerDataIn_;\n>   \n> +\tGLint textureUniformLSCRed_;\n> +\tGLint textureUniformLSCGreen_;\n> +\tGLint textureUniformLSCBlue_;\n> +\n>   \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n>   \tGLint ccmUniformDataIn_;\n>","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 881FBC328D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jan 2026 11:30:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BAA361FCA;\n\tMon, 26 Jan 2026 12:30:42 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3315661FC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 12:30:41 +0100 (CET)","from [192.168.33.36] (185.221.142.123.nat.pool.zt.hu\n\t[185.221.142.123])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0850863F;\n\tMon, 26 Jan 2026 12:30:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XiiGAWB5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769427005;\n\tbh=uLq0cg/Ua5/CXDO6MvhZwt6JQg3N24Rvqzvp/eY49s8=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=XiiGAWB5Wii0vftsisK7i0l7Lk/6nmDwRI5QQIkwmP2TQCR8D5jhRCS7R7yoGOnVo\n\tUaZxP5hFj6SkJ+CW/l+jxpo2imU8skbbd64bTeBcHlEVrSVq71I7DdTJVtBQq+tHvN\n\tP68b0tVku8tPH/Vvjq8To8ly6DY7uBxMB7WDlFns=","Message-ID":"<ccbb9e66-aa01-4f7c-86c9-59018e70c000@ideasonboard.com>","Date":"Mon, 26 Jan 2026 12:30:39 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"xander.c.pronk@gmail.com, derekgielen@outlook.com,\n\t22012540@student.hhs.nl, johannes.goede@oss.qualcomm.com,\n\tRick ten Wolde <rick_libcamera@wolde.info>","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<20260126104256.119697-6-rick.w.ten.wolde@gmail.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260126104256.119697-6-rick.w.ten.wolde@gmail.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":37952,"web_url":"https://patchwork.libcamera.org/comment/37952/","msgid":"<85h5s8cs0f.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-26T15:28:48","subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi,\n\nthank you for the patches.\n\nRick ten Wolde <rick.w.ten.wolde@gmail.com> writes:\n\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n>\n> Add support for passing the LSC tables from debayerParams to\n> the shaders.\n>\n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>  src/libcamera/software_isp/debayer_egl.cpp | 21 +++++++++++++++++++++\n>  src/libcamera/software_isp/debayer_egl.h   |  9 +++++++++\n>  2 files changed, 30 insertions(+)\n>\n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index 8e089032..0f36b149 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -111,6 +111,10 @@ int DebayerEGL::getShaderVariableLocations(void)\n>  \ttextureUniformBayerFirstRed_ = glGetUniformLocation(programId_, \"tex_bayer_first_red\");\n>  \ttextureUniformProjMatrix_ = glGetUniformLocation(programId_, \"proj_matrix\");\n>  \n> +\ttextureUniformLSCRed_ = glGetUniformLocation(programId_, \"lsc_tex_red\");\n> +\ttextureUniformLSCGreen_ = glGetUniformLocation(programId_, \"lsc_tex_green\");\n> +\ttextureUniformLSCBlue_ = glGetUniformLocation(programId_, \"lsc_tex_blue\");\n> +\n>  \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n>  \t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n>  \t\t\t    << \" ccm \" << ccmUniformDataIn_\n> @@ -140,6 +144,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n>  \t/* Specify GL_OES_EGL_image_external */\n>  \tegl_.pushEnv(shaderEnv, \"#extension GL_OES_EGL_image_external: enable\");\n>  \n> +\t/* Always use LSC */\n> +\tegl_.pushEnv(shaderEnv, \"#define DO_LSC\");\n\nI think this should be conditional.  For example, what if LSC algorithm\nis disabled?  Or LSC parameters are not available in the tuning file?\n\n> +\n>  \t/*\n>  \t * Tell shaders how to re-order output taking account of how the\n>  \t * pixels are actually stored by GBM\n> @@ -349,6 +356,12 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n>  \t */\n>  \tstats_->setWindow(Rectangle(window_.size()));\n>  \n> +\teglImageLSCLookupRed_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupGreen_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupBlue_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\tif (!eglImageLSCLookupRed_ || !eglImageLSCLookupGreen_ || !eglImageLSCLookupBlue_)\n> +\t\treturn -ENOMEM;\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -488,6 +501,14 @@ void DebayerEGL::setShaderVariableValues(DebayerParams &params)\n>  \tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n>  \tLOG(Debayer, Debug) << \" ccmUniformDataIn_ \" << ccmUniformDataIn_ << \" data \" << params.ccm;\n>  \n> +\tegl_.createTexture2D(*eglImageLSCLookupRed_, GL_LUMINANCE, 16, 16, &params.LSC_red, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupBlue_, GL_LUMINANCE, 16, 16, &params.LSC_green, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupGreen_, GL_LUMINANCE, 16, 16, &params.LSC_blue, GL_LINEAR);\n> +\n> +\tglUniform1i(textureUniformLSCRed_, eglImageLSCLookupRed_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCGreen_, eglImageLSCLookupGreen_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCBlue_, eglImageLSCLookupBlue_->texture_unit_uniform_id_);\n> +\n>  \t/*\n>  \t * 0 = Red, 1 = Green, 2 = Blue\n>  \t */\n> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\n> index a5033bc6..61feadab 100644\n> --- a/src/libcamera/software_isp/debayer_egl.h\n> +++ b/src/libcamera/software_isp/debayer_egl.h\n> @@ -85,6 +85,11 @@ private:\n>  \tstd::unique_ptr<eGLImage> eglImageBayerIn_;\n>  \tstd::unique_ptr<eGLImage> eglImageBayerOut_;\n>  \n> +\t/* Pointer to object representing input texture */\n> +\teGLImage *eglImageLSCLookupRed_;\n> +\teGLImage *eglImageLSCLookupBlue_;\n> +\teGLImage *eglImageLSCLookupGreen_;\n> +\n>  \t/* Shader parameters */\n>  \tfloat firstRed_x_;\n>  \tfloat firstRed_y_;\n> @@ -98,6 +103,10 @@ private:\n>  \n>  \tGLint textureUniformBayerDataIn_;\n>  \n> +\tGLint textureUniformLSCRed_;\n> +\tGLint textureUniformLSCGreen_;\n> +\tGLint textureUniformLSCBlue_;\n> +\n>  \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n>  \tGLint ccmUniformDataIn_;","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 99EA5C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jan 2026 15:28:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45EA161FC8;\n\tMon, 26 Jan 2026 16:28:56 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AF6CC61A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 16:28:54 +0100 (CET)","from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n\t[209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-321-H2j1wxMKMkS6vs09eH3KAw-1; Mon, 26 Jan 2026 10:28:51 -0500","by mail-wm1-f70.google.com with SMTP id\n\t5b1f17b1804b1-47d5c7a2f54so56403515e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 07:28:51 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-435b1e7156dsm31704180f8f.20.2026.01.26.07.28.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 26 Jan 2026 07:28:49 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"A8xAF+Tg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1769441333;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=ASeSmWZ01ayX/fXjngxzKjZmebdWPzA9I4lHvsePybs=;\n\tb=A8xAF+Tg26e7liiLFhxqmr9zr6YMTHHELhoiIeZtru1yn4PRwF19CWbswPEjlRTnffkuSO\n\trHExlzQ6TTgKYSRLeoQTUuROHIDPFVvaF6Mx+k/DKSXGTkbMnL9S4WYRKKc9zoMvz/dPyv\n\tJGUIRx0msdOGZD400+u5jfuvNARY8Vg=","X-MC-Unique":"H2j1wxMKMkS6vs09eH3KAw-1","X-Mimecast-MFC-AGG-ID":"H2j1wxMKMkS6vs09eH3KAw_1769441331","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1769441330; x=1770046130;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=ASeSmWZ01ayX/fXjngxzKjZmebdWPzA9I4lHvsePybs=;\n\tb=rCRUhP5/N++WkHcdWu2CyC4gMdv6lJTWt8P1vLx2/gs+ry6WrfJJ97e650Q7kkcal6\n\tbxO0fZhi/rgbtcFeD5IsvrqO+IgXbF+ZAXxxlssj8mZ55aBx/Egob/f4Cl8fcnJPWeEw\n\tN/gE8sKc1RFJgrG2Tn+Fd003Q5Cc220r5wvDRP6I8nz1SYM38WekJa1EOSl4mEcO/5IC\n\tv+w7zKTjeVsCwzCovrbsiFfY+VnRhjOpl2Hxi6Zf5nsk08e87o2KHlT2YOQMgT31yk5Q\n\t41QLOSzqtdruUcZHiOzrHmFA8iy/Bie0xdN7BxXLxTeY0LkSobG7oxRr+CFVnUw9+WaW\n\tPx/w==","X-Gm-Message-State":"AOJu0YzTz8suiH8G3cjorDqylM0vO68usIsh0x2crv2L1l2ceOeZwNvL\n\tTxJswZqzgS0bHvq00zhd7do7pksCTdQk/7Qf+sTaZ8qhXuMJoLDKOVgGm6wgW/mIhI+9HsmHkeM\n\tt7woqs5VkrfIdmLZkQj2hWihaNBRUeM3ED8GUcbmksjGm+sdqgxvA6tYf9qjsW88MkbSZQu5C1K\n\to=","X-Gm-Gg":"AZuq6aLfyue2NYXqzuEpMdocqIrvVWsQ6bGvIcKbKnOEBVP+lZ8FGTFjk8peXHaRvb9\n\tb8RPpSIdFNQf/ay4iuEFBSzNGX0yHxyygZLP8PZYZlBJDmSqK2B4yV1y0IlD8s6aaHSdQgg3CiU\n\txxxXRSebbuReD4yAx8saRJ+bf7e+6mglvVkXpdINQcCSKPYN0rgGLwwDqy9lXlaOLUSDcHOir8G\n\tJzX5S0wkVM9LCfkmtUxP7pj5MAhCz8Q3pdNTaJN6N7ERPUS+pEDCn65GwMbbpOTEKYtNsas6wPM\n\ttOYKeTNAoIETeUt0rehGzDjb9V58g+fZMlNXrwp5jBWSYSIzvGmCBulyOqEJOuiRps/ko4X123X\n\tKXKzMUg1XMi0CEEwEX3FHv0SrNMQFyeCjJn+QoYIuLqVQ8IjueeGfW+jpwWDFcTE=","X-Received":["by 2002:a05:600c:5395:b0:47e:e981:78b4 with SMTP id\n\t5b1f17b1804b1-4805ce43727mr74253775e9.12.1769441330530; \n\tMon, 26 Jan 2026 07:28:50 -0800 (PST)","by 2002:a05:600c:5395:b0:47e:e981:78b4 with SMTP id\n\t5b1f17b1804b1-4805ce43727mr74253455e9.12.1769441330041; \n\tMon, 26 Jan 2026 07:28:50 -0800 (PST)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org,  xander.c.pronk@gmail.com,\n\tderekgielen@outlook.com,  22012540@student.hhs.nl,\n\tjohannes.goede@oss.qualcomm.com,  Rick ten Wolde\n\t<rick_libcamera@wolde.info>","Subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","In-Reply-To":"<20260126104256.119697-6-rick.w.ten.wolde@gmail.com> (Rick ten\n\tWolde's message of \"Mon, 26 Jan 2026 11:42:53 +0100\")","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<20260126104256.119697-6-rick.w.ten.wolde@gmail.com>","Date":"Mon, 26 Jan 2026 16:28:48 +0100","Message-ID":"<85h5s8cs0f.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"2T4hR-u1eAvj4jBkUh58AMEzp-mTe2lxHP2d_UQB4rY_1769441331","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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":38080,"web_url":"https://patchwork.libcamera.org/comment/38080/","msgid":"<894323fa-aea0-4208-be3c-a7643ef7913a@linaro.org>","date":"2026-02-04T15:23:40","subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/people/175/","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"content":"On 26/01/2026 10:42, Rick ten Wolde wrote:\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n> \n> Add support for passing the LSC tables from debayerParams to\n> the shaders.\n> \n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>   src/libcamera/software_isp/debayer_egl.cpp | 21 +++++++++++++++++++++\n>   src/libcamera/software_isp/debayer_egl.h   |  9 +++++++++\n>   2 files changed, 30 insertions(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index 8e089032..0f36b149 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -111,6 +111,10 @@ int DebayerEGL::getShaderVariableLocations(void)\n>   \ttextureUniformBayerFirstRed_ = glGetUniformLocation(programId_, \"tex_bayer_first_red\");\n>   \ttextureUniformProjMatrix_ = glGetUniformLocation(programId_, \"proj_matrix\");\n> \n> +\ttextureUniformLSCRed_ = glGetUniformLocation(programId_, \"lsc_tex_red\");\n> +\ttextureUniformLSCGreen_ = glGetUniformLocation(programId_, \"lsc_tex_green\");\n> +\ttextureUniformLSCBlue_ = glGetUniformLocation(programId_, \"lsc_tex_blue\");\n> +\n>   \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n>   \t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n>   \t\t\t    << \" ccm \" << ccmUniformDataIn_\n> @@ -140,6 +144,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n>   \t/* Specify GL_OES_EGL_image_external */\n>   \tegl_.pushEnv(shaderEnv, \"#extension GL_OES_EGL_image_external: enable\");\n> \n> +\t/* Always use LSC */\n> +\tegl_.pushEnv(shaderEnv, \"#define DO_LSC\");\n> +\n\nIf you are always doing LSC there's not much point in having it \ncontrolled by define.\n\nYou also need to update qcam -> src/apps/qcam/viewfinder_gl.cpp\n\nWhat happens if I don't have LSC data though ?\n\n>   \t/*\n>   \t * Tell shaders how to re-order output taking account of how the\n>   \t * pixels are actually stored by GBM\n> @@ -349,6 +356,12 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n>   \t */\n>   \tstats_->setWindow(Rectangle(window_.size()));\n> \n> +\teglImageLSCLookupRed_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupGreen_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n> +\teglImageLSCLookupBlue_ = new eGLImage(20, 20, sizeof(GLubyte), GL_TEXTURE5, 5);\n\nI think this should be be GL_TEXTURE2, 2) GL_TEXTURE3, 3) and \nGL_TEXTURE4, 4) respectively.\n\nIn the sampler only one texture can be active with one texture unit at \nany one time.\n\nSo the only texture you are really using in the fragment shader is the \nlast bound shader.\n\nThat's why for these tables, we use a different texture unit for each R, \nG and B channel.\n\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/blob/v0.5.2-gpuisp-v5a/src/libcamera/software_isp/debayer_egl.cpp?ref_type=heads#L394\n\nPrompt Gemini: \"can i create multiple textures on the same texture unit\"\n\nAns: \"In OpenGL, you can technically bind multiple textures to the same\n       texture unit, but only one can be active and usable by a sampler\n       at any given time. To use multiple textures in a single shader\n       pass, you must bind each texture to a different texture unit\n       (e.g., GL_TEXTURE0, GL_TEXTURE1)\"\n\nhttps://www.google.com/search?client=firefox-b-d&q=can+i+create+multiple+textures+on+the+same+texture+unit&zx=1770218257332&no_sw_cr=1#fpstate=ive&vld=cid:763327a7,vid:9cP1w2ykaYc,st:351\n\n> +\tif (!eglImageLSCLookupRed_ || !eglImageLSCLookupGreen_ || !eglImageLSCLookupBlue_)\n> +\t\treturn -ENOMEM;\n> +\n>   \treturn 0;\n>   }\n> \n> @@ -488,6 +501,14 @@ void DebayerEGL::setShaderVariableValues(DebayerParams &params)\n>   \tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n>   \tLOG(Debayer, Debug) << \" ccmUniformDataIn_ \" << ccmUniformDataIn_ << \" data \" << params.ccm;\n> \n> +\tegl_.createTexture2D(*eglImageLSCLookupRed_, GL_LUMINANCE, 16, 16, &params.LSC_red, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupBlue_, GL_LUMINANCE, 16, 16, &params.LSC_green, GL_LINEAR);\n> +\tegl_.createTexture2D(*eglImageLSCLookupGreen_, GL_LUMINANCE, 16, 16, &params.LSC_blue, GL_LINEAR);\n> +\n> +\tglUniform1i(textureUniformLSCRed_, eglImageLSCLookupRed_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCGreen_, eglImageLSCLookupGreen_->texture_unit_uniform_id_);\n> +\tglUniform1i(textureUniformLSCBlue_, eglImageLSCLookupBlue_->texture_unit_uniform_id_);\n> +\n>   \t/*\n>   \t * 0 = Red, 1 = Green, 2 = Blue\n>   \t */\n> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\n> index a5033bc6..61feadab 100644\n> --- a/src/libcamera/software_isp/debayer_egl.h\n> +++ b/src/libcamera/software_isp/debayer_egl.h\n> @@ -85,6 +85,11 @@ private:\n>   \tstd::unique_ptr<eGLImage> eglImageBayerIn_;\n>   \tstd::unique_ptr<eGLImage> eglImageBayerOut_;\n> \n> +\t/* Pointer to object representing input texture */\n> +\teGLImage *eglImageLSCLookupRed_;\n> +\teGLImage *eglImageLSCLookupBlue_;\n> +\teGLImage *eglImageLSCLookupGreen_;\n> +\n>   \t/* Shader parameters */\n>   \tfloat firstRed_x_;\n>   \tfloat firstRed_y_;\n> @@ -98,6 +103,10 @@ private:\n> \n>   \tGLint textureUniformBayerDataIn_;\n> \n> +\tGLint textureUniformLSCRed_;\n> +\tGLint textureUniformLSCGreen_;\n> +\tGLint textureUniformLSCBlue_;\n> +\n>   \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n>   \tGLint ccmUniformDataIn_;\n> \n> --\n> 2.51.0\n>","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 E474ABD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Feb 2026 15:23:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3DC4462038;\n\tWed,  4 Feb 2026 16:23:45 +0100 (CET)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C90A261FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Feb 2026 16:23:43 +0100 (CET)","by mail-wm1-x32c.google.com with SMTP id\n\t5b1f17b1804b1-482f2599980so42306295e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 04 Feb 2026 07:23:43 -0800 (PST)","from [192.168.0.40] (188-141-3-146.dynamic.upc.ie. [188.141.3.146])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4830ec69cfasm23368475e9.5.2026.02.04.07.23.41\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 04 Feb 2026 07:23:42 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"kUD7jkGi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1770218623; x=1770823423;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:in-reply-to:content-language:from\n\t:references:cc:to:subject:user-agent:mime-version:date:message-id\n\t:from:to:cc:subject:date:message-id:reply-to;\n\tbh=pNQ3DaIo88GN52/0FLUbM8zu2NA2Yio1ct1B0yDTJ+I=;\n\tb=kUD7jkGi4mUjK36XhZcpYT9LL93AHDwilIiM7QlVbE69J+Pk2h/28Xsbew+GKwyaaO\n\tr3cQR54YFPxAIiVYDI2bZZ+8gRbTkxWCdcNAkAY+WgrbdZqY1FKE/19TN7Gs1Q6qMyt7\n\t6wo3TBd0jIRKH5+B6bfNmWb1M3qtzelA97Fb1hOjloNwb2210NQSXmUvzVKbKXPyEIPw\n\tIJvD6ZJy3GEJO4gct7FgiKs88Kr0ZRf+sPFE7lSRDS6/CfWDtukbdtttGqwGoI/z9lug\n\tli3i5TYjCK6LQNcdOI1zxWqXrdkWbnhzWIsAsPswqmwOiINCLPVHTZFt19UY9tVcXQGp\n\taR+Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1770218623; x=1770823423;\n\th=content-transfer-encoding:in-reply-to:content-language:from\n\t:references:cc:to:subject:user-agent:mime-version:date:message-id\n\t:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=pNQ3DaIo88GN52/0FLUbM8zu2NA2Yio1ct1B0yDTJ+I=;\n\tb=d1i7RUMPpB0Fjba0TNt1Azud1m+KAaGGVtR3CNs1eK+pSDZYsfxLlsFL6EeK59nLbH\n\tKUw4omsToxsRs1Phbs4j9uMCe68NY6hCY7NwfZIVN1pBrmQnqaHWO+OlHb52WiUAoBp/\n\tNYBMdzc4tMyt/bwamUuEHaiwP1sHdCaPpFlpUs33FE8yyfUjp5SAxa8H+hhZd643nuHx\n\tiiKpWktMmFlaA3UaY0yhZP5vKgnC894g7fyqLOmPBFZzXQ7cixenFWA1P/ppkjNJzD13\n\t468Dw/I8fvyBy2rlab/dkSD72a7ywX2GbAxT9V0UmH4CA7sHWGMtEdUurVFip0TggJ3S\n\tzqHA==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCUTTkDtdRksHdb9Kdfh5vwKMktUEz3CXbvtWKUpwYfuiXeaguVCmd+9QWpghI1RyrU0taQ16RRfjDIuMbEI/Ak=@lists.libcamera.org","X-Gm-Message-State":"AOJu0Yzl1h/T/xsgR0ikU8xu1CCy/xlhB46fZWBx5iB9yYUk9+zh9Xqi\n\tWiJy7yhLikLUJbgnYz5BoMwNOwR0dcq4zQJL27CKeB/yjW03F2wL313RnsTJvNytRSY=","X-Gm-Gg":"AZuq6aIckpxXUGz+bhmWCbRU0Qi/N7JW7d+QPhb0Xh/QoyPPfKzINC8ieEgneRz3LMl\n\tyL/KX0EPl5kGrrsdsjAMewQhhEhsO4n0MjG5LTv3kZPW1nqgn/mm3iHlvLAwX4mzzaCHdGEwW1D\n\tJ0CQh/p9bIAXy1UcvrRvizNc+RC0hBxsA19NyrKSF4DYxKPDiKrUJ1yJfbpBP/JKwWvYxa4jRxm\n\tiGwzCus+IZfvNcCaBcZaoWRF/piUaW3B0R6HEQWyFm3nZT47bgMa2+Mu+NZB6u+F1T9cs+/Ydlk\n\tPIXc8aJOD0utN13ob/5LNb5z3W6J/U/gFQ2NJRlfnFzFShOoCOZ7AajaSIW5U7C3e41za3uUk4T\n\ty8mo79Ar2JSqgtJ3ZzZfIJflK7JOSHIi+CbnVYK8pbrpbsIhoJ1LcH7reWXKfee2W4tw3qNRvYs\n\tOK1wgwkF+JeoYdRk4B3xHUMOh/sK3GnnUoDjacV1gbMQBeLTqeTX5Y","X-Received":"by 2002:a05:600c:680a:b0:480:6c75:ddce with SMTP id\n\t5b1f17b1804b1-4830e9a9b17mr46797155e9.33.1770218623129; \n\tWed, 04 Feb 2026 07:23:43 -0800 (PST)","Message-ID":"<894323fa-aea0-4208-be3c-a7643ef7913a@linaro.org>","Date":"Wed, 4 Feb 2026 15:23:40 +0000","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 5/7] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"xander.c.pronk@gmail.com, derekgielen@outlook.com,\n\t22012540@student.hhs.nl, johannes.goede@oss.qualcomm.com,\n\tRick ten Wolde <rick_libcamera@wolde.info>","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<EkIVlyjQlXqLN4OQvEIPBqs6Ji0X_FSoFExDGQ7xUtINdIwxF4URyCuOLhhgpVt1Eo95Dl0Bobo0kvvscZdCwg==@protonmail.internalid>\n\t<20260126104256.119697-6-rick.w.ten.wolde@gmail.com>","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Content-Language":"en-US","In-Reply-To":"<20260126104256.119697-6-rick.w.ten.wolde@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}}]