From patchwork Thu Nov 27 02:37:26 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: 25248 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 B290AC32DE for ; Thu, 27 Nov 2025 02:38:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5541A60AA0; Thu, 27 Nov 2025 03:38:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WftqorXx"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DAAE0609DE for ; Thu, 27 Nov 2025 03:38:10 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-47790b080e4so1181175e9.3 for ; Wed, 26 Nov 2025 18:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764211090; x=1764815890; 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=ks/FmitMWmPckFVWZHkmtbgY2cBV7upypIHZAZgxRaA=; b=WftqorXxCLQGye6PtgSxaMwLiZWxk01/5nfUByeK/YBba/P/4x240kiXoM1k/mLq9V WbjA1zFyz83FL0RGdAAQmqs9iaj2J2WsPgcJigL7YwuCT/bBzPcNG1kYi0YYwVbFkbhF IQ1LxZFIPYNTqlD+0ElHOY2kZMyRkHTT0d4kd0DvXq1ImBrCEhfU9kZtRelM6aHlaEKr DXhO7eghPCECieKEHd3kSTyPiTH3rij0JJnbtdGy/Em8ftNdV6l1iAV/k/vGNlo9eMdj FRNLMArd9ZdceT3tjIy/h+XG5SkLmaEmJ2eCAOqHD9XuvNdy/WChD8VMUInQP3yvU/sb JYyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764211090; x=1764815890; 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=ks/FmitMWmPckFVWZHkmtbgY2cBV7upypIHZAZgxRaA=; b=NUdRAdIhg12/cRIZB/FHiOxMDqrhB8mWV8m/RqBrA7ZMPSqFpdOn5Z0pXkCGKqmXqi 8kndkto2AxR4zkZIQr5uDMvVET2TcHCrLAnrSpQdTchMEWdUuJFPM2/9rBNtpVxq24fT loINA35taRPF9qPubggMVRaiKrdrCLLt9Kkm3PLVr+yCTJ2j0bAN0Hw7aES53cA4lihC /O/GnXV3kko4w5to6AW8JwQ5zXoE7I1D2kAVJxPSmfmdWS7pZvgepz00sJQYptdCa7vL FatfkNIECfExPy0mulSZfxqTXo9YmcSvUpgcAKPZGRBXxGjX6lF5ZNZQAVx+eunUl4xe oFEA== X-Gm-Message-State: AOJu0YzNioQKh8+Qlz+bjnDxG8A+e7+j5grckmMaj+BwalulgvRiLaCU F/aTnA+Pa7vKHMI2GleCg+xCK3rMfka0KIbJngGzkjpBJ2OVGHogVo8uMrxYlmr4lFYGOG1txzi khGLofL8= X-Gm-Gg: ASbGncuwKlVGoIZ5zl14lnCn5IxRUvmzyqGMhs3DySLkfIQfy2AkUbbKW1wSlOfAmzF /VnGDkpGsrNqP1pOtuqFhTRE7MiZEsS6cBZm2ovKpnyvDXXzYCY5eW9x6jy+D4h4BIlCDF4RQHy wMewqlPBrTWPCrY4NmZT0O2sAC2g1sU7VxIX2/QnWauOP4YIrdXgytQCk8JB4mnuWNux1v+aUxS pUirXQlrpOmh/gRtoHAtFWH5x5mc+a8WtSt5gZVqihH3HITUalJhVj+Gf23P9fbDqZgqpsID380 eSWHB2SwF0WPKVePWq1sD4M7dKvcBLCAljGkVNsMW92zP9QulnvvSVW5ogr7VvaWbYKBkPxRAQ0 eVug7GBeECcOY6i3HutKX2FiR7kA0yrWOvPA2JYPD2iqCJax02XxWsAZatdh8+iImQ6mnRMh1pm bbQEXIwBNkZFiigMvGeg6rddWlpx4bZiZlhk9F/FeafM5Yw2NCCUY//QCl5StN7Jm9pcw= X-Google-Smtp-Source: AGHT+IFt5IRKqw0XbYBKni8onyaQ09yv7FduvRaNor25K9aoOJKUhMXXeksEjz9jhrOhaZjp8B9vcw== X-Received: by 2002:a05:600c:1914:b0:471:114e:5894 with SMTP id 5b1f17b1804b1-477c112587fmr175550055e9.25.1764211090287; Wed, 26 Nov 2025 18:38:10 -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-4790552c3c9sm58186345e9.0.2025.11.26.18.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:38:09 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Bryan O'Donoghue Subject: [PATCH v5 11/24] libcamera: shaders: Fix input sampling when width != stride Date: Thu, 27 Nov 2025 02:37:26 +0000 Message-ID: <20251127023739.179652-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127023739.179652-1-bryan.odonoghue@linaro.org> References: <20251127023739.179652-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,