From patchwork Fri Dec 12 00:29:22 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: 25526 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 F3D9FBD1F1 for ; Fri, 12 Dec 2025 00:34:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AE2656168E; Fri, 12 Dec 2025 01:34:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UKZjV2bW"; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AD5561635 for ; Fri, 12 Dec 2025 01:33:59 +0100 (CET) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-7e1651ae0d5so592205b3a.1 for ; Thu, 11 Dec 2025 16:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765499638; x=1766104438; 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=YOU8yzvJmLe2CYSAv2DGpWHlxVqrCoB7v5e5gKZ8hTI=; b=UKZjV2bW8I98CMbqU9UU0SXvuor5D95dN0syEzQU5fZIf2YDZWX++3kYcs8WJK8V2g uoljtstZA5jPF2kXkJAxcSTYPnT/3NMtuHR9EHvmATIwMLXHkYsrGVNREPqnHuwRhAEK dx4juGdzfJLGHyOB9noHJTshAEv8JeSA+FtlpzIgfs5VtjPaYvSvnZ6PP/3DJKvTa/Hm kZg/hRtQUA0F5W1w4QMnzXl9TJvodNgDCXNPq8L0PoJJyMiVDhYko0PKBtNDuAUjC4Sa Inz+aG4i9qAEcUHH1QSZWoLYkt1OQsvQ1hyv123aMIpFtkeDFIf4GU9er8b/qc3W4Ueo HKGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765499638; x=1766104438; 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=YOU8yzvJmLe2CYSAv2DGpWHlxVqrCoB7v5e5gKZ8hTI=; b=lvqhgVbIlaPFqlw3yK9Hms3kln+X98Yfm6LuzPw9rB2CtN2cwRKK6BOufGycpHlYkR zu+R0ah5BG8ixnJ6IhfYaiR3TX/lKzRN2uB6gWXk4LmMZkXvWkUzwO8I0JWth2JnGSpm naUqqETawmbZhwDE6skjCWQtYSAtYxbhxCRgvgnHeDc+JzQO9t/BjxQVAxvDPtxEgAL2 Ltn4At5W9nPbikoFoXKWqGz5+IPM0Bo35LHAOPPnMhevNK+MqIw+m/5dADYAFe2WmN45 qdqkfb0pQ2bVdLrNsR6+WFTwySRsr/BAzAesuSsgEbqJnOSW9qxT6CnxsO6hA1CBMIwy FndQ== X-Gm-Message-State: AOJu0YxBUFnD57DZ02E/esLIp++dRzqUanJ0ehJhoH496plQfuzvoyFB 9Oqv7qdwK1zGXc9lOmD67vYAYtf4s2+SHfoQ+NDGj4dppau3eLdP7DeraJgVqbt1BQ02PAc6Oy9 Ia48N X-Gm-Gg: AY/fxX58hBjys3Ysec3bYSCGanTFQa4pQZCbjoYV3jvtyTQz4q8R5cQGP/Xh1EpE+VC jLgw29DM6UaXqNGnfFKXuVuAcL+Hj0ZWplDCrbbJM1Wg3q4BvQ/mwHuXX1yhwLuc2eUQfTUnYM+ vprs682Ek31K7ZpP7BOzLUuUM8MeBbbpMtkLoVX4eIl3a+HQEgAs9c2VCKonBPwP1KO4dJc8l6G UsD0ad9lJwfhI3p2tmanROl6uFg5mGHEe77o7xNwecJdACF0PG6RXNOc9McCP3ktFXAcQpaLhy7 aalfxLyJEtvqQ+azNL+kJH1oikoMLm+zcqC8LXYN/ku+UQVpIDqOo811r/qBvPTK3uKGFXxoRU3 C0/qba228lkDaj85p39rXg/r3g/oSJO2z0w8GCP/mkOanOdw/m0lbz9F7sKLG0EZbujYkaPOp87 hJJ8IWROxemSw5oriuKboAC/driV8lAx2mcynPR/KhiP+dKj9kktow6UPLx4Neyhlupu80Jg== X-Google-Smtp-Source: AGHT+IFIIWBdUJzKJq6CiCUmgDW+Ea3qewSygyNDvKXn75MGxofk0dZMGitPRC3Qs21pV4VrgethqA== X-Received: by 2002:a05:6a21:6da2:b0:361:3311:322e with SMTP id adf61e73a8af0-369afa029dbmr289599637.46.1765499637670; Thu, 11 Dec 2025 16:33:57 -0800 (PST) Received: from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp. [153.246.134.249]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 16:33:57 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v8 11/26] libcamera: shaders: Fix input sampling when width != stride Date: Fri, 12 Dec 2025 00:29:22 +0000 Message-ID: <20251212002937.3118-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251212002937.3118-1-bryan.odonoghue@linaro.org> References: <20251212002937.3118-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 Reviewed-by: Milan Zamazal 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,