From patchwork Thu Nov 20 23:33: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: 25139 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 F2171BD80A for ; Thu, 20 Nov 2025 23:34:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9BA9C60AD2; Fri, 21 Nov 2025 00:34:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YF3aef3H"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8331760A9E for ; Fri, 21 Nov 2025 00:34:21 +0100 (CET) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-429c48e05aeso968675f8f.1 for ; Thu, 20 Nov 2025 15:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763681661; x=1764286461; 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=EbZ/Wuv7VrFPMAILTWJXMItIZK7H6ypYImRnfvuiCeU=; b=YF3aef3HMWLV4PkvzYWMu1zRA74QFsEV0H9fhRJRF9hKWNKWZzUnYmUt73D1FXH2Bu eFrjbSFd4Ve3Kqw3fkaHh7SQtnXdFxly6ts+h2eo49uEh6bzq4BX+S8O6e6y4ic+nl/b t5mB/2gkJsmWjaHVCn8erzL3uNcy8uzzflYJ1vrV/FZXsL4Jn2BjlZEabsHgtkjT25YN qJ74AtLNKroUbpchtHDBlJKKCCXBjq33rleMWQKkOhn4zswYiJHDw7hWM9Mzb5BJTdju zkwSDtFCsp9/0qisKgvrURg8xHyAul+lbsXJMRHQ7e+7jw+6rKHG9cwzHkzJdr8yXBHU U+GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763681661; x=1764286461; 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=EbZ/Wuv7VrFPMAILTWJXMItIZK7H6ypYImRnfvuiCeU=; b=iR403bpQ4++rvMOODmHa2y2l5RLxJP1A2sZkCmfWBCwYZrVMk7fOcv+ZIvZkIUxLqH JhJAaZUXRNw2yyN1JXjfR26wQFHWRSU/kIGYWe1JS55Bl04IPicioeQKis1WCyRTp8yp fL5XM2LFceEwt9bWrCtfwHVIAq4oWqHiM88RDPCJJdflIRhOoe0lth/jZzBPsVEs+3F1 kjZcnFhSfHhm8bFz+bLamMbE/xqFqnDORH4rZ5Jr0K4YUUUW9Y8O774AM9azoXOf1D8l FaxmwFXPNsM9qQInahz6B37WglMRsX0KLE5J9SFh2jjfc54tDYJqbVHZqnJ7qWTn1xD5 /maA== X-Gm-Message-State: AOJu0YyIAA7/EV1WthKov1lsncB+up6hM6K+6TQyBP+lbbzb6+W2Poo4 AgfQeJv9QIsFmNHqmdFFYo3iuESqD7rd/dNlneZp/pGQws+DIE65QNjuWQscVDBNx+Q4zcBN3BC 7O/aDB+M= X-Gm-Gg: ASbGnctLKJ/pkUZARuWzErHlYKFWCwC+hmxm9YNObq96N0w8hDfdVcegqBUvvulfJkv tHDjMnqT7FX4RWic1NBDtMIX3s9nqgQ8JEBejO4GCcoBYkrfCvnx5H7EeRfnac32c1bMRTxPZI3 VPNqU24tQPYnkzgnyP2kjroitOZZhcMWZ9Jv436UNZxHBiWY11LaYM29eG2LAUlBGzyMQRAnd0I bMAJORSvfVuAR7MzNZIYh4HrlR6Z1yscTquAIQMuMEMNIu9RcsdDtZISjAmG/D5/phQoKKetVHd 8L1CZAZAiqYCbgm0LZGk71XkpnrvsJ9TlCWuqVjs4I/LDzbbtFnuIF+uDrFlh87gqNbtbfDGIFX QTSstmBD92d1DML2SEXOkVJ5BcyFCKm/txHsYJTuxzkgtU11qyDDTxPGG893nZaaS99IOTAEdw0 ohbawOFWez9huKgXXjZ6OMB49tttk2AYjmEZuUjz4hkMwtLjBTHCdAIeoX/fGWnzdJ2Wg= X-Google-Smtp-Source: AGHT+IGXGbawGYEbrqSXCDOpenbBj8HkBy7Cxa9Tmi7n+jBH75BL295qfKiP4oDXfoCiMfud6kH8NQ== X-Received: by 2002:a05:6000:228a:b0:428:3d14:7378 with SMTP id ffacd0b85a97d-42cba7b465bmr5092916f8f.24.1763681660908; Thu, 20 Nov 2025 15:34:20 -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 ffacd0b85a97d-42cb7fa3a81sm7984139f8f.26.2025.11.20.15.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 15:34:19 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v4 15/23] libcamera: software_isp: GPU support for unpacked 10/12-bit formats Date: Thu, 20 Nov 2025 23:33:39 +0000 Message-ID: <20251120233347.5046-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251120233347.5046-1-bryan.odonoghue@linaro.org> References: <20251120233347.5046-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 16262feb2..c519fad1f 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -47,9 +47,17 @@ float apply_contrast(float normalise, float contrast_in) 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.