From patchwork Sat Nov 22 20:55:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 25154 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 E3908C0F1B for ; Sat, 22 Nov 2025 20:55:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 92BAC60AA4; Sat, 22 Nov 2025 21:55:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="ffgG9U6x"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XVEcgC/F"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 38994609E0 for ; Sat, 22 Nov 2025 21:55:16 +0100 (CET) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AMGcAiE3253455 for ; Sat, 22 Nov 2025 20:55:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=xAZhZamYdPv muJpD7wA18v7dx3lZ5EUv1YVdXphtjbs=; b=ffgG9U6xKRtGt9bwkHODVxBfLoZ 7VEmGpJSGzkWxsB3dCIbuO+bbdKp2VPozvtBWCXG8lw2lM4Z4fXgA5Z1Cuqcl1Ac bzLatwDCEpqdzz1As1xKj85fycNKf6wfX737FSR1fUMvDitQNTlrDcHHalskLwHl ePX8gXg9E2zN+zfyh2/Hn8T65nHCoK90/KNsf8b98gJ1v/fb58B/UzMnWfZpCpHa vxMH0Dife3j5zkoVq8AvOR7YhxaxrCRwiKCqh/5c6XACzBQ0TUMhX2KMTvlSvKNO Pid2x6qCOGkFcO/tuJ+mkGaDmLahfsli0Iv+U1zSdRV/noEBYE+1zL5tvSg== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak6a51amk-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 22 Nov 2025 20:55:15 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4ee416413a8so30264471cf.1 for ; Sat, 22 Nov 2025 12:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763844914; x=1764449714; 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=xAZhZamYdPvmuJpD7wA18v7dx3lZ5EUv1YVdXphtjbs=; b=XVEcgC/FVAoQUPG19bDavHuGHF/BGLn/O7wQ+9s0qAB8IB9sRSgZ87Jb8jTkUpq8BM 7AKzRNHOy1iotgQ+JNHamwSqi34vswyTg6Gdw3RHd3TYh2z6giwH6s/O4UNMNQS1nJx1 LVVkTwiF0EkwcFvdI3iJ8FZxXdw8YO43k3RDiZk7TbN1P8zteWQLBwwq1iMUT52PBzzC F/qqeAnmR6aDghHtVS/qXiaF80LCbLcKQXUJ9pOFpoSDg+SWh4G6H8o6QLDji06TmPM1 dRUe2W2D6EonuprlLz4hLhrKPraHRyCnh+p4aT1uFFhQYrdEDnpJ8vW1DBqKOboIzrfh BT/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763844914; x=1764449714; 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=xAZhZamYdPvmuJpD7wA18v7dx3lZ5EUv1YVdXphtjbs=; b=FDDBsSW21QPvHjszfDd4Je5uN+9U0C3rCwXvHJrtJmz5ae0VHLKhJD51EKLUe7bGYE csZaKqaVdf5T5JJHr8SxaCAX7YxV6s5pd8JghTUUh+zyEZvwiPRwth1QnBozmBFzRK/Q ZvwYpO+H6QdGFdEpPjH6w0s0O5EKC2vxsoAUfIDPuEUI46Toxd5hufR77hg0twUbxSjD s5EwXWyv3lUFBqcD6x2POalaguU03umNXpI6GTbkfef4/6/5BQ76Tvc7Mp8CivpV4/tj 6HjsiJTy1BdWHimVMoKgF08ujg02ZJyawhybwZ2O4zdT3s6oj0XayM/7EOjOIxX6qG0i J6jQ== X-Gm-Message-State: AOJu0YwmL0KAlYoXhAhy3x9kt4GNHeThibGie3FzX5ne9MpFO7IAW6jD g9spMQ010LMMx9MZ5WdbBfbiS1E3cYsEEhmCygSUUVnhOZEr2aaPftP2xb6raU5AkIkNGDM532a Jpb1HylQa2SG6w+nyGO3TT0/0NE8oKh1vptbryNdVNpA9ohUMitatHpf3UNbU8HLMC9weJUT3NA FxUM7ad2R6 X-Gm-Gg: ASbGncvY2xEGZiJGmFWTmnPyfm0HatEVbvWqXzAYWe19sh2ti9ie2L7jzVnawZEqpsl zXFlNzqDM1QmFjPcOuU9Q8S6lFtRg1q/BvW3HPDpQOUEj9Ru4Po/DdSWTqyVDtBGyVs7ObColPw 1YBaCdVE6hl06E4BcScqeSdcmw5YWs4k6EmeI7byp2eS/NVYNCBTiKI2sJd64IJGBhYGfAGSKtn QY2+/dlUae+Jt/TwnLvhtGXgV0H+FIuugrvao2FHevT23Amfab/h07pyh6I0OkLh1jLE5nMbV0k x5oNUJipLtxEMuVVJzMeGDVd2MaHMP1hePLIt0/p+YZu/KIb4/LhZXCxbu1ixSrvyDLVNZJjjzD 7zC/QqfSq/hmIQSxxg3vijCC8XZrgZs/zbSTSdse2cWvCeNLCUJvKUACkxzHThoPLvM5+8QXuVe QfhRDtFSl05zBf7CRBJrjDk+6n X-Received: by 2002:a05:622a:24f:b0:4d8:531e:f896 with SMTP id d75a77b69052e-4ee58862e12mr90266511cf.27.1763844914101; Sat, 22 Nov 2025 12:55:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IE88ljn2E0f0+NPTy3gyM0DhKHfeFO8hsM/Cx15PSag34gD1bcKPU/p6VcZVPIHb1alf0N9aw== X-Received: by 2002:a05:622a:24f:b0:4d8:531e:f896 with SMTP id d75a77b69052e-4ee58862e12mr90266231cf.27.1763844913536; Sat, 22 Nov 2025 12:55:13 -0800 (PST) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b7655050c53sm822745966b.68.2025.11.22.12.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Nov 2025 12:55:12 -0800 (PST) From: Hans de Goede To: libcamera-devel@lists.libcamera.org, Bryan O'Donoghue Cc: Hans de Goede Subject: [PATCH 2/3] libcamera: software_isp: debayer_egl: Fix input sampling when width != stride Date: Sat, 22 Nov 2025 21:55:06 +0100 Message-ID: <20251122205507.37387-3-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251122205507.37387-1-johannes.goede@oss.qualcomm.com> References: <20251122205507.37387-1-johannes.goede@oss.qualcomm.com> MIME-Version: 1.0 X-Authority-Analysis: v=2.4 cv=Hup72kTS c=1 sm=1 tr=0 ts=69222333 cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=xqWC_Br6kY4A:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=ss4-n0EdsD2TUQPG-kIA:9 a=dawVfQjAaf238kedN5IG:22 X-Proofpoint-GUID: e-IYa5thtcdumddVErsJzKxVsgQF8ryk X-Proofpoint-ORIG-GUID: e-IYa5thtcdumddVErsJzKxVsgQF8ryk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIyMDE3NCBTYWx0ZWRfXzG4fboD7BitN pO6SXqkVEnYzMlw4DwgUH34Na08CAlfl1BRXF9QEC0R6FZGpJ6yA7OUjWTW9CVXDAmL7Al8tIil GRlxMt5gVIgNX1QnUTEIIblZ4AM6rXA0Qa9pBMRNm0rbo8dqhJRhIJyBqL+DLwg2iuFjtUNsw3b weCgbZGbMTI4mWX91mM79JnXNwllSiycZmqHiLCivHsdYfrgL4ZDF3+n0ygzm/P10n1wyw3spt1 7isd+3Gq+c7e+hi+fgkAmZVk8Uyrt+gFTCtrZMUa5ZbH0uSg+jsMdh9hlHD+K10ICRNHD8rmw7S 1zU01E80BmEh3Duxl42d1XvseuMUQb6fCvK9yiV1M6ubV3MnWB/X4aiTbq340TmDhYe5HLIgBCd rOn2uPz/ZTwVZq2Jh5VmJUGVQQFMGQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1121, Hydra:6.1.9, FMLib:17.12.100.49 definitions=2025-11-22_08,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511220174 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" 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 --- Besides using stride_factor to correct center.x this also requires debayer_egl to actuall set stride_factor instead of hardcoding it to 1.0, this last part should be squashed into "libcamera: software_isp: debayer_egl: Add an eGL debayer class" --- include/libcamera/internal/shaders/bayer_unpacked.vert | 4 +++- src/libcamera/software_isp/debayer_egl.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_unpacked.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert index fb5109ee..1425b449 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.vert +++ b/include/libcamera/internal/shaders/bayer_unpacked.vert @@ -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, diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index cf40478f..29a8ae70 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -455,7 +455,7 @@ void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms) (GLfloat)height_ }; GLfloat Step[] = { static_cast(bytesPerPixel_) / (inputConfig_.stride - 1), 1.0f / (height_ - 1) }; - GLfloat Stride = 1.0f; + GLfloat Stride = (GLfloat)width_ / (inputConfig_.stride / bytesPerPixel_); GLfloat scaleX = (GLfloat)window_.width / width_; GLfloat scaleY = (GLfloat)window_.height / height_; GLfloat transX = -(1.0f - scaleX);