From patchwork Sun Aug 24 00:48:45 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: 24214 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 DB276C32BB for ; Sun, 24 Aug 2025 00:49:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3792769318; Sun, 24 Aug 2025 02:49:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aTwkWI30"; 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 2A7086931D for ; Sun, 24 Aug 2025 02:49:07 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45b4d892175so15072415e9.2 for ; Sat, 23 Aug 2025 17:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755996546; x=1756601346; darn=lists.libcamera.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xjd+e35XGRyCcjAf/q+jMn0VY9rYr8yYKkhDmX1kIWI=; b=aTwkWI30aCeJHo14fSgSq7COAA0Qz4WBRTj45p4uIu/hcyf2YbhcUyat8kmFUdXWrY EJUMeu0yPeltf43DcjkpOzdz87UOnGCC3ftz1UTTYEEz0sJbv+ml4eHT2dzgjMpYgk2s 3p9cJ4rda0ipQ/tbAwLmXDQkWNCYrmYWQlvUSlTmPr5JldUxFfqtOvHvBHPw747fFGzd Yon0ZjpajUJutzlaF9Xccf3i1y12QcMwmM3t9A+1ZcjdYLgbw60bdMnbScwTR+nbpLbk zJ1BI8nwwHuZQj/AeYdTiM4ZfWX5qh2r/rnXZ5+ebAQGqJXBbLmTk0yhaVPwGtOT5pee nDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755996546; x=1756601346; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xjd+e35XGRyCcjAf/q+jMn0VY9rYr8yYKkhDmX1kIWI=; b=gJ3qcuIRCEYmE2Fh07jZdg9QgLvwLxds9TGaztlL7aeF73auAvXUybJAll5rOazNPG kQefAbmMie9/6dnKyQRFAUxtDAhP7bvcu57ieDqozHDP1AhH/pq/MKKBtXkvg4o+apwM E7apwpnYDrqSDNX62ZkvOy/LeRuKxwxr1MFpp94RpBKiS5aTfSURHeChKen8XRoPZtEO MfOFs3DL68RVq7zAJQQ57VAVE7LxdJSLYdWoQVGfrHzaXk/JHBzx5pAjsi++V+58PUTe fYYeAnOd8EJRGPcuvoyLwOVxBJ3RDWNwr6ll4Ak68twflqr/ZC2v06sPPGudqSxvn7fl 6xZg== X-Gm-Message-State: AOJu0YxJhrbr21Up+uysNT1mRdXHty1xyoIddU4JsTYOrkr5N7pJ+twE tGLkZ+pBHh6Jv1YHihPopqYFTvcSMrsVpCf+KngPm3s/3OMpXLe6mylaBkWvSC+0Ypk= X-Gm-Gg: ASbGncuZ/3LdRaxqwgywcH2JIxikPjan8/KGlM+TtBiDnb5D6UqebCZf2D182P51Sav OwlZ0HapPhb07J+qNMaIy5RFzSlTlwRsBrSN1mywGBrWUPeAv6cEA6hbIfE4kQIJrMjzVMugbKN r14mR1dgn3rT2MOkDjDwqDcD6ti4cJFOTPdAht4BaJclS4TVZ/gLreo9fAfxTCcygI5n7s89sEF ymhbJ+8B5kMr+UOypZQYii3xAiYSfD5I+2uM+eUOrtZPBwykzjXiML7sfRJYhB0TEVmsTlDjdA9 Kbt4FMn/Hr37LdH5yJ4d0AMk31b1azPp/DaGfiNJLszPYwPcKwWrGr6Nh/RxL22NPP52zGdtawM NI5SzdiO3K0KIwOx4GT15PwBc0wpdyh6rCjaX3/5UojBCWroSmGov2mG7tZz3BJ4I4ztYSgYV1/ iDbTUO6+OSi3EOMnaCEYQg X-Google-Smtp-Source: AGHT+IF74a8LNFkLt9QfyfMNBZ0VTJJkh3a/dfbAznwGUu6ZpN2eeEXukBDCIo5rNC4Hz9huXbeXtA== X-Received: by 2002:a05:600c:1c87:b0:456:173c:8a53 with SMTP id 5b1f17b1804b1-45b5179cdd5mr53665335e9.2.1755996546348; Sat, 23 Aug 2025 17:49:06 -0700 (PDT) Received: from [192.168.0.13] (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b4e1d530esm69347225e9.0.2025.08.23.17.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Aug 2025 17:49:05 -0700 (PDT) From: Bryan O'Donoghue Date: Sun, 24 Aug 2025 01:48:45 +0100 Subject: [PATCH v2 33/37] libcamera: shaders: Fix neighbouring positions in 8-bit debayering MIME-Version: 1.0 Message-Id: <20250824-b4-v0-5-2-gpuisp-v2-a-v2-33-96f4576c814e@linaro.org> References: <20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org> In-Reply-To: <20250824-b4-v0-5-2-gpuisp-v2-a-v2-0-96f4576c814e@linaro.org> To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue , Milan Zamazal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1932; i=bryan.odonoghue@linaro.org; h=from:subject:message-id; bh=jkyIf6VT15/NL0QWBEUviS0cZy+665gBkjAmjr6MTjI=; b=owEBbQKS/ZANAwAKASJxO7Ohjcg6AcsmYgBoqmFi8cBG3nEuUupIUu5IL1GsAfs/SH3QzGPT8 xiH/ibit4yJAjMEAAEKAB0WIQTmk/sqq6Nt4Rerb7QicTuzoY3IOgUCaKphYgAKCRAicTuzoY3I OjUqD/oCRUts1rWJPnUKeD4TCldVu/w47UAwrboXEAV4NMCiPhyCOoydKo9CfctqWrPVEKCRUau 8XH1YVkepKgsU3fy6GJR6V5ozcngceIYOiuoxPnAcM9n24wQhNQpESK5W7MstxjEBv4tPR4fEnr Xa0B/gXPf60u+2bgb0AWs4cgxl6wn41wp1aHHuXY7fLYanNBkhpujD3jCuOakVbI7rm3FdNtxrb 9LDhlY6dw1MTQQzhV5KqbaobX2LL99GMDx3UW8TBfyAZvWAg26OInkVvZVE5lTLmvNAlxFO0nZi lYVmodanJxGvqIBstWTYyjWvNHNlIcDRokzEhY382EQGcwlMkeksPI32YiHG20XhV4P4Xygf3hb /LvkH2cYGu5HdttaxQTbFapJM7XnpiYVXaUvOWkBP4sCl2x34R/spzQ56tIIjAmWJRyGtXQsjV3 8UaNCHiWAj5YFBU7IGXNP2+wMeXD0lGICZ+dlQBKjf4KfgIbBsPYwCKriOXMjc6IzshqunWjs3Q OtG9D6WUsDwX5D/wnndupIe9w27Wq0QvdNy23kzxLWiD/2THjiIIyJ0E02+wN8CKwzRJrKL7r1x MU9m/WoI5HqTrqd5RlEasGCglpbqgqCXHQZ4nps8eCwuPZj314ZbsivqXfIii8faA7RQN2d4ka7 q5dkIRQEXutcl9Q== X-Developer-Key: i=bryan.odonoghue@linaro.org; a=openpgp; fpr=E693FB2AABA36DE117AB6FB422713BB3A18DC83A 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: Milan Zamazal When accessing a texture position in a shader, the pixel with the nearest centre to the specified texture coordinates (as mandated by specifying GL_NEAREST parameter) is taken. The current vertex shader determines the positions of the neighbouring pixels by adding the provided texture steps to the exact centre pixel coordinates. But this places the computed coordinates, from the point of view of GL_NEAREST, exactly between the pixels and is thus prone to floating point inaccuracies. Wrong neighbouring pixel coordinates may be used, resulting in artefacts in the output image. Let's fix the problem by shifting the initial coordinates a bit from the pixel border. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_8.vert | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_8.vert b/include/libcamera/internal/shaders/bayer_8.vert index fb5109eee3f556e4f4e4e444899eff8d922be573..fc1cf89f2d98acf8ebc4501cadad194fd07985bd 100644 --- a/include/libcamera/internal/shaders/bayer_8.vert +++ b/include/libcamera/internal/shaders/bayer_8.vert @@ -44,10 +44,10 @@ void main(void) { center.xy = textureIn; center.zw = textureIn * tex_size + tex_bayer_first_red; - xCoord = center.x + vec4(-2.0 * tex_step.x, - -tex_step.x, tex_step.x, 2.0 * tex_step.x); - yCoord = center.y + vec4(-2.0 * tex_step.y, - -tex_step.y, tex_step.y, 2.0 * tex_step.y); + xCoord = center.x + 0.1 * tex_step.x + + vec4(-2.0 * tex_step.x, -tex_step.x, tex_step.x, 2.0 * tex_step.x); + yCoord = center.y + 0.1 * tex_step.y + + vec4(-2.0 * tex_step.y, -tex_step.y, tex_step.y, 2.0 * tex_step.y); gl_Position = proj_matrix * vertexIn; }