Patch Detail
Show a patch.
GET /api/patches/10801/?format=api
{ "id": 10801, "url": "https://patchwork.libcamera.org/api/patches/10801/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10801/", "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": "<20210101171553.32727-3-andrey.konovalov@linaro.org>", "date": "2021-01-01T17:15:53", "name": "[libcamera-devel,RFC,v2,2/2] qcam: viewfinder_gl: Add shader to render packed RAW12 formats", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b30be6801e89c3d928a7511b1b1f1ba850b5c8df", "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/10801/mbox/", "series": [ { "id": 1565, "url": "https://patchwork.libcamera.org/api/series/1565/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1565", "date": "2021-01-01T17:15:51", "name": "qcam: viewfinder_gl: add RAW12P format support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1565/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10801/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10801/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 EEF69C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 1 Jan 2021 17:16:27 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B846A615D2;\n\tFri, 1 Jan 2021 18:16:27 +0100 (CET)", "from mail-lf1-x134.google.com (mail-lf1-x134.google.com\n\t[IPv6:2a00:1450:4864:20::134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D7476031C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 1 Jan 2021 18:16:25 +0100 (CET)", "by mail-lf1-x134.google.com with SMTP id o13so49862371lfr.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 01 Jan 2021 09:16:25 -0800 (PST)", "from localhost.localdomain ([85.249.43.69])\n\tby smtp.googlemail.com with ESMTPSA id\n\tm12sm7873213lji.110.2021.01.01.09.16.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 01 Jan 2021 09:16:23 -0800 (PST)" ], "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=\"Dp6qHITx\"; 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\tbh=9IyTWCw2utGO0KRGIo3WDP0dk63K2gFAGl/Yab4UDtM=;\n\tb=Dp6qHITxEOw3j067VMliEfo/stR4OdrDYwQ4jP82Asco0HQA7qQibL/XQXkH6oQLQH\n\tI7CKqbsMALUAdHygArKq6+K9GK9iXT54Y2bqcBDKyAQQNyy49bwDSf5pCdcB5UnzGAmH\n\tkjZC9rBmpSFcI9fpY0VTbevuxVzzbOY0qi6A6ahWXXzPguHkyrsZdzFz7iFLWsbMTJgj\n\tF4VZ8qEcUACEKFK8jvDdNW2bLnkAtluORBqXRqkkbssZmbQQ2mEphQOy53eNtcbBixVt\n\t+dH2Gmz1GGk2Rr75kV6dxD9+y2fTY6Llxb4sL4eiwfHax5Zw2b2wcejK0fl1j+k5FrC8\n\tFSXw==", "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;\n\tbh=9IyTWCw2utGO0KRGIo3WDP0dk63K2gFAGl/Yab4UDtM=;\n\tb=QXZhm/Ga1n3RhZD5yI+wCVrqMpiYvmrTIYzFpKXEQqvwxbjspq6wy58M7zv7tC9dmy\n\ttCc4m0EzSJpUMjZIsiYSLVukPKM4SiqpPrVnep8KKbv6Z1hv5qipHmO0u2ovDYCNAw3d\n\tBYNFqXvhkjymh264CGzP7c2g28OW/w8pzjRGfKsJvRd1RJ/jD9ntytoge9uwuhJD6SDE\n\tI6Mf8FeiJpjCbn6mJXjZrl0rtcS2la2NBK2MEkKjmm6uGpi4h0O4QEEb5ys7IW8i3fRV\n\tvtMG1buLT0tbyjZeR6FLO8RqIeBoILystSvoKdkBo3hhXhd7FRpogY1QEi4JhBlYFHgJ\n\t/BEA==", "X-Gm-Message-State": "AOAM533eeDbTM6amqIFrmFZV26AF7zUJoM/1w/o2vSmHROsmh+1/UAtr\n\tEQz+nwqwaPl+goIwG6YyvMPzwzFiqu5G2/Pf", "X-Google-Smtp-Source": "ABdhPJyio7hslykYyuv08mWDFweA3kOZM6/1dIgzrcp3r3KINnJ6V+B5NnugomTAw55g0jiP594A7A==", "X-Received": "by 2002:a19:8985:: with SMTP id\n\tl127mr14216946lfd.617.1609521384506; \n\tFri, 01 Jan 2021 09:16:24 -0800 (PST)", "From": "Andrey Konovalov <andrey.konovalov@linaro.org>", "To": "libcamera-devel@lists.libcamera.org,\n\tlaurent.pinchart@ideasonboard.com", "Date": "Fri, 1 Jan 2021 20:15:53 +0300", "Message-Id": "<20210101171553.32727-3-andrey.konovalov@linaro.org>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20210101171553.32727-1-andrey.konovalov@linaro.org>", "References": "<20210101171553.32727-1-andrey.konovalov@linaro.org>", "Subject": "[libcamera-devel] [PATCH][RFC v2 2/2] qcam: viewfinder_gl: Add\n\tshader to render packed RAW12 formats", "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", "MIME-Version": "1.0", "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": "The shader supports all 4 packed RAW12 variants.\nSimple bi-linear filtering is implemented.\nThe 4 LS bits of the 12-bit colour values are dropped as the RGBA\nformat we convert into has only 8 bits per colour.\n\nThe texture coordinates passed to the fragment shader are ajusted\nto point to the nearest pixel in the image. This prevents artifacts\nwhen the image is scaled from the frame resolution to the window size.\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/qcam/assets/shader/bayer_12_packed.frag | 196 ++++++++++++++++++++\n src/qcam/assets/shader/shaders.qrc | 1 +\n src/qcam/viewfinder_gl.cpp | 72 ++++++-\n src/qcam/viewfinder_gl.h | 6 +\n 4 files changed, 273 insertions(+), 2 deletions(-)\n create mode 100644 src/qcam/assets/shader/bayer_12_packed.frag", "diff": "diff --git a/src/qcam/assets/shader/bayer_12_packed.frag b/src/qcam/assets/shader/bayer_12_packed.frag\nnew file mode 100644\nindex 00000000..9de7e802\n--- /dev/null\n+++ b/src/qcam/assets/shader/bayer_12_packed.frag\n@@ -0,0 +1,196 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Based on the code 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+ *\n+ * Modified by Linaro Ltd for 12-bit packed vs 8-bit raw Bayer format,\n+ * and for simpler demosaic algorithm.\n+ * Copyright (C) 2020, Linaro\n+ *\n+ * bayer_12_packed.frag - Fragment shader code for raw Bayer 12-bit packed\n+ * format\n+ */\n+\n+#ifdef GL_ES\n+precision mediump float;\n+#endif\n+\n+varying vec2 textureOut;\n+\n+uniform vec2 tex_size;\n+uniform vec2 tex_step;\n+uniform vec2 tex_bayer_first_red;\n+\n+uniform sampler2D tex_raw;\n+\n+void main(void)\n+{\n+\tvec3 rgb;\n+\n+\t/*\n+\t * center holds the coordinates of the pixel being sampled.\n+\t * center.xy are on the [0, 1] range,\n+\t * center.zw are in pixels: [0, frame width - 1] and\n+\t * [0, frame height - 1] respectively.\n+\t */\n+\tvec4 center;\n+\t/*\n+\t * x-positions of the adjacent pixels on the [0, 1] range.\n+\t */\n+\tvec2 xcoords;\n+\t/*\n+\t * y-positions of the adjacent pixels on the [0, 1] range.\n+\t */\n+\tvec2 ycoords;\n+\n+\t/*\n+\t * The coordinates passed to the shader in textureOut may point\n+\t * to a place in between the pixels if the viewfinder window is scaled\n+\t * from the original captured frame size. Align them to the nearest\n+\t * texel (center.xy) and pixel (center.zw).\n+\t */\n+\tcenter.xy = textureOut * tex_size;\t/* [0, texture size) */\n+\tcenter.z = floor(center.x * 2.0);\n+\tcenter.xy = floor(center.xy);\n+\tcenter.w = center.y;\n+\tcenter.xy *= tex_step;\t/* on the [0, 1] range */\n+\n+\tvec2 alternate = mod(center.zw + tex_bayer_first_red, 2.0);\n+\tbool even_col = alternate.x < 1.0;\n+\tbool even_raw = alternate.y < 1.0;\n+\n+\txcoords = center.x + vec2(-tex_step.x, tex_step.x);\n+\tycoords = center.y + vec2(-tex_step.y, tex_step.y);\n+\n+\t/*\n+\t * We need to sample the central pixel and the ones with offset\n+\t * of -1 to +1 pixel in both X and Y directions. Let's name these\n+\t * pixels as below, where C is the central pixel:\n+\t * +----+----+----+----+\n+\t * | \\ x| | | |\n+\t * |y \\ | -1 | 0 | +1 | \n+\t * +----+----+----+----+\n+\t * | +1 | D2 | A1 | D3 |\n+\t * +----+----+----+----+\n+\t * | 0 | B0 | C | B1 |\n+\t * +----+----+----+----+\n+\t * | -1 | D0 | A0 | D1 |\n+\t * +----+----+----+----+\n+\t * As we use RGB texture, and take only 8 MS bits of every pixel value,\n+\t * the blue component is never used.\n+\t * In the below equations (0,-1).r means \"r component of the texel\n+\t * shifted by -tex_step.y from the center.xy one\" etc.\n+\t * In the even raw / even column (EE) case the colour values are:\n+\t * R = C = (0,0).r,\n+\t * G = (A0 + A1 + B0 + B1) / 4.0 =\n+\t * ( (0,-1).r + (0,1).r + (-1,0).g + (0,0).g ) / 4.0,\n+\t * B = (D0 + D1 + D2 + D3) / 4.0 =\n+\t * ( (-1,-1).g + (0,-1).g + (-1,1).g + (0,1).g ) / 4.0\n+\t * For even raw / odd column (EO):\n+\t * R = (B0 + B1) / 2.0 = ( (0,0).r + (1,0).r ) / 2.0,\n+\t * G = C = (0,0).g,\n+\t * B = (A0 + A1) / 2.0 = ( (0,-1).g + (0,1).g ) / 2.0\n+\t * For odd raw / even column (OE):\n+\t * R = (A0 + A1) / 2.0 = ( (0,-1).r + (0,1).r ) / 2.0,\n+\t * G = C = (0,0).r,\n+\t * B = (B0 + B1) / 2.0 = ( (-1,0).g + (0,0).g ) / 2.0\n+\t * For odd raw / odd column (OO):\n+\t * R = (D0 + D1 + D2 + D3) / 4.0 =\n+\t * ( (0,-1).r + (1,-1).r + (0,1).r + (1,1).r ) / 4.0,\n+\t * G = (A0 + A1 + B0 + B1) / 4.0 =\n+\t * ( (0,-1).g + (0,1).g + (0,0).r + (1,0).r ) / 4.0,\n+\t * B = C = (0,0).g\n+\t */\n+\n+\t/* Fetch all the values we might need */\n+\n+\t/* .xy = (0,-1).rg, zw = (0, 1).rg - all Ax, and some of Dx values */\n+\tvec4 vals_AD = vec4(\n+\t\ttexture2D(tex_raw, vec2(center.x, ycoords[0])).rg,\n+\t\ttexture2D(tex_raw, vec2(center.x, ycoords[1])).rg);\n+\t/*\n+\t * .xy = (0,0).rg, .z = (-1,0).g, .w = (1,0).r\n+\t * - all Bx and C, some of Dx values\n+\t */\n+\tvec4 vals_BCD = vec4(\n+\t\ttexture2D(tex_raw, center.xy).rg,\n+\t\ttexture2D(tex_raw, vec2(xcoords[0], center.y)).g,\n+\t\ttexture2D(tex_raw, vec2(xcoords[1], center.y)).r);\n+\t/*\n+\t * .x = (-1,-1).g, .y = (-1,1).g, .z = (1,-1).r, .w = (1,1).r\n+\t * - the remaining Dx values\n+\t */\n+\tvec4 vals_D = vec4(\n+\t\ttexture2D(tex_raw, vec2(xcoords[0], ycoords[0])).g,\n+\t\ttexture2D(tex_raw, vec2(xcoords[0], ycoords[1])).g,\n+\t\ttexture2D(tex_raw, vec2(xcoords[1], ycoords[0])).r,\n+\t\ttexture2D(tex_raw, vec2(xcoords[1], ycoords[1])).r);\n+\n+\t/*\n+\t * Let:\n+\t * E = ( (0,-1).r + (0, 1).r ) / 2.0\n+\t * F = ( (0,-1).g + (0, 1).g ) / 2.0\n+\t * G = ( (0,0).g + (-1,0).g ) / 2.0\n+\t * H = ( (0,0).r + (1,0).r ) / 2.0\n+\t * J = ( (-1,-1).g + (-1,1).g ) / 2.0\n+\t * K = ( (1,-1).r + (1,1).r ) / 2.0\n+\t * Then:\n+\t * Even raw, even column case (EE):\n+\t * Red = (0,0).r,\n+\t * Green = (E + G) / 2.0,\n+\t * Blue = (F + J) / 2.0\n+\t * EO:\n+\t * Red = H,\n+\t * Green = (0,0).g,\n+\t * Blue = F\n+\t * OE:\n+\t * Red = E,\n+\t * Green = (0,0).r,\n+\t * Blue = G\n+\t * OO:\n+\t * R = (E + K) / 2.0,\n+\t * G = (F + H ) / 2.0,\n+\t * B = (0,0).g\n+\t * Then if we let:\n+\t * L = (E + G) / 2.0\n+\t * M = (F + H) / 2.0\n+\t * and modify J and K like this:\n+\t * J = (F + J) / 2.0\n+\t * K = (E + K) / 2.0\n+\t * the Red/Green/Blue output values can be obtained from EFGH and JKLM\n+\t * with swizzles thus eliminating the branches.\n+\t */\n+\n+\tvec4 EFGH = vec4(\n+\t\tvals_AD.x + vals_AD.z,\n+\t\tvals_AD.y + vals_AD.w,\n+\t\tvals_BCD.y + vals_BCD.z,\n+\t\tvals_BCD.x + vals_BCD.w\n+\t\t) / 2.0;\n+\tvec4 JKLM = vec4(\n+\t\tvals_D.x + vals_D.y,\n+\t\tvals_D.z + vals_D.w,\n+\t\tEFGH.x + EFGH.z,\t/* E + G */\n+\t\tEFGH.y + EFGH.w\t\t/* F + H */\n+\t\t) / 2.0;\n+\n+\tJKLM.xy = (JKLM.xy + EFGH.yx) / 2.0;\n+\n+\trgb = (even_col) ?\n+\t\t((even_raw) ?\n+\t\t\tvec3(vals_BCD.x, JKLM.z, JKLM.x) :\n+\t\t\tvec3(EFGH.x, vals_BCD.x, EFGH.z)) :\n+\t\t((even_raw) ?\n+\t\t\tvec3(EFGH.w, vals_BCD.y, EFGH.y) :\n+\t\t\tvec3(JKLM.y, JKLM.w, vals_BCD.y));\n+\n+\tgl_FragColor = vec4(rgb, 1.0);\n+}\ndiff --git a/src/qcam/assets/shader/shaders.qrc b/src/qcam/assets/shader/shaders.qrc\nindex 8a8f9de1..2650e0e3 100644\n--- a/src/qcam/assets/shader/shaders.qrc\n+++ b/src/qcam/assets/shader/shaders.qrc\n@@ -5,6 +5,7 @@\n \t<file>YUV_2_planes.frag</file>\n \t<file>YUV_3_planes.frag</file>\n \t<file>YUV_packed.frag</file>\n+\t<file>bayer_12_packed.frag</file>\n \t<file>identity.vert</file>\n </qresource>\n </RCC>\ndiff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex ff719418..89e70730 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -36,6 +36,11 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n \tlibcamera::formats::RGBA8888,\n \tlibcamera::formats::BGR888,\n \tlibcamera::formats::RGB888,\n+\t/* Raw Bayer 12-bit packed */\n+\tlibcamera::formats::SBGGR12_CSI2P,\n+\tlibcamera::formats::SGBRG12_CSI2P,\n+\tlibcamera::formats::SGRBG12_CSI2P,\n+\tlibcamera::formats::SRGGB12_CSI2P,\n };\n \n ViewFinderGL::ViewFinderGL(QWidget *parent)\n@@ -114,6 +119,9 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)\n {\n \tbool ret = true;\n \n+\t/* Set min/mag filters to GL_LINEAR by default. */\n+\ttextureMinMagFilters_ = GL_LINEAR;\n+\n \tfragmentShaderDefines_.clear();\n \n \tswitch (format) {\n@@ -203,6 +211,30 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)\n \t\tfragmentShaderDefines_.append(\"#define RGB_PATTERN bgr\");\n \t\tfragmentShaderFile_ = \":RGB.frag\";\n \t\tbreak;\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\t\tfirstRed_.setX(1.0);\n+\t\tfirstRed_.setY(1.0);\n+\t\tfragmentShaderFile_ = \":bayer_12_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\t\tfirstRed_.setX(0.0);\n+\t\tfirstRed_.setY(1.0);\n+\t\tfragmentShaderFile_ = \":bayer_12_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\t\tfirstRed_.setX(1.0);\n+\t\tfirstRed_.setY(0.0);\n+\t\tfragmentShaderFile_ = \":bayer_12_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tfirstRed_.setX(0.0);\n+\t\tfirstRed_.setY(0.0);\n+\t\tfragmentShaderFile_ = \":bayer_12_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n \tdefault:\n \t\tret = false;\n \t\tqWarning() << \"[ViewFinderGL]:\"\n@@ -290,6 +322,8 @@ bool ViewFinderGL::createFragmentShader()\n \ttextureUniformU_ = shaderProgram_.uniformLocation(\"tex_u\");\n \ttextureUniformV_ = shaderProgram_.uniformLocation(\"tex_v\");\n \ttextureUniformStep_ = shaderProgram_.uniformLocation(\"tex_step\");\n+\ttextureUniformSize_ = shaderProgram_.uniformLocation(\"tex_size\");\n+\ttextureUniformBayerFirstRed_ = shaderProgram_.uniformLocation(\"tex_bayer_first_red\");\n \n \t/* Create the textures. */\n \tfor (std::unique_ptr<QOpenGLTexture> &texture : textures_) {\n@@ -306,8 +340,10 @@ bool ViewFinderGL::createFragmentShader()\n void ViewFinderGL::configureTexture(QOpenGLTexture &texture)\n {\n \tglBindTexture(GL_TEXTURE_2D, texture.textureId());\n-\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n-\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n+\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,\n+\t\t\ttextureMinMagFilters_);\n+\tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,\n+\t\t\ttextureMinMagFilters_);\n \tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n \tglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n }\n@@ -547,6 +583,38 @@ void ViewFinderGL::doRender()\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \t\tbreak;\n \n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\t/*\n+\t\t * Packed raw Bayer 12-bit formats are stored in RGB texture\n+\t\t * to match the OpenGL texel size with the 3 bytes repeating\n+\t\t * pattern in RAW12P.\n+\t\t * The texture width is thus half of the image with.\n+\t\t */\n+\t\tglActiveTexture(GL_TEXTURE0);\n+\t\tconfigureTexture(*textures_[0]);\n+\t\tglTexImage2D(GL_TEXTURE_2D,\n+\t\t\t 0,\n+\t\t\t GL_RGB,\n+\t\t\t size_.width() / 2,\n+\t\t\t size_.height(),\n+\t\t\t 0,\n+\t\t\t GL_RGB,\n+\t\t\t GL_UNSIGNED_BYTE,\n+\t\t\t data_);\n+\t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n+\t\tshaderProgram_.setUniformValue(textureUniformBayerFirstRed_,\n+\t\t\t\t\t firstRed_);\n+\t\tshaderProgram_.setUniformValue(textureUniformSize_,\n+\t\t\t\t\t size_.width() / 2,\n+\t\t\t\t\t size_.height());\n+\t\tshaderProgram_.setUniformValue(textureUniformStep_,\n+\t\t\t\t\t 1.0f / (size_.width() / 2 - 1),\n+\t\t\t\t\t 1.0f / (size_.height() - 1));\n+\t\tbreak;\n+\n \tdefault:\n \t\tbreak;\n \t};\ndiff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\nindex 1b1faa91..337718e3 100644\n--- a/src/qcam/viewfinder_gl.h\n+++ b/src/qcam/viewfinder_gl.h\n@@ -81,13 +81,19 @@ private:\n \t/* Textures */\n \tstd::array<std::unique_ptr<QOpenGLTexture>, 3> textures_;\n \n+\t/* Common texture parameters */\n+\tGLuint textureMinMagFilters_;\n \t/* YUV texture parameters */\n \tGLuint textureUniformU_;\n \tGLuint textureUniformV_;\n \tGLuint textureUniformY_;\n+\tGLuint textureUniformSize_;\n \tGLuint textureUniformStep_;\n \tunsigned int horzSubSample_;\n \tunsigned int vertSubSample_;\n+\t/* Raw Bayer texture parameters */\n+\tGLuint textureUniformBayerFirstRed_;\n+\tQPointF firstRed_;\n \n \tQMutex mutex_; /* Prevent concurrent access to image_ */\n };\n", "prefixes": [ "libcamera-devel", "RFC", "v2", "2/2" ] }