[{"id":37506,"web_url":"https://patchwork.libcamera.org/comment/37506/","msgid":"<176777989223.3486172.13160471073173386920@ping.linuxembedded.co.uk>","date":"2026-01-07T09:58:12","subject":"Re: [PATCH v11 04/24] qcam: viewfinder_gl: Set no-op Bayer shader\n\tvalues","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Bryan O'Donoghue (2026-01-06 17:00:39)\n> Populate qcam viewfinder_gl to set default Bayer values so that the\n> shaders can be used in their original mode without conditional compilation.\n> \n> Set an identity CCM, identity Black Level and set Gamma and Contrast to\n> 1.0f respectively.\n> \n> Once this change is made we can use the Bayer shaders in their original\n> format in qcam with raw streams.\n> \n> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\nI don't really fully understand the magic of shaders here - but\neverything looks sensible, and once tested I'm fine with this being\nmerged so:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/apps/qcam/viewfinder_gl.cpp | 26 ++++++++++++++++++++++++++\n>  src/apps/qcam/viewfinder_gl.h   | 12 ++++++++++++\n>  2 files changed, 38 insertions(+)\n> \n> diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp\n> index 1554c94d5..0d06122f6 100644\n> --- a/src/apps/qcam/viewfinder_gl.cpp\n> +++ b/src/apps/qcam/viewfinder_gl.cpp\n> @@ -473,6 +473,10 @@ bool ViewFinderGL::createFragmentShader()\n>         textureUniformSize_ = shaderProgram_.uniformLocation(\"tex_size\");\n>         textureUniformStrideFactor_ = shaderProgram_.uniformLocation(\"stride_factor\");\n>         textureUniformBayerFirstRed_ = shaderProgram_.uniformLocation(\"tex_bayer_first_red\");\n> +       ccmUniformDataIn_ = shaderProgram_.uniformLocation(\"ccm\");\n> +       blackLevelUniformDataIn_ = shaderProgram_.uniformLocation(\"blacklevel\");\n> +       gammaUniformDataIn_ = shaderProgram_.uniformLocation(\"gamma\");\n> +       contrastExpUniformDataIn_ = shaderProgram_.uniformLocation(\"contrastExp\");\n>  \n>         /* Create the textures. */\n>         for (std::unique_ptr<QOpenGLTexture> &texture : textures_) {\n> @@ -542,6 +546,16 @@ void ViewFinderGL::doRender()\n>         /* Stride of the first plane, in pixels. */\n>         unsigned int stridePixels;\n>  \n> +       /* Identity CCM */\n> +       float ccm[] = { 1.0f, 0.0f, 0.0f,\n> +                       0.0f, 1.0f, 0.0f,\n> +                       0.0f, 0.0f, 1.0f };\n> +\n> +       QMatrix3x3 qCcmMat(ccm);\n> +\n> +       /* Black Level */\n> +       QVector3D qBlackLevelVec(0.0f, 0.0f, 0.0f);\n> +\n>         switch (format_) {\n>         case libcamera::formats::NV12:\n>         case libcamera::formats::NV21:\n> @@ -788,6 +802,18 @@ void ViewFinderGL::doRender()\n>                  * the generic stride factor to 1.0.\n>                  */\n>                 stridePixels = size_.width();\n> +\n> +               /* Colour Correction Matrix */\n> +               shaderProgram_.setUniformValue(ccmUniformDataIn_, qCcmMat);\n> +\n> +               /* Black Level */\n> +               shaderProgram_.setUniformValue(blackLevelUniformDataIn_, qBlackLevelVec);\n> +\n> +               /* Gamma */\n> +               shaderProgram_.setUniformValue(gammaUniformDataIn_, 1.0f);\n> +\n> +               /* Contrast */\n> +               shaderProgram_.setUniformValue(contrastExpUniformDataIn_, 1.0f);\n>                 break;\n>  \n>         default:\n> diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h\n> index 23c657bcf..1aa85e4fc 100644\n> --- a/src/apps/qcam/viewfinder_gl.h\n> +++ b/src/apps/qcam/viewfinder_gl.h\n> @@ -103,5 +103,17 @@ private:\n>         GLuint textureUniformBayerFirstRed_;\n>         QPointF firstRed_;\n>  \n> +       /* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n> +       GLint ccmUniformDataIn_;\n> +\n> +       /* Black Level compensation */\n> +       GLint blackLevelUniformDataIn_;\n> +\n> +       /* Gamma */\n> +       GLint gammaUniformDataIn_;\n> +\n> +       /* Contrast */\n> +       GLint contrastExpUniformDataIn_;\n> +\n>         QMutex mutex_; /* Prevent concurrent access to image_ */\n>  };\n> -- \n> 2.52.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 1423ABDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Jan 2026 09:58:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1143661FBB;\n\tWed,  7 Jan 2026 10:58:17 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6751761F61\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Jan 2026 10:58:15 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9845773B;\n\tWed,  7 Jan 2026 10:57:53 +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=\"qNNLdxqm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767779873;\n\tbh=i3zmKEV3hX+KxKcv1WL2vFhae5lNpGvf1n/xM/sYaWU=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=qNNLdxqmWehdmfPqwbzRWRPqR2nEMDHGEJTPh1enSnrhCfz29GJfY2fGTlprYWkYg\n\t5gof5WNNHxBN7cF8MqcHzEeGi0dbQJVm2HH0GHwbgSkvX2bnRxybXlM39yL6O9xxwx\n\tdRUx0OyiEYtJxivu2ufbCEdh3v0HOqU6XWI4qxP8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260106170059.56193-5-bryan.odonoghue@linaro.org>","References":"<20260106170059.56193-1-bryan.odonoghue@linaro.org>\n\t<20260106170059.56193-5-bryan.odonoghue@linaro.org>","Subject":"Re: [PATCH v11 04/24] qcam: viewfinder_gl: Set no-op Bayer shader\n\tvalues","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMilan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 07 Jan 2026 09:58:12 +0000","Message-ID":"<176777989223.3486172.13160471073173386920@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]