From patchwork Wed Dec 17 10:01:28 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: 25589 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 F2430C32EA for ; Wed, 17 Dec 2025 10:02:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1403F61D61; Wed, 17 Dec 2025 11:02:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iFVwTFfS"; 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 459ED61A5D for ; Wed, 17 Dec 2025 11:02:03 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-47a80d4a065so34399635e9.2 for ; Wed, 17 Dec 2025 02:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765965722; x=1766570522; 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=HhtFnWRlGMhahKWMF7YUw5HWUh4rGouum/Sd9bsme4c=; b=iFVwTFfSrDszGMjEhPZre7AzEyoln26S0l8+1hIy9vSeXi2iFdz02XnTJYqfVBIlrY 7Ts7k8jzFtr/6g/dOrHVS+F31YSVmlNV83xgBdG7jZi5ESI1rBhwnT59iF68FM1P49X7 Dd6nNtI//SvK6APQk1o1XQZjbmg8b1WLE5PIwkf3zAA4ReqdIsCApzmO5UjFr/5Khat5 zR5X6Y1Z8GdOSRpMC+X18lTxCyRvtUF/dX3kSGrIEV5A8T811rmskFQx1gVwNsLhKKXq SmcsHMG5qj3OQgjAjSg0gkCCvuH5PbTGrWudZNkoDMqqaII5joJcJwTRSb1X3YIUnoq7 e3Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765965722; x=1766570522; 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=HhtFnWRlGMhahKWMF7YUw5HWUh4rGouum/Sd9bsme4c=; b=k+KHcEK4+woYbr5a3LMMuuhbO8M5xNFLmpmNRvaChxiD2TLPKT2sYf+hrk5Rat3Q9H CicPHNNr2TxX3097nE7UFK0xio2WBIDobVsFP9nHaC7fZ2WVlQbzpasvnEdXVRAjIrFd YFE50rLkWBVOXpokvjKRMMj9RtJYx4E7ArIGGcop/nVLN6YabdMefFrL9h8loBUti+u2 ZRAq+ZQyqeWR22IBf9CMze+/4NYFS2TE7+aMzkdKsY/qneQas2bkHWFoc/AVV6erx8xu FE/s/zp1hi18/xO4ZILRl6bxw/2h9g/EGI0mrsR+NjHgSJJYjt5+8JW/21LAEb8sHQiz YF7g== X-Gm-Message-State: AOJu0Yxo+uyQm2sVa620xClqsCC7WkP1XxOHj8cQQIXutYMubkYbZR2/ nqARecQYyFprztf54F5+pfcDmcHGCLj2JphobI+kOKc5Mhj7dZelhZ16SHCGLGqQd+gyMtmUOlk GZL7B X-Gm-Gg: AY/fxX5fAUYWTk9w8LfNaUjQLR1nfnK6UzOMfRs+cTNbWfaG8OnxPZmW9ewwsqv9rey LQcmCfC+sI2hq8T95wOtQFVv80ezqD3Ax9rgpaCiaTeHKpsZ7cbFI350U7SGR1knJRrNaZ+fLTl 6NvxOx57AG3fbCPHBBZ4zZji1dZUfgRH4wQUKJHY99PjyjtOhxKaZSI2Y91T/fhqVupdMuwohKt o0IgL5dArFHvbeRrXKQeaXTANRE900aDaI81wI9XN0M+jI+zq8grN+kf+dBdPeyYzWfK7TIBSAf mi03PPv3G1IUChtG4sSVA+/KRlXivvkKqBNnS8LWyCmrXztQjG0SlTd3S539RxhXPpGxsj25fFD 7mRc8Zznjja5ehjI5aINi/pI+hIbSSj4zwQME/hMr7tfciCeedSBeYFspCoxliVgEHNix034zSj qH9Ff9kDYEqHghjp52CuMPO+NY+UALqRXq+AVTnCkVZpHrZWvtrwyIm0ePArYRN4jbs1M= X-Google-Smtp-Source: AGHT+IG+MBWNlnyRkWB6WvCtr/mb9eU2Pi5slwFy2nlm3x5eGfGYuNmDVHK/Sd6Tca6h9a/kLjzkqg== X-Received: by 2002:a05:600c:4e4c:b0:471:114e:5894 with SMTP id 5b1f17b1804b1-47a8f90da04mr188513975e9.25.1765965722478; Wed, 17 Dec 2025 02:02:02 -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-47bdc1583fbsm32292585e9.0.2025.12.17.02.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 02:02:02 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v9 16/26] libcamera: software_isp: GPU support for unpacked 10/12-bit formats Date: Wed, 17 Dec 2025 10:01:28 +0000 Message-ID: <20251217100138.82525-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217100138.82525-1-bryan.odonoghue@linaro.org> References: <20251217100138.82525-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: Milan Zamazal The GPU processing supports 8-bit sensor formats and 10/12-bit packed formats. Support for 10/12-bit unpacked formats is missing, let's add it. 10/12-bit unpacked formats use two adjacent bytes to store the value. This means the 8-bit shaders can be used if we can modify them for additional support of 16-bit addressing. This requires the following modifications: - Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte per pixel) as the texture format for the given input formats. - Setting the texture width to the number of pixels rather than the number of bytes. - Making the definition of `fetch' macro variable, according to the pixel format. - Using only `fetch' for accessing the texture. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Hans de Goede --- src/libcamera/shaders/bayer_unpacked.frag | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag index 114e32058..477e8bbf6 100644 --- a/src/libcamera/shaders/bayer_unpacked.frag +++ b/src/libcamera/shaders/bayer_unpacked.frag @@ -41,9 +41,17 @@ float apply_contrast(float value, float contrastExp) void main(void) { vec3 rgb; + #if defined(RAW10P) + #define pixel(p) p.r / 4.0 + p.g * 64.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #elif defined(RAW12P) + #define pixel(p) p.r / 16.0 + p.g * 16.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #else #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r + #endif - float C = texture2D(tex_y, center.xy).r; // ( 0, 0) + float C = fetch(center.x, center.y); // ( 0, 0) const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0; // Determine which of four types of pixels we are on.