From patchwork Fri Jan 1 17:15:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10800 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 8B92CC0F1A for ; Fri, 1 Jan 2021 17:16:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A35862000; Fri, 1 Jan 2021 18:16:22 +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="AyFzw4d6"; 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 A86846031C for ; Fri, 1 Jan 2021 18:16:20 +0100 (CET) Received: by mail-lf1-x130.google.com with SMTP id l11so49903562lfg.0 for ; Fri, 01 Jan 2021 09:16:20 -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=AyFzw4d6PIeDXemBIme0OHCdHCeD9dpvRz+pgYIfDVcT5Uxmmup03I5g1tAqYNSn7N i5tZF+hCbvY1iW+NT/CIqY00jpX1thyO1cJZ1QllKUnleEAj9OWW5+usLvzuMvCpvyCY S6hAO3fcm2QMn4dmq6U+BH6zy/omu7zMw4gbISSl8c4N74+aYnPmXR46UC03V3SFCscb 5yuvPX2PdnVHgJvIhd6vCN/+b86a8oqjT4hPU5II6MKVtLGGuYjeedj1K4NfeYbMLWd3 PqwSEYDb1rsaF0/c3lAyPDQsGZxv734Zl0qp9PiH0iRsZV51uPuT/i3B6HDTDLDSz61I f0OQ== 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=jQIVBFAcrTfw8oGPi4p6y2bsEqehYsNGefuqImyFK8DFtxdBR8msGrz6T69JpDLGAu 3AeLmrwOCULGhLmrHOXCrVGuJaQd5SFj2cSkXJFbwrGdo//sGGMItiYDzzw0wFQ3znsQ YpyeEnNPWwZTWWJxhGTVn2eBGFZbwb4/vpXrR0/Kl//uCpfonihhy0zsAA/xB1XXlT8G 2XuyFW04r/he7mRCZ5GYtxRCJYAhnkdS9nEJnCg2LR9oGM+0nk4QuhmYGq9ASNGHRmsR 0rHhVc6wEnLtE4OQ/ON0Rd2rtjLntJVvg0InCsDqOHiaei9LjhlJPlNwfn4ncD3CXfWi jmnQ== X-Gm-Message-State: AOAM533oV+EPCSqmOfeW12wKfrDuICXC2QcYJSgCJz0ieeiHlikY7kj2 F97eNxWufftKP0iMOAasHGuhvevQbPHNlNQ1 X-Google-Smtp-Source: ABdhPJxDmTqjWq0omseuIry97X5UX/ayLcTp0FosM48F7eFGs+l9r4fwF9TzzbZwGjKVvEQDeCjofA== X-Received: by 2002:a2e:6818:: with SMTP id c24mr32603941lja.184.1609521379717; Fri, 01 Jan 2021 09:16:19 -0800 (PST) Received: from localhost.localdomain ([85.249.43.69]) by smtp.googlemail.com with ESMTPSA id m12sm7873213lji.110.2021.01.01.09.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 09:16:19 -0800 (PST) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com Date: Fri, 1 Jan 2021 20:15:52 +0300 Message-Id: <20210101171553.32727-2-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 1/2] 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_;