[libcamera-devel] [PATCH v5 1/9] qcam: viewfinder_gl: change uniform float tex_stepx to vec2 tex_step
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Jun 30 02:30:42 CEST 2021
Hi Andrey,
Thank you for the patch.
On Tue, Jun 22, 2021 at 04:46:44PM +0300, Andrey Konovalov wrote:
> 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 <andrey.konovalov at linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> 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<QOpenGLTexture> &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_;
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list