[{"id":37201,"web_url":"https://patchwork.libcamera.org/comment/37201/","msgid":"<85ecpb1it3.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-12-03T19:12:08","subject":"Re: [PATCH v6 11/24] libcamera: shaders: Fix input sampling when\n\twidth != stride","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> From: Hans de Goede <johannes.goede@oss.qualcomm.com>\n>\n> When bayer_unpacked.vert is calculating the center and x/yCoord values\n> stride != width is taken into account for x/yCoord deltas since it is taken\n> into account by debayer_egl when setting the x part of tex_step uniform.\n>\n> But it is not taken into account for the center.x which is just directly\n> copied from textureIn, leading to the input width sampling covering\n> the entire input stride instead of just covering the input width.\n>\n> Use the existing and currently unused stride_factor uniform to pass\n> the width/stride ratio and correct center.x for this. This fixes\n> the misrendering seen on x86 laptops which is caused by the CSI2 receiver\n> there requiring a stride which is a multiple of 32 often leading to\n> stride != width.\n>\n> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/libcamera/shaders/bayer_unpacked.vert | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/shaders/bayer_unpacked.vert b/src/libcamera/shaders/bayer_unpacked.vert\n> index fb5109eee..423dde0fa 100644\n> --- a/src/libcamera/shaders/bayer_unpacked.vert\n> +++ b/src/libcamera/shaders/bayer_unpacked.vert\n> @@ -21,7 +21,7 @@ attribute vec2 textureIn;\n>  \n>  uniform mat4 proj_matrix;\n>  \n> -uniform vec2 tex_size;\t/* The texture size in pixels */\n> +uniform vec2 tex_size;  /* The texture size in pixels */\n>  uniform vec2 tex_step;\n>  \n>  /** Pixel position of the first red pixel in the */\n> @@ -40,8 +40,10 @@ varying vec4            xCoord;\n>  /** of the adjacent pixels.*/\n>  varying vec4            yCoord;\n>  \n> +uniform float stride_factor;\n\nWould it be nicer to put this next to the other uniform declarations\nabove?\n\nAnyway, with or without that change:\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> +\n>  void main(void) {\n> -    center.xy = textureIn;\n> +    center.xy = vec2(textureIn.x * stride_factor, textureIn.y);\n>      center.zw = textureIn * tex_size + tex_bayer_first_red;\n>  \n>      xCoord = center.x + vec4(-2.0 * tex_step.x,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CDBE4C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Dec 2025 19:12:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 017E06101E;\n\tWed,  3 Dec 2025 20:12:17 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC1A4609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Dec 2025 20:12:14 +0100 (CET)","from mail-wr1-f71.google.com (mail-wr1-f71.google.com\n\t[209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-61-3Awb1bY_MyuJsj730xnzLw-1; Wed, 03 Dec 2025 14:12:11 -0500","by mail-wr1-f71.google.com with SMTP id\n\tffacd0b85a97d-42e2e3c3e1aso67773f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 03 Dec 2025 11:12:10 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-42e1ca1a2easm42303286f8f.23.2025.12.03.11.12.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 03 Dec 2025 11:12:08 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"AcBj2UWx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1764789133;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=ZN1oq8KicN9GvzA/MpPf/hU8dlXLu1E87VgVCVB6vUc=;\n\tb=AcBj2UWx6W9scC/aZPPMLZd/L2DvIUaw3cFELAWgBlIoAvPoxxvvOeK2lVTsvuUmKZHjnx\n\tYjDsbC0EkOanHBE9myhCpanRIb9gG0G/yrQkVNxstVK5mcOh+0L3TVXuCJyniVFDlmNv5H\n\tHVLrmdK8zNhVQB3jRP1+CdtpzkIKuYI=","X-MC-Unique":"3Awb1bY_MyuJsj730xnzLw-1","X-Mimecast-MFC-AGG-ID":"3Awb1bY_MyuJsj730xnzLw_1764789130","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1764789130; x=1765393930;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=ZN1oq8KicN9GvzA/MpPf/hU8dlXLu1E87VgVCVB6vUc=;\n\tb=k+k8aPgYGcyke48VOKHzeVwkPK0iSEwdSkbkiZrQO9pMo8Yrtv/ksubip6PjjLRNdc\n\t5SE+VLj91uCPDTZmw+s8eTH68BEmEjuuvA4rWJWPB6dLiYADqJk4EjNqBk09qau54mAM\n\t87IHpbxlkefYbln7wvY4835v3yyJudyQs7HSkqPE8KMMBdCMUI8mxrSTgemq40S9ioX9\n\tTVSpGJEPN5l13n7x/u0pgiNcrmjSbFimOA5jkVxyeJD8ExY9wsks/qgWnD4eM4WWEQBT\n\t3KANzY6X/Z4QyBl2dUc9TfVYCvx3gI4j4ZAdy92vxhHM4wkSLn18fvkX7QxgBrEg/VOu\n\tYOwg==","X-Gm-Message-State":"AOJu0YxoD53d6QPXpsRJaavr5OdOR3ItxJyAOKr/SlIf1zYHi3peARtQ\n\ts3dgGMEq9JCIUOO4grnwJYjZL35f/krbZmwRLwY1/5ccT7EFlhqGcga9u7ubbIuMVpCluVm+XKM\n\t3iKyLjx3S8t/xjF9oV2icaqpe9Xifv+M0uXF/JIk5nfqIVgu5ZwtKmfuES1PGFc6Wd8G3TEY+UM\n\tA=","X-Gm-Gg":"ASbGncudZ6PW37jNX5EvDuV4DV3Z9QuZjpeqVj0N03mTpZpeTU6vfcBjOsfy/7TKEpB\n\tp/41L6oHto0XAIrcV8MklifjLCPYAIsH67yYsOgwymbj+0f1sootG9BiIOzviyMBW7RVDbrEExD\n\tJy4cn2HKkykNcjYvaQ51Iqi3X05PgY7QkLr/1upVa0voB3vyNbxS88SE9kPvGRjMAHYkIWYp6DZ\n\tQmyksPgH6jeiwYZm0hQtG3kybv6hGaMLKhBALZQS+WQx+e8Pd4SlhVLvBRt1+5UsYDy51KpX9OI\n\tf9AhNHOtWUjW/hrUAiejY2APRSlQ0gsG0nikcvQ33Z/SFlgZQdhoDVwEjCJRlhAV4Sn1XOrVUMU\n\tlss+UApUDBGm9QvirPXUPKWqapzhIeGfY5PPm84DOda0m5tDt5yxNZrkAu9Rf28A=","X-Received":["by 2002:a05:6000:240b:b0:42b:3b55:8908 with SMTP id\n\tffacd0b85a97d-42f731c9dffmr3584098f8f.51.1764789129930; \n\tWed, 03 Dec 2025 11:12:09 -0800 (PST)","by 2002:a05:6000:240b:b0:42b:3b55:8908 with SMTP id\n\tffacd0b85a97d-42f731c9dffmr3584078f8f.51.1764789129509; \n\tWed, 03 Dec 2025 11:12:09 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IFi5nntJqbgTYNbJE9abDs20ME0sjZNH0ZHLpyrFqJYINWV5Aa5voEukfE+aI2/l6hzXjwyug==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  pavel@ucw.cz,  Hans de Goede\n\t<johannes.goede@oss.qualcomm.com>","Subject":"Re: [PATCH v6 11/24] libcamera: shaders: Fix input sampling when\n\twidth != stride","In-Reply-To":"<20251202134544.662446-12-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Tue, 2 Dec 2025 13:45:31 +0000\")","References":"<20251202134544.662446-1-bryan.odonoghue@linaro.org>\n\t<20251202134544.662446-12-bryan.odonoghue@linaro.org>","Date":"Wed, 03 Dec 2025 20:12:08 +0100","Message-ID":"<85ecpb1it3.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"KkYNf8e26a77Xi_HjQk3Hxm4PvfuJR2s8tLGZ3HcKoU_1764789130","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]