From patchwork Thu Jun 17 12:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12630 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 F1CACC3218 for ; Thu, 17 Jun 2021 12:40:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B5BE46892D; Thu, 17 Jun 2021 14:40:11 +0200 (CEST) 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="Qn3qEsyY"; dkim-atps=neutral Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73B0F6050C for ; Thu, 17 Jun 2021 14:40:10 +0200 (CEST) Received: by mail-lf1-x12f.google.com with SMTP id a1so10070749lfr.12 for ; Thu, 17 Jun 2021 05:40:10 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=mv2rnIZBXYiZJVAJqcAZOvGmMppMCyKTu4OnVWYQArQ=; b=Qn3qEsyYiHvvtIfhMLxPcjQBPVxiAoxmyTcqHf3xdGnq4cJAYQi3AX7BsRpK6wsRae 3NX76FwfNYmiNk06d0kPPK3x0G4ELsGhqiaELM9cqITkHPbzzboiidGiyzumgrtitN9W eeZEV/sDddwaRSjd5vkYIqp6rVPclgK//XrI85GglKt2v/AT+2Xl+Ubpox1EPWxYKbIA do3F3Wia2jeTmmbiRe+W32RzVlFaai8B12F3S8BTH8E4zQ95fkbUI+G4g48AQC2SYf1N OQ+2DAGyrhFLRfNT9ZgWKcK3qZDk/ZL3dzp01988qVG9wYXebm9bD73lQQ6Uiaj4GKq6 vCdQ== 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:mime-version:content-transfer-encoding; bh=mv2rnIZBXYiZJVAJqcAZOvGmMppMCyKTu4OnVWYQArQ=; b=oBXF6/9UzdZcdroDpuWuiV02A/PThpwahgp8BptsMVkYvr5qAPoMTfCTMopLmttFiF UVxLBIzFMhsyrZS2Yt/n0EavKV9ATECuWfzJ4cf27cckXSNKfHOnyDBaVI/x/c8+yCBB 0ZyFYJJIT4FvUCRxVN6G2+iUKtqo0350SqXVcHMvRui6BAgJA4xAwVGHZtMKwr4feRuI vJ+SKozBYv0/qpfllLc3YBk+QEv97AXoF5ZOBX2hhO5UHB3cS7JX5Wvk4xzsGHeYc2cg pgmz491dl7jHbRnFVfKMwoSJjfZ1wWGrG3V1VPVXy7wleSSVDleqD1jh3mCVYIAQwFId wBdA== X-Gm-Message-State: AOAM533RdYjcrQQXKZOh3nP32UdB9LT2ssiUXMp6PbV+v1bYypVr+gHN TFbwEZsBsBiHfvJUs5T4RcY/qKVGzaEAKA== X-Google-Smtp-Source: ABdhPJxpVlSfCa5tpu8Ss6yVcYhTg6RH7HBLQSnIw7EewiiuyKtrYXUBYkcdDjIvJBlDuk0EVBvt6w== X-Received: by 2002:a05:6512:2192:: with SMTP id b18mr3919926lft.422.1623933609002; Thu, 17 Jun 2021 05:40:09 -0700 (PDT) Received: from localhost.localdomain ([85.249.44.185]) by smtp.googlemail.com with ESMTPSA id t17sm268800ljt.1.2021.06.17.05.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 05:40:08 -0700 (PDT) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com Date: Thu, 17 Jun 2021 15:39:39 +0300 Message-Id: <20210617123941.1095481-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617123941.1095481-1-andrey.konovalov@linaro.org> References: <20210617123941.1095481-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/3] 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 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 Reviewed-by: Laurent Pinchart --- 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_;