From patchwork Wed Oct 15 01:22:49 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: 24682 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 E2DE6C3339 for ; Wed, 15 Oct 2025 01:23:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7480D6061B; Wed, 15 Oct 2025 03:23:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wi5ldj7U"; dkim-atps=neutral Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 437F560669 for ; Wed, 15 Oct 2025 03:23:33 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b5b823b4f3dso221355466b.3 for ; Tue, 14 Oct 2025 18:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491412; x=1761096212; 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=NQ8UK1PjcLrLcomgawtJFUp2Hb3suu4LRcvqz99T9V8=; b=wi5ldj7UEShuXRKXHaxGWPKpaQNCRKrq3UpDTsRo/SxnuvuX85CwGBPbwnkUAN7Gye lExbm0y6g3H4iSXdKpRuaJj5wG50qJ6Hn1TyLWz9eA/gIKq/JNaMdsMs4WwBByFRp2XL w/NokGQ1Cjpmnb09l6B1lD1kxmltJzuVwrWMnap23dGcGWI8EfGnsEXIRQO8aP4B3KoM FYUH3vielwm+FIuv7fvnJZVH8HNJ8r02Er5JkTiuhvP6u7SniUErz59s2gXETShYRKNX uakfG9fCcPFsPGMLsA78DxiOLi/nbfisaWXg2oNlheT/jeMa7R486hEPGacPaXe0atOc wvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491412; x=1761096212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NQ8UK1PjcLrLcomgawtJFUp2Hb3suu4LRcvqz99T9V8=; b=ZgaTDEBHF2K/OU0XhO5Grch8hGEqbuNotB9MVyRxqyR01Pkwm83SrKFj7eWHPxItiS YuEXwr7RKUdQI2sbjEoknNru/zyDPzyfuJ/ET1MxVziDaMMzvFrkjd0eQLRI2ynaQkpd J4E4SkxfZrxAM5scop26CO3Qi3SwkgHdqH9RbfgqO/J/NKh0xftGmbfygI4zUdfis6Bs v5lDGb+PONnNI4wdnaq1RomDUW22hnxbu/IxDasMnIySgGB95xlSginq+ZN7R21jWFOC YaTQ/2aSUD+b1prEO+U+4SFBnR8ianaZmbh5nSsdIW4sajgeqpDDFoBdWAN3bBHuhnqp +OCQ== X-Gm-Message-State: AOJu0YzIjSRpoxmsPr/xSnloPmitAVsh2EBrxBlJQ5mVNbS1A+uedQfp DEf3yCLvrtCxjuWevzr1pg7Bo8H7mztnTh+bkrDvkSTyo4qpVk8z1Pe77MFKovsk9e3z9pKjDAi 68ah0 X-Gm-Gg: ASbGncszwA8ofw8BZ6ZIBq0T6XJRmf5V+BbUk8WV16T3AhHO9fEtAL92fBJrpzGWo00 /xaeVj3maLX/umkMnFPLM1fY/WeORMknX9Rq7JcqekjiCf2lnVLB2HheHPYEOYJgBmPYrp3NOVV FN4fVKsoZdKFBmCwIV38t+OH448669jZuzc8054ukBKTPqL2EZR4uQR8QAmBKfBuctkouYC/cyB sMsN4gVvVGrT30zdC4uZeW11p09K5b2edo0pHrent3JKryUO39f5Kb6UbV8a9OqHx3VbQQVGMTG 2Xeh/1K3+zbaf6ASXypZXtCbaATWYCSig/Nl74G/XmRAPIz7nkPc9iG3A5eyYBJEeepi3Jgk3Jv c3mNfUBqv9meBRdJc7zqgmvltpjre0/qLsb9mwlu+8BIomz1I8FZX5ckF3K4gjlmyYsTp4kXNyC X6Tt3mS/Gs3HHKBjrj645pHWqwogyLFmYe1sbmF1Vk X-Google-Smtp-Source: AGHT+IFrpSsZ0pU24nYtdv3hSFExslCTaQRNZ5yqdg/9R2QOQ8kbMRql7mgUiHEgG8qbKiYcPjiuUQ== X-Received: by 2002:a17:906:6a1d:b0:b30:2f6b:448f with SMTP id a640c23a62f3a-b50aa8a8f8fmr3060657966b.25.1760491412481; Tue, 14 Oct 2025 18:23:32 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:32 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 37/39] libcamera: software_isp: GPU support for unpacked 10/12-bit formats Date: Wed, 15 Oct 2025 02:22:49 +0100 Message-ID: <20251015012251.17508-38-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-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 --- include/libcamera/internal/shaders/bayer_unpacked.frag | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index 37bd4812..96a6d554 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -33,9 +33,17 @@ uniform vec3 awb; 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.