From patchwork Wed Dec 10 00:53:39 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: 25428 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 5B944C3257 for ; Wed, 10 Dec 2025 00:54:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25CE761473; Wed, 10 Dec 2025 01:54:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ic7AuhRa"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C590B6144E for ; Wed, 10 Dec 2025 01:54:45 +0100 (CET) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7f0da2dfeaeso1327938b3a.1 for ; Tue, 09 Dec 2025 16:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765328084; x=1765932884; 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=Ic7AuhRaAotFmUBEjLiS1xt/fE3r8QXWyKsM9MIq3yku8ovEBed5ZLtY4bIxT5sr11 5MDPOvEilwbuAzAcCUZxlQfECpj7863BI2uHsfdTG31HlESpm3UmkwN40xnb2DhnA0Ng esKGVQAT8hN25uxpOkapWKhFhlxTPQ2w9wb5M8JFPgRxFDa1YjunD6SYDVvy/F/6+gHj zft0iPFaoDhpyQwM8dprSOs1u2VLFxmTQo+x5JoYlXUF8nEkwCdlH4Oj+Dl0s6TaZfaz m97lRg0gGw8ipMmJvm/QAb9THr5u38FuO8f1QdPm6wDI/kncyl9Z7YtnRuoUxSV7luCR 3eQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765328084; x=1765932884; 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=aBycxRuyNc8FM1rMT4ca6DXs1zVDZgZ+UkTKlbRnDH7j+SYHAmJH64ZkxGcDKbUmoI cxom3AwGPM3ifIk8Arjz4qJ8xBx6YN+PVo1XHZrM4BPyBdZGdWGN4qEtVvbmpQbEdUWN IRgYUi7uugboTOH0UXinl2GDxo1Mpyz9oRO/CO506YqXjbANJ7fbHHHJjvzpdqED8gqw Tn1cwfVJzLMtIMjZl8GKExLMj2+/rATw53AW9iEqoqzOcSBmzWiWtOe3L9yke9T74xzq qLYbtZKMOzFjM0SQoPRFGI3/TC7GcTGDBew/yLua5HEz14KDBNKlO1fQ9mGaN+gnQ456 kbYA== X-Gm-Message-State: AOJu0Yw90C5wKOAou17/717FuKnbNgjJgSoavrzSNtVQ63RhZ6Ius0TV m4gZAe8Exoqo+ujrL19AOcnlJYq+4+olHpVJk585FwMgBGqnIr+uXhLdQ7ZgMl1ElSJv8aHVZl0 Wkzmw X-Gm-Gg: ASbGncvBha0wmpaNyLAkEziyFHY/Bh+Nx271wAfuvSoEkO7LNqogFS6mKvVA4+T6Ctx QqtrK8NZQkXS+7YSStthB4pKMgq0jF1gQYwl8m8aZpnO3I4MhgJk9oWIfwzltEBAL7FFahZz0Nm box9/zRgS8rrZbBnyjss3WsFAfX56mgGJol2weMlkKdJtgkypjKeMSQY5zfH6zV6bRvDCOVAhjG 2yxCwnWgBJNvaVx57z8Rt4PGnA7t2j63ovLotV9UXhtMF/NYReLT24thtiRG70bX03Nv353EWXo FTTj2xF9C7sOI2f8yVph7hBQW4qVSftV3bq/OfvBqXqnjReG0GoArjYlvQJMrBqyf+I7IzuN724 vSBIB0iEJDRvMMxUiZBTtYmeXyWxn7RvgwMMZMJ+AQbldN9XWZq5rZyg4RHaleSPddqUgmONlef J/btUvLITb/Jj9HGZtX8q4fwdYb/IBosEcXXxwjUN83dwANq+nmCjVDwZ+5E9l6sEO X-Google-Smtp-Source: AGHT+IEgnkBt55tcUHxAxpLwzUQaHO5HsAYqJEUwyEq5AJrRC6IZriATljCHKE6bvewu1tlau/V3vw== X-Received: by 2002:a05:6a20:7fa0:b0:366:5927:6a09 with SMTP id adf61e73a8af0-366e03d6b9emr542265637.12.1765328084118; Tue, 09 Dec 2025 16:54:44 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bf6875cc8eesm16057762a12.16.2025.12.09.16.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:54:43 -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 v7 11/26] libcamera: shaders: Fix input sampling when width != stride Date: Wed, 10 Dec 2025 00:53:39 +0000 Message-ID: <20251210005354.44726-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210005354.44726-1-bryan.odonoghue@linaro.org> References: <20251210005354.44726-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,