From patchwork Sun Aug 14 16:07:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17116 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 D3F7DC3272 for ; Sun, 14 Aug 2022 16:08:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 24D0B61FC1; Sun, 14 Aug 2022 18:08:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493291; bh=CFCCm3qhsYlV/cSMq0SuqhAn9aXHQPSameYXDa/7Guk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fTzog0ciAyB8GsjO/bAwQt4e0BiVqDSKoJaMr1QuLmzxoAB2Cl1+Wc0qfAd53iCwC nDyn9vQ/EoG7BRTQHz6ikc0ojWKbJdgyvFMZu6fv1HGZREOXXLQCvn6n/CPrSlqCaS 447GVgmyK97yNDFtU/raRUw6E0FLWNUoEVrcZ8H3Qanr2nLk0ribt9Xf0aqd9NF0Vt wQr6I8dv0LSswNwnmzEfXu9bBJc0409v3/AsdeiKEJpaGC1kqT4pjsetJKpr9vnGrv kshNwdRKmovvbIJV/pF3oFhDGAHwXgMyokcxZpsAOjvUX3MQpLeOANx9YNbkzFyM90 6hkZvblriL5Eg== Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E26F361FBA for ; Sun, 14 Aug 2022 18:08:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eScTQl+w"; dkim-atps=neutral Received: by mail-pj1-x1034.google.com with SMTP id w11-20020a17090a380b00b001f73f75a1feso12545050pjb.2 for ; Sun, 14 Aug 2022 09:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=Mv2/OGgWITkybWi8yKAUa6aKvJhjxQYpPZCXqcbgkr0=; b=eScTQl+wmZU+rKw5uN/VVhMtZhdq8HZ6yeSR+fksErP7NXZw504IUzBiqSdmphH/W/ r2Bvbrdf6undZNg4dyvQuCkcRdsprdi3EMq5n3VWg2t2pjtp8hda8qMDjIwyh3M0Clt7 gIY5rSvHwtCtkZoiT6ECBVHqaYHy6ie9qdjwdW4I6FZfQ/qn+FVRXv9HYu+bJmA6jW8A Oc3N/9cE623DnL/+Ij69Yfvq061WXykSRq8ouLNuIg0b5rqwq6Np0UqmHnXliOKyezOh ZM///cXiIIc7Mf61JQI2N0mK738AJf6FfsRu6IvwSxsGegxRB2jhJs2sUrnEWDwHe1SJ nVTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=Mv2/OGgWITkybWi8yKAUa6aKvJhjxQYpPZCXqcbgkr0=; b=WgbHy+IXBYWVuxmtPaqTdPgCa9TaNNwDdKfl4ukHSWGIaajVEIem9tAzDaFxJmnxVk L8uSL67iQXp81izViRPQy6XrLZHHXEjs8tPYl8SlGkccHNKHAO0Ke9gaZ1Kl7zQ/bG1i UU9Q+YXXTVD+ehSZvOG5iB4ohjOFHky+CTV68z7diNrj4M1Y1Rw4H8mq0EJdFgSs4rGy sWjzdgU35hm9/YgwZQHOHNOPDnWpGsOTck45AlYSWAjDTMG3lUAhWPPfbfMdmsQwsM4r dJtYF4xADrgUQJE064USIJVtvTSbM8s9OdiRTykTFxOpmvtT3p/GKHgDIUvUj2fRafm5 qiCA== X-Gm-Message-State: ACgBeo2oHsKN0dZZgzuYeueE9u75BgOIkogWtFvJoEXyI0vb9AomfgxT HUgHZpxqAyvIvrsf9c+sfawyzumwjsE= X-Google-Smtp-Source: AA6agR7P4Fzas4Gqq8cKMB8swQyW0DGru32OGlG/tRU0ooyoQjuIfc6peaKGrUL1edZ4Z1W9oWKb7g== X-Received: by 2002:a17:902:820d:b0:16e:c853:ddd1 with SMTP id x13-20020a170902820d00b0016ec853ddd1mr13097273pln.31.1660493287725; Sun, 14 Aug 2022 09:08:07 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:08:07 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:42 +0530 Message-Id: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/6] pipeline: simple: shader: Shaders for debayering 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Default and Bayer shaders which performs debayering on raw input data Signed-off-by: Kunal Agarwal --- .../pipeline/simple/shader/bayer_8.frag | 107 ++++++++++++++++++ .../pipeline/simple/shader/bayer_8.vert | 51 +++++++++ .../pipeline/simple/shader/default.frag | 16 +++ .../pipeline/simple/shader/default.vert | 23 ++++ 4 files changed, 197 insertions(+) create mode 100644 src/libcamera/pipeline/simple/shader/bayer_8.frag create mode 100644 src/libcamera/pipeline/simple/shader/bayer_8.vert create mode 100644 src/libcamera/pipeline/simple/shader/default.frag create mode 100644 src/libcamera/pipeline/simple/shader/default.vert diff --git a/src/libcamera/pipeline/simple/shader/bayer_8.frag b/src/libcamera/pipeline/simple/shader/bayer_8.frag new file mode 100644 index 00000000..7e35ca88 --- /dev/null +++ b/src/libcamera/pipeline/simple/shader/bayer_8.frag @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* +From http://jgt.akpeters.com/papers/McGuire08/ + +Efficient, High-Quality Bayer Demosaic Filtering on GPUs + +Morgan McGuire + +This paper appears in issue Volume 13, Number 4. +--------------------------------------------------------- +Copyright (c) 2008, Morgan McGuire. All rights reserved. + +Modified by Linaro Ltd to integrate it into libcamera. +Copyright (C) 2021, Linaro +*/ + +//Pixel Shader +#ifdef GL_ES +precision mediump float; +#endif + +/** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/ +uniform sampler2D tex_y; +varying vec4 center; +varying vec4 yCoord; +varying vec4 xCoord; + +void main(void) { + #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r + + float C = texture2D(tex_y, center.xy).r; // ( 0, 0) + const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0; + + // Determine which of four types of pixels we are on. + vec2 alternate = mod(floor(center.zw), 2.0); + + vec4 Dvec = vec4( + fetch(xCoord[1], yCoord[1]), // (-1,-1) + fetch(xCoord[1], yCoord[2]), // (-1, 1) + fetch(xCoord[2], yCoord[1]), // ( 1,-1) + fetch(xCoord[2], yCoord[2])); // ( 1, 1) + + vec4 PATTERN = (kC.xyz * C).xyzz; + + // Can also be a dot product with (1,1,1,1) on hardware where that is + // specially optimized. + // Equivalent to: D = Dvec[0] + Dvec[1] + Dvec[2] + Dvec[3]; + Dvec.xy += Dvec.zw; + Dvec.x += Dvec.y; + + vec4 value = vec4( + fetch(center.x, yCoord[0]), // ( 0,-2) + fetch(center.x, yCoord[1]), // ( 0,-1) + fetch(xCoord[0], center.y), // (-2, 0) + fetch(xCoord[1], center.y)); // (-1, 0) + + vec4 temp = vec4( + fetch(center.x, yCoord[3]), // ( 0, 2) + fetch(center.x, yCoord[2]), // ( 0, 1) + fetch(xCoord[3], center.y), // ( 2, 0) + fetch(xCoord[2], center.y)); // ( 1, 0) + + // Even the simplest compilers should be able to constant-fold these to + // avoid the division. + // Note that on scalar processors these constants force computation of some + // identical products twice. + const vec4 kA = vec4(-1.0, -1.5, 0.5, -1.0) / 8.0; + const vec4 kB = vec4( 2.0, 0.0, 0.0, 4.0) / 8.0; + const vec4 kD = vec4( 0.0, 2.0, -1.0, -1.0) / 8.0; + + // Conserve constant registers and take advantage of free swizzle on load + #define kE (kA.xywz) + #define kF (kB.xywz) + + value += temp; + + // There are five filter patterns (identity, cross, checker, + // theta, phi). Precompute the terms from all of them and then + // use swizzles to assign to color channels. + // + // Channel Matches + // x cross (e.g., EE G) + // y checker (e.g., EE B) + // z theta (e.g., EO R) + // w phi (e.g., EO R) + #define A (value[0]) + #define B (value[1]) + #define D (Dvec.x) + #define E (value[2]) + #define F (value[3]) + + // Avoid zero elements. On a scalar processor this saves two MADDs + // and it has no effect on a vector processor. + PATTERN.yzw += (kD.yz * D).xyy; + + PATTERN += (kA.xyz * A).xyzx + (kE.xyw * E).xyxz; + PATTERN.xw += kB.xw * B; + PATTERN.xz += kF.xz * F; + + gl_FragColor.rgb = (alternate.y == 0.0) ? + ((alternate.x == 0.0) ? + vec3(C, PATTERN.xy) : + vec3(PATTERN.z, C, PATTERN.w)) : + ((alternate.x == 0.0) ? + vec3(PATTERN.w, C, PATTERN.z) : + vec3(PATTERN.yx, C)); +} diff --git a/src/libcamera/pipeline/simple/shader/bayer_8.vert b/src/libcamera/pipeline/simple/shader/bayer_8.vert new file mode 100644 index 00000000..3695a5e9 --- /dev/null +++ b/src/libcamera/pipeline/simple/shader/bayer_8.vert @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* +From http://jgt.akpeters.com/papers/McGuire08/ + +Efficient, High-Quality Bayer Demosaic Filtering on GPUs + +Morgan McGuire + +This paper appears in issue Volume 13, Number 4. +--------------------------------------------------------- +Copyright (c) 2008, Morgan McGuire. All rights reserved. + +Modified by Linaro Ltd to integrate it into libcamera. +Copyright (C) 2021, Linaro +*/ + +//Vertex Shader + +attribute vec4 vertexIn; +attribute vec2 textureIn; + +uniform vec2 tex_size; /* The texture size in pixels */ +uniform vec2 tex_step; + +/** Pixel position of the first red pixel in the */ +/** Bayer pattern. [{0,1}, {0, 1}]*/ +uniform vec2 tex_bayer_first_red; + +/** .xy = Pixel being sampled in the fragment shader on the range [0, 1] + .zw = ...on the range [0, sourceSize], offset by firstRed */ +varying vec4 center; + +/** center.x + (-2/w, -1/w, 1/w, 2/w); These are the x-positions */ +/** of the adjacent pixels.*/ +varying vec4 xCoord; + +/** center.y + (-2/h, -1/h, 1/h, 2/h); These are the y-positions */ +/** of the adjacent pixels.*/ +varying vec4 yCoord; + +void main(void) { + center.xy = textureIn; + center.zw = textureIn * tex_size + tex_bayer_first_red; + + xCoord = center.x + vec4(-2.0 * tex_step.x, + -tex_step.x, tex_step.x, 2.0 * tex_step.x); + yCoord = center.y + vec4(-2.0 * tex_step.y, + -tex_step.y, tex_step.y, 2.0 * tex_step.y); + + gl_Position = vertexIn; +} diff --git a/src/libcamera/pipeline/simple/shader/default.frag b/src/libcamera/pipeline/simple/shader/default.frag new file mode 100644 index 00000000..5899f8fc --- /dev/null +++ b/src/libcamera/pipeline/simple/shader/default.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; +// Outputs colors in RGBA +out vec4 FragColor; + +//Inputs color from the Vertex Shader +in vec3 color; +// Inputs the texture coordinates from the Vertex Shader +in vec2 texCoord; + +uniform sampler2D tex0; + +void main() +{ + FragColor = texture(tex0,texCoord); +} diff --git a/src/libcamera/pipeline/simple/shader/default.vert b/src/libcamera/pipeline/simple/shader/default.vert new file mode 100644 index 00000000..1a24284b --- /dev/null +++ b/src/libcamera/pipeline/simple/shader/default.vert @@ -0,0 +1,23 @@ +#version 310 es +precision mediump float; +//Positions/Coordinates +layout (location = 0) in vec3 aPos; +//Colors +layout (location = 1) in vec3 aColor; +// Texture Coordinates +layout (location = 2) in vec2 aTex; + +//Outputs the color for the Fragment Shader +out vec3 color; +// Outputs the texture coordinates to the fragment shader +out vec2 texCoord; + + +void main() +{ + gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); + //Assigns the color from the vertex Data to "color" + color = aColor; + // Assigns the texture coordinates from the Vertex Data to "texCoord" + texCoord = aTex; +} \ No newline at end of file From patchwork Sun Aug 14 16:07:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17117 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 39AE4C3272 for ; Sun, 14 Aug 2022 16:08:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 050F161FBA; Sun, 14 Aug 2022 18:08:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493332; bh=cn5cxbSO9TKRTz95mqMJUItKo7xk7Pgzu8KIow2cAJU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FSOZVADeoMrCTz1uaKOg0VCZJ16UEueZ/WTjT4Z2git4PH2wLFStb8LidGYnct48n AhuKzNLG1H2d9hS0ViV2WTgzCQtY95SHCaPz976y6nmXtmykd+IN1iBaO9FODoq+0U vt3hQomMQhNLEGQvbJffMB1kVHx7xkYAn6Sv6oGtQ/FHjgYxJ5PZ3liGKDo/2ubB5U Hy/rxYPZtWIR3K07PwjWVxkM/jBdd4+upbmg4neOAGotogMir9c38D0pd5ta0soGVg 3oU13K/M5HM99Map3QNohHkHLdSqVlKhinNhY+WuOncn4tP55dWYX9neM/JdNrb5W6 NOSd8f9xROuMw== Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BA28761FBA for ; Sun, 14 Aug 2022 18:08:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R1BMq26o"; dkim-atps=neutral Received: by mail-pl1-x62d.google.com with SMTP id p18so4583541plr.8 for ; Sun, 14 Aug 2022 09:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vK8jRGiVpF4kQwMqlfQbjrWhJfA8FqWvwjpfSDafvp4=; b=R1BMq26okBNtAWsSyv04RqlGeD5hCdhgZ6YAe/gHuEHPDPQRpejWQQUqhp0tqbq53M RpZKJpr+yOMaYYmSD2FLoCnVy9rPy/nwkK5QT8Ca2n3w8B9DQZc23iR0HAJ+Zsof6aP1 6345GjXsNpUipU7lcUPopeJdzhvKutUx1rslHe1jS19cr7d1KNYQnfHriVOVQnGcKNeg s2IYIF5B26NPmg3J5Sgt+tKgJ90TMRjq3mNSB/9MXsl5uYIR+0KhclUCoKR8r8SMaiCB tgKofmb3cav58I70yuNMkf1sf3LHcpa4V9yojqFgpA903XXboTntwrONNcuts5qJNjKI qbBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vK8jRGiVpF4kQwMqlfQbjrWhJfA8FqWvwjpfSDafvp4=; b=XOrxL/YRnIhBQtcDtDKshMSqOY15uJ+wDB4ddhQSpjgQVgot4qu0VJQMf/65MbB3hl rEkicJrrvdzwbRxEOJrxVPAYSTJLhaNDSMSqHD3t8vt83fSsniE4mVlc+56SfuNDbzdS XhaWN+tYFxFSDu1KyIK8Ua1MYEG+lFUqFg02oxwNbmPy57UGmRE+vXVvB5GMBlfNMARh 5ABMln47Ri30c9rNpkog4RpSzv6qGMsmdWVYN/9DTjN70FIhlr8MObm+9mnD7+1geoLo NsdabqhO4dSihUSF1SIMo8+b9Tj7dA4NO7u5pjGRwxFAOzogstS/2lGxmWavGIcP0e9w taNg== X-Gm-Message-State: ACgBeo3i8h6S/EITWnYm7bMnkE66bvR6o6GLhy9kAqVR3LjjxEeQVMUF Bb5lNM2muqtARfj3W1rkB93G4LM68A8= X-Google-Smtp-Source: AA6agR7mIHt8BYXc+FBs7NETfUeH9thK3i3dIcfoVXpGFnho0ganRfwcM8bFnYi6GVNuiATR83Jdkg== X-Received: by 2002:a17:90a:e2cc:b0:1f3:1151:e0ff with SMTP id fr12-20020a17090ae2cc00b001f31151e0ffmr14582275pjb.50.1660493329069; Sun, 14 Aug 2022 09:08:49 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:08:48 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:43 +0530 Message-Id: <20220814160747.52093-2-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> References: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/6] pipeline: simple: Implements Shader Handling 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Shader Class which includes functions for building, activating, deleting and compiling shaders Signed-off-by: Kunal Agarwal --- src/libcamera/pipeline/simple/shader.cpp | 110 +++++++++++++++++++++++ src/libcamera/pipeline/simple/shader.h | 34 +++++++ 2 files changed, 144 insertions(+) create mode 100644 src/libcamera/pipeline/simple/shader.cpp create mode 100644 src/libcamera/pipeline/simple/shader.h diff --git a/src/libcamera/pipeline/simple/shader.cpp b/src/libcamera/pipeline/simple/shader.cpp new file mode 100644 index 00000000..f0079618 --- /dev/null +++ b/src/libcamera/pipeline/simple/shader.cpp @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * shader.cpp - Shader Handling + */ + +#include "shader.h" + +#include +#include + +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(SimplePipeline) + +/* Reads a text file and outputs a string with everything in the text file */ +static std::string get_file_contents(const char *filename) +{ + std::string fullname = std::string("/home/pi/Desktop/compile/libcamera/src/libcamera/pipeline/simple/shader/") + filename; + + File file(fullname); + if (!file.open(File::OpenModeFlag::ReadOnly)) + return ""; + + Span data = file.map(); + return std::string(reinterpret_cast(data.data()), data.size()); +} + +/* Constructor that build the Shader Program from 2 different shaders */ +void ShaderProgram::callShader(const char *vertexFile, const char *fragmentFile) +{ + /* Read vertexFile and fragmentFile and store the strings */ + std::string vertexCode = get_file_contents(vertexFile); + std::string fragmentCode = get_file_contents(fragmentFile); + const char *vertexSource = vertexCode.c_str(); + const char *fragmentSource = fragmentCode.c_str(); + + /* Create the vertex shader, set its source code and compile it. */ + GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertexShader, 1, &vertexSource, NULL); + glCompileShader(vertexShader); + compileErrors(vertexShader, "VERTEX"); + + /* Create the fragment shader, set its source code and compile it. */ + GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragmentShader, 1, &fragmentSource, NULL); + glCompileShader(fragmentShader); + compileErrors(fragmentShader, "FRAGMENT"); + + /* Create Shader Program Object and get its reference */ + id_ = glCreateProgram(); + + /* Attach and wrap-up/link the Vertex and Fragment Shaders to the Shader Program */ + glAttachShader(id_, vertexShader); + glAttachShader(id_, fragmentShader); + glLinkProgram(id_); + + /* Checks if Shaders linked succesfully */ + compileErrors(id_, "PROGRAM"); + + /* Delete the Vertex and Fragment Shader objects. Here, they are flagged for deletion + and will not be deleted until they are detached from the program object. This frees + up the memory used to store the shader source. */ + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); +} + +/* Activates the Shader Program */ +void ShaderProgram::activate() +{ + glUseProgram(id_); +} + +/* Deletes the Shader Program */ +void ShaderProgram::deleteProgram() +{ + glDeleteProgram(id_); +} + +/* Checks if the different Shaders have compiled properly */ +void ShaderProgram::compileErrors(unsigned int shader, const char *type) +{ + /* Stores status of compilation */ + GLint hasCompiled; + GLint logLength; + /* Character array to store error message in */ + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); + char *infoLog = new char[logLength]; + if (strcmp(type, "PROGRAM") != 0) { + glGetShaderiv(shader, GL_COMPILE_STATUS, &hasCompiled); + if (hasCompiled == GL_FALSE) { + glGetShaderInfoLog(shader, logLength, NULL, infoLog); + LOG(SimplePipeline, Error) << "SHADER_COMPILATION_ERROR for:" + << type << "\t" + << infoLog; + } + } else { + glGetProgramiv(shader, GL_LINK_STATUS, &hasCompiled); + if (hasCompiled == GL_FALSE) { + glGetProgramInfoLog(shader, logLength, NULL, infoLog); + LOG(SimplePipeline, Error) << "SHADER_LINKING_ERROR for:" + << type << "\t" + << infoLog; + } + } +} +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/simple/shader.h b/src/libcamera/pipeline/simple/shader.h new file mode 100644 index 00000000..921e4040 --- /dev/null +++ b/src/libcamera/pipeline/simple/shader.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * shader.h - Shader Handling + */ + +#pragma once + +#include +#include + +#include + +namespace libcamera { + +class ShaderProgram +{ +public: + void callShader(const char *vertexFile, const char *fragmentFile); + + void activate(); + + void deleteProgram(); + + int id() const { return id_; }; + +private: + /* Reference ID of the Shader Program */ + GLuint id_; + void compileErrors(unsigned int shader, const char *type); +}; + +} /* namespace libcamera */ From patchwork Sun Aug 14 16:07:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17118 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 BCA9BC3272 for ; Sun, 14 Aug 2022 16:08:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85CFE61FC0; Sun, 14 Aug 2022 18:08:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493336; bh=r2idUaRfzEcTQdxg1Ff5xpPqVRdDMeYRlgk/SOSaxS0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=4SXdutv8JWfRiE7kfs7b2sCUx4EBi+Rjss/PLzOFYn+tS8Uao+2OCiAFEvGP9CdIb TGAZ0KhVOZXT71TEQr95Br54jwqpM/kWOilVgDwLNgnOrDpQLvO7kL0h2g64DnFogg qzSug1Vo445Ist2UxW5z5xzJHn1zOvrOO+4x9471RKBmjERmJlkLtwYC3bSpIf9kVt Ju/7QrLY/1ytXEJRp5EeIO2IpgOtXcDPHY3BvriKK9NESvIXrurzkK0RnuR8Syqyur odal2M3LZWFV8M4xeK/QwwifOv5fohG0a4yU18d5fWy8FIFSwjYprecWv2qVyD/hue t27DtmwFxJLug== Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C4C2961FBC for ; Sun, 14 Aug 2022 18:08:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zn1LfA2u"; dkim-atps=neutral Received: by mail-pg1-x536.google.com with SMTP id bh13so4772867pgb.4 for ; Sun, 14 Aug 2022 09:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=83YbuU0kUdKgf06BbOz5ZPqh339HmPmLaxDcEZrp7Xk=; b=Zn1LfA2uvqlXVVW7t+lJlJ73Ui5utwjilauyPuCN/NoJccJiashRV2Fj3fyTFU5GeK 902w3OtiC33ZvMaNLwHeMLuJjD0atPT+XIdf0KQXNSpmZwOri3ImTWtNiP4ks78G4WIW pY4tM68TRAzGcOZqzbiUUo6w0DcVAtXdfPpQdWt76dT/cb4YdqHidPlcdvrGEO1xx/ue Lq8Ol8gazueGw64J7mhbb9Kgyi44XG+WXCzw7ym+WviC1tpZACVLpoiVA4390RbwMnhe /HAZ0ZHJwiPTJAxi634NHlNHqR4cOEOjLXOAPwzjK/IYxuh/7mY3nSaZrYAw3yKMVhPv 7abw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=83YbuU0kUdKgf06BbOz5ZPqh339HmPmLaxDcEZrp7Xk=; b=JNLn6tguLxkFy5QMX+wVqvyh9+JXbSZH9r+qihLvqNqAiK/URn04BeLG8j9PeICp8Z Nf8lB1p5OrBafLgm+pWmYTZXjNdlYIzNRtnQriy9znUXh67bJzlC5wA5dcF/46dsWeuv lr4rR46Rh1/ReBn0+ZxS9KJygF2H1SST7c+zljXL+S8tYT0plDCSfI76u0cgED1623Eo 6WNKt017SVKNnrb8PNiOtfZSgfsT0Vt9MYORmmu5F1ikjPUeCGhBchygLUm06u3c9TOZ RGfpFJVcHXf3cw66JtjmXUaIFGOXiXYMuVyL05DI473GBOITwGVvBC1xVAu/9Kp/hyTv vusw== X-Gm-Message-State: ACgBeo0Nblpy4zk20efduRJpfkGPRkihrA1ONwxyZTd52fTO36hKR+k+ DvGR9BXlQDAzgEWUAN8S5752ZDyEwwE= X-Google-Smtp-Source: AA6agR6I55IT9l4Kqv5PGT5U6zBabTPCohla9dPqoI+fmdRzz/2yvcy0+ZZs1htyhkZ7uApm4p5nRQ== X-Received: by 2002:a63:4547:0:b0:41d:ba0a:870a with SMTP id u7-20020a634547000000b0041dba0a870amr10828401pgk.216.1660493333080; Sun, 14 Aug 2022 09:08:53 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:08:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:44 +0530 Message-Id: <20220814160747.52093-3-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> References: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/6] pipeline: simple: Implements Texture Handling 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Texture Class which includes functions for binding, unbinding, deleting and rendering on textures Signed-off-by: Kunal Agarwal --- src/libcamera/pipeline/simple/texture.cpp | 53 +++++++++++++++++++++++ src/libcamera/pipeline/simple/texture.h | 42 ++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 src/libcamera/pipeline/simple/texture.cpp create mode 100644 src/libcamera/pipeline/simple/texture.h diff --git a/src/libcamera/pipeline/simple/texture.cpp b/src/libcamera/pipeline/simple/texture.cpp new file mode 100644 index 00000000..3551ebc7 --- /dev/null +++ b/src/libcamera/pipeline/simple/texture.cpp @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * texture.cpp - Texture Handling + */ + +#include "texture.h" + +#include + +#include + +namespace libcamera { +void Texture::initTexture(GLenum slot) +{ + /* Generates an OpenGL texture object and assigns the texture to a Texture Unit */ + glGenTextures(1, &idTex_); + glActiveTexture(slot); + glBindTexture(type_, idTex_); + + /* Configures the type of algorithm that is used to make the image smaller or bigger */ + glTexParameteri(type_, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(type_, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + /* Prevents edge bleeding */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +void Texture::startTexture(MappedFrameBuffer *image, GLenum format, GLenum pixelType, Size pixelSize) +{ + /* Assigns the image to the OpenGL Texture object */ + glTexImage2D(type_, 0, GL_LUMINANCE, pixelSize.width, pixelSize.height, 0, format, pixelType, image->planes()[0].data()); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, idTex_, 0); +} + +void Texture::bind() +{ + glBindTexture(type_, idTex_); +} + +void Texture::unbind() +{ + glBindTexture(type_, 0); +} + +void Texture::deleteText() +{ + glDeleteTextures(1, &idTex_); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/simple/texture.h b/src/libcamera/pipeline/simple/texture.h new file mode 100644 index 00000000..c4a41f6f --- /dev/null +++ b/src/libcamera/pipeline/simple/texture.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * texture.h - Texture Handling + */ + +#pragma once + +#include + +#include "libcamera/internal/mapped_framebuffer.h" + +#include "shader.h" + +namespace libcamera { + +class FrameBuffer; + +class Texture +{ +public: + GLuint idTex_; + GLenum type_; + + Texture(GLenum texType, GLuint rend_text) + : idTex_(rend_text), type_(texType){}; + + void initTexture(GLenum slot); + + void startTexture(MappedFrameBuffer *image, GLenum format, GLenum pixelType, Size pixelSize); + + void texUnit(ShaderProgram &shader, const char *uniform, GLuint unit); + + void bind(); + + void unbind(); + + void deleteText(); +}; + +} /* namespace libcamera */ From patchwork Sun Aug 14 16:07:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17119 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 8401FC3272 for ; Sun, 14 Aug 2022 16:09:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2140661FC6; Sun, 14 Aug 2022 18:09:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493340; bh=xDQy7Yy0hcbmpWo62Aixp8tF1ZzVL9XntObilG+0xww=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=fSE1ybFlUWdVuqegh14DNjX6/tB7dFer3hKsomeNwYpoZJziLsee2FjZOzvlYOTB8 0emJLoW3T2E/vmFgx2VYiYGTwEulbSFJeHpJ0zOr44cJffv27OtAVsvEDK65VRmIL0 ljkV9ZP86cOh+7lZ9m7IVyDeAR0jJOM16tuACHjaIOl1MfWwUPYxDRDgm6qPhVpbt+ rgpJdC4T5Tua5tugdzHZA4LUXsMC/XdNmVOGFLY55CyyEgk6T5K6wt8k6U1POg2Jag 3X49EhEl8uLwZTEAgV5DAhpCs17Re0tpYnw0vK0tmVyNFAgV7iQGI34dTPzN6zUcmY iY+hKlmc+3hNQ== Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 064A661FBC for ; Sun, 14 Aug 2022 18:08:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HKcLO1xd"; dkim-atps=neutral Received: by mail-pf1-x430.google.com with SMTP id k14so4978993pfh.0 for ; Sun, 14 Aug 2022 09:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=eQ+c35Jw1mdaAvRe1cjqx4UoVwJ02sxS2HxP9a+AEoo=; b=HKcLO1xdS+QANOigJsggytzfAnYBCDbIs2WLv2ygaDS1gJFguDolA1ybKri8VUOyFx /p2Z+1gRGj+TRaNO4YRXaxwBK4P7FflG4LUE2IgfTTKnk3e/2vv6+874lan5wCjRq2ON kNRjaBLtatB63QeEn9V5wUNBhE3Hm+hUJitT2qdVwDswBwAuf0NK+AUVRcV7ZZppUmq5 qsHHQvOlb1nowtIxBMg7Lj8zx/Uc1pqPtcEQ4U3VkAUv/d6v8XqCsZHwOBKuhDn6Vk94 tOI3o8yaGcUuw6J+SkpH5e80AzBCQU0gWkY3O+M/jkPMN8nJIikGYA7/MK46Bs02UnV1 +TLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=eQ+c35Jw1mdaAvRe1cjqx4UoVwJ02sxS2HxP9a+AEoo=; b=TrXCYtNYoo9LmJrrEtIxkHNbUy3dVQB6qgqScwYEUn3hMXXvfKhqyQcgMyg0fGRV+j RJx3TPvHGC0PFydXiegFFgJ5C6ihHNKeVu2cIWchCQCQHZ0iID4slvAxdKWafFa2B9Vx NTcte/2tZSXeEnXhIg+AL6oY+0ZeUq+G2x3VUsAymzXd5TKC/TH3EAtM9jI/h1IV6lys 6oSFg5nfTIkGDZhfsq2TjiAROle8NBrzUOieUD41QAsmGM3rXwfFWk80gvODUh09ptnt VW+UWbaE9/j5QvrlZZo9qWyjh57pNYRv9tah9JsReBVn3S8Jr/vM+ifPOa1qMC796x29 kweQ== X-Gm-Message-State: ACgBeo2kz5C8sIhmEhNDwIQFW2tGnfkebUCoWmFhxCVmw1ZHFvCDiIyn 1VZ6B6IPwCSqQoUFfHQFqqS+ajn5v8g= X-Google-Smtp-Source: AA6agR5aIGL3dY+ggWYLc0g3w0bIYMt2P2gl4N3XSsWCC0vjO1V8U0O7xlG5qtz/k4i73XR/daEBEA== X-Received: by 2002:aa7:9813:0:b0:52d:395d:c98d with SMTP id e19-20020aa79813000000b0052d395dc98dmr12611450pfl.55.1660493336987; Sun, 14 Aug 2022 09:08:56 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:08:56 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:45 +0530 Message-Id: <20220814160747.52093-4-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> References: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/6] pipeline: simple: GL Converter implementation 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Drop-in replacement for already existing converter which performs debayering on Raw input data and outputs data in RGB format The GL converter uses GPU for debayering via OpenGL compute Shaders Signed-off-by: Kunal Agarwal --- .../pipeline/simple/converter_gl.cpp | 297 ++++++++++++++++++ src/libcamera/pipeline/simple/converter_gl.h | 116 +++++++ 2 files changed, 413 insertions(+) create mode 100644 src/libcamera/pipeline/simple/converter_gl.cpp create mode 100644 src/libcamera/pipeline/simple/converter_gl.h diff --git a/src/libcamera/pipeline/simple/converter_gl.cpp b/src/libcamera/pipeline/simple/converter_gl.cpp new file mode 100644 index 00000000..2d123da7 --- /dev/null +++ b/src/libcamera/pipeline/simple/converter_gl.cpp @@ -0,0 +1,297 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * converter_gl.cpp - GL converter for debayering + */ + +#include "converter_gl.h" + +#include +#include + +#include + +#include +#include + +#include "libcamera/internal/formats.h" + +#include +#include + +#include "texture.h" + +namespace libcamera { + +LOG_DECLARE_CATEGORY(SimplePipeline) + +float rectangleVertices[] = { + /* Coords */ /* texCoords */ + 1.0f, -1.0f, 1.0f, 0.0f, + -1.0f, -1.0f, 0.0f, 0.0f, + -1.0f, 1.0f, 0.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + -1.0f, 1.0f, 0.0f, 1.0f +}; + +int SimpleConverter::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs) +{ + int ret = configureGL(inputCfg, outputCfgs.front()); + return ret; +} + +int SimpleConverter::configureGL(const StreamConfiguration &inputCfg, + const StreamConfiguration &outputCfg) +{ + informat_.size = inputCfg.size; + informat_.planes[0].bpl_ = inputCfg.stride; + outformat_.size = outputCfg.size; + outformat_.planes[0].bpl_ = outputCfg.stride; + return 0; +} + +std::vector SimpleConverter::formats([[maybe_unused]] PixelFormat input) +{ + return { + PixelFormat::fromString("RGB888"), + PixelFormat::fromString("ARGB8888"), + }; +} + +SizeRange SimpleConverter::sizes(const Size &input) +{ + SizeRange sizes({ 1, 1 }, input); + return sizes; +} + +std::tuple +SimpleConverter::strideAndFrameSize(const PixelFormat &pixelFormat, const Size &sz) +{ + const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat); + return std::make_tuple(info.stride(sz.width, 0, 1), info.frameSize(sz, 1)); +} + +int SimpleConverter::exportBuffers(unsigned int output, unsigned int count, + std::vector> *buffers) +{ + if (output != 0) + return -EINVAL; + + if (outputBuffers.size() > 0) + return -EINVAL; + + std::vector> out; + for (unsigned i = 0; i < count; ++i) { + auto tex = createBuffer(); + outputBuffers.emplace_back(tex.second); + buffers->push_back(std::move(tex.first)); + } + return count; +} + +std::pair, GlRenderTarget> SimpleConverter::createBuffer() +{ + bo = gbm_bo_create(gbm, outformat_.size.width, outformat_.size.height, + GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING); + if (!bo) + LOG(SimplePipeline, Error) << "GBM buffer not created "; + + unsigned int filedesc = gbm_bo_get_fd(bo); + + LOG(SimplePipeline, Debug) << "File Descriptor value: " << filedesc; + + DmabufImage dimg = importDmabuf(filedesc, outformat_.size, libcamera::formats::ARGB8888); + + std::vector planes; + UniqueFD fd(filedesc); + FrameBuffer::Plane plane; + plane.fd = SharedFD(std::move(fd)); + plane.offset = gbm_bo_get_offset(bo, 0); + plane.length = gbm_bo_get_stride_for_plane(bo, 0) * outformat_.size.height; + + planes.push_back(std::move(plane)); + + auto fb = std::make_unique(planes); + return std::make_pair(std::move(fb), GlRenderTarget(fb.get(), dimg)); +} + +SimpleConverter::DmabufImage SimpleConverter::importDmabuf(int fdesc, Size pixelSize, PixelFormat format) +{ + int bytes_per_pixel = 4; + EGLint const attrs[] = { + EGL_WIDTH, + (int)pixelSize.width, + EGL_HEIGHT, + (int)pixelSize.height, + EGL_LINUX_DRM_FOURCC_EXT, + (int)format.fourcc(), + EGL_DMA_BUF_PLANE0_FD_EXT, + fdesc, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, + 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, + (int)pixelSize.width * bytes_per_pixel, + EGL_NONE, + }; + + EGLImageKHR image = eglCreateImageKHR( + display_, + EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + NULL, + attrs); + + int e = glGetError(); + + if (e != GL_NO_ERROR) + LOG(SimplePipeline, Error) << "GL_ERROR: " << e; + + GLuint texture; + glGenTextures(1, &texture); + struct DmabufImage img = { + .texture = texture, + .image = image, + }; + + glBindTexture(GL_TEXTURE_2D, texture); + auto glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + + return img; +} + +int SimpleConverter::start() +{ + eglBindAPI(EGL_OPENGL_API); + device_ = open("/dev/dri/card0", O_RDWR); + + if (!device_) + LOG(SimplePipeline, Error) << "GBM Device not opened "; + + gbm = gbm_create_device(device_); + + if (!gbm) + LOG(SimplePipeline, Error) << " GBM Device not created "; + + auto eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); + + /* get an EGL display connection */ + display_ = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, gbm, NULL); + + /* initialize the EGL display connection */ + eglInitialize(display_, NULL, NULL); + EGLConfig config; + EGLint n_of_configs; + + eglGetConfigs(display_, &config, 1, &n_of_configs); + + context_ = eglCreateContext(display_, config, EGL_NO_CONTEXT, NULL); + + if (context_ == EGL_NO_CONTEXT) { + EGLint err = eglGetError(); + LOG(SimplePipeline, Error) << " Context creation failed: " << err; + return -1; + } + + /* connect the context to the surface */ + eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, context_); + + shaderProgram_.callShader("default.vert", "default.frag"); + framebufferProgram_.callShader("bayer_8.vert", "bayer_8.frag"); + framebufferProgram_.activate(); + glBindAttribLocation(framebufferProgram_.id(), 0, "vertexIn"); + glBindAttribLocation(framebufferProgram_.id(), 2, "textureIn"); + glUniform1i(glGetUniformLocation(framebufferProgram_.id(), "tex_y"), 0); + glUniform2f(glGetUniformLocation(framebufferProgram_.id(), "tex_step"), 1.0f / (informat_.planes[0].bpl_ - 1), + 1.0f / (informat_.size.height - 1)); + glUniform2i(glGetUniformLocation(framebufferProgram_.id(), "tex_size"), informat_.size.width, + informat_.size.height); + glUniform2f(glGetUniformLocation(framebufferProgram_.id(), "tex_bayer_first_red"), 0.0, 1.0); + + /* Prepare framebuffer rectangle VBO and VAO */ + + glGenVertexArrays(1, &rectVAO); + glGenBuffers(1, &rectVBO); + glBindVertexArray(rectVAO); + glBindBuffer(GL_ARRAY_BUFFER, rectVBO); + glBufferData(GL_ARRAY_BUFFER, sizeof(rectangleVertices), &rectangleVertices, GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)0); + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(2 * sizeof(float))); + + /* create FrameBuffer object */ + + glGenFramebuffers(1, &fbo_); + glBindFramebuffer(GL_FRAMEBUFFER, fbo_); + + return 0; +} + +int SimpleConverter::queueBuffers(FrameBuffer *input, + const std::map &outputs) +{ + int ret; + if (outputs.empty()) + return -EINVAL; + + for (auto &ib : outputs) { + ret = queueBufferGL(input, ib.second); + if (ret < 0) + return ret; + } + + return 0; +} + +int SimpleConverter::queueBufferGL(FrameBuffer *input, FrameBuffer *output) +{ + DmabufImage rend_tex = importDmabuf(output->planes()[0].fd.get(), outformat_.size, libcamera::formats::ARGB8888); + + Texture bayer(GL_TEXTURE_2D, rend_tex.texture); + bayer.initTexture(GL_TEXTURE0); + bayer.startTexture(mappedBuffers_[input].get(), GL_LUMINANCE, GL_UNSIGNED_BYTE, informat_.size); + bayer.unbind(); + + /* Error checking framebuffer*/ + GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + if (fboStatus != GL_FRAMEBUFFER_COMPLETE) + LOG(SimplePipeline, Debug) << "Framebuffer error: " << fboStatus; + + /* Main */ + /* Bind the custom framebuffer */ + glBindFramebuffer(GL_FRAMEBUFFER, fbo_); + /* Specify the color of the background */ + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + /* Clean the back buffer and assign the new color to it */ + glClear(GL_COLOR_BUFFER_BIT); + /* Bind the default framebuffer */ + glBindFramebuffer(GL_FRAMEBUFFER, 0); + /* Draw the framebuffer rectangle */ + framebufferProgram_.activate(); + glBindVertexArray(rectVAO); + bayer.bind(); + glDrawArrays(GL_TRIANGLES, 0, 6); + + return 0; +} + +void SimpleConverter::stop() +{ + /* Delete all the objects we've created */ + shaderProgram_.deleteProgram(); + glDeleteFramebuffers(1, &fbo_); + eglDestroyContext(display_, context_); + eglTerminate(display_); + + gbm_bo_destroy(bo); + gbm_device_destroy(gbm); + close(device_); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/simple/converter_gl.h b/src/libcamera/pipeline/simple/converter_gl.h new file mode 100644 index 00000000..a61cead0 --- /dev/null +++ b/src/libcamera/pipeline/simple/converter_gl.h @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Kunal Agarwal + * + * converter_gl.cpp - GL converter for debayering + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "libcamera/internal/mapped_framebuffer.h" + +#include +#include + +#include "shader.h" + +namespace libcamera { + +class FrameBuffer; +class GlRenderTarget; + +class SimpleConverter +{ +public: + int configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs); + std::vector formats(PixelFormat input); + SizeRange sizes(const Size &input); + + std::tuple + strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size); + + int queueBuffers(FrameBuffer *input, + const std::map &outputs); + + int start(); + void stop(); + + int exportBuffers(unsigned int output, unsigned int count, + std::vector> *buffers); + std::pair, GlRenderTarget> createBuffer(); + bool isValid() const { return true; } + + Signal inputBufferReady; + Signal outputBufferReady; + struct DmabufImage { + GLuint texture; + EGLImageKHR image; + }; + +private: + int configureGL(const StreamConfiguration &inputCfg, + const StreamConfiguration &outputCfg); + DmabufImage importDmabuf(int fdesc, Size pixelSize, PixelFormat format); + int queueBufferGL(FrameBuffer *input, FrameBuffer *output); + + std::map> + mappedBuffers_; + + struct ConverterFormat { + struct Plane { + uint32_t size_ = 0; + uint32_t bpl_ = 0; + }; + PixelFormat fourcc; + Size size; + std::array planes; + unsigned int planesCount = 0; + }; + + int device_; + unsigned int rectVAO, rectVBO; + EGLDisplay display_; + EGLContext context_; + + struct gbm_device *gbm; + struct gbm_bo *bo; + unsigned int fbo_; + + ConverterFormat informat_; + ConverterFormat outformat_; + ShaderProgram shaderProgram_; + ShaderProgram framebufferProgram_; + std::vector outputBuffers; + PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); +}; + +class GlRenderTarget +{ +public: + struct SimpleConverter::DmabufImage texture_; + + /* This is never to be dereferenced. Only serves for comparison */ + const FrameBuffer *buffer_; + + GlRenderTarget(FrameBuffer *buffer, struct SimpleConverter::DmabufImage texture) + : texture_(texture), buffer_(buffer) + { + } +}; + +} /* namespace libcamera */ From patchwork Sun Aug 14 16:07:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17120 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 3AE02C3272 for ; Sun, 14 Aug 2022 16:09:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EC89D61FC3; Sun, 14 Aug 2022 18:09:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493359; bh=XXyEynVdu4y+F579v801F4ppNzP39vH+kn2cB1i9Yis=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KzgqQ1oHi6/7IqiY6XXgVQXYuECZs47ZQDWiVe5oM1SOPpMaFGMuUa6RrzPBVlCjM ZhWyVT8YV+FJhJHRa2Nsue/GV6LONo96XexwgJ7vYQCeo+aT0ndcXnsKUPiaj+YBSl OVJX2B05lYCJwTPnb7wkj6LU+/PExXmvrvIzKTYmYnlntEeF3K3N01MrpUidkw8mQk 98Yq6/hB2pA1l4FdxBn6Cc8Dhd1NLvmU3ULQVn7SPH8nq2iUr+iRLu+2DzXtBaphDj WFxqmU31cvMYeAT6isAJnVVMwuazgcIm5a4AqntVu+JM03htrVs6fjhG6aGsdEgujf 6sRy3UcPw+Kww== Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B794461FBA for ; Sun, 14 Aug 2022 18:09:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MTzFAGB6"; dkim-atps=neutral Received: by mail-pl1-x631.google.com with SMTP id x23so4589491pll.7 for ; Sun, 14 Aug 2022 09:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FkuiYHjnNT30yQpCOMkDwgtN3xIa8EcKcOneXpSZ+38=; b=MTzFAGB6dFfmEKL4aMJ1IfvgG2bY58d4iifPZ1DrRZddw4gcgtYb8nw+0waALmg4e1 PmZlhWjKbg3uss4xvTkZi3Qa/H5dNYP3TvwTRy847GEqjeDao7X9a8LY9RaULDaPqneJ 5x3uygbP14oH8flw4VyiEc8fAht1eW+p3WiD20k/QEcKq5HxRWFCffiG9N3XrXLW/3KO Sm6xH5U1KbLqjNNjXM1lijoodyeJ/LpPvtPOlhA3jriwJay0KgNRUpGAA1d15Y27a5H3 PgryKwQvfeanLKEKCkCv5oHMAN5s30cnVilEnpolvcrQkO7Q0mPZ2m5A/0jp9KbE4TBQ Wa3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FkuiYHjnNT30yQpCOMkDwgtN3xIa8EcKcOneXpSZ+38=; b=BNfWaCN8irCWVHN9WD89+7eDkNwfMOKOsWidMWo8bNu3gxZITVvZO15It6elo9ReSw TNR73eyuEODcrW0Xz9zjEMdoUeGNmqUY9dTfT1cRp3RT+mm/v6e5g97fhoEgutLfBRbE x/jqwQGxHlA3Kl8d8lfX9wFRePVYFJJjzlxCbT89V8C/SLf84SW1QNLN2c09qUWOT++v LGCRlX2f/c2JKBkmdI0i+zl6yzgZwNKxb+6SOqnuh0jD9WodE8VXcLf9HjN4cIJn+KbR xBfOIeywXB++LGd7Dc3M0zxZkHeZdWlGZeUss8dCxyMHmniQbuz0POO9/LgwODau/rkb Yx1Q== X-Gm-Message-State: ACgBeo2o2+sH58zQhUfjxaESyGrebl7IRytjGJMRi9HBslyyY7JMuPre SZLWzsOBcns4ePc2V/HrBFNy8Q0hTtM= X-Google-Smtp-Source: AA6agR4w4ukh/d2obgSkZympMGAuP/SNM0AixE9YZBkYQ+SW/hOxGSQPp4ZRb39DZvji2a98tWv6mQ== X-Received: by 2002:a17:90b:4b89:b0:1f5:68b:b14e with SMTP id lr9-20020a17090b4b8900b001f5068bb14emr24544244pjb.30.1660493357121; Sun, 14 Aug 2022 09:09:17 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:09:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:46 +0530 Message-Id: <20220814160747.52093-5-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> References: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/6] [HACK]pipeline: simple: simple.cpp: Hack to test the GL converter 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Includes converter_gl header file and add unicam to list of supported devices to run on RaspberryPi Removes parameterized constructor call for SimpleConverter, which passed Mediadevice converter Sets Number of streams to 1 when converter is in use Signed-off-by: Kunal Agarwal --- src/libcamera/pipeline/simple/simple.cpp | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index bc0cb1a0..485282fb 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -36,7 +36,7 @@ #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" -#include "converter.h" +#include "converter_gl.h" namespace libcamera { @@ -187,6 +187,7 @@ static const SimplePipelineInfo supportedDevices[] = { { "imx7-csi", { { "pxp", 1 } } }, { "qcom-camss", {} }, { "sun6i-csi", {} }, + { "unicam", {} }, }; } /* namespace */ @@ -452,18 +453,16 @@ int SimpleCameraData::init() SimplePipelineHandler *pipe = SimpleCameraData::pipe(); int ret; - /* Open the converter, if any. */ - MediaDevice *converter = pipe->converter(); - if (converter) { - converter_ = std::make_unique(converter); - if (!converter_->isValid()) { - LOG(SimplePipeline, Warning) - << "Failed to create converter, disabling format conversion"; - converter_.reset(); - } else { - converter_->inputBufferReady.connect(this, &SimpleCameraData::converterInputDone); - converter_->outputBufferReady.connect(this, &SimpleCameraData::converterOutputDone); - } + /* Open the converter. */ + + converter_ = std::make_unique(); + if (!converter_->isValid()) { + LOG(SimplePipeline, Warning) + << "Failed to create converter, disabling format conversion"; + converter_.reset(); + } else { + converter_->inputBufferReady.connect(this, &SimpleCameraData::converterInputDone); + converter_->outputBufferReady.connect(this, &SimpleCameraData::converterOutputDone); } video_ = pipe->video(entities_.back().entity); @@ -1281,7 +1280,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) DeviceMatch converterMatch(name); converter_ = acquireMediaDevice(enumerator, converterMatch); if (converter_) { - numStreams = streams; + numStreams = 1; break; } } From patchwork Sun Aug 14 16:07:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunal Agarwal X-Patchwork-Id: 17121 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 D359FC3272 for ; Sun, 14 Aug 2022 16:09:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F37861FC4; Sun, 14 Aug 2022 18:09:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660493370; bh=gqLogKPxVh/WCIMHL8siNzuaNJ+1yCwFOZuK8dhBCtE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Pndt+dMinPcTW30HZsH6E1rGYlUd5S478KqYuPXV0SrXV1S+zh5tY2FIrc81BGlYw MbK+9XLOaMGxLNZdxomkB3W8YiaSnZF8/Ojnxp4TviPzxFnZPL6JuOjiLue/w026M9 VS8MRYF/Ekuc/CreWMRRJ6Rq2quVSnmDEztdk1Tm9RjHEeSCCT6TBE1560FlVKe+1d PZu7OY7p2JtWcGcMMLlY6Z+7NvZTca0BDEOi72+6YyS6epOU56KKojU2pCoQxXdljW s2snYhhDwyQYyfhm5sqVmH+yRL1K84HISbw6wEgm/bGroK8AFHUwJAcwpygNHrDFya zXfeQvObac4Lg== Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6D6C61FBA for ; Sun, 14 Aug 2022 18:09:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XmTR/AJI"; dkim-atps=neutral Received: by mail-pl1-x635.google.com with SMTP id 13so4568961plo.12 for ; Sun, 14 Aug 2022 09:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=thstpLkjmu5aChZH/pskTvwz85n+Z9IHTFGY7BPADSU=; b=XmTR/AJIKWeVFI/wf81JnOfOmIyt5xuj36MOsbRUvRwRKlLYEn3Ecizz0UfUgjQu5o OGeFWPoQ01+eZKj/ajePbyCttKjYv2JblSSafig+7mzv4Dbi/SNXKpHgrCzu2djMmF1H WmlNfzsk9Xy4pWfBvpStq8O9KMvluqtoEXfFAYZxlYyT6LfvIYtwHYLwQkmbRXvzhISo xKkVimP+UX/IfouPH18AdGBkdrr9zm1zCAxcVq/DYdj6Hjpcx8qIDRJIm9sDaQKYDt02 Nf008H4F4MEu0E8lmFpFx2HAgPq9rxJf8pzh0pPzYw3/7y+/X50dKuuuBveEh2x720PD xupQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=thstpLkjmu5aChZH/pskTvwz85n+Z9IHTFGY7BPADSU=; b=J4ccFYdyi0lz3bVJWlpJLF/986LlpnoSWvChKK0G0nDbHf4BKGSCbt9asVg4GFKuRT MVbVOLaZ8h5CYG4KFdy5+gTmR5JQImq04CFXs/AXW6XV1h44WW+ho/khOh0pLze7/iFc N6F1MiFrDjCo9LzXBSGquTglpO89prNqDcar5Jn1mpoGhi8hTDJ5+WDxuIH/raiRDQhX qxKFQForoYYC9JnzoxphfdSetqABrIzIjohO8+bss7UlS2zpHyTTD2QbcOvQwz5caIDI 24wwF4ySutzFUMCYUWkTueSaz6a7J6YNHBAbR0s+WUmmv+MOezFRLS4McMHOTX9QHzRW 9BFA== X-Gm-Message-State: ACgBeo1vPCe0USQY/mlJO/sZ/vszKa+8dMqQSYkciyaLigX/ayLus+Iv XChdRpw351XM2MGpfVJGzTXnEN9+j68= X-Google-Smtp-Source: AA6agR4jySUCu0D3Hwdk7nvJ7Q0dPT2m//7kLFDreHDBSOLoBN7FwszeC6NwQAq1p6EVGROI1/c1Uw== X-Received: by 2002:a17:902:e5c6:b0:16e:f3b6:ddb5 with SMTP id u6-20020a170902e5c600b0016ef3b6ddb5mr12875867plf.122.1660493367065; Sun, 14 Aug 2022 09:09:27 -0700 (PDT) Received: from pop-os.localdomain ([115.96.217.20]) by smtp.googlemail.com with ESMTPSA id j6-20020a170902da8600b001709aea1516sm5576653plx.276.2022.08.14.09.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:09:26 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 14 Aug 2022 21:37:47 +0530 Message-Id: <20220814160747.52093-6-kunalagarwal1072002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> References: <20220814160747.52093-1-kunalagarwal1072002@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/6] Additions in meson.build files 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: , X-Patchwork-Original-From: Kunal Agarwal via libcamera-devel From: Kunal Agarwal Reply-To: Kunal Agarwal Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Adds files and dependencies required for GL Converter to compile Signed-off-by: Kunal Agarwal --- src/libcamera/meson.build | 3 +++ src/libcamera/pipeline/simple/meson.build | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index b57bee7e..b14102f8 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -136,6 +136,9 @@ libcamera_deps = [ libcamera_base, libcamera_base_private, libdl, + libegl, + libgbm, + libgl, libgnutls, liblttng, libudev, diff --git a/src/libcamera/pipeline/simple/meson.build b/src/libcamera/pipeline/simple/meson.build index 9c99b32f..02929456 100644 --- a/src/libcamera/pipeline/simple/meson.build +++ b/src/libcamera/pipeline/simple/meson.build @@ -1,6 +1,12 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_sources += files([ - 'converter.cpp', + 'converter_gl.cpp', + 'shader.cpp', 'simple.cpp', + 'texture.cpp', ]) + +libegl = dependency('egl', required : true) +libgbm = dependency('gbm', required : true) +libgl = dependency('gl', required : true)