Patch Detail
Show a patch.
GET /api/patches/12688/?format=api
{ "id": 12688, "url": "https://patchwork.libcamera.org/api/patches/12688/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12688/", "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": "<20210622134652.1279260-5-andrey.konovalov@linaro.org>", "date": "2021-06-22T13:46:47", "name": "[libcamera-devel,v5,4/9] qcam: viewfinder_gl: Copy the shaders for RAW8 Bayer format from motmot", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "6ffa5389bb73246736e7c7a186405444baaa34df", "submitter": { "id": 25, "url": "https://patchwork.libcamera.org/api/people/25/?format=api", "name": "Andrey Konovalov", "email": "andrey.konovalov@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12688/mbox/", "series": [ { "id": 2168, "url": "https://patchwork.libcamera.org/api/series/2168/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2168", "date": "2021-06-22T13:46:43", "name": "qcam: viewfinder_gl: add RAW8, RAW10P and RAW12P formats", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2168/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12688/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12688/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 F3727C321B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Jun 2021 13:47:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B23586893C;\n\tTue, 22 Jun 2021 15:47:15 +0200 (CEST)", "from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com\n\t[IPv6:2a00:1450:4864:20::22e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8489660292\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jun 2021 15:47:14 +0200 (CEST)", "by mail-lj1-x22e.google.com with SMTP id u11so19285704ljh.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jun 2021 06:47:14 -0700 (PDT)", "from localhost.localdomain ([85.249.44.185])\n\tby smtp.googlemail.com with ESMTPSA id\n\tb19sm163125ljo.37.2021.06.22.06.47.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Jun 2021 06:47:13 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"u+eUkAja\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=toJkMwr37AcuRN1/3qMxHgEcqlJJsuiq1b1YEw63lPk=;\n\tb=u+eUkAjaJGEFrra6wa6saS9zp9nt8MST9TbwiQ/+0aLj/rtn2iOGojqr+fQ7XiYvoR\n\tRcb4ob/cqq2sYF1FKw3fT3i2q++6o39DISjwc8s0qMaHjYEU/KAhAwEtQG2/wLONCiKr\n\t1mClsdLNA95LIQhLXa2K1PnynaDNa5lk1eNuwX5fqazGLkTVDgV3mIsjsVyG7RHTrDvv\n\t3dSUVTsVP3BvFbnlIIuMJ9jWoBGL1Now2KszliI3fSxC4CzyxoM+RAoVovwE0v0x7nYD\n\t9Uwi4Ca0sbm2ggpJxeO8uNpyVfbrxBjmHDqc3Xc0Krj2QuT441dW2ghhoS/nRcTh/ZtQ\n\tdFig==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=toJkMwr37AcuRN1/3qMxHgEcqlJJsuiq1b1YEw63lPk=;\n\tb=NDG0yQjGEZIesW0ejYB39sl8fBKurw8dM/zhtJE65ZEIhbwJ1tbEwDfSdnMSNrxpQn\n\tgFmDXw8baAAuinPl4tCxg+1GzohRAwLX8NlTiKhWKkzZ4NRxCwcuUmohkXaG0oNSUXEw\n\tALiMr3uQHzIRh8gZlm4kqh+5SjtVOeLAe5CLFZ3yR8hTTwHEZjbXgCChA5srt11bi2zu\n\tFbK5jUc7VJ3phYEQNazeDM2DXyYafOMbwuXW6bQPhp/cPmQLfjCWURazouJyr2hwAnSP\n\tbeUQSevTxADEUgbZrANkVO07X5kDE9R140kRwoN/fJ9xV6nlFFdKcMbPdUsW2nfp+PDB\n\tnlYA==", "X-Gm-Message-State": "AOAM5332vpHpzkucS6k/P//vyO0cfuGS2iL3nVj6e0gdVnyblXnfgpqS\n\tL7Jl+1mLEGGAWjbjUeqphZPRfsFV/P/pog==", "X-Google-Smtp-Source": "ABdhPJyCnNOKuamRlJeETEX/D/ZSr7LFdWtaogQdKsBC9gIOvylCG+GTT5MzOX9g9xg9XKICBsDwhA==", "X-Received": "by 2002:a2e:9788:: with SMTP id y8mr3327363lji.100.1624369633926;\n\tTue, 22 Jun 2021 06:47:13 -0700 (PDT)", "From": "Andrey Konovalov <andrey.konovalov@linaro.org>", "To": "libcamera-devel@lists.libcamera.org,\n\tlaurent.pinchart@ideasonboard.com", "Date": "Tue, 22 Jun 2021 16:46:47 +0300", "Message-Id": "<20210622134652.1279260-5-andrey.konovalov@linaro.org>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20210622134652.1279260-1-andrey.konovalov@linaro.org>", "References": "<20210622134652.1279260-1-andrey.konovalov@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 4/9] qcam: viewfinder_gl: Copy the\n\tshaders for RAW8 Bayer format from motmot", "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>", "Cc": "morgan@casual-effects.com, Morgan McGuire <morgan3d@gmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Morgan McGuire <morgan3d@gmail.com>\n\nThis commit copies the shaders from:\n\nhttps://github.com/motmot/libcamiface/commit/e36d51580510c211afc0430141085eb7a77d811b\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/qcam/assets/shader/bayer_8.frag | 124 ++++++++++++++++++++++++++++\n src/qcam/assets/shader/bayer_8.vert | 70 ++++++++++++++++\n 2 files changed, 194 insertions(+)\n create mode 100644 src/qcam/assets/shader/bayer_8.frag\n create mode 100644 src/qcam/assets/shader/bayer_8.vert", "diff": "diff --git a/src/qcam/assets/shader/bayer_8.frag b/src/qcam/assets/shader/bayer_8.frag\nnew file mode 100644\nindex 00000000..707e76ed\n--- /dev/null\n+++ b/src/qcam/assets/shader/bayer_8.frag\n@@ -0,0 +1,124 @@\n+/*\n+From http://jgt.akpeters.com/papers/McGuire08/\n+\n+Efficient, High-Quality Bayer Demosaic Filtering on GPUs\n+\n+Morgan McGuire\n+\n+This paper appears in issue Volume 13, Number 4.\n+---------------------------------------------------------\n+Copyright (c) 2008, Morgan McGuire. All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are\n+met:\n+\n+ * Redistributions of source code must retain the above copyright\n+ notice, this list of conditions and the following disclaimer.\n+\n+ * Redistributions in binary form must reproduce the above\n+ copyright notice, this list of conditions and the following\n+ disclaimer in the documentation and/or other materials provided\n+ with the distribution.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+*/\n+\n+//Pixel Shader\n+\n+/** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n+uniform sampler2D source;\n+varying vec4 center;\n+varying vec4 yCoord;\n+varying vec4 xCoord;\n+\n+void main(void) {\n+ #define fetch(x, y) texture2D(source, vec2(x, y)).r\n+\n+ float C = texture2D(source, center.xy).r; // ( 0, 0)\n+ const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0;\n+\n+ // Determine which of four types of pixels we are on.\n+ vec2 alternate = mod(floor(center.zw), 2.0);\n+\n+ vec4 Dvec = vec4(\n+ fetch(xCoord[1], yCoord[1]), // (-1,-1)\n+ fetch(xCoord[1], yCoord[2]), // (-1, 1)\n+ fetch(xCoord[2], yCoord[1]), // ( 1,-1)\n+ fetch(xCoord[2], yCoord[2])); // ( 1, 1)\n+\n+ vec4 PATTERN = (kC.xyz * C).xyzz;\n+\n+ // Can also be a dot product with (1,1,1,1) on hardware where that is\n+ // specially optimized.\n+ // Equivalent to: D = Dvec[0] + Dvec[1] + Dvec[2] + Dvec[3];\n+ Dvec.xy += Dvec.zw;\n+ Dvec.x += Dvec.y;\n+\n+ vec4 value = vec4(\n+ fetch(center.x, yCoord[0]), // ( 0,-2)\n+ fetch(center.x, yCoord[1]), // ( 0,-1)\n+ fetch(xCoord[0], center.y), // (-1, 0)\n+ fetch(xCoord[1], center.y)); // (-2, 0)\n+\n+ vec4 temp = vec4(\n+ fetch(center.x, yCoord[3]), // ( 0, 2)\n+ fetch(center.x, yCoord[2]), // ( 0, 1)\n+ fetch(xCoord[3], center.y), // ( 2, 0)\n+ fetch(xCoord[2], center.y)); // ( 1, 0)\n+\n+ // Even the simplest compilers should be able to constant-fold these to\n+ // avoid the division.\n+ // Note that on scalar processors these constants force computation of some\n+ // identical products twice.\n+ const vec4 kA = vec4(-1.0, -1.5, 0.5, -1.0) / 8.0;\n+ const vec4 kB = vec4( 2.0, 0.0, 0.0, 4.0) / 8.0;\n+ const vec4 kD = vec4( 0.0, 2.0, -1.0, -1.0) / 8.0;\n+\n+ // Conserve constant registers and take advantage of free swizzle on load\n+ #define kE (kA.xywz)\n+ #define kF (kB.xywz)\n+\n+ value += temp;\n+\n+ // There are five filter patterns (identity, cross, checker,\n+ // theta, phi). Precompute the terms from all of them and then\n+ // use swizzles to assign to color channels.\n+ //\n+ // Channel Matches\n+ // x cross (e.g., EE G)\n+ // y checker (e.g., EE B)\n+ // z theta (e.g., EO R)\n+ // w phi (e.g., EO R)\n+ #define A (value[0])\n+ #define B (value[1])\n+ #define D (Dvec.x)\n+ #define E (value[2])\n+ #define F (value[3])\n+\n+ // Avoid zero elements. On a scalar processor this saves two MADDs\n+ // and it has no effect on a vector processor.\n+ PATTERN.yzw += (kD.yz * D).xyy;\n+\n+ PATTERN += (kA.xyz * A).xyzx + (kE.xyw * E).xyxz;\n+ PATTERN.xw += kB.xw * B;\n+ PATTERN.xz += kF.xz * F;\n+\n+ gl_FragColor.rgb = (alternate.y == 0.0) ?\n+ ((alternate.x == 0.0) ?\n+ vec3(C, PATTERN.xy) :\n+ vec3(PATTERN.z, C, PATTERN.w)) :\n+ ((alternate.x == 0.0) ?\n+ vec3(PATTERN.w, C, PATTERN.z) :\n+ vec3(PATTERN.yx, C));\n+}\ndiff --git a/src/qcam/assets/shader/bayer_8.vert b/src/qcam/assets/shader/bayer_8.vert\nnew file mode 100644\nindex 00000000..3354860f\n--- /dev/null\n+++ b/src/qcam/assets/shader/bayer_8.vert\n@@ -0,0 +1,70 @@\n+/*\n+From http://jgt.akpeters.com/papers/McGuire08/\n+\n+Efficient, High-Quality Bayer Demosaic Filtering on GPUs\n+\n+Morgan McGuire\n+\n+This paper appears in issue Volume 13, Number 4.\n+---------------------------------------------------------\n+Copyright (c) 2008, Morgan McGuire. All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are\n+met:\n+\n+ * Redistributions of source code must retain the above copyright\n+ notice, this list of conditions and the following disclaimer.\n+\n+ * Redistributions in binary form must reproduce the above\n+ copyright notice, this list of conditions and the following\n+ disclaimer in the documentation and/or other materials provided\n+ with the distribution.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+*/\n+\n+//Vertex Shader\n+\n+\n+/** (w,h,1/w,1/h) */\n+uniform vec4 sourceSize;\n+\n+/** Pixel position of the first red pixel in the */\n+/** Bayer pattern. [{0,1}, {0, 1}]*/\n+uniform vec2 firstRed;\n+\n+/** .xy = Pixel being sampled in the fragment shader on the range [0, 1]\n+ .zw = ...on the range [0, sourceSize], offset by firstRed */\n+varying vec4 center;\n+\n+/** center.x + (-2/w, -1/w, 1/w, 2/w); These are the x-positions */\n+/** of the adjacent pixels.*/\n+varying vec4 xCoord;\n+\n+/** center.y + (-2/h, -1/h, 1/h, 2/h); These are the y-positions */\n+/** of the adjacent pixels.*/\n+varying vec4 yCoord;\n+\n+void main(void) {\n+ center.xy = gl_MultiTexCoord0.xy;\n+ center.zw = gl_MultiTexCoord0.xy * sourceSize.xy + firstRed;\n+\n+ vec2 invSize = sourceSize.zw;\n+ xCoord = center.x + vec4(-2.0 * invSize.x,\n+ -invSize.x, invSize.x, 2.0 * invSize.x);\n+ yCoord = center.y + vec4(-2.0 * invSize.y,\n+ -invSize.y, invSize.y, 2.0 * invSize.y);\n+\n+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n+}\n", "prefixes": [ "libcamera-devel", "v5", "4/9" ] }