From patchwork Tue Nov 3 15:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10323 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 E3020BDB89 for ; Tue, 3 Nov 2020 15:51:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B66EF62BC9; Tue, 3 Nov 2020 16:51:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Yc0xpJBk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D32C62B7E for ; Tue, 3 Nov 2020 16:51:19 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E706FD7; Tue, 3 Nov 2020 16:51:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1604418679; bh=FardDCZkpEqMXQU1/dKBmNrNAzq9W338e50vTQ1iJRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yc0xpJBkQsjR1KpoaI7tqkCQOk86KAFZ95HggFksgc4lcp9YW4IBvdL2B52HJmLPc EuMLGbor5Gr0xBOILyn0ZqRnLAABHznGxEsj+AS3wi/VukNj7B0YbYMNYm35p9yh5X YBaHjGKBZZG7k5226fkA41o0GRBnTvjn/0FlW9hc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 3 Nov 2020 17:50:20 +0200 Message-Id: <20201103155025.5948-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201103155025.5948-1-laurent.pinchart@ideasonboard.com> References: <20201103155025.5948-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/7] qcam: viewfinder_gl: Keep fragment shader when format doesn't change 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" When ViewFinderGL::setFormat() is called, the fragment shader is deleted and recreated for the new format. This results in unnecessary shader recompilation if only the size is changed and the pixel format remains the same. Keep the existing shader in that case. The null test for fragmentShader_ can be removed, as if the shader program is linked, the fragment shader is guaranteed to exist. Signed-off-by: Laurent Pinchart Reviewed-by: Andrey Konovalov Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/qcam/viewfinder_gl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index 03a576ba89d2..c07292523504 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -53,19 +53,23 @@ const QList &ViewFinderGL::nativeFormats() const int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, const QSize &size) { - /* If the fragment is created remove it and create a new one. */ - if (fragmentShader_) { + if (format != format_) { + /* + * If the fragment already exists, remove it and create a new + * one for the new format. + */ if (shaderProgram_.isLinked()) { shaderProgram_.release(); shaderProgram_.removeShader(fragmentShader_.get()); fragmentShader_.reset(); } + + if (!selectFormat(format)) + return -1; + + format_ = format; } - if (!selectFormat(format)) - return -1; - - format_ = format; size_ = size; updateGeometry();