From patchwork Tue Dec 2 13:45:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25320 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 0CA97C32F0 for ; Tue, 2 Dec 2025 13:46:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49EBD60D26; Tue, 2 Dec 2025 14:46:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yVYAamle"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4196960D0C for ; Tue, 2 Dec 2025 14:46:09 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so40125785e9.0 for ; Tue, 02 Dec 2025 05:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764683168; x=1765287968; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lT2eJ2agSvDxCvtLEFurZF722zwcGLXZKk9J6KGVpFg=; b=yVYAamleZy0RZ5rmYLIhNnvLZR6OTiXLhFD3QSn+1+erUoSqXvGof6pukDcK7W5aIn 69D/AHwCMog7fAyEwuFNofFzpV1WrNeIUNS/G8/bGFvpW3CSjd7Y93AFoyca/9tSTxdF I28RJTS5lPI+pmTq+stcsnG7LpSbXsVMAhHLhaw1y3F08H79Hh1FnZYXTJPzoB1eTToy g/qe8XdnWFsNCwHCyTefMJ0FIk8HqC5lPEMWIXNugSBRskwuFpkoJRTwvIXHlDaLOJ1l 7bf++ekibptRjAESVHMtY3OU3etYCS9X0HQ9Nt2x5UgAnwVmz1ihvOfdQOC2p+ZAPyM2 lBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764683168; x=1765287968; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lT2eJ2agSvDxCvtLEFurZF722zwcGLXZKk9J6KGVpFg=; b=Mdo4poqnHDV9MWxZxeEdSWB1fd1HIANYiGk5AAkXG6imMvWMy7Xue92bcpZYcsmpTr EaTlGX10UecKeV1gHy/YyhdZpFB8WcpnquvnnNoMG2XUv9q3pRniLlsRtuji36NXBwRl olxrzTKIVmM8cENvDA1TbhqwekdwZTtkJkG+8JIo9xNgjwEHrr3M1Es4qr2HWjvvXsFo Q7Wk7PJ7RnMBH3GhMQB8DVX7ekFHq3cXTga/fXDdR9ahl/pFOj/S7dguZFnJL+g4DR+Y lhlk/JvM6Y0Co8w3Nw6lxcIz1BHkccGaqaCRvSrQXTb+koeRbv9kZoJFioLmClOyVZwq TeWw== X-Gm-Message-State: AOJu0YxIm1uWArWTNM6kSEJBz4ALUIezj4UcaC0XnK/G0REFFvqxU/Ho ThwmVqNLtG4qkZqydnVUowfgqSj83fRZs/Ewsb8A6NKN41aHGXGl2mvKDIb/8mMMVRG9w+Tts9n hmYww X-Gm-Gg: ASbGnctjlxUGEXdzv21ye0KNk+pAW0ksk8xHPGFuOsiuwF3bFCkBtfbQHBk7X77ZVdJ 9BHQ2TFZK9G5XtHaUT4JXv1xiaYJ0xLuo99rCHDnnfmSiOmeGY/H5yeOEyccVoRLwPscriEEF0m NyJHADwqIyPuw0LyS6BioHGiXT3uXspUtpA/e5pkQE1nGmVjl0MlygjNTAzlTBUqkeVFvKfo6U5 8nHjb27MFtNzofmbEwSrDdIuhjHJNu+w466PeqYv4ze1D3yIB1h4Hx+5DIc+9n5z7aeNYYcdbgw sDa/f5BWecO+1WUneLviMY8ylUrMLusjjZIRgdHRXL2J0WSQ2eJcdx8piKrmum0VUBmB9yrnyBW v+Gx1L8j++VyqgpHUGLVi8f4KosHyQhDFwQbCOPull3u4Rq07rIlBRskEIoNZ3DQV9OoSrAHhMp LibMZEpJaBMRzrRwUl+WTVeudf9acOWr06Xndz372/ilMgYQQPcwq/7vnAh/mMupcVH4s= X-Google-Smtp-Source: AGHT+IFD4sbIsWk93pwjlLd69+3+IWVVU37mH3l+piLhbrBYqCjhzmurd8MMnQHrxbwws1KkjmV5mg== X-Received: by 2002:a05:600c:1d1b:b0:477:9671:3a42 with SMTP id 5b1f17b1804b1-477c1133e4bmr416225035e9.35.1764683168522; Tue, 02 Dec 2025 05:46:08 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47926f0ec69sm19383375e9.1.2025.12.02.05.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 05:46:08 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Bryan O'Donoghue Subject: [PATCH v6 11/24] libcamera: shaders: Fix input sampling when width != stride Date: Tue, 2 Dec 2025 13:45:31 +0000 Message-ID: <20251202134544.662446-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251202134544.662446-1-bryan.odonoghue@linaro.org> References: <20251202134544.662446-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hans de Goede When bayer_unpacked.vert is calculating the center and x/yCoord values stride != width is taken into account for x/yCoord deltas since it is taken into account by debayer_egl when setting the x part of tex_step uniform. But it is not taken into account for the center.x which is just directly copied from textureIn, leading to the input width sampling covering the entire input stride instead of just covering the input width. Use the existing and currently unused stride_factor uniform to pass the width/stride ratio and correct center.x for this. This fixes the misrendering seen on x86 laptops which is caused by the CSI2 receiver there requiring a stride which is a multiple of 32 often leading to stride != width. Signed-off-by: Hans de Goede Signed-off-by: Bryan O'Donoghue --- src/libcamera/shaders/bayer_unpacked.vert | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcamera/shaders/bayer_unpacked.vert b/src/libcamera/shaders/bayer_unpacked.vert index fb5109eee..423dde0fa 100644 --- a/src/libcamera/shaders/bayer_unpacked.vert +++ b/src/libcamera/shaders/bayer_unpacked.vert @@ -21,7 +21,7 @@ attribute vec2 textureIn; uniform mat4 proj_matrix; -uniform vec2 tex_size; /* The texture size in pixels */ +uniform vec2 tex_size; /* The texture size in pixels */ uniform vec2 tex_step; /** Pixel position of the first red pixel in the */ @@ -40,8 +40,10 @@ varying vec4 xCoord; /** of the adjacent pixels.*/ varying vec4 yCoord; +uniform float stride_factor; + void main(void) { - center.xy = textureIn; + center.xy = vec2(textureIn.x * stride_factor, textureIn.y); center.zw = textureIn * tex_size + tex_bayer_first_red; xCoord = center.x + vec4(-2.0 * tex_step.x,