Patch Detail
Show a patch.
GET /api/patches/21225/?format=api
{ "id": 21225, "url": "https://patchwork.libcamera.org/api/patches/21225/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21225/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240910234649.28591-2-laurent.pinchart@ideasonboard.com>", "date": "2024-09-10T23:46:47", "name": "[1/3] qcam: viewfinder_gl: Fix binding of vertex buffer and shader program", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ab9651d8b047bc56acdafb5e10891a8b8652f26b", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21225/mbox/", "series": [ { "id": 4578, "url": "https://patchwork.libcamera.org/api/series/4578/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4578", "date": "2024-09-10T23:46:46", "name": "qcam: Fix GL renderer on Qt 6", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4578/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21225/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21225/checks/", "tags": {}, "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 2629FBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Sep 2024 23:47:28 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B04EF63502;\n\tWed, 11 Sep 2024 01:47:26 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A144634F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 11 Sep 2024 01:47:24 +0200 (CEST)", "from pendragon.ideasonboard.com\n\t(213-229-8-243.static.upcbusiness.at [213.229.8.243])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 325B3BEB;\n\tWed, 11 Sep 2024 01:46:07 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"IbNTiej5\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1726011967;\n\tbh=KGfAVXmSPWZE+yattAsCkhFdb5Uewtihi2avsou+KGw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=IbNTiej5kez5BfcmivdpS7xMOQnhLeI8crmjKNhQf8//URl9iuXsRIZtd4ZBPjOjN\n\tya/Vtwosbj98Ld096HDYaHMyoBeKgulCAaamTLpSCvgZu6GAJOPXkfLUJw44u9kJWI\n\tKQEHdYTXd2t0ToscxbNWFer4USH4QK273AM8vF2I=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Neal Gompa <neal@gompa.dev>", "Subject": "[PATCH 1/3] qcam: viewfinder_gl: Fix binding of vertex buffer and\n\tshader program", "Date": "Wed, 11 Sep 2024 02:46:47 +0300", "Message-ID": "<20240910234649.28591-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.44.2", "In-Reply-To": "<20240910234649.28591-1-laurent.pinchart@ideasonboard.com>", "References": "<20240910234649.28591-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "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>" }, "content": "Starting in Qt 6.7.0, vertex buffers and shader programs are unbound\njust before calling QOpenGLWidget::paintGL(). This breaks rendering in\nthe GL viewfinder in two ways.\n\nFirst, we bind the vertex buffer only once at initialization time. There\nis therefore no vertex buffer mapped at rendering time, preventing both\nthe vertex shader from having access to the vertex and texture\ncoordinates.\n\nThen, we bind the shader program only when rendering the first frame.\nThere is thus no shader program bound for all subsequent frames,\nbreaking rendering.\n\nFix this by binding the vertex buffer where needed, when setting\nattribute buffers for the shader program, and binding the shader program\nfor every frame.\n\nAs we use a single vertex buffer, we could bind it at the beginning of\npaintGL() and keep it bound indefinitely. That would however fail to\nclearly indicate in the source code where the vertex buffer is needed,\nmaking the code more difficult to understand as it would rely on\nimplicit assumptions. Release the vertex buffer explicitly when we don't\nneed it anymore to avoid this.\n\nWhile at it, fix a coding style violation by adding missing curly\nbrackets.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/apps/qcam/viewfinder_gl.cpp | 19 ++++++++++++-------\n 1 file changed, 12 insertions(+), 7 deletions(-)", "diff": "diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp\nindex 9d2a69600db1..5be7bec539bf 100644\n--- a/src/apps/qcam/viewfinder_gl.cpp\n+++ b/src/apps/qcam/viewfinder_gl.cpp\n@@ -443,15 +443,11 @@ bool ViewFinderGL::createFragmentShader()\n \t\tclose();\n \t}\n \n-\t/* Bind shader pipeline for use */\n-\tif (!shaderProgram_.bind()) {\n-\t\tqWarning() << \"[ViewFinderGL]:\" << shaderProgram_.log();\n-\t\tclose();\n-\t}\n-\n \tattributeVertex = shaderProgram_.attributeLocation(\"vertexIn\");\n \tattributeTexture = shaderProgram_.attributeLocation(\"textureIn\");\n \n+\tvertexBuffer_.bind();\n+\n \tshaderProgram_.enableAttributeArray(attributeVertex);\n \tshaderProgram_.setAttributeBuffer(attributeVertex,\n \t\t\t\t\t GL_FLOAT,\n@@ -466,6 +462,8 @@ bool ViewFinderGL::createFragmentShader()\n \t\t\t\t\t 2,\n \t\t\t\t\t 2 * sizeof(GLfloat));\n \n+\tvertexBuffer_.release();\n+\n \ttextureUniformY_ = shaderProgram_.uniformLocation(\"tex_y\");\n \ttextureUniformU_ = shaderProgram_.uniformLocation(\"tex_u\");\n \ttextureUniformV_ = shaderProgram_.uniformLocation(\"tex_v\");\n@@ -809,11 +807,18 @@ void ViewFinderGL::doRender()\n \n void ViewFinderGL::paintGL()\n {\n-\tif (!fragmentShader_)\n+\tif (!fragmentShader_) {\n \t\tif (!createFragmentShader()) {\n \t\t\tqWarning() << \"[ViewFinderGL]:\"\n \t\t\t\t << \"create fragment shader failed.\";\n \t\t}\n+\t}\n+\n+\t/* Bind shader pipeline for use. */\n+\tif (!shaderProgram_.bind()) {\n+\t\tqWarning() << \"[ViewFinderGL]:\" << shaderProgram_.log();\n+\t\tclose();\n+\t}\n \n \tif (image_) {\n \t\tglClearColor(0.0, 0.0, 0.0, 1.0);\n", "prefixes": [ "1/3" ] }