Patch Detail
Show a patch.
GET /api/1.1/patches/9606/?format=api
{ "id": 9606, "url": "https://patchwork.libcamera.org/api/1.1/patches/9606/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9606/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200915024623.30667-1-laurent.pinchart@ideasonboard.com>", "date": "2020-09-15T02:46:19", "name": "[libcamera-devel,v7,0/4] qcam: accelerate format conversion by OpenGL shader", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "46e73c0a745d1039000ff090e84e7eff43f28f6b", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/1.1/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/9606/mbox/", "series": [], "comments": "https://patchwork.libcamera.org/api/patches/9606/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9606/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 0CF7FC3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Sep 2020 02:46:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 830E762E01;\n\tTue, 15 Sep 2020 04:46:56 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E56D62901\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Sep 2020 04:46:55 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 86C45275;\n\tTue, 15 Sep 2020 04:46:54 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"hDUdb4/U\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600138014;\n\tbh=dM4Nc5HD8SRj+D7AJ/V5t/xXaTkGD6FuWqbpCOHjsBY=;\n\th=From:To:Subject:Date:From;\n\tb=hDUdb4/UrZShTs8dEBGmVSaSx7hg7MMSrHeqqbAaJRKaCCMJfkTkBc2EZhhD/e4mj\n\tLyYZuF3g/W4V335m6OhzJgpxdKVA1fIwtXYn+Uzp9zy4xQ9h5L7I9zKi+aW0cfbsnB\n\tyfN8AYk3pzk0s76AFcrZ6J7esWPDp0VmyLCXd/8s=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org,\n\tShow Liu <show.liu@linaro.org>", "Date": "Tue, 15 Sep 2020 05:46:19 +0300", "Message-Id": "<20200915024623.30667-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v7 0/4] qcam: accelerate format conversion\n\tby OpenGL shader", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Hello,\n\nThis patch series is an updated version of Show's v6. I've updated the\npatches during review as I wanted to test my review comments, and it\nwould be pointless for Show to do the same independently to post a v7.\n\nThe series only incorporates review comments. Show, could you please let\nme know if you're fine with the result ? To make the comparison easier,\nhere's the diff between v6 and v7.\n\n\nShow Liu (4):\n qcam: Add OpenGL shader code as Qt resource\n qcam: New viewfinder hierarchy\n qcam: Add ViewFinderGL class to accelerate the format conversion\n qcam: Add additional command line option to select the renderer type\n\n meson.build | 1 +\n src/qcam/assets/shader/NV_2_planes_UV_f.glsl | 32 ++\n src/qcam/assets/shader/NV_2_planes_VU_f.glsl | 32 ++\n src/qcam/assets/shader/NV_3_planes_f.glsl | 33 ++\n src/qcam/assets/shader/NV_vertex_shader.glsl | 16 +\n src/qcam/assets/shader/shaders.qrc | 9 +\n src/qcam/main.cpp | 3 +\n src/qcam/main_window.cpp | 32 +-\n src/qcam/main_window.h | 1 +\n src/qcam/meson.build | 20 +-\n src/qcam/viewfinder.h | 57 +--\n src/qcam/viewfinder_gl.cpp | 451 ++++++++++++++++++\n src/qcam/viewfinder_gl.h | 96 ++++\n .../{viewfinder.cpp => viewfinder_qt.cpp} | 24 +-\n src/qcam/viewfinder_qt.h | 64 +++\n 15 files changed, 806 insertions(+), 65 deletions(-)\n create mode 100644 src/qcam/assets/shader/NV_2_planes_UV_f.glsl\n create mode 100644 src/qcam/assets/shader/NV_2_planes_VU_f.glsl\n create mode 100644 src/qcam/assets/shader/NV_3_planes_f.glsl\n create mode 100644 src/qcam/assets/shader/NV_vertex_shader.glsl\n create mode 100644 src/qcam/assets/shader/shaders.qrc\n create mode 100644 src/qcam/viewfinder_gl.cpp\n create mode 100644 src/qcam/viewfinder_gl.h\n rename src/qcam/{viewfinder.cpp => viewfinder_qt.cpp} (86%)\n create mode 100644 src/qcam/viewfinder_qt.h", "diff": "diff --git a/src/qcam/assets/shader/NV_2_planes_UV_f.glsl b/src/qcam/assets/shader/NV_2_planes_UV_f.glsl\nindex 80478c5d0dd4..67633a11ee0f 100644\n--- a/src/qcam/assets/shader/NV_2_planes_UV_f.glsl\n+++ b/src/qcam/assets/shader/NV_2_planes_UV_f.glsl\n@@ -18,10 +18,10 @@ void main(void)\n \tvec3 yuv;\n \tvec3 rgb;\n \tmat3 yuv2rgb_bt601_mat = mat3(\n-\t\t\t\t vec3(1.164, 1.164, 1.164),\n-\t\t\t\t vec3(0.000, -0.392, 2.017),\n-\t\t\t\t vec3(1.596, -0.813, 0.000)\n-\t\t\t\t );\n+\t\tvec3(1.164, 1.164, 1.164),\n+\t\tvec3(0.000, -0.392, 2.017),\n+\t\tvec3(1.596, -0.813, 0.000)\n+\t);\n\n \tyuv.x = texture2D(tex_y, textureOut).r - 0.063;\n \tyuv.y = texture2D(tex_u, textureOut).r - 0.500;\ndiff --git a/src/qcam/assets/shader/NV_2_planes_VU_f.glsl b/src/qcam/assets/shader/NV_2_planes_VU_f.glsl\nindex 3794be843590..086c5b6d11bd 100644\n--- a/src/qcam/assets/shader/NV_2_planes_VU_f.glsl\n+++ b/src/qcam/assets/shader/NV_2_planes_VU_f.glsl\n@@ -18,10 +18,10 @@ void main(void)\n \tvec3 yuv;\n \tvec3 rgb;\n \tmat3 yuv2rgb_bt601_mat = mat3(\n-\t\t\t\t vec3(1.164, 1.164, 1.164),\n-\t\t\t\t vec3(0.000, -0.392, 2.017),\n-\t\t\t\t vec3(1.596, -0.813, 0.000)\n-\t\t\t\t );\n+\t\tvec3(1.164, 1.164, 1.164),\n+\t\tvec3(0.000, -0.392, 2.017),\n+\t\tvec3(1.596, -0.813, 0.000)\n+\t);\n\n \tyuv.x = texture2D(tex_y, textureOut).r - 0.063;\n \tyuv.y = texture2D(tex_u, textureOut).g - 0.500;\ndiff --git a/src/qcam/assets/shader/NV_3_planes_f.glsl b/src/qcam/assets/shader/NV_3_planes_f.glsl\nindex fca9b659ca05..4bc941842710 100644\n--- a/src/qcam/assets/shader/NV_3_planes_f.glsl\n+++ b/src/qcam/assets/shader/NV_3_planes_f.glsl\n@@ -19,10 +19,10 @@ void main(void)\n \tvec3 yuv;\n \tvec3 rgb;\n \tmat3 yuv2rgb_bt601_mat = mat3(\n-\t\t\t\t vec3(1.164, 1.164, 1.164),\n-\t\t\t\t vec3(0.000, -0.392, 2.017),\n-\t\t\t\t vec3(1.596, -0.813, 0.000)\n-\t\t\t\t );\n+\t\tvec3(1.164, 1.164, 1.164),\n+\t\tvec3(0.000, -0.392, 2.017),\n+\t\tvec3(1.596, -0.813, 0.000)\n+\t);\n\n \tyuv.x = texture2D(tex_y, textureOut).r - 0.063;\n \tyuv.y = texture2D(tex_u, textureOut).r - 0.500;\ndiff --git a/src/qcam/main.cpp b/src/qcam/main.cpp\nindex 4b7d04100c08..f60d3cef0ecb 100644\n--- a/src/qcam/main.cpp\n+++ b/src/qcam/main.cpp\n@@ -33,9 +33,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])\n \t\t\t ArgumentRequired, \"camera\");\n \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n \t\t\t \"help\");\n-\tparser.addOption(OptRendered, OptionString,\n-\t\t\t \"Choose the renderer type {qt,gles} (default: qt)\", \"renderer\",\n-\t\t\t ArgumentRequired, \"render\");\n+\tparser.addOption(OptRenderer, OptionString,\n+\t\t\t \"Choose the renderer type {qt,gles} (default: qt)\",\n+\t\t\t \"renderer\", ArgumentRequired, \"renderer\");\n \tparser.addOption(OptStream, &streamKeyValue,\n \t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 315102c39526..e5233f4fb706 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -28,6 +28,8 @@\n #include <libcamera/version.h>\n\n #include \"dng_writer.h\"\n+#include \"viewfinder_gl.h\"\n+#include \"viewfinder_qt.h\"\n\n using namespace libcamera;\n\n@@ -95,9 +97,6 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n {\n \tint ret;\n\n-\t/* Render Type Qt or GLES, and set Qt by default */\n-\tstd::string renderType_ = \"qt\";\n-\n \t/*\n \t * Initialize the UI: Create the toolbar, set the window title and\n \t * create the viewfinder widget.\n@@ -108,17 +107,19 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \tsetWindowTitle(title_);\n \tconnect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));\n\n-\tif (options_.isSet(OptRendered))\n-\t\trenderType_ = options_[OptRendered].toString();\n+\t/* Renderer type Qt or GLES, select Qt by default. */\n+\tstd::string renderType = \"qt\";\n+\tif (options_.isSet(OptRenderer))\n+\t\trenderType = options_[OptRenderer].toString();\n\n-\tif (renderType_ == \"qt\") {\n+\tif (renderType == \"qt\") {\n \t\tViewFinderQt *viewfinder = new ViewFinderQt(this);\n \t\tconnect(viewfinder, &ViewFinderQt::renderComplete,\n \t\t\tthis, &MainWindow::queueRequest);\n \t\tviewfinder_ = viewfinder;\n \t\tsetCentralWidget(viewfinder);\n #ifndef QT_NO_OPENGL\n-\t} else if (renderType_ == \"gles\") {\n+\t} else if (renderType == \"gles\") {\n \t\tViewFinderGL *viewfinder = new ViewFinderGL(this);\n \t\tconnect(viewfinder, &ViewFinderGL::renderComplete,\n \t\t\tthis, &MainWindow::queueRequest);\n@@ -127,7 +128,7 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n #endif\n \t} else {\n \t\tqWarning() << \"Invalid render type\"\n-\t\t\t << QString::fromStdString(renderType_);\n+\t\t\t << QString::fromStdString(renderType);\n \t\tquit();\n \t\treturn;\n \t}\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 251f78bf6833..5c61a4dfce53 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -26,8 +26,6 @@\n\n #include \"../cam/stream_options.h\"\n #include \"viewfinder.h\"\n-#include \"viewfinder_gl.h\"\n-#include \"viewfinder_qt.h\"\n\n using namespace libcamera;\n\n@@ -39,7 +37,7 @@ class HotplugEvent;\n enum {\n \tOptCamera = 'c',\n \tOptHelp = 'h',\n-\tOptRendered = 'r',\n+\tOptRenderer = 'r',\n \tOptStream = 's',\n };\n\ndiff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex 84f48666af5b..fbe21dcf1ad2 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -19,7 +19,7 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n \tlibcamera::formats::NV24,\n \tlibcamera::formats::NV42,\n \tlibcamera::formats::YUV420,\n-\tlibcamera::formats::YVU420\n+\tlibcamera::formats::YVU420,\n };\n\n ViewFinderGL::ViewFinderGL(QWidget *parent)\n@@ -35,9 +35,6 @@ ViewFinderGL::ViewFinderGL(QWidget *parent)\n ViewFinderGL::~ViewFinderGL()\n {\n \tremoveShader();\n-\n-\tif (vertexBuffer_.isCreated())\n-\t\tvertexBuffer_.destroy();\n }\n\n const QList<libcamera::PixelFormat> &ViewFinderGL::nativeFormats() const\n@@ -48,9 +45,7 @@ const QList<libcamera::PixelFormat> &ViewFinderGL::nativeFormats() const\n int ViewFinderGL::setFormat(const libcamera::PixelFormat &format,\n \t\t\t const QSize &size)\n {\n-\tint ret = 0;\n-\n-\t/* If the fragment is ceeated remove it and create a new one */\n+\t/* If the fragment is created remove it and create a new one. */\n \tif (fragmentShader_) {\n \t\tif (shaderProgram_.isLinked()) {\n \t\t\tshaderProgram_.release();\n@@ -59,14 +54,14 @@ int ViewFinderGL::setFormat(const libcamera::PixelFormat &format,\n \t\t}\n \t}\n\n-\tif (selectFormat(format)) {\n-\t\tformat_ = format;\n-\t\tsize_ = size;\n-\t} else {\n-\t\tret = -1;\n-\t}\n+\tif (!selectFormat(format))\n+\t\treturn -1;\n+\n+\tformat_ = format;\n+\tsize_ = size;\n+\n \tupdateGeometry();\n-\treturn ret;\n+\treturn 0;\n }\n\n void ViewFinderGL::stop()\n@@ -279,10 +274,10 @@ void ViewFinderGL::initializeGL()\n \t\t},\n \t\t{\n \t\t\t/* Texture coordinates */\n-\t\t\t{ 1.0f, 0.0f },\n-\t\t\t{ 1.0f, 1.0f },\n \t\t\t{ 0.0f, 1.0f },\n \t\t\t{ 0.0f, 0.0f },\n+\t\t\t{ 1.0f, 0.0f },\n+\t\t\t{ 1.0f, 1.0f },\n \t\t},\n \t};\n\n@@ -306,7 +301,7 @@ void ViewFinderGL::doRender()\n \tcase libcamera::formats::NV61:\n \tcase libcamera::formats::NV24:\n \tcase libcamera::formats::NV42:\n-\t\t/* activate texture Y */\n+\t\t/* Activate texture Y */\n \t\tglActiveTexture(GL_TEXTURE0);\n \t\tconfigureTexture(id_y_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -320,7 +315,7 @@ void ViewFinderGL::doRender()\n \t\t\t yuvData_);\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n\n-\t\t/* activate texture UV/VU */\n+\t\t/* Activate texture UV/VU */\n \t\tglActiveTexture(GL_TEXTURE1);\n \t\tconfigureTexture(id_u_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -336,7 +331,7 @@ void ViewFinderGL::doRender()\n \t\tbreak;\n\n \tcase libcamera::formats::YUV420:\n-\t\t/* activate texture Y */\n+\t\t/* Activate texture Y */\n \t\tglActiveTexture(GL_TEXTURE0);\n \t\tconfigureTexture(id_y_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -350,7 +345,7 @@ void ViewFinderGL::doRender()\n \t\t\t yuvData_);\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n\n-\t\t/* activate texture U */\n+\t\t/* Activate texture U */\n \t\tglActiveTexture(GL_TEXTURE1);\n \t\tconfigureTexture(id_u_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -364,7 +359,7 @@ void ViewFinderGL::doRender()\n \t\t\t (char *)yuvData_ + size_.width() * size_.height());\n \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n\n-\t\t/* activate texture V */\n+\t\t/* Activate texture V */\n \t\tglActiveTexture(GL_TEXTURE2);\n \t\tconfigureTexture(id_v_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -380,7 +375,7 @@ void ViewFinderGL::doRender()\n \t\tbreak;\n\n \tcase libcamera::formats::YVU420:\n-\t\t/* activate texture Y */\n+\t\t/* Activate texture Y */\n \t\tglActiveTexture(GL_TEXTURE0);\n \t\tconfigureTexture(id_y_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -394,7 +389,7 @@ void ViewFinderGL::doRender()\n \t\t\t yuvData_);\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n\n-\t\t/* activate texture V */\n+\t\t/* Activate texture V */\n \t\tglActiveTexture(GL_TEXTURE2);\n \t\tconfigureTexture(id_v_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -406,9 +401,9 @@ void ViewFinderGL::doRender()\n \t\t\t GL_RED,\n \t\t\t GL_UNSIGNED_BYTE,\n \t\t\t (char *)yuvData_ + size_.width() * size_.height());\n-\t\tshaderProgram_.setUniformValue(textureUniformV_, 1);\n+\t\tshaderProgram_.setUniformValue(textureUniformV_, 2);\n\n-\t\t/* activate texture U */\n+\t\t/* Activate texture U */\n \t\tglActiveTexture(GL_TEXTURE1);\n \t\tconfigureTexture(id_u_);\n \t\tglTexImage2D(GL_TEXTURE_2D,\n@@ -420,7 +415,7 @@ void ViewFinderGL::doRender()\n \t\t\t GL_RED,\n \t\t\t GL_UNSIGNED_BYTE,\n \t\t\t (char *)yuvData_ + size_.width() * size_.height() * 5 / 4);\n-\t\tshaderProgram_.setUniformValue(textureUniformU_, 2);\n+\t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n \t\tbreak;\n\n \tdefault:\n", "prefixes": [ "libcamera-devel", "v7", "0/4" ] }