From patchwork Thu Feb 25 18:36:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11388 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 B8B89BD1F1 for ; Thu, 25 Feb 2021 18:37:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8843168A5D; Thu, 25 Feb 2021 19:37:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MQETSXHw"; dkim-atps=neutral Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 16AC168A59 for ; Thu, 25 Feb 2021 19:36:59 +0100 (CET) Received: by mail-lf1-x130.google.com with SMTP id u4so10095226lfs.0 for ; Thu, 25 Feb 2021 10:36:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=olzp5+f2p8vLdXof0aF2IDvl6Y/vw19jdOA72WR6mWo=; b=MQETSXHwHgzMdIBAksHaiRXvf+ePh+8OtSux7W+IePaX1ODcMIkJpD8qWfMCUGQSLn k92jwqDck+G0ewKL+A09W/Fa7WKOq9UhQu8nQnwLBcTEUk9friDlE4PqaUZaBFHhRCvs wjuiqGFE8dFyYMC2B4cGFbbfB6YF2k/MbcHHqEFi0LpqBJITzkTRjb4spMTTTyR1goT9 eSokwU+jInttsHK+H18ohpqOqc09oFIqpxs11ThuD9xVCbiu6DLnLcGV9OZuzp3yAj6k ofs1NDepR/OSRBde2UYX7lgON2nIIK8hEUR+ZteiAm+QZThiruaBUOy+y4wV7oiHiT/O rnhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=olzp5+f2p8vLdXof0aF2IDvl6Y/vw19jdOA72WR6mWo=; b=KFknzOhpi/HhKdzvuKotXrfuiMagOWzNoBEO/FlExuYiXB4Dnt3bzxu0WDxH+8N5kh cN0El0MvZoQQOmu8sF4lclq6NITKOZApzW+cRou12iCibF5tL64NtqbpMGYMCYGmOFZr wYeWprzX4YpZhW1j+fQgWmz67TeCl1yNo29Vi9xxVy+9olNdechIjadOXeGBAWV7TAQx sOyQhesj6u+JUM1t+LBYPCJZM0dqL//R4YWQVUURngpiqspQjkLf4dv6JvcarAArf5g8 Yw1qL3oVxPiXemIjgBd4RUhUH06VHqahC1xOYNqKJVj2MwCBZZ8EnRdVp8LLYhkeI0jQ AeEQ== X-Gm-Message-State: AOAM532jYoIZ6WhYIF59bh/FVW3OIytrDSiw8GoTuXoY23vTK9DYn2Pa DY0Lqlr2I+B295TBnuxV3zG4Ha8c8cSEbg== X-Google-Smtp-Source: ABdhPJwY/OHs+uajDSmRYX5jny9OQ7rltrRc7q6pII2I9Tlqs/hlUA/m5cwT8J3wN13BWuFkRpQmJQ== X-Received: by 2002:a05:6512:34c8:: with SMTP id w8mr2714772lfr.537.1614278218615; Thu, 25 Feb 2021 10:36:58 -0800 (PST) Received: from localhost.localdomain ([85.249.43.69]) by smtp.googlemail.com with ESMTPSA id x1sm1136772ljh.62.2021.02.25.10.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 10:36:58 -0800 (PST) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com Date: Thu, 25 Feb 2021 21:36:22 +0300 Message-Id: <20210225183626.28288-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225183626.28288-1-andrey.konovalov@linaro.org> References: <20210225183626.28288-1-andrey.konovalov@linaro.org> Subject: [libcamera-devel] [PATCH 1/5] qcam: viewfinder_gl: change uniform float tex_stepx to vec2 tex_step 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: , Cc: morgan@casual-effects.com MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In preparation to extend the supported formats, extend the tex_stepx uniform to cover the steps between texels in both horizontal and vertical directions. Signed-off-by: Andrey Konovalov --- src/qcam/assets/shader/YUV_packed.frag | 8 ++++---- src/qcam/viewfinder_gl.cpp | 7 ++++--- src/qcam/viewfinder_gl.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qcam/assets/shader/YUV_packed.frag b/src/qcam/assets/shader/YUV_packed.frag index 224dfafe..d6efd4ce 100644 --- a/src/qcam/assets/shader/YUV_packed.frag +++ b/src/qcam/assets/shader/YUV_packed.frag @@ -12,7 +12,7 @@ precision mediump float; varying vec2 textureOut; uniform sampler2D tex_y; -uniform float tex_stepx; +uniform vec2 tex_step; void main(void) { @@ -49,10 +49,10 @@ void main(void) * a = fract(x) * 2 - 1 if fract(x) >= 0.5 */ vec2 pos = textureOut; - float f_x = fract(pos.x / tex_stepx); + float f_x = fract(pos.x / tex_step.x); - vec4 left = texture2D(tex_y, vec2(pos.x - f_x * tex_stepx, pos.y)); - vec4 right = texture2D(tex_y, vec2(pos.x + (1.0 - f_x) * tex_stepx , pos.y)); + vec4 left = texture2D(tex_y, vec2(pos.x - f_x * tex_step.x, pos.y)); + vec4 right = texture2D(tex_y, vec2(pos.x + (1.0 - f_x) * tex_step.x , pos.y)); #if defined(YUV_PATTERN_UYVY) float y_left = mix(left.g, left.a, f_x * 2.0); diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index 5d9b442e..ff719418 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -289,7 +289,7 @@ bool ViewFinderGL::createFragmentShader() textureUniformY_ = shaderProgram_.uniformLocation("tex_y"); textureUniformU_ = shaderProgram_.uniformLocation("tex_u"); textureUniformV_ = shaderProgram_.uniformLocation("tex_v"); - textureUniformStepX_ = shaderProgram_.uniformLocation("tex_stepx"); + textureUniformStep_ = shaderProgram_.uniformLocation("tex_step"); /* Create the textures. */ for (std::unique_ptr &texture : textures_) { @@ -508,8 +508,9 @@ void ViewFinderGL::doRender() * ([0, 1]). There are exactly width - 1 steps between the * leftmost and rightmost texels. */ - shaderProgram_.setUniformValue(textureUniformStepX_, - 1.0f / (size_.width() / 2 - 1)); + shaderProgram_.setUniformValue(textureUniformStep_, + 1.0f / (size_.width() / 2 - 1), + 1.0f /* not used */); break; case libcamera::formats::ABGR8888: diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index 150fa4ae..1b1faa91 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -85,7 +85,7 @@ private: GLuint textureUniformU_; GLuint textureUniformV_; GLuint textureUniformY_; - GLuint textureUniformStepX_; + GLuint textureUniformStep_; unsigned int horzSubSample_; unsigned int vertSubSample_;